4 #ifndef ROOT_Math_HelperOps
5 #define ROOT_Math_HelperOps 1
28 template <
class T,
unsigned int D1,
unsigned int D2,
class R>
31 template <
class A,
class T,
unsigned int D1,
unsigned int D2,
class R>
34 template <
class T,
unsigned int D>
37 template <
class T,
unsigned int D1,
unsigned int D2>
45 unsigned int D1,
unsigned int D2,
46 class A,
class R1,
class R2>
59 for(
unsigned int i=0; i<D1; ++i)
60 for(
unsigned int j=0; j<D2; ++j) {
61 lhs.
fRep[
l] = rhs(i,j);
70 for(
unsigned int i=0; i<D1; ++i)
71 for(
unsigned int j=0; j<D2; ++j) {
76 for(
unsigned int i=0; i<D1*D2; ++i) lhs.
fRep[i] = tmp[i];
87 unsigned int D1,
unsigned int D2,
100 if (! rhs.IsInUse(lhs.begin() ) ) {
102 for(
unsigned int i=0; i<D1; ++i)
104 for(
unsigned int j=0; j<=i; ++j) {
105 lhs.fRep.Array()[
l] = rhs(i,j);
113 for(
unsigned int i=0; i<D1; ++i)
114 for(
unsigned int j=0; j<=i; ++j) {
130 template <
class T,
unsigned int D1,
unsigned int D2,
class A>
136 STATIC_CHECK(0==1, Cannot_assign_general_to_symmetric_matrix);
160 for(
unsigned int i=0; i<D; ++i)
162 for(
unsigned int j=0; j<=i; ++j) {
163 lhs.fRep.Array()[
l] = rhs(i,j);
175 for(
unsigned int i=0; i<D; ++i)
177 for(
unsigned int j=0; j<=i; ++j) {
178 lhs.fRep.Array()[
l] = rhs(i,j);
193 template <
class T,
unsigned int D1,
unsigned int D2,
class A,
201 for(
unsigned int i=0; i<D1; ++i)
202 for(
unsigned int j=0; j<D2; ++j) {
203 lhs.
fRep[
l] += rhs(i,j);
210 for(
unsigned int i=0; i<D1; ++i)
211 for(
unsigned int j=0; j<D2; ++j) {
216 for(
unsigned int i=0; i<D1*D2; ++i) lhs.
fRep[i] += tmp[i];
230 unsigned int D1,
unsigned int D2,
234 static void Evaluate(
SMatrix<T,D1,D2,
MatRepSym<T,D1> >& lhs,
const Expr<A,T,D1,D2,
MatRepSym<T,D1> >& rhs)
236 if (! rhs.IsInUse(lhs.begin() ) ) {
238 for(
unsigned int i=0; i<D1; ++i)
239 for(
unsigned int j=0; j<=i; ++j) {
240 lhs.fRep.Array()[
l] += rhs(i,j);
247 for(
unsigned int i=0; i<D1; ++i)
248 for(
unsigned int j=0; j<=i; ++j) {
260 template <
class T,
unsigned int D1,
unsigned int D2,
class A>
266 STATIC_CHECK(0==1, Cannot_plusEqual_general_to_symmetric_matrix);
277 template <
class T,
unsigned int D1,
unsigned int D2,
class A,
285 for(
unsigned int i=0; i<D1; ++i)
286 for(
unsigned int j=0; j<D2; ++j) {
287 lhs.
fRep[
l] -= rhs(i,j);
294 for(
unsigned int i=0; i<D1; ++i)
295 for(
unsigned int j=0; j<D2; ++j) {
300 for(
unsigned int i=0; i<D1*D2; ++i) lhs.
fRep[i] -= tmp[i];
313 unsigned int D1,
unsigned int D2,
317 static void Evaluate(
SMatrix<T,D1,D2,
MatRepSym<T,D1> >& lhs,
const Expr<A,T,D1,D2,
MatRepSym<T,D1> >& rhs)
319 if (! rhs.IsInUse(lhs.begin() ) ) {
321 for(
unsigned int i=0; i<D1; ++i)
322 for(
unsigned int j=0; j<=i; ++j) {
323 lhs.fRep.Array()[
l] -= rhs(i,j);
330 for(
unsigned int i=0; i<D1; ++i)
331 for(
unsigned int j=0; j<=i; ++j) {
344 template <
class T,
unsigned int D1,
unsigned int D2,
class A>
350 STATIC_CHECK(0==1, Cannot_minusEqual_general_to_symmetric_matrix);
358 template <
class T,
unsigned int D1,
unsigned int D2,
359 unsigned int D3,
unsigned int D4,
364 unsigned int row,
unsigned int col) {
366 assert(row+D3 <= D1 && col+D4 <= D2);
367 const unsigned int offset = row*D2+col;
369 for(
unsigned int i=0; i<D3*D4; ++i) {
370 lhs.
fRep[offset+(i/D4)*D2+i%D4] = rhs.
apply(i);
376 template <
class T,
unsigned int D1,
unsigned int D2,
377 unsigned int D3,
unsigned int D4,
378 class A,
class R1,
class R2>
381 unsigned int row,
unsigned int col) {
383 assert(row+D3 <= D1 && col+D4 <= D2);
384 const unsigned int offset = row*D2+col;
386 for(
unsigned int i=0; i<D3*D4; ++i) {
387 lhs.
fRep[offset+(i/D4)*D2+i%D4] = rhs.
apply(i);
393 template <
class T,
unsigned int D1,
unsigned int D2,
394 unsigned int D3,
unsigned int D4 >
398 unsigned int ,
unsigned int )
400 STATIC_CHECK(0==1, Cannot_Place_Matrix_general_in_symmetric_matrix);
405 template <
class T,
unsigned int D1,
unsigned int D2,
406 unsigned int D3,
unsigned int D4,
class A >
407 struct PlaceExpr<T, D1, D2, D3, D4, A,
MatRepSym<T,D1>,
MatRepStd<T,D3,D4> > {
410 unsigned int ,
unsigned int )
412 STATIC_CHECK(0==1, Cannot_Place_Matrix_general_in_symmetric_matrix);
418 template <
class T,
unsigned int D1,
unsigned int D2,
419 unsigned int D3,
unsigned int D4 >
423 unsigned int row,
unsigned int col )
428 for(
unsigned int i=0; i<D3; ++i) {
429 for(
unsigned int j=0; j<=i; ++j)
430 lhs.fRep(row+i,col+j) = rhs(i,j);
436 template <
class T,
unsigned int D1,
unsigned int D2,
437 unsigned int D3,
unsigned int D4,
class A >
441 unsigned int row,
unsigned int col )
446 for(
unsigned int i=0; i<D3; ++i) {
447 for(
unsigned int j=0; j<=i; ++j)
448 lhs.fRep(row+i,col+j) = rhs(i,j);
458 template <
class T,
unsigned int D1,
unsigned int D2,
459 unsigned int D3,
unsigned int D4,
464 unsigned int row,
unsigned int col) {
471 for(
unsigned int i=0; i<D1; ++i) {
472 for(
unsigned int j=0; j<D2; ++j)
473 lhs(i,j) = rhs(i+row,j+col);
479 template <
class T,
unsigned int D1,
unsigned int D2,
480 unsigned int D3,
unsigned int D4 >
484 unsigned int ,
unsigned int )
486 STATIC_CHECK(0==1, Cannot_Sub_Matrix_symmetric_in_general_matrix);
491 template <
class T,
unsigned int D1,
unsigned int D2,
492 unsigned int D3,
unsigned int D4 >
496 unsigned int row,
unsigned int col )
503 for(
unsigned int i=0; i<D1; ++i) {
504 for(
unsigned int j=0; j<=i; ++j)
505 lhs(i,j) = rhs(i+row,j+col );
516 template <
class T,
unsigned int D1,
unsigned int D2,
class R>
518 template<
class Iterator>
520 bool triang,
bool lower,
bool check=
true) {
524 Iterator itr = begin;
526 for (
unsigned int i = 0; i < D1; ++i)
527 for (
unsigned int j =0; j <= i; ++j) {
529 lhs.
fRep[i*D2+j] = *itr++;
534 for (
unsigned int i = 0; i < D1; ++i)
535 for (
unsigned int j = i; j <D2; ++j) {
537 lhs.
fRep[i*D2+j] = *itr++;
548 std::copy(begin, end, lhs.
fRep.Array() );
559 template <
class T,
unsigned int D1,
unsigned int D2>
561 template<
class Iterator>
568 std::copy(begin, end, lhs.fRep.Array() );
571 Iterator itr = begin;
572 for (
unsigned int i = 0; i < D1; ++i)
573 for (
unsigned int j = i; j <D2; ++j) {
589 #endif // MATH_HELPEROPS_H
Namespace for new ROOT classes and functions.
MatRepSym Matrix storage representation for a symmetric matrix of dimension NxN This class is a templ...
Structure for assignment to a general matrix from iterator.
static void Evaluate(SMatrix< T, D1, D2, R1 > &lhs, const Expr< A, T, D1, D2, R2 > &rhs)
Structure to deal when a submatrix is placed in a matrix.
static void Evaluate(SMatrix< T, D1, D2, MatRepSym< T, D1 > > &, const SMatrix< T, D3, D4, MatRepStd< T, D3, D4 > > &, unsigned int, unsigned int)
Evaluate the expression performing a += operation Need to check whether creating a temporary object w...
static void Evaluate(SMatrix< T, D1, D2, MatRepSym< T, D1 > > &, const Expr< A, T, D1, D2, MatRepStd< T, D1, D2 > > &)
static void Evaluate(SMatrix< T, D1, D2, MatRepSym< T, D1 > > &, const Expr< A, T, D1, D2, MatRepStd< T, D1, D2 > > &)
static void Evaluate(SMatrix< T, D1, D2, MatRepSym< T, D1 > > &lhs, const Expr< A, T, D3, D4, MatRepSym< T, D3 > > &rhs, unsigned int row, unsigned int col)
#define STATIC_CHECK(expr, msg)
static void Evaluate(SMatrix< T, D1, D2, R1 > &lhs, const SMatrix< T, D3, D4, R2 > &rhs, unsigned int row, unsigned int col)
static void Evaluate(SMatrix< T, D1, D2, MatRepSym< T, D1 > > &lhs, const SMatrix< T, D3, D4, MatRepSym< T, D3 > > &rhs, unsigned int row, unsigned int col)
SMatrix: a generic fixed size D1 x D2 Matrix class.
T apply(unsigned int i) const
T apply(unsigned int i) const
access the parse tree with the index starting from zero and following the C convention for the order ...
Expression wrapper class for Matrix objects.
R fRep
Matrix Storage Object containing matrix data.
iterator begin()
STL iterator interface.
static void Evaluate(SMatrix< T, D1, D2, MatRepSym< T, D1 > > &lhs, Iterator begin, Iterator end, bool, bool lower, bool check=true)
static void Evaluate(SMatrix< T, D1, D2, MatRepSym< T, D1 > > &, const Expr< A, T, D1, D2, MatRepStd< T, D1, D2 > > &)
static void Evaluate(SMatrix< T, D1, D2, MatRepSym< T, D1 > > &lhs, const Expr< A, T, D1, D2, MatRepSym< T, D1 > > &rhs)
Evaluate the expression from symmetric to symmetric matrices.
static void Evaluate(SMatrix< T, D, D, MatRepSym< T, D > > &lhs, const Expr< A, T, D, D, R > &rhs)
assign a symmetric matrix from an expression
static void Evaluate(SMatrix< T, D1, D2, R1 > &lhs, const Expr< A, T, D1, D2, R2 > &rhs)
static void Evaluate(SMatrix< T, D1, D2, MatRepSym< T, D1 > > &lhs, const Expr< A, T, D1, D2, MatRepSym< T, D1 > > &rhs)
Structure to assign from an expression based to general matrix to general matrix. ...
static void Evaluate(SMatrix< T, D1, D2, R > &lhs, Iterator begin, Iterator end, bool triang, bool lower, bool check=true)
static void Evaluate(SMatrix< T, D1, D2, R1 > &lhs, const SMatrix< T, D3, D4, R2 > &rhs, unsigned int row, unsigned int col)
static void Evaluate(SMatrix< T, D1, D2, MatRepSym< T, D1 > > &lhs, const SMatrix< T, D3, D4, MatRepSym< T, D3 > > &rhs, unsigned int row, unsigned int col)
static void Evaluate(SMatrix< T, D1, D2, MatRepSym< T, D1 > > &lhs, const Expr< A, T, D1, D2, MatRepSym< T, D1 > > &rhs)
Namespace for new Math classes and functions.
static void Evaluate(SMatrix< T, D1, D2, MatRepSym< T, D1 > > &, const SMatrix< T, D3, D4, MatRepStd< T, D3, D4 > > &, unsigned int, unsigned int)
Structure for getting sub matrices We have different cases according to the matrix representations...
ROOT::Math::PlaceExpr< T, D1, D2, D3, D4, A, MatRepSym< T, D1 >, MatRepStd< T, D3, D4 > >::Evaluate static void Evaluate(SMatrix< T, D1, D2, MatRepSym< T, D1 > > &, const Expr< A, T, D3, D4, MatRepStd< T, D3, D4 > > &, unsigned int, unsigned int)
static void Evaluate(SMatrix< T, D, D, MatRepSym< T, D > > &lhs, const SMatrix< T, D, D, R > &rhs)
assign the symmetric matric from a general matrix
static void Evaluate(SMatrix< T, D1, D2, R1 > &lhs, const Expr< A, T, D1, D2, R2 > &rhs)
Evaluate the expression from general to general matrices.
Evaluate the expression performing a -= operation Need to check whether creating a temporary object w...
Force Expression evaluation from general to symmetric.
static void Evaluate(SMatrix< T, D1, D2, R1 > &lhs, const Expr< A, T, D3, D4, R2 > &rhs, unsigned int row, unsigned int col)
bool IsInUse(const T *p) const
function to determine if any use operand is being used (has same memory adress)