finitediff
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
SNmatrix< T, tp_size > Class Template Reference

Represent a square numerical matrix. More...

#include <SNline.h>

Inheritance diagram for SNmatrix< T, tp_size >:
Inheritance graph
[legend]
Collaboration diagram for SNmatrix< T, tp_size >:
Collaboration graph
[legend]

Public Member Functions

 SNmatrix ()
 
 SNmatrix (const SNmatrix< T, tp_size > &)
 
 SNmatrix (const SNgeneric< T, tp_size > &)
 
 SNmatrix (const T &x)
 
max_norm () const
 
SNelement< T, tp_size > getElement (m_num line, m_num col) const
 
void swapLines (m_num l1, m_num l2)
 swap the lines l1 and l2. More...
 
SNplu< T, tp_size > getPLU () const
 
- Public Member Functions inherited from SNgeneric< T, tp_size >
virtual unsigned int getSize () const final
 
virtual T & at (const m_num, const m_num) final
 
virtual T get (const m_num, const m_num) const final
 
virtual SNline< T, tp_size > getSNline (m_num l) const
 
template<class V , unsigned int s>
void subtract (const SNgeneric< V, s > &)
 
template<class V , unsigned int s>
void subtract (const SNgaussian< V, s > &)
 
SNgaussian< T, tp_size > getGaussian (const m_num c) const
 
template<class V , unsigned int s>
bool isNumericallyEqual (const SNgeneric< V, s > &A, const double &epsilon) const
 

Private Member Functions

SNelement< T, tp_size > getLargerUnder (m_num f_line, m_num col) const
 
void lineMinusLine (m_num line, SNline< T, tp_size > v)
 
SNelement< T, tp_size > getLargerOnColumn (m_num col) const
 
SNelement< T, tp_size > getLargerUnderDiagonal (m_num col) const
 
SNline< T, tp_size > gaussEliminationLine (m_num line)
 
T & _at (const m_num, const m_num) override
 
_get (const m_num, const m_num) const override
 
void _set_from (const SNgeneric< T, tp_size > &)
 
void set_identity ()
 

Private Attributes

std::array< T, tp_size *tp_size > data
 
unsigned int size =tp_size
 

Friends

template<class U , unsigned int s, class V , unsigned int t>
bool operator== (const SNmatrix< U, s > &, const SNmatrix< V, t > &)
 
template<class U , unsigned int s, class V , unsigned int t>
SNmatrix< U, s > operator+ (const SNmatrix< U, s > &A, const SNmatrix< V, t > &B)
 
std::array< T, tp_size *tp_size > SNupperTriangular (const SNmatrix< T, tp_size > &) const
 
std::array< T, tp_size *tp_size > SNlowerTriangular (const SNmatrix< T, tp_size > &) const
 

Detailed Description

template<class T, unsigned int tp_size>
class SNmatrix< T, tp_size >

Represent a square numerical matrix.

This is a template class that represents a fixed size square numerical matrix (SN=Square Numerical).

template <class T,unsigned int tp_size>
class SNmatrix

NOTE : if you want the identity matrix, there is the SNidentity class.

For creating a matrix knowing its elements, be best way is to do something like

sn.at(0,0)=1;
sn.at(0,1)=2;
sn.at(1,0)=3;
sn.at(1,1)=4;

Notice that the elements are numbered from 0 to tp_size-1. Not from 1.

Constructor & Destructor Documentation

template<class T , unsigned int tp_size>
SNmatrix< T, tp_size >::SNmatrix ( )
template<class T , unsigned int tp_size>
SNmatrix< T, tp_size >::SNmatrix ( const SNmatrix< T, tp_size > &  snm)
template<class T , unsigned int tp_size>
SNmatrix< T, tp_size >::SNmatrix ( const SNgeneric< T, tp_size > &  A)

Construct a SNmatrix as copy of a generic matrix. Here we copy every elements.

template<class T , unsigned int tp_size>
SNmatrix< T, tp_size >::SNmatrix ( const T &  x)

Creates a matrix full of x

Member Function Documentation

template<class T , unsigned int tp_size>
T & SNmatrix< T, tp_size >::_at ( const m_num  ,
const m_num   
)
overrideprivatevirtual

Return by reference the requested element of the matrix

Implements SNgeneric< T, tp_size >.

template<class T , unsigned int tp_size>
T SNmatrix< T, tp_size >::_get ( const m_num  ,
const m_num   
) const
overrideprivatevirtual

Return by value the requested element of the matrix

Implements SNgeneric< T, tp_size >.

template<class T , unsigned int tp_size>
void SNmatrix< T, tp_size >::_set_from ( const SNgeneric< T, tp_size > &  A)
private

Set the matrix from another one

template<class T , unsigned int tp_size>
SNline< T, tp_size > SNmatrix< T, tp_size >::gaussEliminationLine ( m_num  line)
private
template<class T , unsigned int tp_size>
SNelement< T, tp_size > SNmatrix< T, tp_size >::getElement ( m_num  line,
m_num  col 
) const
template<class T , unsigned int tp_size>
SNelement< T, tp_size > SNmatrix< T, tp_size >::getLargerOnColumn ( m_num  col) const
private
template<class T , unsigned int tp_size>
SNelement< T, tp_size > SNmatrix< T, tp_size >::getLargerUnder ( m_num  f_line,
m_num  col 
) const
private

the larger element on column 'col' under (or on) the line 'f_line'.

template<class T , unsigned int tp_size>
SNelement< T, tp_size > SNmatrix< T, tp_size >::getLargerUnderDiagonal ( m_num  col) const
private
template<class T , unsigned int tp_size>
SNplu< T, tp_size > SNmatrix< T, tp_size >::getPLU ( ) const

return the PLU decomposition as a SNplu object.

template<class T , unsigned int tp_size>
void SNmatrix< T, tp_size >::lineMinusLine ( m_num  line,
SNline< T, tp_size >  v 
)
private
template<class T , unsigned int tp_size>
T SNmatrix< T, tp_size >::max_norm ( ) const
template<class T , unsigned int tp_size>
void SNmatrix< T, tp_size >::set_identity ( )
private
template<class T , unsigned int tp_size>
void SNmatrix< T, tp_size >::swapLines ( m_num  l1,
m_num  l2 
)

swap the lines l1 and l2.

Friends And Related Function Documentation

template<class T, unsigned int tp_size>
template<class U , unsigned int s, class V , unsigned int t>
SNmatrix<U,s> operator+ ( const SNmatrix< U, s > &  A,
const SNmatrix< V, t > &  B 
)
friend

Sum of two SNmatrix.

The return type is the one of the left argument. THUS : this is not totally commutative. You may have $ A+B\neq B+A $

template<class T, unsigned int tp_size>
template<class U , unsigned int s, class V , unsigned int t>
bool operator== ( const SNmatrix< U, s > &  A,
const SNmatrix< V, t > &  B 
)
friend
template<class T, unsigned int tp_size>
std::array<T,tp_size*tp_size> SNlowerTriangular ( const SNmatrix< T, tp_size > &  ) const
friend
template<class T, unsigned int tp_size>
std::array<T,tp_size*tp_size> SNupperTriangular ( const SNmatrix< T, tp_size > &  ) const
friend

Member Data Documentation

template<class T, unsigned int tp_size>
std::array<T,tp_size*tp_size> SNmatrix< T, tp_size >::data
private
template<class T, unsigned int tp_size>
unsigned int SNmatrix< T, tp_size >::size =tp_size
private

The documentation for this class was generated from the following files: