4 #ifndef ROOT_Math_MatrixRepresentationsStatic
5 #define ROOT_Math_MatrixRepresentationsStatic 1
22 #ifndef ROOT_Math_StaticCheck
28 #include <type_traits>
54 template <
class T,
unsigned int D1,
unsigned int D2=D1>
61 inline const T&
operator()(
unsigned int i,
unsigned int j)
const {
79 for(
unsigned int i=0; i<
kSize; ++i)
fArray[i] += rhs[i];
85 for(
unsigned int i=0; i<
kSize; ++i)
fArray[i] -= rhs[i];
91 for(
unsigned int i=0; i<
kSize; ++i)
fArray[i] = rhs[i];
98 for(
unsigned int i=0; i<
kSize; ++i) {
99 rc = rc && (
fArray[i] == rhs[i]);
131 template<
unsigned int D>
136 for (
unsigned int i=1; i<D; ++i)
138 for (
unsigned int i=0; i<D; ++i) {
139 for (
unsigned int j=0; j<=i; ++j)
140 fOff[i*D+j] = v[i]+j;
141 for (
unsigned int j=i+1; j<D; ++j)
142 fOff[i*D+j] = v[j]+i ;
145 inline int operator()(
unsigned int i,
unsigned int j)
const {
return fOff[i*D+j]; }
146 inline int apply(
unsigned int i)
const {
return fOff[i]; }
150 namespace rowOffsetsUtils {
156 template<
int I,
class IndexTuple,
int N>
159 template<
int I,
int... Indices,
int N>
166 template<
int N,
int... Indices>
177 template<
int I0,
class F,
int... I>
178 constexpr std::array<decltype(std::declval<F>()(std::declval<int>())),
sizeof...(I)>
181 return std::array<decltype(std::declval<F>()(std::declval<int>())),
182 sizeof...(I)>{{
f(I0 + I)... }};
185 template<
int N,
int I0 = 0,
class F>
186 constexpr std::array<decltype(std::declval<F>()(std::declval<int>())), N>
213 template <
class T,
unsigned int D>
251 Cannot_assign_general_to_symmetric_matrix_representation);
255 for(
unsigned int i=0; i<
kSize; ++i)
fArray[i] = rhs.Array()[i];
265 Cannot_add_general_to_symmetric_matrix_representation);
269 for(
unsigned int i=0; i<
kSize; ++i)
fArray[i] += rhs.Array()[i];
279 Cannot_substract_general_to_symmetric_matrix_representation);
283 for(
unsigned int i=0; i<
kSize; ++i)
fArray[i] -= rhs.Array()[i];
289 for(
unsigned int i=0; i<D*D; ++i) {
304 static constexpr
int off0(
int i) {
return i==0 ? 0 :
off0(i-1)+i;}
305 static constexpr
int off2(
int i,
int j) {
return j<i ?
off0(i)+j :
off0(j)+i; }
306 static constexpr
int off1(
int i) {
return off2(i/D, i%D);}
309 static constexpr
auto v = rowOffsetsUtils::make<D*D>(
off1);
313 static inline constexpr
unsigned int
332 #endif // MATH_MATRIXREPRESENTATIONSSTATIC_H
T apply(unsigned int i) const
return no of elements: rows*columns
T & operator()(unsigned int i, unsigned int j)
Namespace for new ROOT classes and functions.
MatRepStd< T, D1, D2 > & operator=(const R &rhs)
static constexpr int off2(int i, int j)
T & operator()(unsigned int i, unsigned int j)
MatRepSym< T, D > & operator-=(const R &)
self subtraction : only symmetric to symmetric allowed
T & operator[](unsigned int i)
MatRepSym Matrix storage representation for a symmetric matrix of dimension NxN This class is a templ...
MatRepSym< T, D > & operator=(const R &)
assignment : only symmetric to symmetric allowed
const T & operator[](unsigned int i) const
T apply(unsigned int i) const
T & operator[](unsigned int i)
constexpr std::array< decltype(std::declval< F >)(std::declval< int >))), N > make(F f)
#define STATIC_CHECK(expr, msg)
Static structure to keep the conversion from (i,j) to offsets in the storage data for a symmetric mat...
MatRepSym< T, D > & operator+=(const MatRepSym &rhs)
return no. of matrix rows
int apply(unsigned int i) const
indices< Indices...> type
Expression wrapper class for Matrix objects.
static constexpr int off0(int i)
bool operator==(const R &rhs) const
bool operator==(const R &rhs) const
MatRepSym< T, D > & operator=(const MatRepSym &rhs)
constexpr std::array< decltype(std::declval< F >)(std::declval< int >))), sizeof...(I)> do_make(F f, indices< I...>)
MatRepStd< T, D1, D2 > & operator+=(const R &rhs)
T const & operator()(unsigned int i, unsigned int j) const
static constexpr unsigned int offset(unsigned int i, unsigned int j)
const T & operator()(unsigned int i, unsigned int j) const
Namespace for new Math classes and functions.
return no. of matrix columns
MatRepSym< T, D > & operator+=(const R &)
self addition : only symmetric to symmetric allowed
T const & operator[](unsigned int i) const
static constexpr int off1(int i)
return no. of matrix rows
int operator()(unsigned int i, unsigned int j) const
return no of elements: rows*columns
MatRepSym< T, D > & operator-=(const MatRepSym &rhs)
return no. of matrix columns
MatRepStd< T, D1, D2 > & operator-=(const R &rhs)
make_indices_impl< I+1, indices< Indices..., I >, N >::type type