19 #ifndef __SNMATRIX_H__153113__ 20 #define __SNMATRIX_H__153113__ 36 #include "../SNvector.h" 37 #include "../exceptions/SNexceptions.cpp" 39 #include "../Utilities.h" 43 template <
class T,
unsigned int tp_size>
78 template <
class T,
unsigned int tp_size>
85 template <
class U,
unsigned int s,
class V,
unsigned int t>
87 template <
class U,
unsigned int s,
class V,
unsigned int t>
95 std::array<T,tp_size*tp_size>
data;
163 template <
class T,
unsigned int tp_size>
166 template <
class T,
unsigned int tp_size>
169 template <
class T,
unsigned int tp_size>
173 for (
unsigned int k=0;k<tp_size*tp_size;++k)
179 template <
class T,
unsigned int tp_size>
187 template <
class T,
unsigned int tp_size>
190 for (
m_num i=0;i<tp_size;i++)
192 for (
m_num j=0;j<tp_size;j++)
194 this->
at(i,j)=A.
get(i,j);
198 template <
class T,
unsigned int tp_size>
201 for (
m_num i=0;i<tp_size;i++)
203 for (
m_num j=0;j<tp_size;j++)
214 template <
class T,
unsigned int tp_size>
223 template <
class T,
unsigned int tp_size>
226 return data.at(j*tp_size+i);
229 template <
class T,
unsigned int tp_size>
232 return data.at(j*tp_size+i);
240 template <
class T,
unsigned int tp_size>
255 template <
class T,
unsigned int tp_size>
261 for (
m_num line=f_line;line<tp_size;line++)
263 if (std::abs(this->
get(line,col))>max_val)
265 max_val=std::abs(this->
get(line,col));
272 template <
class T,
unsigned int tp_size>
278 template <
class T,
unsigned int tp_size>
284 template <
class T,
unsigned int tp_size>
289 for (
m_num col=0;col<tp_size;col++)
291 T tmp = this->
get(l1,col);
292 this->
at(l1,col)=this->
get(l2,col);
293 this->
at(l2,col)=tmp;
299 template <
class T,
unsigned int tp_size>
302 for (
m_num c=0;c<tp_size;c++)
304 this->
at(line,c)=this->
get(line,c)-v.
get(c);
308 template <
class T,
unsigned int tp_size>
316 template <
class T,
unsigned int tp_size>
340 for (
m_num c=0;c<tp_size;c++)
342 auto max_el = mU.getLargerUnderDiagonal(c);
344 if (max_el.getValue()!=0)
349 permutation=permutation*el_perm;
350 mU.swapLines(c,max_el.line);
364 auto killing_line=mU.gaussEliminationLine(c);
365 for (
m_num l=c+1;l<tp_size;l++)
371 mU.lineMinusLine(l,m*killing_line);
void _setU(const SNmatrix< T, tp_size > &A)
Definition: SNplu.h:71
friend SNmatrix< U, s > operator+(const SNmatrix< U, s > &A, const SNmatrix< V, t > &B)
Definition: SNoperators.h:451
void swapLines(m_num l1, m_num l2)
swap the lines l1 and l2.
Definition: SNmatrix.h:285
friend class GaussTest
Definition: SNmatrix.h:83
std::array< T, tp_size *tp_size > _get_other_data(const SNmatrix< T, tp_size > &) const
Definition: SNlowerTriangular.h:94
virtual T & at(const m_num, const m_num) final
Definition: SNgeneric.h:218
friend bool operator==(const SNmatrix< U, s > &, const SNmatrix< V, t > &)
Definition: SNoperators.h:489
SNmatrix()
Definition: SNmatrix.h:164
Represent a square numerical matrix.
Definition: SNline.h:29
void lineMinusLine(m_num line, SNline< T, tp_size > v)
Definition: SNmatrix.h:300
This is the base class for the other matrices types.
Definition: MathUtilities.h:32
T get(const unsigned int i) const
Definition: SNline.h:138
Definition: SNidentity.h:28
SNplu< T, tp_size > getPLU() const
Definition: SNmatrix.h:317
T & _at(const m_num, const m_num) override
Definition: SNmatrix.h:224
SNgaussian< T, tp_size > getGaussian(const m_num c) const
Definition: SNgeneric.h:229
SNelement< T, tp_size > getLargerUnderDiagonal(m_num col) const
Definition: SNmatrix.h:279
std::array< T, tp_size *tp_size > _get_other_data(const SNmatrix< T, tp_size > &) const
Definition: SNupperTriangular.h:64
Definition: SNmultiGaussian.h:42
virtual T get(const m_num, const m_num) const final
Definition: SNgeneric.h:211
T max_norm() const
Definition: SNmatrix.h:241
SNelement< T, tp_size > getLargerOnColumn(m_num col) const
Definition: SNmatrix.h:273
virtual SNline< T, tp_size > getSNline(m_num l) const
Definition: SNgeneric.h:147
SNelement< T, tp_size > getLargerUnder(m_num f_line, m_num col) const
Definition: SNmatrix.h:256
void makeUnit()
Definition: SNline.h:168
void _set_from(const SNgeneric< T, tp_size > &)
Definition: SNmatrix.h:188
Definition: MelementaryPermutation.h:34
Mpermutation< tp_size > data_P
Definition: SNplu.h:38
T _get(const m_num, const m_num) const override
Definition: SNmatrix.h:230
SNelement< T, tp_size > getElement(m_num line, m_num col) const
Definition: SNmatrix.h:215
This is a template class that represent an element of a SNmatrix.
Definition: SNelement.h:40
std::array< T, tp_size *tp_size > data
Definition: SNmatrix.h:95
void swapLines(const m_num &i, const m_num &j)
Definition: SNmultiGaussian.h:282
This class represents a permutation (not a matrix).
Definition: MelementaryPermutation.h:26
friend class SNmatrixTest
Definition: SNmatrix.h:82
void _setL(const SNmatrix< T, tp_size > &A)
Definition: SNplu.h:78
SNline< T, tp_size > gaussEliminationLine(m_num line)
Definition: SNmatrix.h:309
SNmultiGaussian< T, tp_size > inverse() const
Definition: SNmultiGaussian.h:260
unsigned int size
Definition: SNmatrix.h:96
void set_identity()
Definition: SNmatrix.h:199