4 #ifndef ROOT_Math_SMatrix
5 #define ROOT_Math_SMatrix
93 template <
class T,
unsigned int D>
class SVector;
95 struct SMatrixIdentity { };
96 struct SMatrixNoInit { };
122 unsigned int D2 = D1,
123 class R=MatRepStd<T, D1, D2> >
129 typedef T value_type;
138 typedef const T* const_iterator;
152 inline SMatrix( SMatrixNoInit ){}
157 SMatrix( SMatrixIdentity );
161 SMatrix(
const SMatrix<T,D1,D2,R>& rhs);
167 SMatrix(
const SMatrix<T,D1,D2,R2>& rhs);
175 template <
class A,
class R2>
176 SMatrix(
const Expr<A,T,D1,D2,R2>& rhs);
192 template<
class InputIterator>
193 SMatrix(InputIterator begin, InputIterator end,
bool triang =
false,
bool lower =
true);
206 template<
class InputIterator>
207 SMatrix(InputIterator begin,
unsigned int size,
bool triang =
false,
bool lower =
true);
213 #ifndef UNSUPPORTED_TEMPLATE_EXPRESSION
214 SMatrix(
const SVector<T, D1*(D2+1)/2> & v,
bool lower =
true );
216 template<
unsigned int N>
217 SMatrix(
const SVector<T,N> & v,
bool lower =
true );
224 explicit SMatrix(
const T& rhs);
231 SMatrix<T,D1,D2,R>& operator=(
const M& rhs);
233 SMatrix<T,D1,D2,R>& operator=(
const SMatrix<T,D1,D2,R>& rhs);
238 template <
class A,
class R2>
239 SMatrix<T,D1,D2,R>& operator=(
const Expr<A,T,D1,D2,R2>& rhs);
244 SMatrix<T,D1,D2,R> & operator=(SMatrixIdentity );
249 SMatrix<T,D1,D2,R>& operator=(
const T& rhs);
273 T apply(
unsigned int i)
const;
276 const T* Array()
const;
301 const_iterator begin()
const;
304 const_iterator end()
const;
319 template<
class InputIterator>
320 void SetElements(InputIterator begin, InputIterator end,
bool triang =
false,
bool lower =
true);
333 template<
class InputIterator>
334 void SetElements(InputIterator begin,
unsigned int size,
bool triang =
false,
bool lower =
true);
339 bool operator==(
const T& rhs)
const;
341 bool operator!=(
const T& rhs)
const;
344 bool operator==(
const SMatrix<T,D1,D2,R2>& rhs)
const;
346 bool operator!=(
const SMatrix<T,D1,D2,R>& rhs)
const;
348 template <
class A,
class R2>
349 bool operator==(
const Expr<A,T,D1,D2,R2>& rhs)
const;
351 template <
class A,
class R2>
352 bool operator!=(
const Expr<A,T,D1,D2,R2>& rhs)
const;
355 bool operator>(
const T& rhs)
const;
357 bool operator<(
const T& rhs)
const;
360 bool operator>(
const SMatrix<T,D1,D2,R2>& rhs)
const;
363 bool operator<(const SMatrix<T,D1,D2,R2>& rhs)
const;
365 template <
class A,
class R2>
366 bool operator>(
const Expr<A,T,D1,D2,R2>& rhs)
const;
368 template <
class A,
class R2>
369 bool operator<(const Expr<A,T,D1,D2,R2>& rhs)
const;
374 const T& operator()(
unsigned int i,
unsigned int j)
const;
378 T& operator()(
unsigned int i,
unsigned int j);
384 const T& At(
unsigned int i,
unsigned int j)
const;
389 T& At(
unsigned int i,
unsigned int j);
396 SMatrixRow ( SMatrix<T,D1,D2,R> & rhs,
unsigned int i ) :
399 T & operator[](
int j) {
return (*fMat)(fRow,j); }
401 SMatrix<T,D1,D2,R> * fMat;
405 class SMatrixRow_const {
407 SMatrixRow_const (
const SMatrix<T,D1,D2,R> & rhs,
unsigned int i ) :
411 const T & operator[](
int j)
const {
return (*fMat)(fRow, j); }
414 const SMatrix<T,D1,D2,R> * fMat;
421 SMatrixRow_const operator[](
unsigned int i)
const {
return SMatrixRow_const(*
this, i); }
425 SMatrixRow operator[](
unsigned int i) {
return SMatrixRow(*
this, i); }
431 SMatrix<T,D1,D2,R>&operator+=(
const T& rhs);
437 SMatrix<T,D1,D2,R>&operator+=(
const SMatrix<T,D1,D2,R2>& rhs);
442 template <
class A,
class R2>
443 SMatrix<T,D1,D2,R>& operator+=(
const Expr<A,T,D1,D2,R2>& rhs);
448 SMatrix<T,D1,D2,R>& operator-=(
const T& rhs);
454 SMatrix<T,D1,D2,R>&operator-=(
const SMatrix<T,D1,D2,R2>& rhs);
459 template <
class A,
class R2>
460 SMatrix<T,D1,D2,R>& operator-=(
const Expr<A,T,D1,D2,R2>& rhs);
465 SMatrix<T,D1,D2,R>& operator*=(
const T& rhs);
475 SMatrix<T,D1,D2,R>& operator*=(
const SMatrix<T,D1,D2,R2>& rhs);
480 template <
class A,
class R2>
481 SMatrix<T,D1,D2,R>& operator*=(
const Expr<A,T,D1,D2,R2>& rhs);
488 SMatrix<T,D1,D2,R>& operator/=(
const T& rhs);
510 SMatrix<T,D1,D2,R> Inverse(
int & ifail )
const;
528 SMatrix<T,D1,D2,R> InverseFast(
int & ifail )
const;
550 SMatrix<T,D1,D2,R> InverseChol(
int & ifail )
const;
566 bool Det2(T& det)
const;
572 template <
unsigned int D>
573 SMatrix<T,D1,D2,R>& Place_in_row(
const SVector<T,D>& rhs,
577 template <
class A,
unsigned int D>
578 SMatrix<T,D1,D2,R>& Place_in_row(
const VecExpr<A,T,D>& rhs,
582 template <
unsigned int D>
583 SMatrix<T,D1,D2,R>& Place_in_col(
const SVector<T,D>& rhs,
587 template <
class A,
unsigned int D>
588 SMatrix<T,D1,D2,R>& Place_in_col(
const VecExpr<A,T,D>& rhs,
592 template <
unsigned int D3,
unsigned int D4,
class R2>
593 SMatrix<T,D1,D2,R>& Place_at(
const SMatrix<T,D3,D4,R2>& rhs,
597 template <
class A,
unsigned int D3,
unsigned int D4,
class R2>
598 SMatrix<T,D1,D2,R>& Place_at(
const Expr<A,T,D3,D4,R2>& rhs,
605 SVector<T,D2> Row(
unsigned int therow)
const;
610 SVector<T,D1> Col(
unsigned int thecol)
const;
617 template <
class SubVector>
618 SubVector SubRow(
unsigned int therow,
unsigned int col0 = 0 )
const;
625 template <
class SubVector>
626 SubVector SubCol(
unsigned int thecol,
unsigned int row0 = 0)
const;
633 template <
class SubMatrix >
634 SubMatrix Sub(
unsigned int row0,
unsigned int col0)
const;
640 SVector<T,D1> Diagonal()
const;
647 template <
class Vector>
648 void SetDiagonal(
const Vector & v);
662 #ifndef UNSUPPORTED_TEMPLATE_EXPRESSION
663 SVector<T, D1 * (D2 +1)/2> UpperBlock()
const;
665 template<
class SubVector>
666 SubVector UpperBlock()
const;
674 #ifndef UNSUPPORTED_TEMPLATE_EXPRESSION
675 SVector<T, D1 * (D2 +1)/2> LowerBlock()
const;
677 template<
class SubVector>
678 SubVector LowerBlock()
const;
692 bool IsInUse(
const T* p)
const;
697 std::ostream& Print(std::ostream& os)
const;
719 template <
class T,
unsigned int D1,
unsigned int D2,
class R>
720 inline std::ostream& operator<<(std::ostream& os, const ROOT::Math::SMatrix<T,D1,D2,R>& rhs) {
721 return rhs.Print(os);