Home
Install
Use
Develop
Support
News
Credits
hosted by
|
15 #include "complex_promote.h"
19 template < unsigned Rows, unsigned Columns, typename T>
31 for ( unsigned i=0; i<Rows; i++)
40 template< typename U> Matrix& operator =
43 for ( unsigned i=0; i<Rows; i++)
51 for ( unsigned i=0; i<Rows; i++)
52 for ( unsigned j=0; j<Columns; j++)
53 s.x[i][j] = -s.x[i][j];
59 for ( unsigned i=0; i<Rows; i++)
60 for ( unsigned j=0; j<Columns; j++)
61 this->x[i][j] = T(0.0);
67 template< unsigned Rows, unsigned Columns, typename T, typename U>
72 for ( unsigned i=0; i<Rows; i++)
78 template< unsigned Rows, unsigned Columns, typename T, typename U>
83 for ( unsigned j=0; j<Columns; j++)
84 for ( unsigned i=0; i<Rows; i++)
85 r[j] += m[i][j] * b[i];
90 template< unsigned R1, unsigned C1R2, unsigned C2, typename T>
95 for ( unsigned i=0; i<R1; i++)
96 for ( unsigned j=0; j<C2; j++)
97 for ( unsigned k=0; k<C1R2; k++)
98 r[i][j] += a[i][k]*b[k][j];
102 template < unsigned Rows, unsigned C1, typename T, unsigned C2, typename U>
113 for (i=0; i<Rows; i++) {
119 for (j=0; j<Rows; j++) {
121 for (k=0; k<Rows; k++) {
123 if (fabs(a[j][k]) >= big) {
129 else if (ipiv[k] > 1)
130 throw std::runtime_error( "GaussJordan (Matrix) Singular Matrix-1");
139 for (j=0; j<Rows; j++)
140 std::swap (a[irow][j], a[icol][j]);
142 std::swap (b[irow][j], b[icol][j]);
150 if (a[icol][icol] == 0.0)
151 throw std::runtime_error ( "GaussJordan (Matrix) Singular Matrix-2");
155 T pivinv = 1.0/a[icol][icol];
158 for (j=0; j<Rows; j++)
159 a[icol][j] *= pivinv;
161 b[icol][j] *= pivinv;
165 for (j=0; j<Rows; j++)
169 for (k=0; k<Rows; k++)
170 a[j][k] -= a[icol][k]*dum;
172 b[j][k] -= b[icol][k]*dum;
180 for (i=Rows; i>0; i--) {
181 if (indxr[i-1] != indxc[i-1])
182 for (j=0; j<Rows; j++)
183 std::swap(a[j][indxr[i-1]],a[j][indxc[i-1]]);
190 template < unsigned RC, typename T>
193 for ( unsigned i=0; i<RC; i++)
194 for ( unsigned j=0; j<RC; j++)
202 template< unsigned Square, typename T>
206 for ( unsigned i=0; i<Square; i++)
211 template < unsigned RC, typename T>
217 matrix_identity (inverse);
219 GaussJordan (copy, inverse);
224 template < unsigned Rows, unsigned Columns, typename T>
229 for ( unsigned i=0; i<Rows; i++)
230 for ( unsigned j=0; j<Columns; j++)
231 result[j][i] = m[i][j];
236 template < unsigned Rows, unsigned Columns, typename T>
241 for ( unsigned i=0; i<Rows; i++)
242 for ( unsigned j=0; j<Columns; j++)
243 result[j][i] = myconj( m[i][j] );
249 template< unsigned Rows, unsigned Columns, typename T, typename U>
255 for ( unsigned i=0; i<Rows; i++)
256 for ( unsigned j=0; j<Columns; j++)
257 result[i][j] = a[i] * b[j];
263 template< unsigned Ar, unsigned Ac, typename At,
264 unsigned Br, unsigned Bc, typename Bt>
270 for ( unsigned ar=0; ar<Ar; ar++)
271 for ( unsigned ac=0; ac<Ac; ac++)
272 for ( unsigned br=0; br<Br; br++)
273 for ( unsigned bc=0; bc<Bc; bc++)
274 result[ar*Br+br][ac*Bc+bc] = a[ar][ac] * b[br][bc];
280 template< unsigned U, unsigned L, unsigned B, unsigned R, typename T>
292 upper_left[i][j] = A[i][j];
294 upper_right[i][j] = A[i][j+L];
300 bottom_left[i][j] = A[i+U][j];
302 bottom_right[i][j] = A[i+U][j+L];
307 template< unsigned U, unsigned L, unsigned B, unsigned R, typename T>
319 A[i][j] = upper_left[i][j];
321 A[i][j+L] = upper_right[i][j];
327 A[i+U][j] = bottom_left[i][j];
329 A[i+U][j+L] = bottom_right[i][j];
334 template< unsigned M, typename T>
344 partition (covariance, ul, ur, bl, cov_matrix);
351 template< unsigned M, typename T>
363 for ( unsigned i=0; i<M; i++)
364 ur[0][i] = bl[i][0] = cov_vector[i];
366 compose (covariance, ul, ur, bl, cov_matrix);
377 double s = sin(radians);
378 double c = cos(radians);
384 ( v[0]*v[0]*u + c , v[1]*v[0]*u - v[2]*s, v[2]*v[0]*u + v[1]*s );
386 ( v[0]*v[1]*u + v[2]*s, v[1]*v[1]*u + c , v[2]*v[1]*u - v[0]*s );
388 ( v[0]*v[2]*u - v[1]*s, v[1]*v[2]*u + v[0]*s, v[2]*v[2]*u + c );
394 template< unsigned R, unsigned C, typename T>
397 T sum = normsq(v[0]);
398 for ( unsigned i=1; i < R; i++)
404 template< unsigned R, unsigned C, typename T>
409 static inline unsigned ndim () { return R*C; }
411 { return t[i/C][i%C]; }
412 static inline const T element ( const Matrix<R,C,T>& t, unsigned i)
413 { return t[i/C][i%C]; }
418 template< unsigned R, unsigned C, typename T>
419 std::ostream& operator<< (std::ostream& ostr, const Matrix<R,C,T>& m)
422 for ( unsigned i=1; i<R; i++)
423 ostr << ",\n " << m[i];
Matrix & operator=(const Vector< Rows, Vector< Columns, U > > &s)
friend const friend Matrix operator-(Matrix s)
Vector. Definition: Vector.h:22
Matrix is a column vector of row vectors. Definition: Matrix.h:20
Template class manages Reference::Able objects. Definition: Reference.h:74
Manages Reference::To references to the instance. Definition: ReferenceAble.h:40
Traits of the data type. Definition: Traits.h:70
Generated using doxygen 1.8.17
|