24 #ifndef OPERATORS_H__064802_ 25 #define OPERATORS_H__064802_ 34 #include "../exceptions/SNexceptions.cpp" 52 template <
class U,
class V,
unsigned int s,
unsigned int t>
55 tooGenericWarning(
"Warning : using a very generic product 'SNgeneric * SNgeneric'. Can't you be more specific ?");
58 for (
unsigned int i=0;i<s;i++)
60 for (
unsigned int j=0;j<s;j++)
87 template <
class U,
class V,
unsigned int s,
unsigned int t>
102 for (
m_num line=c+1;line<s;++line)
104 for (
m_num col=0;col<s;++col)
106 ans.
at(line,col)=B.get(line,col)+A.
get(line,c)*B.get(c,col);
115 template <
class U,
class V,
unsigned int s,
unsigned int t>
120 unsigned int tp_size=s;
127 for (
m_num line = col+1 ; line< tp_size ;++line )
129 ans.
at(line,col)=A.
get(line,col)+B.get(line,col);
145 for (
m_num line=col+1;line<s;++line)
147 ans.
at(line,col)=A.
get(line,col);
150 else if (col==B.getColumn())
154 ans.
at(line,col)=B.get(line,col);
163 for (
m_num line=col+1;line<s;++line)
176 for (
m_num l=c+1;l<s;l++)
178 ans.
at(l,c)=A.
get(l,c)+B.get(l,c);
187 template <
class U,
class V,
unsigned int s,
unsigned int t>
198 m_num col=G.getColumn();
199 for (
m_num line=col+1;line<s;++line)
208 for (
m_num l=G.getColumn()+1;l<s;l++)
210 ans.
at(l,G.getColumn())+=G.get(l,G.getColumn());
241 template <
class U,
class V,
unsigned int s,
unsigned int t>
247 const unsigned int tp_size=M.
getSize();
254 for (
m_num col=0;col<tp_size;++col)
256 ans.
at(0,col)=E.get(0,col);
260 for (
m_num line=1;line <= last_col;++line)
262 for (
m_num col=0;col<tp_size;++col)
265 for (
m_num k=0; k < line;++k)
267 acc+=M.
get(line,k)*E.get(k,col);
269 ans.
at(line,col)=acc+E.get(line,col);
274 for (
m_num line=last_col+1;line<tp_size;++line)
276 for (
m_num col=0;col<tp_size;++col)
279 for (
m_num k=0;k <= last_col;++k)
281 acc+=M.
get(line,k)*E.get(k,col);
283 ans.
at(line,col)=acc+E.get(line,col);
292 template <
class U,
class V,
unsigned int s,
unsigned int t>
302 for (
m_num line=col+1;line<s;++line)
306 for (
m_num k=col;k <= line;++k)
308 acc+=(A.
get(line,k)*B.get(k,col));
310 ans.
at(line,col)=acc;
318 template <
class U,
class V,
unsigned int s,
unsigned int t>
333 for (
unsigned int i=0;i<c+1;i++)
335 for (
unsigned int j=0;j<i+1;j++)
337 ans.
at(i,j)=B.get(i,j);
340 for (
unsigned int i=c+1;i<size;i++)
342 for (
unsigned int j=0;j<i+1;j++)
376 template <
class U,
class V,
unsigned int s,
unsigned int t>
383 const unsigned int tp_size=G.
getSize();
392 for (
m_num i=col+1;i<tp_size;++i)
394 for (
m_num j=0;j<i;++j)
408 template <
unsigned int tp_size>
413 for (
unsigned int i=0;i<tp_size;++i)
415 new_perm.
at(i)=p1.
image( p2.image(i) );
429 template <
unsigned int tp_size>
433 for (
unsigned int k=0;k<tp_size;++k)
450 template <
class U,
unsigned int s,
class V,
unsigned int t>
458 for (
unsigned int k=0;k<s*s;k++)
460 new_matrix.
data.at(k)+=B.
data.at(k);
467 template <
class U,
unsigned int s,
class V,
unsigned int t>
472 for (
m_num k=0;k<s;k++)
474 new_matrix.
at(k,k)-=1;
482 template <
class U,
unsigned int s,
class V,
unsigned int t>
488 template <
class U,
unsigned int s,
class V,
unsigned int t>
495 template <
class U,
unsigned int s,
class V,
unsigned int t>
505 template <
unsigned int tp_size>
514 template <
unsigned int tp_size>
517 for (
unsigned int k=0;k<tp_size;++k)
virtual T & at(const m_num, const m_num) final
Definition: SNgeneric.h:218
Definition: SNupperTriangular.h:34
virtual unsigned int image(const unsigned int k) const =0
Definition: SNgaussian.h:61
Represent a square numerical matrix.
Definition: SNline.h:29
void checkSizeCompatibility(const SNgeneric< U, s > &A, const SNgeneric< V, t > &B)
Definition: MathUtilities.h:35
This is the base class for the other matrices types.
Definition: MathUtilities.h:32
m_num getLastColumn() const
Definition: SNmultiGaussian.h:209
void setLastColumn(const m_num &lc)
Set the number of the last non trivial column.
Definition: SNmultiGaussian.h:215
Definition: SNidentity.h:28
A permutation is a bijection of a finite subset of N.
Definition: MgenericPermutation.h:48
Definition: SNmultiGaussian.h:42
std::array< unsigned int, tp_size > data
Definition: Mpermutation.h:52
virtual T get(const m_num, const m_num) const final
Definition: SNgeneric.h:211
SNmatrix< U, s > operator+(const SNmatrix< U, s > &A, const SNmatrix< V, t > &B)
Definition: SNoperators.h:451
m_num getColumn() const
Definition: SNgaussian.h:144
void setFirstLines(const SNgeneric< U, s > &other, const m_num max_l)
copies the first max_l lines from other to this.
Definition: SNmultiGaussian.h:228
unsigned int & at(const unsigned int k)
return by reference the image of 'k' by the permutation
Definition: Mpermutation.h:78
unsigned int image(const unsigned int k) const override
Definition: Mpermutation.h:129
SNmatrix< U, s > operator-(const SNgeneric< U, s > &A, const SNidentity< V, t > &B)
Definition: SNoperators.h:468
Represents a lower triangular matrix (the diagonal can be non zero).
Definition: SNlowerTriangular.h:37
void tooGenericWarning(const std::string &message)
Display a small warning.
Definition: Utilities.cpp:34
bool operator==(const SNgeneric< U, s > &A, const SNgeneric< V, t > &B)
Definition: SNoperators.h:483
void copyFirstLines(SNgeneric< U, t > &ans, const SNgeneric< T, tp_size > &A, const m_num max_l)
copy the first lines of a matrix in an other one.
Definition: MathUtilities.h:114
virtual unsigned int getSize() const final
Definition: SNgeneric.h:203
bool componentWiseeEquality(const T &A, const U &B)
Definition: MathUtilities.h:45
std::array< T, tp_size *tp_size > data
Definition: SNmatrix.h:95
SNmatrix< U, s > operator*(const SNgeneric< U, s > &A, const SNgeneric< V, t > &B)
SNgeneric * SNgeneric.
Definition: SNoperators.h:53
This class represents a permutation (not a matrix).
Definition: MelementaryPermutation.h:26
T matrixProductComponent(const SNgeneric< T, s > &A, const SNgeneric< U, t > &B, unsigned int i, unsigned int j)
compute the component (i,j) of the matrix product A*B
Definition: MathUtilities.h:78