Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Tensor3D3x3x3.cpp
1 /*
2 This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4 Copyright (C) 2003-2009 (see file CONTACT for details)
5  Multimediale Systeme der Informationsverarbeitung
6  Institut fuer Informatik
7  Christian-Albrechts-Universitaet Kiel
8 
9 
10 BIAS is free software; you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14 
15 BIAS is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU Lesser General Public License for more details.
19 
20 You should have received a copy of the GNU Lesser General Public License
21 along with BIAS; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24 
25 #include <Base/Common/W32Compat.hh>
26 #include <math.h>
27 #include "Tensor3D3x3x3.hh"
28 #include "Matrix3x3.hh"
29 
30 #include <Base/Common/BIASpragma.hh>
31 
32 using namespace BIAS;
33 using namespace std;
34 
35 template <class T>
37  : Tensor3D<T>(3, 3, 3, (T)0.0)
38 {}
39 
40 template <class T>
42 {
43  this->Destroy();
44 }
45 
46 template <class T>
47 void Tensor3D3x3x3<T>::NewSize(const int /*i*/, const int /*j*/, const int /*k*/,
48  const T& /*deflt*/)
49 {
50  BIASERR("do not call NewSize for Tensor3D3x3x3<T>, it has fixed size of 3x3x3");
51  //BIASASSERT(false);
52  BIASABORT;
53 }
54 
55 template <class T>
56 void Tensor3D3x3x3<T>::newsize(const int /*i*/, const int /*j*/, const int /*k*/,
57  const T& /*deflt*/)
58 {
59  BIASERR("do not call newsize for Tensor3D3x3x3<T>, it has fixed size of 3x3x3");
60  //BIASASSERT(false);
61  BIASABORT;
62 }
63 
64 
65 template <class T>
67  Tensor3D3x3x3<T> &result) const
68 {
69  for (int i=0; i<3; i++)
70  for (int j=0; j<3; j++)
71  for (int k=0; k<3; k++)
72  {
73  double v = 0;
74  for (int p=0; p<3; p++)
75  v += this->_DataArray[p][j][k] * M[p][i];
76  result(i,j,k) = (T)v; // we cast to the type to avoid warnings
77  }
78 }
79 
80 
81 template <class T>
83  Tensor3D3x3x3<T> &result) const
84 {
85  for (int i=0; i<3; i++)
86  for (int j=0; j<3; j++)
87  for (int k=0; k<3; k++)
88  {
89  double v = 0;
90  for (int p = 0; p < 3; ++p)
91  v += this->_DataArray[i][p][k] * M[p][j];
92  result(i,j,k) = (T)v;
93  }
94 }
95 
96 
97 template <class T>
99  Tensor3D3x3x3<T> &result) const
100 {
101  for (int i=0; i<3; i++)
102  for (int j=0; j<3; j++)
103  for (int k=0; k<3; k++)
104  {
105  double v = 0;
106  for (int p = 0; p < 3; ++p)
107  v += this->_DataArray[i][j][p] * M[p][k];
108  result(i,j,k) = (T)v;
109  }
110 }
111 
112 
113 template <class T>
115  Tensor3D3x3x3<T> &result) const
116 {
117  for (int i=0; i<3; i++)
118  for (int j=0; j<3; j++)
119  for (int k=0; k<3; k++)
120  {
121  double v = 0;
122  for (int p = 0; p < 3; ++p)
123  v += M[i][p] * this->_DataArray[p][j][k];
124  result(i,j,k) = (T)v;
125  }
126 }
127 
128 
129 template <class T>
131  Tensor3D3x3x3<T> &result) const
132 {
133  for (int i=0; i<3; i++)
134  for (int j=0; j<3; j++)
135  for (int k=0; k<3; k++)
136  {
137  double v = 0;
138  for (int p = 0; p < 3; ++p)
139  v += M[j][p] * this->_DataArray[i][p][k];
140  result(i,j,k) = (T)v;
141  }
142 }
143 
144 
145 template <class T>
147  Tensor3D3x3x3<T> &result) const
148 {
149  for (int i=0; i<3; i++)
150  for (int j=0; j<3; j++)
151  for (int k=0; k<3; k++)
152  {
153  double v = 0;
154  for (int p = 0; p < 3; ++p)
155  v += M[k][p] * this->_DataArray[i][j][p];
156  result(i,j,k) = (T)v;
157  }
158 }
159 
160 
161 #define INST(type) \
162 template class BIASMathBase_EXPORT BIAS::Tensor3D3x3x3<type>;\
163 
164 INST(short)
165 INST(int)
166 INST(float)
167 INST(double)
void premultiply2(const BIAS::Matrix3x3< T > &M, Tensor3D3x3x3< T > &result) const
compute S_{ijk} = M_{jp} T_{ipk}
void postmultiply2(const BIAS::Matrix3x3< T > &M, Tensor3D3x3x3< T > &result) const
Compute S_{ijk} = T_{ipk} M_{pj}.
void newsize(const int i, const int j, const int k, const T &def=(T) 0.0)
void postmultiply1(const BIAS::Matrix3x3< T > &M, Tensor3D3x3x3< T > &result) const
Compute S_{ijk} = T_{pjk} M_{pi}.
void premultiply3(const BIAS::Matrix3x3< T > &M, Tensor3D3x3x3< T > &result) const
compute S_{ijk} = M_{kp} T_{ijp}
INST(unsigned char)
is a &#39;fixed size&#39; quadratic matrix of dim.
Definition: Matrix.hh:54
void postmultiply3(const BIAS::Matrix3x3< T > &M, Tensor3D3x3x3< T > &result) const
Compute S_{ijk} = T_{ijp} M_{pk}.
void premultiply1(const BIAS::Matrix3x3< T > &M, Tensor3D3x3x3< T > &result) const
compute S_{ijk} = M_{ip} T_{pjk}
void NewSize(const int i, const int j, const int k, const T &def=(T) 0.0)