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
445 /**
446 multiplication with another compatible matrix (it is a real matrix multiplication)
447 Note that this operation does not avid to create a temporary to store intermediate result
448 */
449 template <class R2>
451
452 /**
453 multiplication with a compatible matrix expression (it is a real matrix multiplication)
454 */
455 template <class A, class R2>
457
458
459 /**
460 division with a scalar
461 */
462 SMatrix<T,D1,D2,R>& operator/=(const T& rhs);
463
464
465
466 /** @name --- Linear Algebra Functions --- */
467
468 /**
469 Invert a square Matrix ( this method changes the current matrix).
470 Return true if inversion is successful.
471 The method used for general square matrices is the LU factorization taken from Dinv routine
472 from the CERNLIB (written in C++ from CLHEP authors)
473 In case of symmetric matrices Bunch-Kaufman diagonal pivoting method is used
474 (The implementation is the one written by the CLHEP authors)
475 */
476 bool Invert();
477
478 /**
479 Invert a square Matrix and returns a new matrix. In case the inversion fails
480 the current matrix is returned.
481 \param ifail . ifail will be set to 0 when inversion is successful.
482 See ROOT::Math::SMatrix::Invert for the inversion algorithm
483 */
484 SMatrix<T,D1,D2,R> Inverse(int & ifail ) const;
485
486 /**
487 Fast inversion of a square Matrix ( this method changes the current matrix).
488 Return true if inversion is successful.
489 The method used is based on direct inversion using the Cramer rule for
490 matrices upto 5x5. Afterwards the same default algorithm of Invert() is used.
491 Note that this method is faster but can suffer from much larger numerical accuracy
492 when the condition of the matrix is large
493 */
494 bool InvertFast();
495
496 /**
497 Invert a square Matrix and returns a new matrix. In case the inversion fails
498 the current matrix is returned.
499 \param ifail . ifail will be set to 0 when inversion is successful.
500 See ROOT::Math::SMatrix::InvertFast for the inversion algorithm
501 */
502 SMatrix<T,D1,D2,R> InverseFast(int & ifail ) const;
503
504 /**
505 Inversion of a symmetric positive defined Matrix using Choleski decomposition.
506 ( this method changes the current matrix).
507 Return true if inversion is successful.
508 The method used is based on Choleski decomposition
509 A compile error is given if the matrix is not of type symmetric and a run-time failure if the
510 matrix is not positive defined.
511 For solving a linear system, it is possible to use also the function
512 ROOT::Math::SolveChol(matrix, vector) which will be faster than performing the inversion
513 */
514 bool InvertChol();
515
516 /**
517 Invert of a symmetric positive defined Matrix using Choleski decomposition.
518 A compile error is given if the matrix is not of type symmetric and a run-time failure if the
519 matrix is not positive defined.
520 In case the inversion fails the current matrix is returned.
521 \param ifail . ifail will be set to 0 when inversion is successful.
522 See ROOT::Math::SMatrix::InvertChol for the inversion algorithm
523 */
524 SMatrix<T,D1,D2,R> InverseChol(int & ifail ) const;
525
526 /**
527 determinant of square Matrix via Dfact.
528 Return true when the calculation is successful.
529 \param det will contain the calculated determinant value
530 \b Note: this will destroy the contents of the Matrix!
531 */
532 bool Det(T& det);
533
534 /**
535 determinant of square Matrix via Dfact.
536 Return true when the calculation is successful.
537 \param det will contain the calculated determinant value
538 \b Note: this will preserve the content of the Matrix!
539 */
540 bool Det2(T& det) const;
541
542
543 /** @name --- Matrix Slice Functions --- */
544
545 /// place a vector in a Matrix row
546 template <unsigned int D>
548 unsigned int row,
549 unsigned int col);
550 /// place a vector expression in a Matrix row
551 template <class A, unsigned int D>
553 unsigned int row,
554 unsigned int col);
555 /// place a vector in a Matrix column
556 template <unsigned int D>
558 unsigned int row,
559 unsigned int col);
560 /// place a vector expression in a Matrix column
561 template <class A, unsigned int D>
563 unsigned int row,
564 unsigned int col);
565 /// place a matrix in this matrix
566 template <unsigned int D3, unsigned int D4, class R2>
568 unsigned int row,
569 unsigned int col);
570 /// place a matrix expression in this matrix
571 template <class A, unsigned int D3, unsigned int D4, class R2>
573 unsigned int row,
574 unsigned int col);
575
576 /**
577 return a full Matrix row as a vector (copy the content in a new vector)
578 */
579 SVector<T,D2> Row(unsigned int therow) const;
580
581 /**
582 return a full Matrix column as a vector (copy the content in a new vector)
583 */
584 SVector<T,D1> Col(unsigned int thecol) const;
585
586 /**
587 return a slice of therow as a vector starting at the column value col0 until col0+N,
588 where N is the size of the vector (SVector::kSize )
589 Condition col0+N <= D2
590 */
591 template <class SubVector>
592 SubVector SubRow(unsigned int therow, unsigned int col0 = 0 ) const;
593
594 /**
595 return a slice of the column as a vector starting at the row value row0 until row0+Dsub.
596 where N is the size of the vector (SVector::kSize )
597 Condition row0+N <= D1
598 */
599 template <class SubVector>
600 SubVector SubCol(unsigned int thecol, unsigned int row0 = 0) const;
601
602 /**
603 return a submatrix with the upper left corner at the values (row0, col0) and with sizes N1, N2
604 where N1 and N2 are the dimension of the sub-matrix (SubMatrix::kRows and SubMatrix::kCols )
605 Condition row0+N1 <= D1 && col0+N2 <=D2
606 */
607 template <class SubMatrix >
608 SubMatrix Sub(unsigned int row0, unsigned int col0) const;
609
610 /**
611 return diagonal elements of a matrix as a Vector.
612 It works only for squared matrices D1 == D2, otherwise it will produce a compile error
613 */
614 SVector<T,D1> Diagonal() const;
615
616 /**
617 Set the diagonal elements from a Vector
618 Require that vector implements SVector::kSize since a check (statically) is done on
619 diagonal size == vector size
620 */
621 template <class Vector>
622 void SetDiagonal(const Vector & v);
623
624 /**
625 return the trace of a matrix
626 Sum of the diagonal elements
627 */
628 T Trace() const;
629
630
631 /**
632 return the upper Triangular block of the matrices (including the diagonal) as
633 a vector of sizes N = D1 * (D1 + 1)/2.
634 It works only for square matrices with D1==D2, otherwise it will produce a compile error
635 */
636#ifndef UNSUPPORTED_TEMPLATE_EXPRESSION
637 SVector<T, D1 * (D2 +1)/2> UpperBlock() const;
638#else
639 template<class SubVector>
640 SubVector UpperBlock() const;
641#endif
642
643 /**
644 return the lower Triangular block of the matrices (including the diagonal) as
645 a vector of sizes N = D1 * (D1 + 1)/2.
646 It works only for square matrices with D1==D2, otherwise it will produce a compile error
647 */
648#ifndef UNSUPPORTED_TEMPLATE_EXPRESSION
649 SVector<T, D1 * (D2 +1)/2> LowerBlock() const;
650#else
651 template<class SubVector>
652 SubVector LowerBlock() const;
653#endif
654
655
656 /** @name --- Other Functions --- */
657
658 /**
659 Function to check if a matrix is sharing same memory location of the passed pointer
660 This function is used by the expression templates to avoid the alias problem during
661 expression evaluation. When the matrix is in use, for example in operations
662 like A = B * A, a temporary object storing the intermediate result is automatically
663 created when evaluating the expression.
664
665 */
666 bool IsInUse(const T* p) const;
667
668 // submatrices
669
670 /// Print: used by operator<<()
671 std::ostream& Print(std::ostream& os) const;
672
673
674
675
676public:
677
678 /** @name --- Data Member --- */
679
680 /**
681 Matrix Storage Object containing matrix data
682 */
684
685}; // end of class SMatrix
686
687
688
689
690//==============================================================================
691// operator<<
692//==============================================================================
693template <class T, unsigned int D1, unsigned int D2, class R>
694inline std::ostream& operator<<(std::ostream& os, const ROOT::Math::SMatrix<T,D1,D2,R>& rhs) {
695 return rhs.Print(os);
696}
697
698
699 } // namespace Math
700
701} // namespace ROOT
702
703
704
705#include "Math/SMatrix.icc"
706
707#include "Math/MatrixFunctions.h"
708
709#endif /* ROOT_Math_SMatrix */
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
TBuffer & operator<<(TBuffer &buf, const Tmpl *obj)
Definition TBuffer.h:397
winID h TVirtualViewer3D TVirtualGLPainter p
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:683
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 SVector::kSize since a check (...
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()
Inversion 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
@ 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 > & 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 inversion 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 column 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
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...