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