Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
SMatrix.h
Go to the documentation of this file.
1// @(#)root/smatrix:$Id$
2// Author: T. Glebe, L. Moneta, J. Palacios 2005
3
4#ifndef ROOT_Math_SMatrix
5#define ROOT_Math_SMatrix
6
7/*********************************************************************************
8//
9// source:
10//
11// type: source code
12//
13// created: 20. Mar 2001
14//
15// author: Thorsten Glebe
16// HERA-B Collaboration
17// Max-Planck-Institut fuer Kernphysik
18// Saupfercheckweg 1
19// 69117 Heidelberg
20// Germany
21// E-mail: T.Glebe@mpi-hd.mpg.de
22//
23// Description: A fixed size two dimensional Matrix class
24//
25// changes:
26// 20 Mar 2001 (TG) creation
27// 21 Mar 2001 (TG) added operators +=, -=, *=, /=
28// 26 Mar 2001 (TG) place_in_row(), place_in_col() added
29// 02 Apr 2001 (TG) non-const Array() added
30// 03 Apr 2001 (TG) invert() added
31// 07 Apr 2001 (TG) CTOR from SVertex (dyadic product) added
32// 09 Apr 2001 (TG) CTOR from array added
33// 11 Apr 2001 (TG) rows(), cols(), size() replaced by rows, cols, size
34// 25 Mai 2001 (TG) row(), col() added
35// 04 Sep 2001 (TG) moved inlined functions to .icc file
36// 11 Jan 2002 (TG) added operator==(), operator!=()
37// 14 Jan 2002 (TG) added more operator==(), operator!=(), operator>(), operator<()
38//
39***************************************************************************/
40// for platform specific configurations
41
42#include "Math/MConfig.h"
43
44#include <iosfwd>
45
46
47/**
48\defgroup SMatrixSVector Matrix and Vector classes
49\ingroup SMatrixGroup
50
51Classes representing Matrices and Vectors of arbitrary type and dimension.
52For a detailed description and usage examples see:
53
54 - \ref SVectorDoc
55 - \ref SMatrixDoc
56 - \ref MatVecFunctions
57
58*/
59
60
61#include "Math/Expression.h"
63
64
65namespace ROOT {
66
67namespace Math {
68
69
70template <class T, unsigned int D> class SVector;
71
72struct SMatrixIdentity { };
73struct SMatrixNoInit { };
74
75//__________________________________________________________________________
76/**
77 SMatrix: a generic fixed size D1 x D2 Matrix class.
78 The class is template on the scalar type, on the matrix sizes:
79 D1 = number of rows and D2 = number of columns
80 amd on the representation storage type.
81 By default the representation is MatRepStd<T,D1,D2> (standard D1xD2 of type T),
82 but it can be of type MatRepSym<T,D> for symmetric matrices DxD, where the storage is only
83 D*(D+1)/2.
84
85 See \ref SMatrixDoc.
86
87 Original author is Thorsten Glebe
88 HERA-B Collaboration, MPI Heidelberg (Germany)
89
90 @ingroup SMatrixSVector
91
92 @authors T. Glebe, L. Moneta and J. Palacios
93*/
94//==============================================================================
95// SMatrix: column-wise storage
96//==============================================================================
97template <class T,
98 unsigned int D1,
99 unsigned int D2 = D1,
100 class R=MatRepStd<T, D1, D2> >
101class SMatrix {
102public:
103 /** @name --- Typedefs --- */
104
105 /** contained scalar type */
106 typedef T value_type;
107
108 /** storage representation type */
109 typedef R rep_type;
110
111 /** STL iterator interface. */
112 typedef T* iterator;
113
114 /** STL const_iterator interface. */
115 typedef const T* const_iterator;
116
117
118
119 /** @name --- Constructors and Assignment --- */
120
121 /**
122 Default constructor:
123 */
124 SMatrix();
125 ///
126 /**
127 construct from without initialization
128 */
130
131 /**
132 construct from an identity matrix
133 */
135 /**
136 copy constructor (from a matrix of the same representation
137 */
138 SMatrix(const SMatrix<T,D1,D2,R>& rhs);
139 /**
140 construct from a matrix with different representation.
141 Works only from symmetric to general and not viceversa.
142 */
143 template <class R2>
144 SMatrix(const SMatrix<T,D1,D2,R2>& rhs);
145
146 /**
147 Construct from an expression.
148 In case of symmetric matrices does not work if expression is of type general
149 matrices. In case one needs to force the assignment from general to symmetric, one can use the
150 ROOT::Math::AssignSym::Evaluate function.
151 */
152 template <class A, class R2>
153 SMatrix(const Expr<A,T,D1,D2,R2>& rhs);
154
155
156 /**
157 Constructor with STL iterator interface. The data will be copied into the matrix
158 \param begin start iterator position
159 \param end end iterator position
160 \param triang if true only the triangular lower/upper part of the matrix is filled from the iterators
161 \param lower if true the lower triangular part is filled
162
163 Size of the matrix must match size of the iterators, if triang is false, otherwise the size of the
164 triangular block. In the case of symmetric matrices triang is considered always to be true
165 (what-ever the user specifies) and the size of the iterators must be equal to the size of the
166 triangular block, which is the number of independent elements of a symmetric matrix: N*(N+1)/2
167
168 */
169 template<class InputIterator>
170 SMatrix(InputIterator begin, InputIterator end, bool triang = false, bool lower = true);
171
172 /**
173 Constructor with STL iterator interface. The data will be copied into the matrix
174 \param begin start iterator position
175 \param size iterator size
176 \param triang if true only the triangular lower/upper part of the matrix is filled from the iterators
177 \param lower if true the lower triangular part is filled
178
179 Size of the iterators must not be larger than the size of the matrix representation.
180 In the case of symmetric matrices the size is N*(N+1)/2.
181
182 */
183 template<class InputIterator>
184 SMatrix(InputIterator begin, unsigned int size, bool triang = false, bool lower = true);
185
186 /**
187 constructor of a symmetrix a matrix from a SVector containing the lower (upper)
188 triangular part.
189 */
190#ifndef UNSUPPORTED_TEMPLATE_EXPRESSION
191 SMatrix(const SVector<T, D1*(D2+1)/2> & v, bool lower = true );
192#else
193 template<unsigned int N>
194 SMatrix(const SVector<T,N> & v, bool lower = true );
195#endif
196
197
198 /**
199 Construct from a scalar value (only for size 1 matrices)
200 */
201 explicit SMatrix(const T& rhs);
202
203 /**
204 Assign from another compatible matrix.
205 Possible Symmetirc to general but NOT vice-versa
206 */
207 template <class M>
208 SMatrix<T,D1,D2,R>& operator=(const M& rhs);
209
211
212 /**
213 Assign from a matrix expression
214 */
215 template <class A, class R2>
217
218 /**
219 Assign from an identity matrix
220 */
222
223 /**
224 Assign from a scalar value (only for size 1 matrices)
225 */
226 SMatrix<T,D1,D2,R>& operator=(const T& rhs);
227
228 /** @name --- Matrix dimension --- */
229
230 /**
231 Enumeration defining the matrix dimension,
232 number of rows, columns and size = rows*columns)
233 */
234 enum {
235 /// return no. of matrix rows
236 kRows = D1,
237 /// return no. of matrix columns
238 kCols = D2,
239 /// return no of elements: rows*columns
240 kSize = D1*D2
241 };
242
243 /** @name --- Access functions --- */
244
245 /** access the parse tree with the index starting from zero and
246 following the C convention for the order in accessing
247 the matrix elements.
248 Same convention for general and symmetric matrices.
249 */
250 T apply(unsigned int i) const;
251
252 /// return read-only pointer to internal array
253 const T* Array() const;
254 /// return pointer to internal array
255 T* Array();
256
257 /** @name --- STL-like interface ---
258 The iterators access the matrix element in the order how they are
259 stored in memory. The C (row-major) convention is used, and in the
260 case of symmetric matrices the iterator spans only the lower diagonal
261 block. For example for a symmetric 3x3 matrices the order of the 6
262 elements \f${a_0,...a_5}\f$ is:
263 \f[
264 M = \left( \begin{array}{ccc}
265 a_0 & a_1 & a_3 \\
266 a_1 & a_2 & a_4 \\
267 a_3 & a_4 & a_5 \end{array} \right)
268 \f]
269 */
270
271 /** STL iterator interface. */
272 iterator begin();
273
274 /** STL iterator interface. */
275 iterator end();
276
277 /** STL const_iterator interface. */
278 const_iterator begin() const;
279
280 /** STL const_iterator interface. */
281 const_iterator end() const;
282
283 /**
284 Set matrix elements with STL iterator interface. The data will be copied into the matrix
285 \param begin start iterator position
286 \param end end iterator position
287 \param triang if true only the triangular lower/upper part of the matrix is filled from the iterators
288 \param lower if true the lower triangular part is filled
289
290 Size of the matrix must match size of the iterators, if triang is false, otherwise the size of the
291 triangular block. In the case of symmetric matrices triang is considered always to be true
292 (what-ever the user specifies) and the size of the iterators must be equal to the size of the
293 triangular block, which is the number of independent elements of a symmetric matrix: N*(N+1)/2
294
295 */
296 template<class InputIterator>
297 void SetElements(InputIterator begin, InputIterator end, bool triang = false, bool lower = true);
298
299 /**
300 Constructor with STL iterator interface. The data will be copied into the matrix
301 \param begin start iterator position
302 \param size iterator size
303 \param triang if true only the triangular lower/upper part of the matrix is filled from the iterators
304 \param lower if true the lower triangular part is filled
305
306 Size of the iterators must not be larger than the size of the matrix representation.
307 In the case of symmetric matrices the size is N*(N+1)/2.
308
309 */
310 template<class InputIterator>
311 void SetElements(InputIterator begin, unsigned int size, bool triang = false, bool lower = true);
312
313
314 /** @name --- Operators --- */
315 /// element wise comparison
316 bool operator==(const T& rhs) const;
317 /// element wise comparison
318 bool operator!=(const T& rhs) const;
319 /// element wise comparison
320 template <class R2>
321 bool operator==(const SMatrix<T,D1,D2,R2>& rhs) const;
322 /// element wise comparison
323 bool operator!=(const SMatrix<T,D1,D2,R>& rhs) const;
324 /// element wise comparison
325 template <class A, class R2>
326 bool operator==(const Expr<A,T,D1,D2,R2>& rhs) const;
327 /// element wise comparison
328 template <class A, class R2>
329 bool operator!=(const Expr<A,T,D1,D2,R2>& rhs) const;
330
331 /// element wise comparison
332 bool operator>(const T& rhs) const;
333 /// element wise comparison
334 bool operator<(const T& rhs) const;
335 /// element wise comparison
336 template <class R2>
337 bool operator>(const SMatrix<T,D1,D2,R2>& rhs) const;
338 /// element wise comparison
339 template <class R2>
340 bool operator<(const SMatrix<T,D1,D2,R2>& rhs) const;
341 /// element wise comparison
342 template <class A, class R2>
343 bool operator>(const Expr<A,T,D1,D2,R2>& rhs) const;
344 /// element wise comparison
345 template <class A, class R2>
346 bool operator<(const Expr<A,T,D1,D2,R2>& rhs) const;
347
348 /**
349 read only access to matrix element, with indices starting from 0
350 */
351 const T& operator()(unsigned int i, unsigned int j) const;
352 /**
353 read/write access to matrix element with indices starting from 0
354 */
355 T& operator()(unsigned int i, unsigned int j);
356
357 /**
358 read only access to matrix element, with indices starting from 0.
359 Function will check index values and it will assert if they are wrong
360 */
361 const T& At(unsigned int i, unsigned int j) const;
362 /**
363 read/write access to matrix element with indices starting from 0.
364 Function will check index values and it will assert if they are wrong
365 */
366 T& At(unsigned int i, unsigned int j);
367
368
369 // helper class for implementing the m[i][j] operator
370
372 public:
373 SMatrixRow ( SMatrix<T,D1,D2,R> & rhs, unsigned int i ) :
374 fMat(&rhs), fRow(i)
375 {}
376 T & operator[](int j) { return (*fMat)(fRow,j); }
377 private:
379 unsigned int fRow;
380 };
381
383 public:
384 SMatrixRow_const ( const SMatrix<T,D1,D2,R> & rhs, unsigned int i ) :
385 fMat(&rhs), fRow(i)
386 {}
387
388 const T & operator[](int j) const { return (*fMat)(fRow, j); }
389
390 private:
392 unsigned int fRow;
393 };
394
395 /**
396 read only access to matrix element, with indices starting from 0 : m[i][j]
397 */
398 SMatrixRow_const operator[](unsigned int i) const { return SMatrixRow_const(*this, i); }
399 /**
400 read/write access to matrix element with indices starting from 0 : m[i][j]
401 */
402 SMatrixRow operator[](unsigned int i) { return SMatrixRow(*this, i); }
403
404
405 /**
406 addition with a scalar
407 */
408 SMatrix<T,D1,D2,R>&operator+=(const T& rhs);
409
410 /**
411 addition with another matrix of any compatible representation
412 */
413 template <class R2>
415
416 /**
417 addition with a compatible matrix expression
418 */
419 template <class A, class R2>
421
422 /**
423 subtraction with a scalar
424 */
425 SMatrix<T,D1,D2,R>& operator-=(const T& rhs);
426
427 /**
428 subtraction with another matrix of any compatible representation
429 */
430 template <class R2>
432
433 /**
434 subtraction with a compatible matrix expression
435 */
436 template <class A, class R2>
438
439 /**
440 multiplication with a scalar
441 */
442 SMatrix<T,D1,D2,R>& operator*=(const T& rhs);
443
444#ifndef __CINT__
445
446
447 /**
448 multiplication with another compatible matrix (it is a real matrix multiplication)
449 Note that this operation does not avid to create a temporary to store intermidiate result
450 */
451 template <class R2>
453
454 /**
455 multiplication with a compatible matrix expression (it is a real matrix multiplication)
456 */
457 template <class A, class R2>
459
460#endif
461
462 /**
463 division with a scalar
464 */
465 SMatrix<T,D1,D2,R>& operator/=(const T& rhs);
466
467
468
469 /** @name --- Linear Algebra Functions --- */
470
471 /**
472 Invert a square Matrix ( this method changes the current matrix).
473 Return true if inversion is successfull.
474 The method used for general square matrices is the LU factorization taken from Dinv routine
475 from the CERNLIB (written in C++ from CLHEP authors)
476 In case of symmetric matrices Bunch-Kaufman diagonal pivoting method is used
477 (The implementation is the one written by the CLHEP authors)
478 */
479 bool Invert();
480
481 /**
482 Invert a square Matrix and returns a new matrix. In case the inversion fails
483 the current matrix is returned.
484 \param ifail . ifail will be set to 0 when inversion is successfull.
485 See ROOT::Math::SMatrix::Invert for the inversion algorithm
486 */
487 SMatrix<T,D1,D2,R> Inverse(int & ifail ) const;
488
489 /**
490 Fast Invertion of a square Matrix ( this method changes the current matrix).
491 Return true if inversion is successfull.
492 The method used is based on direct inversion using the Cramer rule for
493 matrices upto 5x5. Afterwards the same default algorithm of Invert() is used.
494 Note that this method is faster but can suffer from much larger numerical accuracy
495 when the condition of the matrix is large
496 */
497 bool InvertFast();
498
499 /**
500 Invert a square Matrix and returns a new matrix. In case the inversion fails
501 the current matrix is returned.
502 \param ifail . ifail will be set to 0 when inversion is successfull.
503 See ROOT::Math::SMatrix::InvertFast for the inversion algorithm
504 */
505 SMatrix<T,D1,D2,R> InverseFast(int & ifail ) const;
506
507 /**
508 Invertion of a symmetric positive defined Matrix using Choleski decomposition.
509 ( this method changes the current matrix).
510 Return true if inversion is successfull.
511 The method used is based on Choleski decomposition
512 A compile error is given if the matrix is not of type symmetric and a run-time failure if the
513 matrix is not positive defined.
514 For solving a linear system, it is possible to use also the function
515 ROOT::Math::SolveChol(matrix, vector) which will be faster than performing the inversion
516 */
517 bool InvertChol();
518
519 /**
520 Invert of a symmetric positive defined Matrix using Choleski decomposition.
521 A compile error is given if the matrix is not of type symmetric and a run-time failure if the
522 matrix is not positive defined.
523 In case the inversion fails the current matrix is returned.
524 \param ifail . ifail will be set to 0 when inversion is successfull.
525 See ROOT::Math::SMatrix::InvertChol for the inversion algorithm
526 */
527 SMatrix<T,D1,D2,R> InverseChol(int & ifail ) const;
528
529 /**
530 determinant of square Matrix via Dfact.
531 Return true when the calculation is successfull.
532 \param det will contain the calculated determinant value
533 \b Note: this will destroy the contents of the Matrix!
534 */
535 bool Det(T& det);
536
537 /**
538 determinant of square Matrix via Dfact.
539 Return true when the calculation is successfull.
540 \param det will contain the calculated determinant value
541 \b Note: this will preserve the content of the Matrix!
542 */
543 bool Det2(T& det) const;
544
545
546 /** @name --- Matrix Slice Functions --- */
547
548 /// place a vector in a Matrix row
549 template <unsigned int D>
551 unsigned int row,
552 unsigned int col);
553 /// place a vector expression in a Matrix row
554 template <class A, unsigned int D>
556 unsigned int row,
557 unsigned int col);
558 /// place a vector in a Matrix column
559 template <unsigned int D>
561 unsigned int row,
562 unsigned int col);
563 /// place a vector expression in a Matrix column
564 template <class A, unsigned int D>
566 unsigned int row,
567 unsigned int col);
568 /// place a matrix in this matrix
569 template <unsigned int D3, unsigned int D4, class R2>
571 unsigned int row,
572 unsigned int col);
573 /// place a matrix expression in this matrix
574 template <class A, unsigned int D3, unsigned int D4, class R2>
576 unsigned int row,
577 unsigned int col);
578
579 /**
580 return a full Matrix row as a vector (copy the content in a new vector)
581 */
582 SVector<T,D2> Row(unsigned int therow) const;
583
584 /**
585 return a full Matrix column as a vector (copy the content in a new vector)
586 */
587 SVector<T,D1> Col(unsigned int thecol) const;
588
589 /**
590 return a slice of therow as a vector starting at the colum value col0 until col0+N,
591 where N is the size of the vector (SubVector::kSize )
592 Condition col0+N <= D2
593 */
594 template <class SubVector>
595 SubVector SubRow(unsigned int therow, unsigned int col0 = 0 ) const;
596
597 /**
598 return a slice of the column as a vector starting at the row value row0 until row0+Dsub.
599 where N is the size of the vector (SubVector::kSize )
600 Condition row0+N <= D1
601 */
602 template <class SubVector>
603 SubVector SubCol(unsigned int thecol, unsigned int row0 = 0) const;
604
605 /**
606 return a submatrix with the upper left corner at the values (row0, col0) and with sizes N1, N2
607 where N1 and N2 are the dimension of the sub-matrix (SubMatrix::kRows and SubMatrix::kCols )
608 Condition row0+N1 <= D1 && col0+N2 <=D2
609 */
610 template <class SubMatrix >
611 SubMatrix Sub(unsigned int row0, unsigned int col0) const;
612
613 /**
614 return diagonal elements of a matrix as a Vector.
615 It works only for squared matrices D1 == D2, otherwise it will produce a compile error
616 */
617 SVector<T,D1> Diagonal() const;
618
619 /**
620 Set the diagonal elements from a Vector
621 Require that vector implements ::kSize since a check (statically) is done on
622 diagonal size == vector size
623 */
624 template <class Vector>
625 void SetDiagonal(const Vector & v);
626
627 /**
628 return the trace of a matrix
629 Sum of the diagonal elements
630 */
631 T Trace() const;
632
633
634 /**
635 return the upper Triangular block of the matrices (including the diagonal) as
636 a vector of sizes N = D1 * (D1 + 1)/2.
637 It works only for square matrices with D1==D2, otherwise it will produce a compile error
638 */
639#ifndef UNSUPPORTED_TEMPLATE_EXPRESSION
640 SVector<T, D1 * (D2 +1)/2> UpperBlock() const;
641#else
642 template<class SubVector>
643 SubVector UpperBlock() const;
644#endif
645
646 /**
647 return the lower Triangular block of the matrices (including the diagonal) as
648 a vector of sizes N = D1 * (D1 + 1)/2.
649 It works only for square matrices with D1==D2, otherwise it will produce a compile error
650 */
651#ifndef UNSUPPORTED_TEMPLATE_EXPRESSION
652 SVector<T, D1 * (D2 +1)/2> LowerBlock() const;
653#else
654 template<class SubVector>
655 SubVector LowerBlock() const;
656#endif
657
658
659 /** @name --- Other Functions --- */
660
661 /**
662 Function to check if a matrix is sharing same memory location of the passed pointer
663 This function is used by the expression templates to avoid the alias problem during
664 expression evaluation. When the matrix is in use, for example in operations
665 like A = B * A, a temporary object storing the intermediate result is automatically
666 created when evaluating the expression.
667
668 */
669 bool IsInUse(const T* p) const;
670
671 // submatrices
672
673 /// Print: used by operator<<()
674 std::ostream& Print(std::ostream& os) const;
675
676
677
678
679public:
680
681 /** @name --- Data Member --- */
682
683 /**
684 Matrix Storage Object containing matrix data
685 */
687
688}; // end of class SMatrix
689
690
691
692
693//==============================================================================
694// operator<<
695//==============================================================================
696template <class T, unsigned int D1, unsigned int D2, class R>
697inline std::ostream& operator<<(std::ostream& os, const ROOT::Math::SMatrix<T,D1,D2,R>& rhs) {
698 return rhs.Print(os);
699}
700
701
702 } // namespace Math
703
704} // namespace ROOT
705
706
707
708
709
710
711#ifndef __CINT__
712
713#include "Math/SMatrix.icc"
714
715#include "Math/MatrixFunctions.h"
716
717#endif //__CINT__
718
719#endif /* ROOT_Math_SMatrix */
TBuffer & operator<<(TBuffer &buf, const Tmpl *obj)
Definition TBuffer.h:399
Expression wrapper class for Matrix objects.
const SMatrix< T, D1, D2, R > * fMat
Definition SMatrix.h:391
const T & operator[](int j) const
Definition SMatrix.h:388
SMatrixRow_const(const SMatrix< T, D1, D2, R > &rhs, unsigned int i)
Definition SMatrix.h:384
SMatrix< T, D1, D2, R > * fMat
Definition SMatrix.h:378
SMatrixRow(SMatrix< T, D1, D2, R > &rhs, unsigned int i)
Definition SMatrix.h:373
SMatrix: a generic fixed size D1 x D2 Matrix class.
Definition SMatrix.h:101
SVector< T, D1 > Col(unsigned int thecol) const
return a full Matrix column as a vector (copy the content in a new vector)
Definition SMatrix.icc:590
SMatrix()
Default constructor:
Definition SMatrix.icc:72
SMatrix< T, D1, D2, R > & operator-=(const T &rhs)
subtraction with a scalar
Definition SMatrix.icc:228
T apply(unsigned int i) const
access the parse tree with the index starting from zero and following the C convention for the order ...
Definition SMatrix.icc:627
bool Det2(T &det) const
determinant of square Matrix via Dfact.
Definition SMatrix.icc:473
SVector< T, D1 *(D2+1)/2 > UpperBlock() const
return the upper Triangular block of the matrices (including the diagonal) as a vector of sizes N = D...
Definition SMatrix.icc:797
iterator end()
STL iterator interface.
Definition SMatrix.icc:675
const T & At(unsigned int i, unsigned int j) const
read only access to matrix element, with indices starting from 0.
Definition SMatrix.icc:653
bool Det(T &det)
determinant of square Matrix via Dfact.
Definition SMatrix.icc:466
SubVector SubCol(unsigned int thecol, unsigned int row0=0) const
return a slice of the column as a vector starting at the row value row0 until row0+Dsub.
Definition SMatrix.icc:728
bool operator>(const T &rhs) const
element wise comparison
Definition SMatrix.icc:347
std::ostream & Print(std::ostream &os) const
Print: used by operator<<()
Definition SMatrix.icc:603
SMatrix< T, D1, D2, R > & operator=(const M &rhs)
Assign from another compatible matrix.
Definition SMatrix.icc:155
SMatrix< T, D1, D2, R > & Place_at(const SMatrix< T, D3, D4, R2 > &rhs, unsigned int row, unsigned int col)
place a matrix in this matrix
Definition SMatrix.icc:552
SMatrix< T, D1, D2, R > Inverse(int &ifail) const
Invert a square Matrix and returns a new matrix.
Definition SMatrix.icc:419
SMatrixRow operator[](unsigned int i)
read/write access to matrix element with indices starting from 0 : m[i][j]
Definition SMatrix.h:402
SubMatrix Sub(unsigned int row0, unsigned int col0) const
return a submatrix with the upper left corner at the values (row0, col0) and with sizes N1,...
Definition SMatrix.icc:745
SMatrix< T, D1, D2, R > & operator*=(const T &rhs)
multiplication with a scalar
Definition SMatrix.icc:258
bool operator<(const T &rhs) const
element wise comparison
Definition SMatrix.icc:379
iterator begin()
STL iterator interface.
Definition SMatrix.icc:670
void SetElements(InputIterator begin, InputIterator end, bool triang=false, bool lower=true)
Set matrix elements with STL iterator interface.
Definition SMatrix.icc:692
R fRep
Matrix Storage Object containing matrix data.
Definition SMatrix.h:686
SMatrix(SMatrixNoInit)
construct from without initialization
Definition SMatrix.h:129
SMatrix< T, D1, D2, R > InverseFast(int &ifail) const
Invert a square Matrix and returns a new matrix.
Definition SMatrix.icc:436
bool operator==(const T &rhs) const
element wise comparison
Definition SMatrix.icc:299
SMatrixRow_const operator[](unsigned int i) const
read only access to matrix element, with indices starting from 0 : m[i][j]
Definition SMatrix.h:398
SMatrix< T, D1, D2, R > & Place_in_row(const SVector< T, D > &rhs, unsigned int row, unsigned int col)
place a vector in a Matrix row
Definition SMatrix.icc:484
SVector< T, D1 > Diagonal() const
return diagonal elements of a matrix as a Vector.
Definition SMatrix.icc:755
SMatrix< T, D1, D2, R > InverseChol(int &ifail) const
Invert of a symmetric positive defined Matrix using Choleski decomposition.
Definition SMatrix.icc:452
void SetDiagonal(const Vector &v)
Set the diagonal elements from a Vector Require that vector implements kSize since a check (staticall...
Definition SMatrix.icc:770
bool operator!=(const T &rhs) const
element wise comparison
Definition SMatrix.icc:327
T * iterator
STL iterator interface.
Definition SMatrix.h:112
const T * const_iterator
STL const_iterator interface.
Definition SMatrix.h:115
SMatrix< T, D1, D2, R > & operator+=(const T &rhs)
addition with a scalar
Definition SMatrix.icc:197
bool InvertChol()
Invertion of a symmetric positive defined Matrix using Choleski decomposition.
Definition SMatrix.icc:446
bool Invert()
Invert a square Matrix ( this method changes the current matrix).
Definition SMatrix.icc:412
bool IsInUse(const T *p) const
Function to check if a matrix is sharing same memory location of the passed pointer This function is ...
Definition SMatrix.icc:895
R rep_type
storage representation type
Definition SMatrix.h:109
SMatrix< T, D1, D2, R > & operator/=(const T &rhs)
division with a scalar
Definition SMatrix.icc:287
T value_type
contained scalar type
Definition SMatrix.h:106
bool InvertFast()
Fast Invertion of a square Matrix ( this method changes the current matrix).
Definition SMatrix.icc:429
SVector< T, D1 *(D2+1)/2 > LowerBlock() const
return the lower Triangular block of the matrices (including the diagonal) as a vector of sizes N = D...
Definition SMatrix.icc:826
T Trace() const
return the trace of a matrix Sum of the diagonal elements
Definition SMatrix.icc:784
SubVector SubRow(unsigned int therow, unsigned int col0=0) const
return a slice of therow as a vector starting at the colum value col0 until col0+N,...
Definition SMatrix.icc:712
const T & operator()(unsigned int i, unsigned int j) const
read only access to matrix element, with indices starting from 0
Definition SMatrix.icc:639
SVector< T, D2 > Row(unsigned int therow) const
return a full Matrix row as a vector (copy the content in a new vector)
Definition SMatrix.icc:575
const T * Array() const
return read-only pointer to internal array
Definition SMatrix.icc:630
@ kCols
return no. of matrix columns
Definition SMatrix.h:238
@ kRows
return no. of matrix rows
Definition SMatrix.h:236
@ kSize
return no of elements: rows*columns
Definition SMatrix.h:240
SMatrix< T, D1, D2, R > & Place_in_col(const SVector< T, D > &rhs, unsigned int row, unsigned int col)
place a vector in a Matrix column
Definition SMatrix.icc:518
SVector: a generic fixed size Vector class.
Definition SVector.h:75
Expression wrapper class for Vector objects.
Definition Expression.h:64
Namespace for new Math classes and functions.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...