1 #ifndef Protium_Matrix_h_
2 #define Protium_Matrix_h_
11 namespace LinearAlgebra{
14 template<
typename T,
int n,
int m>
18 template<
typename T,
int n,
int m>
25 temp[index1++] = other.
At(k).GetSubVector(i);
33 template<
typename T,
int n>
37 int index1 = j==0? 1 : 0;
41 temp[index2++][0] = T(other.
At(k,index1) );
47 template<
typename T,
int m>
51 int index1 = i==0? 1 : 0;
55 temp[0][index2++] = T(other.
At(index1,k) ) ;
67 temp[0][0] = T(other.
At(1,1) );
69 temp[0][0] = T(other.
At(0,1) );
73 temp[0][0] = T(other.
At(1,0) );
75 temp[0][0]= T(other.
At(0,0) );
82 template<
typename T,
int n,
int m>
85 return T( nanf(
'0') );
90 template<
typename T,
int n>
96 det+= (s)*(other.
At(0,i) )*(other.
GetSubMatrix(i,0).GetDeterminant() );
107 return T(other.
At(0,0) );
111 template<
typename T,
int n,
int m>
130 for(
int i=0; i<n;i++)
131 for(
int j=0; j<m;j++)
160 const T&
At(
const int& row,
const int& column)
const{
167 for(
int i =0;i<n;i++)
for(
int j=0;j<m;j++)
168 trans[i][j]= this->
At(j,i);
175 return helper.
Of( (*
this) , i,j);
181 return helper.
Of(*
this );
188 for(
int i=0; i<n;i++)
189 (*
this)[i] += rhs.At(i);
197 for(
int i=0; i<n;i++)
207 for(
int i=0; i<m;i++)
218 for(
int i=0; i<n;i++)
220 ret[i][j] = (this->
At(i) ) * (transpose[j]);
228 for(
int i=0; i<n;i++)
229 (*
this)[i] -=rhs.At(i);
257 for(
int i=0; i<n;i++)
259 ret[i][j] = ((*
this)[i]) * (transpose[j]);
276 for(
int i=0; i<m;i++)
294 for(
int i=0; i<n;i++)
295 ret &= ( this->
At(i) == rhs.At(i) );
302 return !(*
this == rhs);
309 for(
int i=0; i<m;i++)
326 #endif //File Guardian
Matrix< T, n, k > operator*=(const Matrix< T, m, k > &rhs) const
Matrix< T, n, m > & operator*=(const T &rhs)
static Matrix< T, n, m > Unit()
const Vector< T, m > operator*(const Vector< T, n > &rhs)
virtual ~Matrix()
Default Destructor.
const T & At(const int &row, const int &column) const
Vector< T, n > At(const int &row) const
Matrix< T, n, m > & operator=(const Matrix< T, n, m > &rhs)
void Init()
Standard initialization.
std::vector< Vector< T, n >, Protium::Allocation::STLAdapter< Vector< T, n > > > fComponents
Data implementation.
Matrix< double, 6, 6 > SixMatrix
static int GetNColumns()
Retrieves abcissa dimension.
Helper template to get submatrices for a given matrix.
const Matrix< T, n, m > operator*(const T &rhs) const
Matrix< T, 1, 1 > Of(const Matrix< T, 2, 2 > &other, const int &i=0, const int &j=0)
SmallObject DefaultSmallObject
A default small obect type.
Matrix< T, n-1, 0 > Of(const Matrix< T, n, 2 > &other, const int &i=0, const int &j=0)
static int GetNRows()
Retrieves ordinant dimension.
Matrix< T, m-1, n-1 > GetSubMatrix(const int &i, const int &j) const
Get submatrix.
Matrix< T, m, n > Transpose() const
Computes matrix transpose.
Matrix< T, n-1, m-1 > Of(const Matrix< T, n, m > &other, const int &i=0, const int &j=0)
Matrix()
Default constructor.
bool operator!=(const Matrix< T, n, m > &rhs) const
Matrix< double, 7, 7 > SevenMatrix
const Matrix< T, n, m > operator-(const Matrix< T, n, m > &rhs) const
Matrix< double, 5, 5 > FiveMatrix
Matrix(const Matrix< T, n, m > &other)
Copy Constructor.
T GetDeterminant() const
Gets determinant.
T Of(const Matrix< T, 1, 1 > &other)
Vector< T, n > & operator[](const int &row)
const Matrix< T, n, m > operator+(const Matrix< T, n, m > &rhs) const
Matrix< double, 2, 2 > TwoMatrix
Inherit from this in order to benefit from small object allocation.
T Of(const Matrix< T, n, m > &other)
T Of(const Matrix< T, n, n > &other)
Implements matrix addition, subtraction, multiplication.
Matrix< T, n, m > & operator-=(const Matrix< T, n, m > &rhs)
Allocator to be used by STL containers.
Implementation of vector to be used in Linear Algebra.
Helper template produces NaN Determinant in general.
Matrix< double, 4, 4 > FourMatrix
Vector< T, m > operator*=(const Vector< T, n > &rhs)
Matrix< double, 3, 3 > ThreeMatrix
bool operator==(const Matrix< T, n, m > &rhs) const
const Matrix< T, n, k > operator*(const Matrix< T, m, k > &rhs) const
Matrix< T, 0, m-1 > Of(const Matrix< T, 2, m > &other, const int &i=0, const int &j=0)
Matrix< T, n, m > & operator+=(const Matrix< T, n, m > &rhs)