4#ifndef ROOT_Math_SMatrix_icc
5#define ROOT_Math_SMatrix_icc
37#ifndef ROOT_Math_SMatrix
38#error "Do not use SMatrix.icc directly. #include \"Math/SMatrix.h\" instead."
71template <
class T,
unsigned int D1,
unsigned int D2,
class R>
74 for(
unsigned int i=0; i<
R::kSize; ++i) fRep.Array()[i] = 0;
78template <
class T,
unsigned int D1,
unsigned int D2,
class R>
80 for(
unsigned int i=0; i<
R::kSize; ++i)
83 for(
unsigned int i=0; i<D1; ++i)
87 for(
unsigned int i=0; i<D2; ++i)
92template <
class T,
unsigned int D1,
unsigned int D2,
class R>
98template <
class T,
unsigned int D1,
unsigned int D2,
class R>
105template <
class T,
unsigned int D1,
unsigned int D2,
class R>
106template <
class A,
class R2>
115template <
class T,
unsigned int D1,
unsigned int D2,
class R>
116template <
class InputIterator>
123template <
class T,
unsigned int D1,
unsigned int D2,
class R>
124template <
class InputIterator>
128 for(
unsigned int i=0; i<
R::kSize; ++i) fRep.Array()[i] = 0;
137template <
class T,
unsigned int D1,
unsigned int D2,
class R>
143template <
class T,
unsigned int D1,
unsigned int D2,
class R>
153template <
class T,
unsigned int D1,
unsigned int D2,
class R>
160template <
class T,
unsigned int D1,
unsigned int D2,
class R>
166template <
class T,
unsigned int D1,
unsigned int D2,
class R>
167template <
class A,
class R2>
168SMatrix<T,D1,D2,R>&
SMatrix<T,D1,D2,R>::operator=(
const Expr<A,T,D1,D2,R2>& rhs) {
176template <
class T,
unsigned int D1,
unsigned int D2,
class R>
178 for(
unsigned int i=0; i<
R::kSize; ++i)
181 for(
unsigned int i=0; i<D1; ++i)
185 for(
unsigned int i=0; i<D2; ++i)
196template <
class T,
unsigned int D1,
unsigned int D2,
class R>
199 for(
unsigned int i=0; i<
R::kSize; ++i) {
200 fRep.Array()[i] += rhs;
205template <
class T,
unsigned int D1,
unsigned int D2,
class R>
215template <
class T,
unsigned int D1,
unsigned int D2,
class R>
216template <
class A,
class R2>
217SMatrix<T,D1,D2,R>&
SMatrix<T,D1,D2,R>::operator+=(
const Expr<A,T,D1,D2,R2>& rhs) {
227template <
class T,
unsigned int D1,
unsigned int D2,
class R>
230 for(
unsigned int i=0; i<
R::kSize; ++i) {
236template <
class T,
unsigned int D1,
unsigned int D2,
class R>
246template <
class T,
unsigned int D1,
unsigned int D2,
class R>
247template <
class A,
class R2>
248SMatrix<T,D1,D2,R>&
SMatrix<T,D1,D2,R>::operator-=(
const Expr<A,T,D1,D2,R2>& rhs) {
257template <
class T,
unsigned int D1,
unsigned int D2,
class R>
260 for(
unsigned int i=0; i<
R::kSize; ++i) {
261 fRep.
Array()[i] *= rhs;
266template <
class T,
unsigned int D1,
unsigned int D2,
class R>
274template <
class T,
unsigned int D1,
unsigned int D2,
class R>
275template <
class A,
class R2>
276SMatrix<T,D1,D2,R>&
SMatrix<T,D1,D2,R>::operator*=(
const Expr<A,T,D1,D2,R2>& rhs) {
286template <
class T,
unsigned int D1,
unsigned int D2,
class R>
289 for(
unsigned int i=0; i<
R::kSize; ++i) {
290 fRep.
Array()[i] /= rhs;
298template <
class T,
unsigned int D1,
unsigned int D2,
class R>
302 rc = rc && (fRep.Array()[i] == rhs);
307template <
class T,
unsigned int D1,
unsigned int D2,
class R>
310 return fRep == rhs.
fRep;
313template <
class T,
unsigned int D1,
unsigned int D2,
class R>
314template <
class A,
class R2>
317 for(
unsigned int i=0; i<D1*D2; ++i) {
318 rc = rc && (fRep[i] == rhs.
apply(i));
326template <
class T,
unsigned int D1,
unsigned int D2,
class R>
331template <
class T,
unsigned int D1,
unsigned int D2,
class R>
336template <
class T,
unsigned int D1,
unsigned int D2,
class R>
337template <
class A,
class R2>
346template <
class T,
unsigned int D1,
unsigned int D2,
class R>
349 for(
unsigned int i=0; i<D1*D2; ++i) {
350 rc = rc && (fRep[i] > rhs);
355template <
class T,
unsigned int D1,
unsigned int D2,
class R>
359 for(
unsigned int i=0; i<D1*D2; ++i) {
360 rc = rc && (fRep[i] > rhs.
fRep[i]);
365template <
class T,
unsigned int D1,
unsigned int D2,
class R>
366template <
class A,
class R2>
369 for(
unsigned int i=0; i<D1*D2; ++i) {
370 rc = rc && (fRep[i] > rhs.
apply(i));
378template <
class T,
unsigned int D1,
unsigned int D2,
class R>
381 for(
unsigned int i=0; i<D1*D2; ++i) {
382 rc = rc && (fRep[i] < rhs);
387template <
class T,
unsigned int D1,
unsigned int D2,
class R>
391 for(
unsigned int i=0; i<D1*D2; ++i) {
392 rc = rc && (fRep[i] < rhs.
fRep[i]);
397template <
class T,
unsigned int D1,
unsigned int D2,
class R>
398template <
class A,
class R2>
401 for(
unsigned int i=0; i<D1*D2; ++i) {
402 rc = rc && (fRep[i] < rhs.
apply(i));
411template <
class T,
unsigned int D1,
unsigned int D2,
class R>
418template <
class T,
unsigned int D1,
unsigned int D2,
class R>
428template <
class T,
unsigned int D1,
unsigned int D2,
class R>
435template <
class T,
unsigned int D1,
unsigned int D2,
class R>
438 bool ok = tmp.InvertFast();
445template <
class T,
unsigned int D1,
unsigned int D2,
class R>
451template <
class T,
unsigned int D1,
unsigned int D2,
class R>
465template <
class T,
unsigned int D1,
unsigned int D2,
class R>
472template <
class T,
unsigned int D1,
unsigned int D2,
class R>
482template <
class T,
unsigned int D1,
unsigned int D2,
class R>
483template <
unsigned int D>
490 for(
unsigned int i=row*D2+col, j=0; j<D; ++i, ++j) {
491 fRep[i] = rhs.
apply(j);
499template <
class T,
unsigned int D1,
unsigned int D2,
class R>
500template <
class A,
unsigned int D>
507 for(
unsigned int i=row*D2+col, j=0; j<D; ++i, ++j) {
508 fRep[i] = rhs.
apply(j);
516template <
class T,
unsigned int D1,
unsigned int D2,
class R>
517template <
unsigned int D>
524 for(
unsigned int i=row*D2+col, j=0; j<D; i+=D2, ++j) {
525 fRep[i] = rhs.
apply(j);
533template <
class T,
unsigned int D1,
unsigned int D2,
class R>
534template <
class A,
unsigned int D>
541 for(
unsigned int i=row*D2+col, j=0; j<D; i+=D2, ++j) {
542 fRep[i] = rhs.
apply(j);
550template <
class T,
unsigned int D1,
unsigned int D2,
class R>
551template <
unsigned int D3,
unsigned int D4,
class R2>
552SMatrix<T,D1,D2,R>&
SMatrix<T,D1,D2,R>::Place_at(
const SMatrix<T,D3,D4,R2>& rhs,
562template <
class T,
unsigned int D1,
unsigned int D2,
class R>
563template <
class A,
unsigned int D3,
unsigned int D4,
class R2>
564SMatrix<T,D1,D2,R>&
SMatrix<T,D1,D2,R>::Place_at(
const Expr<A,T,D3,D4,R2>& rhs,
567 PlaceExpr<T,D1,D2,D3,D4,A,R,R2>::Evaluate(*
this,rhs,row,col);
574template <
class T,
unsigned int D1,
unsigned int D2,
class R>
577 const unsigned int offset = therow*D2;
580 for(
unsigned int i=0; i<D2; ++i) {
581 tmp[i] = fRep[offset+i];
589template <
class T,
unsigned int D1,
unsigned int D2,
class R>
593 for(
unsigned int i=0; i<D1; ++i) {
594 tmp[i] = fRep[thecol+i*D2];
602template <
class T,
unsigned int D1,
unsigned int D2,
class R>
604 const std::ios_base::fmtflags prevFmt = os.setf(std::ios::right,std::ios::adjustfield);
608 for (
unsigned int i=0; i < D1; ++i) {
609 for (
unsigned int j=0; j < D2; ++j) {
610 os << std::setw(12) << fRep[i*D2+j];
611 if ((!((j+1)%12)) && (j < D2-1))
612 os << std::endl <<
" ...";
615 os << std::endl <<
" ";
619 if (prevFmt != os.flags() ) os.setf(prevFmt, std::ios::adjustfield);
626template <
class T,
unsigned int D1,
unsigned int D2,
class R>
629template <
class T,
unsigned int D1,
unsigned int D2,
class R>
632template <
class T,
unsigned int D1,
unsigned int D2,
class R>
638template <
class T,
unsigned int D1,
unsigned int D2,
class R>
643template <
class T,
unsigned int D1,
unsigned int D2,
class R>
652template <
class T,
unsigned int D1,
unsigned int D2,
class R>
659template <
class T,
unsigned int D1,
unsigned int D2,
class R>
669template <
class T,
unsigned int D1,
unsigned int D2,
class R>
674template <
class T,
unsigned int D1,
unsigned int D2,
class R>
679template <
class T,
unsigned int D1,
unsigned int D2,
class R>
684template <
class T,
unsigned int D1,
unsigned int D2,
class R>
690template <
class T,
unsigned int D1,
unsigned int D2,
class R>
691template <
class InputIterator>
697template <
class T,
unsigned int D1,
unsigned int D2,
class R>
698template <
class InputIterator>
710template <
class T,
unsigned int D1,
unsigned int D2,
class R>
711template <
class SubVector>
714 const unsigned int offset = therow*D2 + col0;
721 tmp[i] = fRep[offset+i];
726template <
class T,
unsigned int D1,
unsigned int D2,
class R>
727template <
class SubVector>
730 const unsigned int offset = thecol + row0*D1;
737 tmp[i] = fRep[offset+i*D1];
743template <
class T,
unsigned int D1,
unsigned int D2,
class R>
744template <
class SubMatrix>
749 (tmp,*
this,row0,col0);
754template <
class T,
unsigned int D1,
unsigned int D2,
class R>
761 for(
unsigned int i=0; i<D1; ++i) {
762 tmp[i] = fRep[ i*D2 + i];
768template <
class T,
unsigned int D1,
unsigned int D2,
class R>
769template <
class Vector>
774 ( ( D2 < D1 ) &&
Vector::kSize == D2 ), SVector_size_NOT_correct );
778 fRep[ i*D2 + i] =
v[i];
783template <
class T,
unsigned int D1,
unsigned int D2,
class R>
785 unsigned int diagSize = D1;
786 if (D2 < D1) diagSize = D2;
788 for(
unsigned int i=0; i< diagSize; ++i) {
789 trace += fRep[ i*D2 + i] ;
795template <
class T,
unsigned int D1,
unsigned int D2,
class R>
796#ifndef UNSUPPORTED_TEMPLATE_EXPRESSION
799template <
class SubVector>
805#ifndef UNSUPPORTED_TEMPLATE_EXPRESSION
814 for(
unsigned int i=0; i<D1; ++i) {
815 for(
unsigned int j=i; j<D2; ++j) {
816 tmp[k] = fRep[ i*D2 + j];
824template <
class T,
unsigned int D1,
unsigned int D2,
class R>
825#ifndef UNSUPPORTED_TEMPLATE_EXPRESSION
828template <
class SubVector>
835#ifndef UNSUPPORTED_TEMPLATE_EXPRESSION
844 for(
unsigned int i=0; i<D1; ++i) {
845 for(
unsigned int j=0; j<=i; ++j) {
846 tmp[k] = fRep[ i*D2 + j];
856template <
class T,
unsigned int D1,
unsigned int D2,
class R>
857#ifndef UNSUPPORTED_TEMPLATE_EXPRESSION
860template <
unsigned int N>
867#ifdef UNSUPPORTED_TEMPLATE_EXPRESSION
874 for(
unsigned int i=0; i<D1; ++i) {
875 for(
unsigned int j=0; j<=i; ++j) {
876 fRep[ i*D2 + j] =
v[k];
877 if ( i != j) fRep[ j*D2 + i] =
v[k];
883 for(
unsigned int i=0; i<D1; ++i) {
884 for(
unsigned int j=i; j<D2; ++j) {
885 fRep[ i*D2 + j] =
v[k];
886 if ( i != j) fRep[ j*D2 + i] =
v[k];
894template <
class T,
unsigned int D1,
unsigned int D2,
class R>
896 return p == fRep.
Array();
#define STATIC_CHECK(expr, msg)
Bool_t operator>(const TDatime &d1, const TDatime &d2)
Bool_t operator!=(const TDatime &d1, const TDatime &d2)
Bool_t operator<(const TDatime &d1, const TDatime &d2)
Bool_t operator==(const TDatime &d1, const TDatime &d2)
TRObject operator()(const T1 &t1) const
Binding & operator=(OUT(*fun)(void))
std::string & operator+=(std::string &left, const TString &right)
Detrminant for a general squared matrix Function to compute the determinant from a square matrix ( ) ...
T apply(unsigned int i) const
Fast Matrix Inverter class Class to specialize calls to Dinv.
Matrix Inverter class Class to specialize calls to Dinv.
SMatrix: a generic fixed size D1 x D2 Matrix class.
SMatrix()
Default constructor:
bool Det(T &det)
determinant of square Matrix via Dfact.
R fRep
Matrix Storage Object containing matrix data.
bool operator==(const T &rhs) const
element wise comparison
bool InvertChol()
Invertion of a symmetric positive defined Matrix using Choleski decomposition.
bool Invert()
Invert a square Matrix ( this method changes the current matrix).
const T * Array() const
return read-only pointer to internal array
SVector: a generic fixed size Vector class.
T apply(unsigned int i) const
access the parse tree. Index starts from zero
Expression wrapper class for Vector objects.
T apply(unsigned int i) const
Namespace for new Math classes and functions.
void Print(std::ostream &os, const OptionType &opt)
int Invert(LASymMatrix &)
ABObj< sym, MatrixInverse< sym, ABObj< sym, LASymMatrix, double >, double >, double > Inverse(const ABObj< sym, LASymMatrix, double > &obj)
LAPACK Algebra functions specialize the Invert function for LASymMatrix.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Structure for assignment to a general matrix from iterator.
Structure to assign from an expression based to general matrix to general matrix.
Evaluate the expression performing a -= operation Need to check whether creating a temporary object w...
Structure to deal when a submatrix is placed in a matrix.
Evaluate the expression performing a += operation Need to check whether creating a temporary object w...
Structure for getting sub matrices We have different cases according to the matrix representations.