Public Member Functions | Protected Attributes

CjMatrixImpl_1D< T > Class Template Reference

Inheritance diagram for CjMatrixImpl_1D< T >:
Inheritance graph
[legend]
Collaboration diagram for CjMatrixImpl_1D< T >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 CjMatrixImpl_1D (const unsigned int width, const unsigned int height, const T *const defaultValue=0)
 creates a matrix filled with the default value, or if not specified, uninitialised cells
 CjMatrixImpl_1D (const CjMatrixImpl_1D< T > &cjm)
 Creates a matrix which is a copy of another CjMatrixImpl_1D.
 CjMatrixImpl_1D (const CjMatrix< T > &cjm, const unsigned int width, const unsigned int height, const T *const defaultValue=0)
 Creates a matrix which is a copy of the specified matrix but with a given size.
template<typename V >
 CjMatrixImpl_1D (V m, const unsigned int w, const unsigned int h, const unsigned int width, const unsigned int height, const T *const defaultValue=0)
 Creates a matrix and copies cells from an 2D array.
 ~CjMatrixImpl_1D ()
 Deletes the CjMatrixImpl_1D.
void swap (CjMatrixImpl_1D &other)
 Swap contents with another instance of CjMatrixImpl_1D.
CjMatrixImpl< T > * clone () const
 Returns a copy of this CjMatrixImpl_1D.
void resizeImpl (const unsigned int width, const unsigned int height)
void resize_with_copyImpl (const unsigned int width, const unsigned int height, const CjMatrix< T > *const cjm=(CjMatrix< T > *) 0)
void setColumnValuesImpl (const unsigned int col, const T &val)
void setRowValuesImpl (const unsigned int row, const T &val)
void setAllValuesImpl (const T &val)
void setDiagonalImpl (const T &val)
void setDefaultValueImpl (const T &val)
getDefaultValueImpl () const
bool getDefaultValueSetImpl () const
bool equalElements (const CjMatrix< T > &) const
void transposeImpl ()
bool isSymmetricImpl () const
unsigned int getWidthImpl () const
unsigned int getHeightImpl () const
T & atImpl (unsigned int row, unsigned int col)
const T & atImpl (unsigned int row, unsigned int col) const
T & getImpl (unsigned int row, unsigned int col)
const T & getImpl (unsigned int row, unsigned int col) const
CjMatrixImpl_1D< T > & operator= (const CjMatrixImpl_1D< T > &)
 std::string returnMatrixDumpImpl(const unsigned int cellWidth, const std::string & rowPrefix, const bool blankDiagonal) const;

Protected Attributes

T * m_data
 the one dimensional array holding our 2D matrix in row major format
unsigned int m_width
 the number of columns in the 2D matrix
unsigned int m_height
 the number of rows in the 2D matrix
unsigned int m_size
 the size of m_data in number of items - ie m_width*m_height
m_defaultValue
 a local copy of the value used to initialise cells - not a copy of the pointer in constructor because we don't want external people changing it
bool m_defaultValueSet

template<typename T>
class CjMatrixImpl_1D< T >


Constructor & Destructor Documentation

template<typename T >
CjMatrixImpl_1D< T >::CjMatrixImpl_1D ( const unsigned int  width,
const unsigned int  height,
const T *const   defaultValue = 0 
) [inline]

creates a matrix filled with the default value, or if not specified, uninitialised cells

Creates a new CjMatrixImpl_1D - optionally initialised.

Creates an empty matrix of the given size. The cells are optionally set to a default value.

Parameters:
width the width of the new matrix
height the height of the new matrix
defaultValue a pointer to the default value which is it be copied into each newly initialised cell. If this is 0 then no cell initialisation is performed
Exceptions:
E_CjMatrix_MemoryAllocFail when memory cannot be allocated to store the matrix
E_CjMatrix_SizeError in case the size parameters supplied are invalid

if defaultValue is not null then the newly created matrix will be initialised with copies of this value

Exceptions:
E_CjMatrix_MemoryAllocFail if memory could not be allocated for the new matrix
E_CjMatrix_SizeError if the width or size are 0
template<typename T >
CjMatrixImpl_1D< T >::CjMatrixImpl_1D ( const CjMatrixImpl_1D< T > &  cjmi  )  [inline, explicit]

Creates a matrix which is a copy of another CjMatrixImpl_1D.

Copy constructor.

Parameters:
cjm The CjMatrix to copy
Exceptions:
E_CjMatrix_MemoryAllocFail when memory cannot be allocated to store the matrix
E_CjMatrix_MemoryAllocFail if memory could not be allocated for the new matrix
template<typename T >
CjMatrixImpl_1D< T >::CjMatrixImpl_1D ( const CjMatrix< T > &  cjm,
const unsigned int  width,
const unsigned int  height,
const T *const   defaultValue = 0 
)

Creates a matrix which is a copy of the specified matrix but with a given size.

The resulting matrix has a size specified by parameters width and height. If these are smaller than the source matrix then only the overlapping region is copied. If these are larger then the additional cells are optionally set to a default value.

Parameters:
cjm The CjMatrix to copy values from
width the width of the new matrix
height the height of the new matrix
defaultValue a pointer to the default value which is it be copied into each newly initialised cell. If this is 0 then no cell initialisation is performed
Exceptions:
E_CjMatrix_MemoryAllocFail when memory cannot be allocated to store the matrix
E_CjMatrix_SizeError in case the size parameters supplied are invalid
template<typename T >
template<typename V >
CjMatrixImpl_1D< T >::CjMatrixImpl_1D ( m,
const unsigned int  w,
const unsigned int  h,
const unsigned int  width,
const unsigned int  height,
const T *const   defaultValue = 0 
)

Creates a matrix and copies cells from an 2D array.

The resulting matrix has a size specified by parameters width and height. If these are smaller than the source matrix then only the overlapping region is copied. If these are larger then the additional cells are optionally set to a default value.

Parameters:
m is an instance of type V, which must be dereferencable by [][] and contain a type which is convertible to T
w the width of a row in m
h the height of a column in m
width the width of the new matrix
height the height of the new matrix
defaultValue a pointer to the default value which is it be copied into each newly initialised cell. If this is 0 then no cell initialisation is performed
Exceptions:
E_CjMatrix_MemoryAllocFail when memory cannot be allocated to store the matrix
E_CjMatrix_SizeError in case the size parameters supplied are invalid

Member Function Documentation

template<typename T >
CjMatrixImpl< T > * CjMatrixImpl_1D< T >::clone (  )  const [inline, virtual]

Returns a copy of this CjMatrixImpl_1D.

Exceptions:
E_CjMatrix_MemoryAllocFail when memory cannot be allocated to store the matrix

Implements CjMatrixImpl< T >.

template<typename T >
CjMatrixImpl_1D< T > & CjMatrixImpl_1D< T >::operator= ( const CjMatrixImpl_1D< T > &  cjmi  )  [inline]

std::string returnMatrixDumpImpl(const unsigned int cellWidth, const std::string & rowPrefix, const bool blankDiagonal) const;

Copies the contents of the RHS matrix to the LHS CjMatrixImpl_1D.

Exceptions:
E_CjMatrix_MemoryAllocFail when the LHS matrix has to be resized and memory could not be allocated
template<typename T >
void CjMatrixImpl_1D< T >::swap ( CjMatrixImpl_1D< T > &  other  )  [inline]

Swap contents with another instance of CjMatrixImpl_1D.

Swaps the contents of this and that CjMatrixImpl_1D.

After execution *this will have the same dimensions and contents as other did before the operation.
Other will have *this's original dimensions and contents after execution.
This operation won't throw.

Parameters:
other An instance of CjMatrixImpl_1D which which to swap contents.

Could throw anything that T's copy constructor could throw


The documentation for this class was generated from the following file:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator