Public Types | Public Member Functions | Private Attributes | List of all members
gnsstk::Matrix< T > Class Template Reference

Detailed Description

template<class T>
class gnsstk::Matrix< T >

An implementation of a matrix class using Vector<T> as its internal basis. This class is STL compliant with the iterator proceeding in row major order. Operators +=, -=, *= and /= are implemented in RefMatrixBase.

See also
matvectest.cpp for examples

Definition at line 72 of file Matrix.hpp.

#include <Matrix.hpp>

Inheritance diagram for gnsstk::Matrix< T >:
Inheritance graph
[legend]

Public Types

typedef Vector< T >::const_iterator const_iterator
 STL const iterator type. More...
 
typedef Vector< T >::const_reference const_reference
 STL const reference type. More...
 
typedef Vector< T >::iterator iterator
 STL iterator type. More...
 
typedef Vector< T >::reference reference
 STL reference type. More...
 
typedef Vector< T >::value_type value_type
 STL value_type. More...
 

Public Member Functions

iterator begin ()
 STL begin. More...
 
const_iterator begin () const
 STL const begin. More...
 
ConstMatrixColSlice< T > col (size_t colNum, const std::slice &s) const
 A const reference column with a given slice. More...
 
ConstMatrixColSlice< T > col (size_t colNum, size_t rowNum=0) const
 A const reference column with a starting row number (i.e. sub-column) More...
 
MatrixColSlice< T > colRef (size_t colNum, const std::slice &s)
 A reference column with a given slice. More...
 
MatrixColSlice< T > colRef (size_t colNum, size_t rowNum=0)
 A reference column with a starting row number (i.e. sub-column) More...
 
size_t cols () const
 The number of columns in the matrix. More...
 
bool empty () const
 STL empty. More...
 
iterator end ()
 STL end. More...
 
const_iterator end () const
 STL const end. More...
 
value_type front ()
 STL front. More...
 
const_reference front () const
 STL const front. More...
 
 Matrix ()
 default constructor More...
 
template<class BaseClass >
 Matrix (const ConstMatrixBase< T, BaseClass > &mat)
 constructor for a ConstMatrixBase object More...
 
template<class BaseClass >
 Matrix (const ConstMatrixBase< T, BaseClass > &mat, size_t topRow, size_t topCol, size_t numRows, size_t numCols)
 submatrix constructor More...
 
 Matrix (size_t rows, size_t cols)
 constructor given an initial size More...
 
template<class BaseClass >
 Matrix (size_t rows, size_t cols, const ConstVectorBase< T, BaseClass > &vec)
 copies out the contents of vec to initialize the matrix More...
 
 Matrix (size_t rows, size_t cols, const T *vec)
 copies out the contents of vec to initialize the matrix More...
 
 Matrix (size_t rows, size_t cols, T initialValue)
 constructor for an initial size and value More...
 
size_t max_size () const
 STL max size. More...
 
T & operator() (size_t rowNum, size_t colNum)
 Non-const matrix operator(row,col) More...
 
operator() (size_t rowNum, size_t colNum) const
 Const matrix operator(row,col) More...
 
template<class BaseClass >
Matrixoperator= (const ConstMatrixBase< T, BaseClass > &mat)
 Copies from any matrix. More...
 
template<class BaseClass >
Matrixoperator= (const ConstVectorBase< T, BaseClass > &mat)
 Copies from any vector. More...
 
Matrixoperator= (const Matrix &mat)
 Copies the other matrix. More...
 
Matrixoperator= (const std::valarray< T > array)
 
Matrixoperator= (const T *array)
 
Matrixoperator= (const T t)
 Assigns all elements of the matrix to t. More...
 
MatrixRowSlice< T > operator[] (size_t row)
 operator[] that returns a row slice More...
 
ConstMatrixRowSlice< T > operator[] (size_t rowNum) const
 const operator[] that returns a const row slice More...
 
Matrixresize (size_t rows, size_t cols)
 
Matrixresize (size_t rows, size_t cols, const T initialValue)
 
ConstMatrixRowSlice< T > row (size_t rowNum, const std::slice &s) const
 A const reference slice of a row with a given std::slice. More...
 
ConstMatrixRowSlice< T > row (size_t rowNum, size_t colNum=0) const
 A const reference slice of a row with a starting column (i.e. sub-row) More...
 
MatrixRowSlice< T > rowRef (size_t rowNum, const std::slice &s)
 A reference slice of a row with a given std::slice. More...
 
MatrixRowSlice< T > rowRef (size_t rowNum, size_t colNum=0)
 A reference slice of a row with a starting column (i.e. sub-row) More...
 
size_t rows () const
 The number of rows in the matrix. More...
 
size_t size () const
 STL size. More...
 
virtual ~Matrix ()
 
- Public Member Functions inherited from gnsstk::RefMatrixBase< T, Matrix< T > >
Matrix< T > & assignFrom (const ConstMatrixBase< T, E > &x)
 
Matrix< T > & assignFrom (const ConstVectorBase< T, E > &x)
 
Matrix< T > & assignFrom (const std::valarray< T > &x)
 
Matrix< T > & assignFrom (const T *x)
 
Matrix< T > & assignFrom (T x)
 
size_t cols () const
 returns the number of columns in the matrix More...
 
T & operator() (size_t i, size_t j)
 returns a reference to the (i,j) element of the matrix. More...
 
Matrix< T > & operator*= (const T x)
 multiplies each element in this matrix by x. More...
 
Matrix< T > & operator+= (const ConstMatrixBase< T, E > &x)
 
Matrix< T > & operator+= (const ConstVectorBase< T, E > &x)
 
Matrix< T > & operator+= (const std::valarray< T > &x)
 
Matrix< T > & operator+= (const T *x)
 
Matrix< T > & operator+= (T x)
 
const Matrix< T > operator- ()
 unary minus: multiplies each element in this matrix by -1. More...
 
Matrix< T > & operator-= (const ConstMatrixBase< T, E > &x)
 
Matrix< T > & operator-= (const ConstVectorBase< T, E > &x)
 
Matrix< T > & operator-= (const std::valarray< T > &x)
 
Matrix< T > & operator-= (const T *x)
 
Matrix< T > & operator-= (T x)
 
Matrix< T > & operator/= (const T x)
 divides each element in this matrix by x. More...
 
 RefMatrixBase ()
 default constructor More...
 
size_t rows () const
 returns the number of rows in the matrix More...
 
size_t size () const
 returns the rows()*cols() size of the matrix More...
 
Matrix< T > & swapCols (size_t col1, size_t col2)
 
Matrix< T > & swapRows (size_t row1, size_t row2)
 
Matrix< T > & zeroize ()
 
Matrix< T > & zeroizeCol (size_t c)
 
Matrix< T > & zeroizeRow (size_t r)
 
virtual ~RefMatrixBase ()
 
- Public Member Functions inherited from gnsstk::ConstMatrixBase< T, Matrix< T > >
Vector< T > colCopy (size_t c, size_t r=0) const
 
size_t cols () const
 the number of columns in the matrix More...
 
 ConstMatrixBase ()
 default constructor More...
 
Vector< T > diagCopy (void) const
 
bool isDiagonal () const
 returns true if this is a diagonal matrix More...
 
bool isLT () const
 returns true if this is a lower triangular matrix. More...
 
bool isSquare () const
 returns true if this is a square matrix (false for a null matrix). More...
 
bool isSymmetric () const
 
bool isUT () const
 returns true if this is an upper triangular matrix. More...
 
operator() (size_t i, size_t j) const
 
Vector< T > rowCopy (size_t r, size_t c=0) const
 
size_t rows () const
 the number of rows in the matrix More...
 
size_t size () const
 the rows()*cols() size of the matrix. More...
 
virtual ~ConstMatrixBase ()
 

Private Attributes

size_t c
 the number of columns More...
 
size_t r
 the number of rows More...
 
size_t s
 the overall size More...
 
Vector< T > v
 the matrix stored in column major order More...
 

Additional Inherited Members

- Protected Member Functions inherited from gnsstk::ConstMatrixBase< T, Matrix< T > >
constMatrixRef (size_t i, size_t j) const
 

Member Typedef Documentation

◆ const_iterator

template<class T >
typedef Vector<T>::const_iterator gnsstk::Matrix< T >::const_iterator

STL const iterator type.

Definition at line 86 of file Matrix.hpp.

◆ const_reference

template<class T >
typedef Vector<T>::const_reference gnsstk::Matrix< T >::const_reference

STL const reference type.

Definition at line 81 of file Matrix.hpp.

◆ iterator

template<class T >
typedef Vector<T>::iterator gnsstk::Matrix< T >::iterator

STL iterator type.

Definition at line 84 of file Matrix.hpp.

◆ reference

template<class T >
typedef Vector<T>::reference gnsstk::Matrix< T >::reference

STL reference type.

Definition at line 78 of file Matrix.hpp.

◆ value_type

template<class T >
typedef Vector<T>::value_type gnsstk::Matrix< T >::value_type

STL value_type.

Definition at line 76 of file Matrix.hpp.

Constructor & Destructor Documentation

◆ Matrix() [1/6]

template<class T >
gnsstk::Matrix< T >::Matrix ( size_t  rows,
size_t  cols 
)

constructor given an initial size

Definition at line 60 of file MatrixImplementation.hpp.

◆ Matrix() [2/6]

template<class T >
gnsstk::Matrix< T >::Matrix ( size_t  rows,
size_t  cols,
initialValue 
)

constructor for an initial size and value

Definition at line 65 of file MatrixImplementation.hpp.

◆ Matrix() [3/6]

template<class T >
gnsstk::Matrix< T >::Matrix ( size_t  rows,
size_t  cols,
const T *  vec 
)

copies out the contents of vec to initialize the matrix

Definition at line 71 of file MatrixImplementation.hpp.

◆ Matrix() [4/6]

template<class T >
template<class BaseClass >
gnsstk::Matrix< T >::Matrix ( size_t  rows,
size_t  cols,
const ConstVectorBase< T, BaseClass > &  vec 
)
inline

copies out the contents of vec to initialize the matrix

Definition at line 98 of file Matrix.hpp.

◆ Matrix() [5/6]

template<class T >
template<class BaseClass >
gnsstk::Matrix< T >::Matrix ( const ConstMatrixBase< T, BaseClass > &  mat)
inline

constructor for a ConstMatrixBase object

Definition at line 104 of file Matrix.hpp.

◆ Matrix() [6/6]

template<class T >
template<class BaseClass >
gnsstk::Matrix< T >::Matrix ( const ConstMatrixBase< T, BaseClass > &  mat,
size_t  topRow,
size_t  topCol,
size_t  numRows,
size_t  numCols 
)
inline

submatrix constructor

Definition at line 115 of file Matrix.hpp.

◆ ~Matrix()

template<class T >
virtual gnsstk::Matrix< T >::~Matrix ( )
inlinevirtual

Definition at line 140 of file Matrix.hpp.

Member Function Documentation

◆ begin() [1/2]

template<class T >
iterator gnsstk::Matrix< T >::begin ( )
inline

STL begin.

Definition at line 144 of file Matrix.hpp.

◆ begin() [2/2]

template<class T >
const_iterator gnsstk::Matrix< T >::begin ( ) const
inline

STL const begin.

Definition at line 146 of file Matrix.hpp.

◆ col() [1/2]

template<class T >
ConstMatrixColSlice< T > gnsstk::Matrix< T >::col ( size_t  colNum,
const std::slice &  s 
) const
inline

A const reference column with a given slice.

Definition at line 120 of file MatrixImplementation.hpp.

◆ col() [2/2]

template<class T >
ConstMatrixColSlice< T > gnsstk::Matrix< T >::col ( size_t  colNum,
size_t  rowNum = 0 
) const
inline

A const reference column with a starting row number (i.e. sub-column)

Definition at line 127 of file MatrixImplementation.hpp.

◆ colRef() [1/2]

template<class T >
MatrixColSlice< T > gnsstk::Matrix< T >::colRef ( size_t  colNum,
const std::slice &  s 
)
inline

A reference column with a given slice.

Definition at line 107 of file MatrixImplementation.hpp.

◆ colRef() [2/2]

template<class T >
MatrixColSlice< T > gnsstk::Matrix< T >::colRef ( size_t  colNum,
size_t  rowNum = 0 
)
inline

A reference column with a starting row number (i.e. sub-column)

Definition at line 113 of file MatrixImplementation.hpp.

◆ cols()

template<class T >
size_t gnsstk::Matrix< T >::cols ( ) const
inline

The number of columns in the matrix.

Definition at line 167 of file Matrix.hpp.

◆ empty()

template<class T >
bool gnsstk::Matrix< T >::empty ( ) const
inline

STL empty.

Definition at line 158 of file Matrix.hpp.

◆ end() [1/2]

template<class T >
iterator gnsstk::Matrix< T >::end ( )
inline

STL end.

Definition at line 148 of file Matrix.hpp.

◆ end() [2/2]

template<class T >
const_iterator gnsstk::Matrix< T >::end ( ) const
inline

STL const end.

Definition at line 150 of file Matrix.hpp.

◆ front() [1/2]

template<class T >
value_type gnsstk::Matrix< T >::front ( )
inline

STL front.

Definition at line 152 of file Matrix.hpp.

◆ front() [2/2]

template<class T >
const_reference gnsstk::Matrix< T >::front ( ) const
inline

STL const front.

Definition at line 155 of file Matrix.hpp.

◆ max_size()

template<class T >
size_t gnsstk::Matrix< T >::max_size ( ) const
inline

STL max size.

Definition at line 162 of file Matrix.hpp.

◆ operator()() [1/2]

template<class T >
T& gnsstk::Matrix< T >::operator() ( size_t  rowNum,
size_t  colNum 
)
inline

Non-const matrix operator(row,col)

Definition at line 187 of file Matrix.hpp.

◆ operator()() [2/2]

template<class T >
T gnsstk::Matrix< T >::operator() ( size_t  rowNum,
size_t  colNum 
) const
inline

Const matrix operator(row,col)

Definition at line 190 of file Matrix.hpp.

◆ operator=() [1/6]

template<class T >
template<class BaseClass >
Matrix& gnsstk::Matrix< T >::operator= ( const ConstMatrixBase< T, BaseClass > &  mat)
inline

Copies from any matrix.

Definition at line 224 of file Matrix.hpp.

◆ operator=() [2/6]

template<class T >
template<class BaseClass >
Matrix& gnsstk::Matrix< T >::operator= ( const ConstVectorBase< T, BaseClass > &  mat)
inline

Copies from any vector.

Definition at line 234 of file Matrix.hpp.

◆ operator=() [3/6]

template<class T >
Matrix& gnsstk::Matrix< T >::operator= ( const Matrix< T > &  mat)
inline

Copies the other matrix.

Definition at line 220 of file Matrix.hpp.

◆ operator=() [4/6]

template<class T >
Matrix& gnsstk::Matrix< T >::operator= ( const std::valarray< T >  array)
inline

Assigns the contents of this matrix to those in array in column major order.

Definition at line 214 of file Matrix.hpp.

◆ operator=() [5/6]

template<class T >
Matrix& gnsstk::Matrix< T >::operator= ( const T *  array)
inline

Assigns this matrix to a T* in column major order.

Warning
be careful that array is as large as the matrix is!

Definition at line 210 of file Matrix.hpp.

◆ operator=() [6/6]

template<class T >
Matrix& gnsstk::Matrix< T >::operator= ( const t)
inline

Assigns all elements of the matrix to t.

Definition at line 217 of file Matrix.hpp.

◆ operator[]() [1/2]

template<class T >
MatrixRowSlice<T> gnsstk::Matrix< T >::operator[] ( size_t  row)
inline

operator[] that returns a row slice

Definition at line 193 of file Matrix.hpp.

◆ operator[]() [2/2]

template<class T >
ConstMatrixRowSlice<T> gnsstk::Matrix< T >::operator[] ( size_t  rowNum) const
inline

const operator[] that returns a const row slice

Definition at line 196 of file Matrix.hpp.

◆ resize() [1/2]

template<class T >
Matrix< T > & gnsstk::Matrix< T >::resize ( size_t  rows,
size_t  cols 
)
inline

Resizes the matrix to rows*cols.

Warning
YOUR DATA MAY NOT BE RETAINED!!!

Definition at line 135 of file MatrixImplementation.hpp.

◆ resize() [2/2]

template<class T >
Matrix< T > & gnsstk::Matrix< T >::resize ( size_t  rows,
size_t  cols,
const initialValue 
)
inline

Definition at line 145 of file MatrixImplementation.hpp.

◆ row() [1/2]

template<class T >
ConstMatrixRowSlice< T > gnsstk::Matrix< T >::row ( size_t  rowNum,
const std::slice &  s 
) const
inline

A const reference slice of a row with a given std::slice.

Definition at line 92 of file MatrixImplementation.hpp.

◆ row() [2/2]

template<class T >
ConstMatrixRowSlice< T > gnsstk::Matrix< T >::row ( size_t  rowNum,
size_t  colNum = 0 
) const
inline

A const reference slice of a row with a starting column (i.e. sub-row)

Definition at line 99 of file MatrixImplementation.hpp.

◆ rowRef() [1/2]

template<class T >
MatrixRowSlice< T > gnsstk::Matrix< T >::rowRef ( size_t  rowNum,
const std::slice &  s 
)
inline

A reference slice of a row with a given std::slice.

Definition at line 79 of file MatrixImplementation.hpp.

◆ rowRef() [2/2]

template<class T >
MatrixRowSlice< T > gnsstk::Matrix< T >::rowRef ( size_t  rowNum,
size_t  colNum = 0 
)
inline

A reference slice of a row with a starting column (i.e. sub-row)

Definition at line 85 of file MatrixImplementation.hpp.

◆ rows()

template<class T >
size_t gnsstk::Matrix< T >::rows ( ) const
inline

The number of rows in the matrix.

Definition at line 165 of file Matrix.hpp.

◆ size()

template<class T >
size_t gnsstk::Matrix< T >::size ( ) const
inline

STL size.

Definition at line 160 of file Matrix.hpp.

Member Data Documentation

◆ c

template<class T >
size_t gnsstk::Matrix< T >::c
private

the number of columns

Definition at line 241 of file Matrix.hpp.

◆ r

template<class T >
size_t gnsstk::Matrix< T >::r
private

the number of rows

Definition at line 240 of file Matrix.hpp.

◆ s

template<class T >
size_t gnsstk::Matrix< T >::s
private

the overall size

Definition at line 242 of file Matrix.hpp.

◆ v

template<class T >
Vector<T> gnsstk::Matrix< T >::v
private

the matrix stored in column major order

Definition at line 239 of file Matrix.hpp.


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


gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:45