kn::Matrix< T > Class Template Reference

class to manipulate a matrix More...

#include <Matrix.hpp>

Collaboration diagram for kn::Matrix< T >:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 Matrix ()
 Constructor to build a 0 size matrix.
 Matrix (const Matrix< T > &m)
 Copy constructor Create a matrix by copying the input matrix.
 Matrix (const Matrix< T > *m)
 Copy constructor Create a matrix by copying the input matrix.
 Matrix (const size_t &n, const size_t &m)
 Create a n*m matrix Create a n*m matrix.
 Matrix (const size_t &n)
 Create a n*n matrix Create a n*m matrix.
 Matrix (const size_t &n, const size_t &m, const T &d)
 Create a n*m matrix Create a n*m matrix and use the value d to set the data of the matrix.
 Matrix (const size_t &n, const size_t &m, T *a)
 create a n*m matrix create a n*m matrix and set data by using the values array d
 Matrix (const size_t &n, T *a)
 create a n*n matrix create a n*n matrix and use the value d to set the data of the matrix
 Matrix (const size_t &n, const size_t &m, const Vector< T > &v, const bool &setasrows=true)
 Create a n*(size of v) or (size of v)*n matrix Create a matrix using the vector v.
 Matrix (const size_t &n, const Vector< T > *v, const bool &setasrows=true)
 Create a n*(size of v) or (size of v)*n matrix Create a matrix using the pointer on the vector v.
virtual ~Matrix (void)
 Destructor.
virtual T * begin () const
 getting the raw data of the image
virtual T * end () const
 getting the end of raw data of the image
T & at (const unsigned int &i, const unsigned int &j)
 Access to an element of the matrix the function allows to reach a specific element of the matrix using m(i,j).
const T & at (const unsigned int &i, const unsigned int &j) const
 Access to an element of the matrix the function allows to reach a specific element of the matrix using m(i,j).
bool operator== (const Matrix< T > &m) const
 Test if the matrix is equal to another one.
bool operator!= (const Matrix< T > &m) const
 Test if the matrix differ from another one.
Matrix< T > & operator= (const Matrix< T > &m)
 Copy m matrix to this matrix if they have the same size; if this matrix has rows=columns=0, allocate the adequat memory before the copy.
Matrix< T > & operator= (const T &value)
 Fill the matrix with a value.
Matrix< T > operator+ (const Matrix< T > &m) const
 Adds two matrices.
Matrix< T > operator- (const Matrix< T > &m) const
 Subtracts two matrices.
Matrix< T > operator/ (const T &d) const
 Divides the matrix with a value.
Matrix< T > operator* (const Matrix< T > &m) const
 Multiplies two matrices.
Vector< T > operator* (const Vector< T > &v) const
 Multiplies the matrix with a vector.
Matrix< T > operator* (const T &d) const
 Multiplies the matrix with a value.
void times (const Matrix< T > &m1, const Matrix< T > &m2)
 Multiplies the matrix m1 with the matrix m2 in the current matrix.
Matrix< T > operator- (void) const
 Compute opposite of the matrix.
Matrix< T > & operator+= (const Matrix< T > &m)
 Adds the matrix with a matrix.
Matrix< T > & operator+= (const T &d)
 Adds d to all the elements of the matrix.
Matrix< T > & operator-= (const Matrix< T > &m)
 Subtracts the matrix with a matrix.
Matrix< T > & operator-= (const T &d)
 Subtracts d to all the elements of the matrix.
Matrix< T > & operator/= (const T &d)
 Divides the matrix with a value All values of the matrix are divided by d.
Matrix< T > & operator*= (const Matrix< T > &m)
 Multiplies the matrix with a matrix.
Matrix< T > & operator*= (const T &d)
 Multiplies the matrix with a value.
T * operator[] (const unsigned int &i) const
 Access to a row of the matrix The function is used to reach a specific element of the matrix.
T & operator() (const unsigned int &i, const unsigned int &j)
 Access to an element of the matrix the function allows to reach a specific element of the matrix using m(i,j).
const T & operator() (const unsigned int &i, const unsigned int &j) const
 Access to an element of the matrix the function allows to reach a specific element of the matrix using m(i,j).
size_t rows (void) const
 Returns the number of rows of the matrix.
size_t columns (void) const
 Returns the number of columns of the matrix.
double getNorm (void) const
 Returns the norm of the matrix The norm is defined as follow : $ \left\|{A}\right\|_{F}^{2}=\sum_{i,j}{|a_{ij}|^2}=trace({A}\times{A})$.
const T * getMatrixArray (void) const
 Returns data of the matrix as an array The size of the array is rows*columns.
Matrix< T > & transpose (void)
 Transposes inplace the current matrix.
Matrix< T > getTranspose (void) const
 Transposes a copy of the matrix Creates and transposes a copy of this matrix.
Matrix< T > & power (const unsigned int &p)
 Computes inplace the power p of this matrix.
void setIdentity (void)
 sets the matrix to identity
void setZero (void)
 sets values of the matrix to zero
void fill (const T &d)
 Sets the value d on every entry of the vector.
void roundZero (const double &d=1.0e-14)
 sets values near 0 (d more or less) to 0
void setSubMatrix (const unsigned int &row, const unsigned int &column, const Matrix< T > &m)
 Copies the content of matrix m inside this matrix.
Matrix< T > getSubMatrix (const unsigned int &firstrow, const unsigned int &row, const unsigned int &firstcolumn, const unsigned int &column)
 Return subMatrix of the current matrix.
void setRow (const unsigned int &row, const Vector< T > &v)
 Defines a row of the matrix using a vector.
void setRow (const unsigned int &row, T *a)
 Defines a row of the matrix using an array of data.
void setRow (const unsigned int &row, const T &d)
 Defines a row of the matrix using the constant d.
void setColumn (const unsigned int &column, const Vector< T > &v)
 Defines a column of the matrix using a vector.
void setColumn (const unsigned int &column, const T *a)
 Defines a column of the matrix using an array of data.
void setColumn (const unsigned int &column, const T &d)
 Defines a column of the matrix using the constant d.
Vector< T > getRow (const unsigned int &row) const
 Returns a vector with values from a specific row.
Vector< T > getColumn (const unsigned int &column) const
 Returns a vector with values from a specific column.
void swapRows (const unsigned int &row1, const unsigned int &row2)
 Swaps two rows of this matrix The swap is not applied if row1=row2.
void swapColumns (const unsigned int &column1, const unsigned int &column2)
 Swaps two columns of this matrix The swap is not applied if column1=column2.
void setDiagonal (const Vector< T > &v)
 Sets diagonal of the matrix with values from a vector.
void setDiagonal (const T *a)
 Sets diagonal of the matrix with values from an array.
void setDiagonal (const T &d)
 Sets diagonal of the matrix with a constant.
Vector< T > getDiagonal (void) const
 Return the diagonal of the matrix as a vector.
bool isSquare (void) const
 Check if it is a square matrix or not.
trace (void) const
 Trace of the Matrix This represents the sum of each element on the diagonal.
void cross3x3 (const kn::Vector< T > v)
 substitute of a vector3 cross product using 3x3 matrix.

Protected Member Functions

void allocate (void)
 Allocates memory and initialize data.

Protected Attributes

size_t rowsMatrix
 Number of rows in the matrix.
size_t columnsMatrix
 Number of columns in the matrix.
T * data
 Content of the matrix.
T * begin_
 Pointer on the beginning of the data.
T * end_
 Pointer on the end of the data.
T ** accessor
 Pointers on the beginning of each rows.


Detailed Description

template<class T>
class kn::Matrix< T >

class to manipulate a matrix

Definition at line 54 of file Matrix.hpp.


Constructor & Destructor Documentation

template<typename T >
kn::Matrix< T >::Matrix (  )  [inline]

Constructor to build a 0 size matrix.

Definition at line 688 of file Matrix.hpp.

template<typename T>
kn::Matrix< T >::Matrix ( const Matrix< T > &  m  )  [inline]

Copy constructor Create a matrix by copying the input matrix.

Parameters:
m the matrix to copy

Definition at line 697 of file Matrix.hpp.

template<typename T>
kn::Matrix< T >::Matrix ( const Matrix< T > *  m  )  [inline]

Copy constructor Create a matrix by copying the input matrix.

Parameters:
m the pointer to the matrix to copy
Exceptions:
MathException pointer is null

Definition at line 705 of file Matrix.hpp.

template<typename T>
kn::Matrix< T >::Matrix ( const size_t n,
const size_t m 
) [inline]

Create a n*m matrix Create a n*m matrix.

Data are not initialized.

Parameters:
n number of rows
m number of columns
Exceptions:
MathException n or m are null

Definition at line 715 of file Matrix.hpp.

template<typename T>
kn::Matrix< T >::Matrix ( const size_t n  )  [inline, explicit]

Create a n*n matrix Create a n*m matrix.

Data are not initialized.

Parameters:
n number of rows
Exceptions:
MathException n or m are null

Definition at line 725 of file Matrix.hpp.

template<typename T>
kn::Matrix< T >::Matrix ( const size_t n,
const size_t m,
const T &  d 
) [inline]

Create a n*m matrix Create a n*m matrix and use the value d to set the data of the matrix.

Parameters:
n number of rows
m number of columns
d value used to set data of the matrix
Exceptions:
MathException n or m are null

Definition at line 734 of file Matrix.hpp.

template<typename T>
kn::Matrix< T >::Matrix ( const size_t n,
const size_t m,
T *  a 
) [inline]

create a n*m matrix create a n*m matrix and set data by using the values array d

Parameters:
n number of rows
m number of columns
a pointer to an array of data
Exceptions:
MathException n or m or d are null

Definition at line 746 of file Matrix.hpp.

template<typename T>
kn::Matrix< T >::Matrix ( const size_t n,
T *  a 
) [inline]

create a n*n matrix create a n*n matrix and use the value d to set the data of the matrix

Parameters:
n number of rows and columns
a pointer to an array of data
Exceptions:
MathException n or d are null

Definition at line 761 of file Matrix.hpp.

template<typename T>
kn::Matrix< T >::Matrix ( const size_t n,
const size_t m,
const Vector< T > &  v,
const bool &  setasrows = true 
) [inline]

Create a n*(size of v) or (size of v)*n matrix Create a matrix using the vector v.

if setasrows is set to true, v is used to fill rows of the matrix, v is used to fill columns otherwise

Parameters:
n number of rows
m number of columns
v a vector
setasrows defined if vector is used to fill columns or rows
Exceptions:
MathException n or m or size of vector is null

Definition at line 773 of file Matrix.hpp.

template<typename T>
kn::Matrix< T >::Matrix ( const size_t n,
const Vector< T > *  v,
const bool &  setasrows = true 
) [inline]

Create a n*(size of v) or (size of v)*n matrix Create a matrix using the pointer on the vector v.

If setasrows is set to true, v is used to fill rows of the matrix, v is used to fill columns otherwise

Parameters:
n number of rows or columns
v a pointer on an array of vectors
setasrows defined if vector is used to fill columns or rows
Exceptions:
MathException n or v or *v size are null
MathException if *v sizes are different

Definition at line 795 of file Matrix.hpp.

template<class T>
virtual kn::Matrix< T >::~Matrix ( void   )  [inline, virtual]

Destructor.

Definition at line 201 of file Matrix.hpp.


Member Function Documentation

template<typename T >
void kn::Matrix< T >::allocate ( void   )  [inline, protected]

Allocates memory and initialize data.

Definition at line 834 of file Matrix.hpp.

template<typename T >
const T & kn::Matrix< T >::at ( const unsigned int &  i,
const unsigned int &  j 
) const [inline]

Access to an element of the matrix the function allows to reach a specific element of the matrix using m(i,j).

Parameters:
i the number of the row
j the number of the column
Returns:
a reference to the element of the matrix
Exceptions:
MathException i or j are out of bounds

Definition at line 854 of file Matrix.hpp.

template<typename T >
T & kn::Matrix< T >::at ( const unsigned int &  i,
const unsigned int &  j 
) [inline]

Access to an element of the matrix the function allows to reach a specific element of the matrix using m(i,j).

Parameters:
i the number of the row
j the number of the column
Returns:
a reference to the element of the matrix
Exceptions:
MathException i or j are out of bounds

Definition at line 846 of file Matrix.hpp.

template<class T>
virtual T* kn::Matrix< T >::begin (  )  const [inline, virtual]

getting the raw data of the image

Returns:
raw data of the image

Definition at line 220 of file Matrix.hpp.

template<class T>
size_t kn::Matrix< T >::columns ( void   )  const [inline]

Returns the number of columns of the matrix.

Returns:
the number of columns

Reimplemented in kn::Matrix3x3< T >, and kn::Matrix4x4< T >.

Definition at line 445 of file Matrix.hpp.

template<typename T>
void kn::Matrix< T >::cross3x3 ( const kn::Vector< T >  v  )  [inline]

substitute of a vector3 cross product using 3x3 matrix.

Given two vector3 x and y, we have z = x^y This equation can be linearized as z = A.y with A : 3x3 matrix. This method fills the A 3x3 matrix from the vector x.

Parameters:
v : the vector3 used to fill the matrix
Exceptions:
MathException matrix and vector dimension should be 3

Definition at line 1327 of file Matrix.hpp.

template<class T>
virtual T* kn::Matrix< T >::end (  )  const [inline, virtual]

getting the end of raw data of the image

Returns:
end of raw data of the image

Definition at line 225 of file Matrix.hpp.

template<class T>
void kn::Matrix< T >::fill ( const T &  d  )  [inline]

Sets the value d on every entry of the vector.

Definition at line 506 of file Matrix.hpp.

template<typename T >
Vector< T > kn::Matrix< T >::getColumn ( const unsigned int &  column  )  const [inline]

Returns a vector with values from a specific column.

Parameters:
column the number of the column
Returns:
a vector of values
Exceptions:
MathException column is out of bounds

Reimplemented in kn::Matrix3x3< T >, and kn::Matrix4x4< T >.

Definition at line 1247 of file Matrix.hpp.

template<typename T >
Vector< T > kn::Matrix< T >::getDiagonal ( void   )  const [inline]

Return the diagonal of the matrix as a vector.

Returns:
a vector

Reimplemented in kn::Matrix3x3< T >, and kn::Matrix4x4< T >.

Definition at line 1309 of file Matrix.hpp.

template<class T>
const T* kn::Matrix< T >::getMatrixArray ( void   )  const [inline]

Returns data of the matrix as an array The size of the array is rows*columns.

Returns:
an array

Definition at line 462 of file Matrix.hpp.

template<typename T >
double kn::Matrix< T >::getNorm ( void   )  const [inline]

Returns the norm of the matrix The norm is defined as follow : $ \left\|{A}\right\|_{F}^{2}=\sum_{i,j}{|a_{ij}|^2}=trace({A}\times{A})$.

Returns:
the norm of the matrix

Definition at line 1078 of file Matrix.hpp.

template<typename T >
Vector< T > kn::Matrix< T >::getRow ( const unsigned int &  row  )  const [inline]

Returns a vector with values from a specific row.

Parameters:
row the number of the row
Returns:
a vector of values
Exceptions:
MathException row is out of bounds

Reimplemented in kn::Matrix3x3< T >, and kn::Matrix4x4< T >.

Definition at line 1237 of file Matrix.hpp.

template<typename T >
Matrix< T > kn::Matrix< T >::getSubMatrix ( const unsigned int &  firstrow,
const unsigned int &  row,
const unsigned int &  firstcolumn,
const unsigned int &  column 
) [inline]

Return subMatrix of the current matrix.

Data from the current matrix are duplicated from the position (firstrow,firstcolumn) and return in a new matrix of size (row,column).

Parameters:
firstrow the row where start the copy
row the number of row to copy
firstcolumn the column where start the copy
column the number of column to copy
Exceptions:
MathException row or column are out of bounds

Definition at line 1160 of file Matrix.hpp.

template<class T>
Matrix<T> kn::Matrix< T >::getTranspose ( void   )  const [inline]

Transposes a copy of the matrix Creates and transposes a copy of this matrix.

The current matrix is unchanged

Returns:
the transposed copy of the matrix

Reimplemented in kn::Matrix3x3< T >, and kn::Matrix4x4< T >.

Definition at line 478 of file Matrix.hpp.

template<class T>
bool kn::Matrix< T >::isSquare ( void   )  const [inline]

Check if it is a square matrix or not.

Returns:
if the matrix is square

Reimplemented in kn::Matrix3x3< T >, and kn::Matrix4x4< T >.

Definition at line 664 of file Matrix.hpp.

template<class T>
bool kn::Matrix< T >::operator!= ( const Matrix< T > &  m  )  const [inline]

Test if the matrix differ from another one.

Parameters:
m the matrix which is compared this matrix
Returns:
true if matrices are different, false otherwise

Definition at line 264 of file Matrix.hpp.

template<typename T >
const T & kn::Matrix< T >::operator() ( const unsigned int &  i,
const unsigned int &  j 
) const [inline]

Access to an element of the matrix the function allows to reach a specific element of the matrix using m(i,j).

Parameters:
i the number of the row
j the number of the column
Returns:
a reference to the element of the matrix

Definition at line 1070 of file Matrix.hpp.

template<typename T >
T & kn::Matrix< T >::operator() ( const unsigned int &  i,
const unsigned int &  j 
) [inline]

Access to an element of the matrix the function allows to reach a specific element of the matrix using m(i,j).

Parameters:
i the number of the row
j the number of the column
Returns:
a reference to the element of the matrix

Definition at line 1065 of file Matrix.hpp.

template<typename T>
Matrix< T > kn::Matrix< T >::operator* ( const T &  d  )  const [inline]

Multiplies the matrix with a value.

Parameters:
d the value multiplied with this matrix
Returns:
a copy of the matrix

Reimplemented in kn::Matrix3x3< T >, and kn::Matrix4x4< T >.

Definition at line 974 of file Matrix.hpp.

template<typename T>
Vector< T > kn::Matrix< T >::operator* ( const Vector< T > &  v  )  const [inline]

Multiplies the matrix with a vector.

Parameters:
v the vector multiplied with this matrix
Returns:
a vector
Exceptions:
MathException vector size is incorrect

Reimplemented in kn::Matrix3x3< T >.

Definition at line 956 of file Matrix.hpp.

template<typename T>
Matrix< T > kn::Matrix< T >::operator* ( const Matrix< T > &  m  )  const [inline]

Multiplies two matrices.

Parameters:
m the matrix multiplied with this matrix
Returns:
a copy of the matrix
Exceptions:
MathException matrice size is incorrect

Definition at line 920 of file Matrix.hpp.

template<typename T>
Matrix< T > & kn::Matrix< T >::operator*= ( const T &  d  )  [inline]

Multiplies the matrix with a value.

Parameters:
d the value multiplied with this matrix
Returns:
the matrix

Reimplemented in kn::Matrix3x3< T >, and kn::Matrix4x4< T >.

Definition at line 1053 of file Matrix.hpp.

template<typename T>
Matrix< T > & kn::Matrix< T >::operator*= ( const Matrix< T > &  m  )  [inline]

Multiplies the matrix with a matrix.

Parameters:
m the matrix multiplied with this matrix
Returns:
the matrix
Exceptions:
MathException matrix size is incorrect

Definition at line 1027 of file Matrix.hpp.

template<typename T>
Matrix< T > kn::Matrix< T >::operator+ ( const Matrix< T > &  m  )  const [inline]

Adds two matrices.

Parameters:
m the matrix added to this matrix
Returns:
a copy of the matrix
Exceptions:
MathException matrix size is incorrect

Definition at line 896 of file Matrix.hpp.

template<typename T>
Matrix< T > & kn::Matrix< T >::operator+= ( const T &  d  )  [inline]

Adds d to all the elements of the matrix.

Parameters:
d the value to add
Returns:
the matrix

Definition at line 1015 of file Matrix.hpp.

template<typename T>
Matrix< T > & kn::Matrix< T >::operator+= ( const Matrix< T > &  m  )  [inline]

Adds the matrix with a matrix.

Parameters:
m the matrix added with this matrix
Returns:
the matrix
Exceptions:
MathException matrix size is incorrect

Definition at line 990 of file Matrix.hpp.

template<typename T>
Matrix< T > kn::Matrix< T >::operator- ( void   )  const [inline]

Compute opposite of the matrix.

Returns:
a copy of the matrix

Reimplemented in kn::Matrix3x3< T >, and kn::Matrix4x4< T >.

Definition at line 982 of file Matrix.hpp.

template<typename T>
Matrix< T > kn::Matrix< T >::operator- ( const Matrix< T > &  m  )  const [inline]

Subtracts two matrices.

Parameters:
m the matrix subtracted to this matrix
Returns:
a copy of the matrix
Exceptions:
MathException matrix size is incorrect

Definition at line 904 of file Matrix.hpp.

template<typename T>
Matrix< T > & kn::Matrix< T >::operator-= ( const T &  d  )  [inline]

Subtracts d to all the elements of the matrix.

Parameters:
d the value to subtracts
Returns:
the matrix

Definition at line 1021 of file Matrix.hpp.

template<typename T>
Matrix< T > & kn::Matrix< T >::operator-= ( const Matrix< T > &  m  )  [inline]

Subtracts the matrix with a matrix.

Parameters:
m the matrix subtracted with this matrix
Returns:
the matrix
Exceptions:
MathException matrix size is incorrect

Definition at line 999 of file Matrix.hpp.

template<typename T>
Matrix< T > kn::Matrix< T >::operator/ ( const T &  d  )  const [inline]

Divides the matrix with a value.

Parameters:
d the value divided with this matrix
Returns:
a copy of the matrix
Exceptions:
MathException d is null

Reimplemented in kn::Matrix3x3< T >, and kn::Matrix4x4< T >.

Definition at line 912 of file Matrix.hpp.

template<typename T>
Matrix< T > & kn::Matrix< T >::operator/= ( const T &  d  )  [inline]

Divides the matrix with a value All values of the matrix are divided by d.

Parameters:
d the value divided with this matrix
Returns:
the matrix
Exceptions:
MathException d is null

Reimplemented in kn::Matrix3x3< T >, and kn::Matrix4x4< T >.

Definition at line 1007 of file Matrix.hpp.

template<typename T>
Matrix< T > & kn::Matrix< T >::operator= ( const T &  value  )  [inline]

Fill the matrix with a value.

Parameters:
value Value to set the matrix with
Returns:
the matrix

Definition at line 888 of file Matrix.hpp.

template<typename T>
Matrix< T > & kn::Matrix< T >::operator= ( const Matrix< T > &  m  )  [inline]

Copy m matrix to this matrix if they have the same size; if this matrix has rows=columns=0, allocate the adequat memory before the copy.

Parameters:
m the matrix used to defined this matrix
Returns:
the matrix
Exceptions:
MathException matrix size is incorrect

Definition at line 870 of file Matrix.hpp.

template<typename T>
bool kn::Matrix< T >::operator== ( const Matrix< T > &  m  )  const [inline]

Test if the matrix is equal to another one.

Parameters:
m the matrix which is compared this matrix
Returns:
true if matrices are equal, false otherwise

Definition at line 863 of file Matrix.hpp.

template<typename T >
T * kn::Matrix< T >::operator[] ( const unsigned int &  i  )  const [inline]

Access to a row of the matrix The function is used to reach a specific element of the matrix.

The function returns a pointer to a row of the matrix. Thus, the access to an element can be achieved as follow : m[i][j] There is no checking on column value access thus use this function at your own risk.

Parameters:
i the number of the row
Returns:
a copy of the pointer to the row

Definition at line 1060 of file Matrix.hpp.

template<typename T >
Matrix< T > & kn::Matrix< T >::power ( const unsigned int &  p  )  [inline]

Computes inplace the power p of this matrix.

Returns:
this matrix
Exceptions:
MathException not a square matrix

Reimplemented in kn::Matrix3x3< T >, and kn::Matrix4x4< T >.

Definition at line 1110 of file Matrix.hpp.

template<typename T >
void kn::Matrix< T >::roundZero ( const double &  d = 1.0e-14  )  [inline]

sets values near 0 (d more or less) to 0

Parameters:
d the limit around which values are set to 0

Definition at line 1137 of file Matrix.hpp.

template<class T>
size_t kn::Matrix< T >::rows ( void   )  const [inline]

Returns the number of rows of the matrix.

Returns:
the number of rows

Reimplemented in kn::Matrix3x3< T >, and kn::Matrix4x4< T >.

Definition at line 437 of file Matrix.hpp.

template<typename T>
void kn::Matrix< T >::setColumn ( const unsigned int &  column,
const T &  d 
) [inline]

Defines a column of the matrix using the constant d.

Parameters:
column the number of the column where the constant is copied
d the constant
Exceptions:
MathException column is out of bounds

Definition at line 1227 of file Matrix.hpp.

template<typename T>
void kn::Matrix< T >::setColumn ( const unsigned int &  column,
const T *  a 
) [inline]

Defines a column of the matrix using an array of data.

Parameters:
column the number of the column where the array is copied
a the array
Exceptions:
MathException a is null
MathException column is out of bounds

Definition at line 1216 of file Matrix.hpp.

template<typename T>
void kn::Matrix< T >::setColumn ( const unsigned int &  column,
const Vector< T > &  v 
) [inline]

Defines a column of the matrix using a vector.

Parameters:
column the number of the column where the vector is copied
v the vector
Exceptions:
MathException v size is null
MathException column is out of bounds

Definition at line 1204 of file Matrix.hpp.

template<typename T>
void kn::Matrix< T >::setDiagonal ( const T &  d  )  [inline]

Sets diagonal of the matrix with a constant.

Parameters:
d a value

Definition at line 1299 of file Matrix.hpp.

template<typename T>
void kn::Matrix< T >::setDiagonal ( const T *  a  )  [inline]

Sets diagonal of the matrix with values from an array.

Parameters:
a an array of values
Exceptions:
MathException pointer is null

Definition at line 1291 of file Matrix.hpp.

template<typename T>
void kn::Matrix< T >::setDiagonal ( const Vector< T > &  v  )  [inline]

Sets diagonal of the matrix with values from a vector.

Parameters:
v the vector of values
Exceptions:
MathException vector size is incorrect

Definition at line 1279 of file Matrix.hpp.

template<typename T >
void kn::Matrix< T >::setIdentity ( void   )  [inline]

sets the matrix to identity

Reimplemented in kn::Matrix3x3< T >, and kn::Matrix4x4< T >.

Definition at line 1130 of file Matrix.hpp.

template<typename T>
void kn::Matrix< T >::setRow ( const unsigned int &  row,
const T &  d 
) [inline]

Defines a row of the matrix using the constant d.

Parameters:
row the number of the row where the constant is copied
d the constant
Exceptions:
MathException out of bounds

Definition at line 1195 of file Matrix.hpp.

template<typename T>
void kn::Matrix< T >::setRow ( const unsigned int &  row,
T *  a 
) [inline]

Defines a row of the matrix using an array of data.

Parameters:
row the number of the row where the array is copied
a the array
Exceptions:
MathException a is null
MathException row is out of bounds

Definition at line 1187 of file Matrix.hpp.

template<typename T>
void kn::Matrix< T >::setRow ( const unsigned int &  row,
const Vector< T > &  v 
) [inline]

Defines a row of the matrix using a vector.

Parameters:
row the number of the row where the vector is copied
v the vector
Exceptions:
MathException v size is null
MathException row is out of bounds

Definition at line 1175 of file Matrix.hpp.

template<typename T>
void kn::Matrix< T >::setSubMatrix ( const unsigned int &  row,
const unsigned int &  column,
const Matrix< T > &  m 
) [inline]

Copies the content of matrix m inside this matrix.

Data from the matrix m are duplicated inside this matrix at the position row and column.

Parameters:
row the row where start the copy
column the column where start the copy
m matrix duplicated inside this matrix
Exceptions:
MathException m cannot be duplicated inside this matrix
MathException row and column are out of bounds

Definition at line 1147 of file Matrix.hpp.

template<class T>
void kn::Matrix< T >::setZero ( void   )  [inline]

sets values of the matrix to zero

Definition at line 498 of file Matrix.hpp.

template<typename T >
void kn::Matrix< T >::swapColumns ( const unsigned int &  column1,
const unsigned int &  column2 
) [inline]

Swaps two columns of this matrix The swap is not applied if column1=column2.

Parameters:
column1 number of the first column
column2 number of the second column
Exceptions:
MathException column1 or column2 are out of bounds

Definition at line 1268 of file Matrix.hpp.

template<typename T >
void kn::Matrix< T >::swapRows ( const unsigned int &  row1,
const unsigned int &  row2 
) [inline]

Swaps two rows of this matrix The swap is not applied if row1=row2.

Parameters:
row1 number of the first row
row2 number of the second row
Exceptions:
MathException row1 or row2 are out of bounds

Definition at line 1258 of file Matrix.hpp.

template<typename T>
void kn::Matrix< T >::times ( const Matrix< T > &  m1,
const Matrix< T > &  m2 
) [inline]

Multiplies the matrix m1 with the matrix m2 in the current matrix.

Parameters:
m1 the first matrix of this multiplication
m2 the second matrix of this multiplication

Definition at line 931 of file Matrix.hpp.

template<typename T >
T kn::Matrix< T >::trace ( void   )  const [inline]

Trace of the Matrix This represents the sum of each element on the diagonal.

Returns:
the trace

Reimplemented in kn::Matrix3x3< T >, and kn::Matrix4x4< T >.

Definition at line 1318 of file Matrix.hpp.

template<typename T >
Matrix< T > & kn::Matrix< T >::transpose ( void   )  [inline]

Transposes inplace the current matrix.

Returns:
this transposed matrix

Reimplemented in kn::Matrix3x3< T >, and kn::Matrix4x4< T >.

Definition at line 1092 of file Matrix.hpp.


Member Data Documentation

template<class T>
T** kn::Matrix< T >::accessor [protected]

Pointers on the beginning of each rows.

Definition at line 86 of file Matrix.hpp.

template<class T>
T* kn::Matrix< T >::begin_ [protected]

Pointer on the beginning of the data.

Definition at line 76 of file Matrix.hpp.

template<class T>
size_t kn::Matrix< T >::columnsMatrix [protected]

Number of columns in the matrix.

Definition at line 66 of file Matrix.hpp.

template<class T>
T* kn::Matrix< T >::data [protected]

Content of the matrix.

Definition at line 71 of file Matrix.hpp.

template<class T>
T* kn::Matrix< T >::end_ [protected]

Pointer on the end of the data.

Definition at line 81 of file Matrix.hpp.

template<class T>
size_t kn::Matrix< T >::rowsMatrix [protected]

Number of rows in the matrix.

Definition at line 61 of file Matrix.hpp.


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

Generated on Thu Nov 12 16:06:35 2009 for OpenKN-math by  doxygen 1.5.8