GenMatrix< T > Class Template Reference

Double-precision column-major matrix for use with LAPACK. More...

List of all members.

Public Member Functions

void Alias (T *ptr_in, index_t n_rows_in, index_t n_cols_in)
 Makes this uninitialized matrix an alias of an existing block of doubles.
void Alias (const GenMatrix &other)
 Makes this uninitialized matrix an alias of another matrix.
void Alias (T *ptr_in, index_t n_rows_in, index_t n_cols_in)
 Makes this uninitialized matrix an alias of an existing block of doubles.
void Alias (const GenMatrix &other)
 Makes this uninitialized matrix an alias of another matrix.
void AliasColVector (const GenVector< T > &col_vector)
 Makes this an N row by 1 column alias of a vector of length N.
void AliasColVector (const GenVector< T > &col_vector)
 Makes this an N row by 1 column alias of a vector of length N.
void AliasRowVector (const GenVector< T > &row_vector)
 Makes this a 1 row by N column alias of a vector of length N.
void AliasRowVector (const GenVector< T > &row_vector)
 Makes this a 1 row by N column alias of a vector of length N.
 ASSIGN_VIA_COPY_CONSTRUCTION (GenMatrix)
 ASSIGN_VIA_COPY_CONSTRUCTION (GenMatrix)
void Copy (const T *ptr_in, index_t n_rows_in, index_t n_cols_in)
 Makes this uninitialized matrix a copy of the other vector.
void Copy (const GenMatrix &other)
 Makes this uninitialized matrix a copy of the other vector.
void Copy (const T *ptr_in, index_t n_rows_in, index_t n_cols_in)
 Makes this uninitialized matrix a copy of the other vector.
void Copy (const GenMatrix &other)
 Makes this uninitialized matrix a copy of the other vector.
void CopyColumnFromMat (index_t col1, index_t col2, index_t ncols, GenMatrix< T > &mat)
 Copies a block of columns to a matrix column.
void CopyColumnFromMat (index_t col1, index_t col2, GenMatrix< T > &mat)
 Copies a vector to a matrix column.
void CopyColumnFromMat (index_t col1, index_t col2, index_t ncols, GenMatrix< T > &mat)
 Copies a block of columns to a matrix column.
void CopyColumnFromMat (index_t col1, index_t col2, GenMatrix< T > &mat)
 Copies a vector to a matrix column.
void CopyValues (const GenMatrix &other)
 Copies the values from another matrix to this matrix.
void CopyValues (const GenMatrix &other)
 Copies the values from another matrix to this matrix.
void CopyVectorToColumn (index_t col, GenVector< T > &vec)
 Copies a column of matrix 1 to a column of matrix 2.
void CopyVectorToColumn (index_t col, GenVector< T > &vec)
 Copies a column of matrix 1 to a column of matrix 2.
void Destruct ()
 Destructs this, so that it is suitable for you to call an initializer on this again.
void Destruct ()
 Destructs this, so that it is suitable for you to call an initializer on this again.
 GenMatrix ()
 Creates a matrix that can be initialized.
 GenMatrix (const GenMatrix< T > &other)
 Copy constructor -- for use in collections.
 GenMatrix (index_t in_rows, index_t in_cols)
 Creates a Matrix with uninitialized elements of the specified size.
 GenMatrix ()
 Creates a matrix that can be initialized.
 GenMatrix (const GenMatrix< T > &other)
 Copy constructor -- for use in collections.
 GenMatrix (index_t in_rows, index_t in_cols)
 Creates a Matrix with uninitialized elements of the specified size.
get (index_t r, index_t c) const
 Gets a particular double at the specified row and column.
get (index_t r, index_t c) const
 Gets a particular double at the specified row and column.
const T * GetColumnPtr (index_t col) const
 Retrieves a pointer to a contiguous array corresponding to a particular column.
T * GetColumnPtr (index_t col)
 Retrieves a pointer to a contiguous array corresponding to a particular column.
const T * GetColumnPtr (index_t col) const
 Retrieves a pointer to a contiguous array corresponding to a particular column.
T * GetColumnPtr (index_t col)
 Retrieves a pointer to a contiguous array corresponding to a particular column.
void Init (index_t in_rows, index_t in_cols)
 Creates a Matrix with uninitialized elements of the specified size.
void Init (index_t in_rows, index_t in_cols)
 Creates a Matrix with uninitialized elements of the specified size.
void InitDiagonal (const GenVector< T > &v)
 Creates a diagonal matrix.
void InitDiagonal (const GenVector< T > &v)
 Creates a diagonal matrix.
void MakeColumnSlice (index_t start_col, index_t n_cols_new, GenMatrix *dest) const
 Make a matrix that is an alias of a particular slice of my columns.
void MakeColumnSlice (index_t start_col, index_t n_cols_new, GenMatrix *dest) const
 Make a matrix that is an alias of a particular slice of my columns.
void MakeColumnSubvector (index_t col, index_t start_row, index_t n_rows_new, GenVector< T > *dest) const
 Makes an alias of a subvector of particular column.
void MakeColumnSubvector (index_t col, index_t start_row, index_t n_rows_new, GenVector< T > *dest) const
 Makes an alias of a subvector of particular column.
void MakeColumnVector (index_t col, GenVector< T > *dest) const
 Makes an alias of a particular column.
void MakeColumnVector (index_t col, GenVector< T > *dest) const
 Makes an alias of a particular column.
void MakeReshaped (index_t n_rows_in, index_t n_cols_in, GenMatrix *dest) const
 Make an alias of a reshaped version of this matrix (column-major format).
void MakeReshaped (index_t n_rows_in, index_t n_cols_in, GenMatrix *dest) const
 Make an alias of a reshaped version of this matrix (column-major format).
index_t n_cols () const
 Returns the number of columns.
index_t n_cols () const
 Returns the number of columns.
size_t n_elements () const
 Returns the total number of elements (power user).
size_t n_elements () const
 Returns the total number of elements (power user).
index_t n_rows () const
 Returns the number of rows.
index_t n_rows () const
 Returns the number of rows.
void Own (T *ptr_in, index_t n_rows_in, index_t n_cols_in)
 Initializes this uninitialized matrix as the "owning copy" of some linearized chunk of RAM allocated with mem::Alloc.
void Own (GenMatrix *other)
 Makes this uninitialized matrix the "owning copy" of the other matrix; the other vector becomes an alias and this becomes the standard.
void Own (T *ptr_in, index_t n_rows_in, index_t n_cols_in)
 Initializes this uninitialized matrix as the "owning copy" of some linearized chunk of RAM allocated with mem::Alloc.
void Own (GenMatrix *other)
 Makes this uninitialized matrix the "owning copy" of the other matrix; the other vector becomes an alias and this becomes the standard.
void PrintDebug (const char *name="", FILE *stream=stderr) const
 Prints to a stream as a debug message.
void PrintDebug (const char *name="", FILE *stream=stderr) const
 Prints to a stream as a debug message.
T * ptr ()
 Returns a pointer to the very beginning of the matrix, stored in a column-major format.
const T * ptr () const
 Returns a pointer to the very beginning of the matrix, stored in a column-major format.
T * ptr ()
 Returns a pointer to the very beginning of the matrix, stored in a column-major format.
const T * ptr () const
 Returns a pointer to the very beginning of the matrix, stored in a column-major format.
T & ref (index_t r, index_t c)
 Gets a reference to a particular row and column.
T & ref (index_t r, index_t c)
 Gets a reference to a particular row and column.
void ResizeNoalias (index_t new_n_cols)
 Changes the number of columns, but REQUIRES that there are no aliases to this matrix anywhere else.
void ResizeNoalias (index_t new_n_cols)
 Changes the number of columns, but REQUIRES that there are no aliases to this matrix anywhere else.
void set (index_t r, index_t c, T v)
 Sets the value at the row and column.
void set (index_t r, index_t c, T v)
 Sets the value at the row and column.
void SetAll (T d)
 Sets the entire matrix to zero.
void SetAll (T d)
 Sets the entire matrix to zero.
void SetDiagonal (const GenVector< T > &v)
 Makes this a diagonal matrix whose diagonals are the values in v.
void SetDiagonal (const GenVector< T > &v)
 Makes this a diagonal matrix whose diagonals are the values in v.
void SetZero ()
 Makes this matrix all zeroes.
void SetZero ()
 Makes this matrix all zeroes.
void StaticCopy (const T *ptr_in, index_t n_rows_in, index_t n_cols_in)
 Makes this uninitialized matrix a static copy of the other vector, which will not be freed!
void StaticCopy (const GenMatrix &other)
 Makes this uninitialized matrix a static copy of the other vector which will not be freed!
void StaticCopy (const T *ptr_in, index_t n_rows_in, index_t n_cols_in)
 Makes this uninitialized matrix a static copy of the other vector, which will not be freed!
void StaticCopy (const GenMatrix &other)
 Makes this uninitialized matrix a static copy of the other vector which will not be freed!
void StaticInit (index_t in_rows, index_t in_cols)
 Creates a Matrix with uninitialized elements of the specified size statically.
void StaticInit (index_t in_rows, index_t in_cols)
 Creates a Matrix with uninitialized elements of the specified size statically.
void StaticInitDiagonal (const GenVector< T > &v)
 Creates a diagonal matrix.
void StaticInitDiagonal (const GenVector< T > &v)
 Creates a diagonal matrix.
void StaticOwn (T *ptr_in, index_t n_rows_in, index_t n_cols_in)
 Initializes this uninitialized matrix as the "owning copy" of some linearized chunk of RAM allocated statically.
void StaticOwn (GenMatrix *other)
 Makes this uninitialized matrix the "owning copy" of the other matrix; the other vector becomes an alias and this becomes the standard statically.
void StaticOwn (T *ptr_in, index_t n_rows_in, index_t n_cols_in)
 Initializes this uninitialized matrix as the "owning copy" of some linearized chunk of RAM allocated statically.
void StaticOwn (GenMatrix *other)
 Makes this uninitialized matrix the "owning copy" of the other matrix; the other vector becomes an alias and this becomes the standard statically.
void SwapValues (GenMatrix *other)
 Swaps all values in this matrix with values in the other.
void SwapValues (GenMatrix *other)
 Swaps all values in this matrix with values in the other.
void WeakCopy (const GenMatrix &other)
 Makes this a weak copy or alias of the other.
void WeakCopy (const GenMatrix &other)
 Makes this a weak copy or alias of the other.
 ~GenMatrix ()
 Empty destructor.
 ~GenMatrix ()
 Empty destructor.

Detailed Description

template<typename T>
class GenMatrix< T >

Double-precision column-major matrix for use with LAPACK.

Your code can have huge performance hits if you fail to realize this is column major. For datasets, your columns should be individual points and your rows should be features.

TODO: If it's not entirely obvious or well documented how to use this class please let the FASTlib people know.

Definition at line 457 of file matrix.h.


Constructor & Destructor Documentation

template<typename T>
GenMatrix< T >::GenMatrix ( index_t  in_rows,
index_t  in_cols 
) [inline]

Creates a Matrix with uninitialized elements of the specified size.

Definition at line 481 of file matrix.h.

template<typename T>
GenMatrix< T >::GenMatrix ( const GenMatrix< T > &  other  )  [inline]

Copy constructor -- for use in collections.

Definition at line 489 of file matrix.h.

template<typename T>
GenMatrix< T >::GenMatrix (  )  [inline]

Creates a matrix that can be initialized.

Definition at line 498 of file matrix.h.

template<typename T>
GenMatrix< T >::~GenMatrix (  )  [inline]

Empty destructor.

Definition at line 505 of file matrix.h.

template<typename T>
GenMatrix< T >::GenMatrix ( index_t  in_rows,
index_t  in_cols 
) [inline]

Creates a Matrix with uninitialized elements of the specified size.

Definition at line 481 of file matrix.h.

template<typename T>
GenMatrix< T >::GenMatrix ( const GenMatrix< T > &  other  )  [inline]

Copy constructor -- for use in collections.

Definition at line 489 of file matrix.h.

template<typename T>
GenMatrix< T >::GenMatrix (  )  [inline]

Creates a matrix that can be initialized.

Definition at line 498 of file matrix.h.

template<typename T>
GenMatrix< T >::~GenMatrix (  )  [inline]

Empty destructor.

Definition at line 505 of file matrix.h.


Member Function Documentation

template<typename T>
void GenMatrix< T >::Alias ( T *  ptr_in,
index_t  n_rows_in,
index_t  n_cols_in 
) [inline]

Makes this uninitialized matrix an alias of an existing block of doubles.

Parameters:
ptr_in the pointer to a block of column-major doubles
n_rows_in the number of rows
n_cols_in the number of columns

Definition at line 677 of file matrix.h.

template<typename T>
void GenMatrix< T >::Alias ( const GenMatrix< T > &  other  )  [inline]

Makes this uninitialized matrix an alias of another matrix.

Changes to one matrix are visible in the other (and vice-versa).

Parameters:
other the other vector

Definition at line 665 of file matrix.h.

template<typename T>
void GenMatrix< T >::Alias ( T *  ptr_in,
index_t  n_rows_in,
index_t  n_cols_in 
) [inline]

Makes this uninitialized matrix an alias of an existing block of doubles.

Parameters:
ptr_in the pointer to a block of column-major doubles
n_rows_in the number of rows
n_cols_in the number of columns

Definition at line 677 of file matrix.h.

template<typename T>
void GenMatrix< T >::Alias ( const GenMatrix< T > &  other  )  [inline]

Makes this uninitialized matrix an alias of another matrix.

Changes to one matrix are visible in the other (and vice-versa).

Parameters:
other the other vector

Definition at line 665 of file matrix.h.

Referenced by GenMatrix< double >::Alias(), GenMatrix< double >::AliasColVector(), GenMatrix< double >::AliasRowVector(), GenMatrix< double >::MakeColumnSlice(), GenMatrix< double >::MakeReshaped(), and GenMatrix< double >::WeakCopy().

template<typename T>
void GenMatrix< T >::AliasColVector ( const GenVector< T > &  col_vector  )  [inline]

Makes this an N row by 1 column alias of a vector of length N.

Parameters:
col_vector the vector to alias

Definition at line 700 of file matrix.h.

template<typename T>
void GenMatrix< T >::AliasColVector ( const GenVector< T > &  col_vector  )  [inline]

Makes this an N row by 1 column alias of a vector of length N.

Parameters:
col_vector the vector to alias

Definition at line 700 of file matrix.h.

template<typename T>
void GenMatrix< T >::AliasRowVector ( const GenVector< T > &  row_vector  )  [inline]

Makes this a 1 row by N column alias of a vector of length N.

Parameters:
row_vector the vector to alias

Definition at line 691 of file matrix.h.

template<typename T>
void GenMatrix< T >::AliasRowVector ( const GenVector< T > &  row_vector  )  [inline]

Makes this a 1 row by N column alias of a vector of length N.

Parameters:
row_vector the vector to alias

Definition at line 691 of file matrix.h.

template<typename T>
void GenMatrix< T >::Copy ( const T *  ptr_in,
index_t  n_rows_in,
index_t  n_cols_in 
) [inline]

Makes this uninitialized matrix a copy of the other vector.

Parameters:
ptr_in the pointer to a block of column-major doubles
n_rows_in the number of rows
n_cols_in the number of columns

Definition at line 615 of file matrix.h.

template<typename T>
void GenMatrix< T >::Copy ( const GenMatrix< T > &  other  )  [inline]

Makes this uninitialized matrix a copy of the other vector.

Parameters:
other the vector to explicitly copy

Definition at line 604 of file matrix.h.

template<typename T>
void GenMatrix< T >::Copy ( const T *  ptr_in,
index_t  n_rows_in,
index_t  n_cols_in 
) [inline]

Makes this uninitialized matrix a copy of the other vector.

Parameters:
ptr_in the pointer to a block of column-major doubles
n_rows_in the number of rows
n_cols_in the number of columns

Definition at line 615 of file matrix.h.

template<typename T>
void GenMatrix< T >::Copy ( const GenMatrix< T > &  other  )  [inline]

Makes this uninitialized matrix a copy of the other vector.

Parameters:
other the vector to explicitly copy

Definition at line 604 of file matrix.h.

Referenced by InfomaxICA::applyICA(), GenMatrix< double >::Copy(), GenMatrix< double >::CopyValues(), GenMatrix< double >::GenMatrix(), schur(), GenMatrix< double >::StaticCopy(), and FastICA::SymmetricFixedPointICA().

template<typename T>
void GenMatrix< T >::CopyColumnFromMat ( index_t  col1,
index_t  col2,
index_t  ncols,
GenMatrix< T > &  mat 
) [inline]

Copies a block of columns to a matrix column.

Parameters:
col1 the column number of this matrix
col2 the column number of the other matrixa
ncols the number of columns
mat the other matrix
Returns:
nothing

Definition at line 903 of file matrix.h.

template<typename T>
void GenMatrix< T >::CopyColumnFromMat ( index_t  col1,
index_t  col2,
GenMatrix< T > &  mat 
) [inline]

Copies a vector to a matrix column.

Parameters:
col1 the column number of this matrix
col2 the column number of the other matrix
mat the other matrix
Returns:
nothing

Definition at line 889 of file matrix.h.

template<typename T>
void GenMatrix< T >::CopyColumnFromMat ( index_t  col1,
index_t  col2,
index_t  ncols,
GenMatrix< T > &  mat 
) [inline]

Copies a block of columns to a matrix column.

Parameters:
col1 the column number of this matrix
col2 the column number of the other matrixa
ncols the number of columns
mat the other matrix
Returns:
nothing

Definition at line 903 of file matrix.h.

template<typename T>
void GenMatrix< T >::CopyColumnFromMat ( index_t  col1,
index_t  col2,
GenMatrix< T > &  mat 
) [inline]

Copies a vector to a matrix column.

Parameters:
col1 the column number of this matrix
col2 the column number of the other matrix
mat the other matrix
Returns:
nothing

Definition at line 889 of file matrix.h.

template<typename T>
void GenMatrix< T >::CopyValues ( const GenMatrix< T > &  other  )  [inline]

Copies the values from another matrix to this matrix.

Parameters:
other the vector to copy from

Definition at line 955 of file matrix.h.

template<typename T>
void GenMatrix< T >::CopyValues ( const GenMatrix< T > &  other  )  [inline]

Copies the values from another matrix to this matrix.

Parameters:
other the vector to copy from

Definition at line 955 of file matrix.h.

template<typename T>
void GenMatrix< T >::CopyVectorToColumn ( index_t  col,
GenVector< T > &  vec 
) [inline]

Copies a column of matrix 1 to a column of matrix 2.

Parameters:
col1 the column number
Returns:
nothing

Definition at line 917 of file matrix.h.

template<typename T>
void GenMatrix< T >::CopyVectorToColumn ( index_t  col,
GenVector< T > &  vec 
) [inline]

Copies a column of matrix 1 to a column of matrix 2.

Parameters:
col1 the column number
Returns:
nothing

Definition at line 917 of file matrix.h.

template<typename T>
void GenMatrix< T >::Destruct (  )  [inline]

Destructs this, so that it is suitable for you to call an initializer on this again.

Definition at line 513 of file matrix.h.

template<typename T>
void GenMatrix< T >::Destruct (  )  [inline]

Destructs this, so that it is suitable for you to call an initializer on this again.

Definition at line 513 of file matrix.h.

Referenced by GenMatrix< double >::~GenMatrix().

template<typename T>
T GenMatrix< T >::get ( index_t  r,
index_t  c 
) const [inline]

Gets a particular double at the specified row and column.

Parameters:
r the row number
c the column number

Definition at line 1004 of file matrix.h.

template<typename T>
T GenMatrix< T >::get ( index_t  r,
index_t  c 
) const [inline]

Gets a particular double at the specified row and column.

Parameters:
r the row number
c the column number

Definition at line 1004 of file matrix.h.

Referenced by NaiveOrthoRangeSearch< T >::Compute(), and main().

template<typename T>
const T* GenMatrix< T >::GetColumnPtr ( index_t  col  )  const [inline]

Retrieves a pointer to a contiguous array corresponding to a particular column.

Parameters:
col the column number
Returns:
an array where the i'th element is the i'th row of that particular column

Definition at line 877 of file matrix.h.

template<typename T>
T* GenMatrix< T >::GetColumnPtr ( index_t  col  )  [inline]

Retrieves a pointer to a contiguous array corresponding to a particular column.

Parameters:
col the column number
Returns:
an array where the i'th element is the i'th row of that particular column

Definition at line 864 of file matrix.h.

template<typename T>
const T* GenMatrix< T >::GetColumnPtr ( index_t  col  )  const [inline]

Retrieves a pointer to a contiguous array corresponding to a particular column.

Parameters:
col the column number
Returns:
an array where the i'th element is the i'th row of that particular column

Definition at line 877 of file matrix.h.

template<typename T>
T* GenMatrix< T >::GetColumnPtr ( index_t  col  )  [inline]

Retrieves a pointer to a contiguous array corresponding to a particular column.

Parameters:
col the column number
Returns:
an array where the i'th element is the i'th row of that particular column

Definition at line 864 of file matrix.h.

Referenced by GenMatrix< double >::CopyColumnFromMat().

template<typename T>
void GenMatrix< T >::Init ( index_t  in_rows,
index_t  in_cols 
) [inline]

Creates a Matrix with uninitialized elements of the specified size.

Definition at line 529 of file matrix.h.

template<typename T>
void GenMatrix< T >::Init ( index_t  in_rows,
index_t  in_cols 
) [inline]
template<typename T>
void GenMatrix< T >::InitDiagonal ( const GenVector< T > &  v  )  [inline]

Creates a diagonal matrix.

Definition at line 540 of file matrix.h.

template<typename T>
void GenMatrix< T >::InitDiagonal ( const GenVector< T > &  v  )  [inline]

Creates a diagonal matrix.

Definition at line 540 of file matrix.h.

template<typename T>
void GenMatrix< T >::MakeColumnSlice ( index_t  start_col,
index_t  n_cols_new,
GenMatrix< T > *  dest 
) const [inline]

Make a matrix that is an alias of a particular slice of my columns.

Parameters:
start_col the first column
n_cols_new the number of columns in the new matrix
dest an UNINITIALIZED matrix

Definition at line 793 of file matrix.h.

template<typename T>
void GenMatrix< T >::MakeColumnSlice ( index_t  start_col,
index_t  n_cols_new,
GenMatrix< T > *  dest 
) const [inline]

Make a matrix that is an alias of a particular slice of my columns.

Parameters:
start_col the first column
n_cols_new the number of columns in the new matrix
dest an UNINITIALIZED matrix

Definition at line 793 of file matrix.h.

template<typename T>
void GenMatrix< T >::MakeColumnSubvector ( index_t  col,
index_t  start_row,
index_t  n_rows_new,
GenVector< T > *  dest 
) const [inline]

Makes an alias of a subvector of particular column.

Parameters:
col the column to alias
start_row the first row to put in the subvector
n_rows_new the number of rows of the subvector
dest a pointer to an uninitialized vector, which will be initialized as an alias to the particular column's subvector

Definition at line 848 of file matrix.h.

template<typename T>
void GenMatrix< T >::MakeColumnSubvector ( index_t  col,
index_t  start_row,
index_t  n_rows_new,
GenVector< T > *  dest 
) const [inline]

Makes an alias of a subvector of particular column.

Parameters:
col the column to alias
start_row the first row to put in the subvector
n_rows_new the number of rows of the subvector
dest a pointer to an uninitialized vector, which will be initialized as an alias to the particular column's subvector

Definition at line 848 of file matrix.h.

template<typename T>
void GenMatrix< T >::MakeColumnVector ( index_t  col,
GenVector< T > *  dest 
) const [inline]

Makes an alias of a particular column.

Parameters:
col the column to alias
dest a pointer to an uninitialized vector, which will be initialized as an alias to the particular column

Definition at line 834 of file matrix.h.

template<typename T>
void GenMatrix< T >::MakeColumnVector ( index_t  col,
GenVector< T > *  dest 
) const [inline]

Makes an alias of a particular column.

Parameters:
col the column to alias
dest a pointer to an uninitialized vector, which will be initialized as an alias to the particular column

Definition at line 834 of file matrix.h.

Referenced by OrthoRangeSearch< T >::Compute().

template<typename T>
void GenMatrix< T >::MakeReshaped ( index_t  n_rows_in,
index_t  n_cols_in,
GenMatrix< T > *  dest 
) const [inline]

Make an alias of a reshaped version of this matrix (column-major format).

For instance, a matrix with 2 rows and 6 columns can be reshaped into a matrix with 12 rows 1 column, 1 row and 12 columns, or a variety of other shapes. The layout of the new elements correspond exactly to just pretending that the current column-major matrix is laid out as a different column-major matrix.

It is required that n_rows_new * n_cols_new is the same as n_rows * n_cols of the original matrix.

TODO: Considering using const Matrix& for third-party classes that want to implicitly convert to Matrix.

Parameters:
n_rows_in new number of rows
n_cols_in new number of columns
dest a pointer to an unitialized matrix
Returns:
a reshaped matrix backed by the original

Definition at line 821 of file matrix.h.

template<typename T>
void GenMatrix< T >::MakeReshaped ( index_t  n_rows_in,
index_t  n_cols_in,
GenMatrix< T > *  dest 
) const [inline]

Make an alias of a reshaped version of this matrix (column-major format).

For instance, a matrix with 2 rows and 6 columns can be reshaped into a matrix with 12 rows 1 column, 1 row and 12 columns, or a variety of other shapes. The layout of the new elements correspond exactly to just pretending that the current column-major matrix is laid out as a different column-major matrix.

It is required that n_rows_new * n_cols_new is the same as n_rows * n_cols of the original matrix.

TODO: Considering using const Matrix& for third-party classes that want to implicitly convert to Matrix.

Parameters:
n_rows_in new number of rows
n_cols_in new number of columns
dest a pointer to an unitialized matrix
Returns:
a reshaped matrix backed by the original

Definition at line 821 of file matrix.h.

template<typename T>
index_t GenMatrix< T >::n_cols (  )  const [inline]

Returns the number of columns.

Definition at line 1037 of file matrix.h.

template<typename T>
index_t GenMatrix< T >::n_cols (  )  const [inline]
template<typename T>
size_t GenMatrix< T >::n_elements (  )  const [inline]

Returns the total number of elements (power user).

This is useful for iterating over all elements of the matrix when the row/column structure is not important.

Definition at line 1052 of file matrix.h.

template<typename T>
size_t GenMatrix< T >::n_elements (  )  const [inline]

Returns the total number of elements (power user).

This is useful for iterating over all elements of the matrix when the row/column structure is not important.

Definition at line 1052 of file matrix.h.

Referenced by GenMatrix< double >::CopyValues(), GenMatrix< double >::ResizeNoalias(), GenMatrix< double >::SetAll(), and GenMatrix< double >::SwapValues().

template<typename T>
index_t GenMatrix< T >::n_rows (  )  const [inline]

Returns the number of rows.

Definition at line 1042 of file matrix.h.

template<typename T>
index_t GenMatrix< T >::n_rows (  )  const [inline]
template<typename T>
void GenMatrix< T >::Own ( T *  ptr_in,
index_t  n_rows_in,
index_t  n_cols_in 
) [inline]

Initializes this uninitialized matrix as the "owning copy" of some linearized chunk of RAM allocated with mem::Alloc.

Parameters:
ptr_in the pointer to a block of column-major doubles allocated via mem::Alloc
n_rows_in the number of rows
n_cols_in the number of columns

Definition at line 738 of file matrix.h.

template<typename T>
void GenMatrix< T >::Own ( GenMatrix< T > *  other  )  [inline]

Makes this uninitialized matrix the "owning copy" of the other matrix; the other vector becomes an alias and this becomes the standard.

The other matrix must be the "owning copy" of its memory.

Parameters:
other a pointer to the other matrix

Definition at line 722 of file matrix.h.

template<typename T>
void GenMatrix< T >::Own ( T *  ptr_in,
index_t  n_rows_in,
index_t  n_cols_in 
) [inline]

Initializes this uninitialized matrix as the "owning copy" of some linearized chunk of RAM allocated with mem::Alloc.

Parameters:
ptr_in the pointer to a block of column-major doubles allocated via mem::Alloc
n_rows_in the number of rows
n_cols_in the number of columns

Definition at line 738 of file matrix.h.

template<typename T>
void GenMatrix< T >::Own ( GenMatrix< T > *  other  )  [inline]

Makes this uninitialized matrix the "owning copy" of the other matrix; the other vector becomes an alias and this becomes the standard.

The other matrix must be the "owning copy" of its memory.

Parameters:
other a pointer to the other matrix

Definition at line 722 of file matrix.h.

Referenced by GenMatrix< double >::Own(), and GenMatrix< double >::StaticOwn().

template<typename T>
void GenMatrix< T >::PrintDebug ( const char *  name = "",
FILE *  stream = stderr 
) const [inline]

Prints to a stream as a debug message.

Parameters:
name a name that will be printed with the matrix
stream the stream to print to, defaults to stderr

Definition at line 967 of file matrix.h.

template<typename T>
void GenMatrix< T >::PrintDebug ( const char *  name = "",
FILE *  stream = stderr 
) const [inline]

Prints to a stream as a debug message.

Parameters:
name a name that will be printed with the matrix
stream the stream to print to, defaults to stderr

Definition at line 967 of file matrix.h.

template<typename T>
T* GenMatrix< T >::ptr (  )  [inline]

Returns a pointer to the very beginning of the matrix, stored in a column-major format.

This is suitable for BLAS and LAPACK calls.

Definition at line 994 of file matrix.h.

template<typename T>
const T* GenMatrix< T >::ptr (  )  const [inline]

Returns a pointer to the very beginning of the matrix, stored in a column-major format.

This is suitable for BLAS and LAPACK calls.

Definition at line 984 of file matrix.h.

template<typename T>
T* GenMatrix< T >::ptr (  )  [inline]

Returns a pointer to the very beginning of the matrix, stored in a column-major format.

This is suitable for BLAS and LAPACK calls.

Definition at line 994 of file matrix.h.

template<typename T>
const T* GenMatrix< T >::ptr (  )  const [inline]

Returns a pointer to the very beginning of the matrix, stored in a column-major format.

This is suitable for BLAS and LAPACK calls.

Definition at line 984 of file matrix.h.

Referenced by GenMatrix< double >::Copy(), GenMatrix< double >::Own(), GenMatrix< double >::StaticCopy(), and GenMatrix< double >::StaticOwn().

template<typename T>
T& GenMatrix< T >::ref ( index_t  r,
index_t  c 
) [inline]

Gets a reference to a particular row and column.

It is highly recommended you treat this as a single value rather than part of an array; use ColumnSlice or Reshaped instead to make subsections.

Definition at line 1030 of file matrix.h.

template<typename T>
T& GenMatrix< T >::ref ( index_t  r,
index_t  c 
) [inline]

Gets a reference to a particular row and column.

It is highly recommended you treat this as a single value rather than part of an array; use ColumnSlice or Reshaped instead to make subsections.

Definition at line 1030 of file matrix.h.

template<typename T>
void GenMatrix< T >::ResizeNoalias ( index_t  new_n_cols  )  [inline]

Changes the number of columns, but REQUIRES that there are no aliases to this matrix anywhere else.

If the size is increased, the remaining space is not initialized.

Parameters:
new_n_cols the new number of columns

Definition at line 930 of file matrix.h.

template<typename T>
void GenMatrix< T >::ResizeNoalias ( index_t  new_n_cols  )  [inline]

Changes the number of columns, but REQUIRES that there are no aliases to this matrix anywhere else.

If the size is increased, the remaining space is not initialized.

Parameters:
new_n_cols the new number of columns

Definition at line 930 of file matrix.h.

template<typename T>
void GenMatrix< T >::set ( index_t  r,
index_t  c,
v 
) [inline]

Sets the value at the row and column.

Parameters:
r the row number
c the column number
v the value to set

Definition at line 1017 of file matrix.h.

template<typename T>
void GenMatrix< T >::set ( index_t  r,
index_t  c,
v 
) [inline]

Sets the value at the row and column.

Parameters:
r the row number
c the column number
v the value to set

Definition at line 1017 of file matrix.h.

Referenced by data::LargeLoad().

template<typename T>
void GenMatrix< T >::SetAll ( d  )  [inline]

Sets the entire matrix to zero.

Definition at line 573 of file matrix.h.

template<typename T>
void GenMatrix< T >::SetAll ( d  )  [inline]

Sets the entire matrix to zero.

Definition at line 573 of file matrix.h.

Referenced by data::LargeLoad(), and GenMatrix< double >::SetZero().

template<typename T>
void GenMatrix< T >::SetDiagonal ( const GenVector< T > &  v  )  [inline]

Makes this a diagonal matrix whose diagonals are the values in v.

Definition at line 589 of file matrix.h.

template<typename T>
void GenMatrix< T >::SetDiagonal ( const GenVector< T > &  v  )  [inline]

Makes this a diagonal matrix whose diagonals are the values in v.

Definition at line 589 of file matrix.h.

Referenced by GenMatrix< double >::InitDiagonal(), and GenMatrix< double >::StaticInitDiagonal().

template<typename T>
void GenMatrix< T >::SetZero (  )  [inline]

Makes this matrix all zeroes.

Definition at line 580 of file matrix.h.

template<typename T>
void GenMatrix< T >::SetZero (  )  [inline]

Makes this matrix all zeroes.

Definition at line 580 of file matrix.h.

Referenced by GenMatrix< double >::SetDiagonal().

template<typename T>
void GenMatrix< T >::StaticCopy ( const T *  ptr_in,
index_t  n_rows_in,
index_t  n_cols_in 
) [inline]

Makes this uninitialized matrix a static copy of the other vector, which will not be freed!

Parameters:
ptr_in the pointer to a block of column-major doubles
n_rows_in the number of rows
n_cols_in the number of columns

Definition at line 642 of file matrix.h.

template<typename T>
void GenMatrix< T >::StaticCopy ( const GenMatrix< T > &  other  )  [inline]

Makes this uninitialized matrix a static copy of the other vector which will not be freed!

Parameters:
other the vector to explicitly copy

Definition at line 630 of file matrix.h.

template<typename T>
void GenMatrix< T >::StaticCopy ( const T *  ptr_in,
index_t  n_rows_in,
index_t  n_cols_in 
) [inline]

Makes this uninitialized matrix a static copy of the other vector, which will not be freed!

Parameters:
ptr_in the pointer to a block of column-major doubles
n_rows_in the number of rows
n_cols_in the number of columns

Definition at line 642 of file matrix.h.

template<typename T>
void GenMatrix< T >::StaticCopy ( const GenMatrix< T > &  other  )  [inline]

Makes this uninitialized matrix a static copy of the other vector which will not be freed!

Parameters:
other the vector to explicitly copy

Definition at line 630 of file matrix.h.

Referenced by GenMatrix< double >::StaticCopy().

template<typename T>
void GenMatrix< T >::StaticInit ( index_t  in_rows,
index_t  in_cols 
) [inline]

Creates a Matrix with uninitialized elements of the specified size statically.

This matrix is not freed!

Definition at line 549 of file matrix.h.

template<typename T>
void GenMatrix< T >::StaticInit ( index_t  in_rows,
index_t  in_cols 
) [inline]

Creates a Matrix with uninitialized elements of the specified size statically.

This matrix is not freed!

Definition at line 549 of file matrix.h.

Referenced by data::LargeLoad(), and GenMatrix< double >::StaticInitDiagonal().

template<typename T>
void GenMatrix< T >::StaticInitDiagonal ( const GenVector< T > &  v  )  [inline]

Creates a diagonal matrix.

Definition at line 565 of file matrix.h.

template<typename T>
void GenMatrix< T >::StaticInitDiagonal ( const GenVector< T > &  v  )  [inline]

Creates a diagonal matrix.

Definition at line 565 of file matrix.h.

template<typename T>
void GenMatrix< T >::StaticOwn ( T *  ptr_in,
index_t  n_rows_in,
index_t  n_cols_in 
) [inline]

Initializes this uninitialized matrix as the "owning copy" of some linearized chunk of RAM allocated statically.

Parameters:
ptr_in the pointer to a block of column-major doubles allocated via mem::Alloc
n_rows_in the number of rows
n_cols_in the number of columns

Definition at line 773 of file matrix.h.

template<typename T>
void GenMatrix< T >::StaticOwn ( GenMatrix< T > *  other  )  [inline]

Makes this uninitialized matrix the "owning copy" of the other matrix; the other vector becomes an alias and this becomes the standard statically.

The other matrix must have been allocated statically.

Parameters:
other a pointer to the other matrix

Definition at line 756 of file matrix.h.

template<typename T>
void GenMatrix< T >::StaticOwn ( T *  ptr_in,
index_t  n_rows_in,
index_t  n_cols_in 
) [inline]

Initializes this uninitialized matrix as the "owning copy" of some linearized chunk of RAM allocated statically.

Parameters:
ptr_in the pointer to a block of column-major doubles allocated via mem::Alloc
n_rows_in the number of rows
n_cols_in the number of columns

Definition at line 773 of file matrix.h.

template<typename T>
void GenMatrix< T >::StaticOwn ( GenMatrix< T > *  other  )  [inline]

Makes this uninitialized matrix the "owning copy" of the other matrix; the other vector becomes an alias and this becomes the standard statically.

The other matrix must have been allocated statically.

Parameters:
other a pointer to the other matrix

Definition at line 756 of file matrix.h.

Referenced by GenMatrix< double >::StaticOwn().

template<typename T>
void GenMatrix< T >::SwapValues ( GenMatrix< T > *  other  )  [inline]

Swaps all values in this matrix with values in the other.

This is different from Swap, because Swap will only change what these point to.

Parameters:
other an identically sized vector to swap values with

Definition at line 944 of file matrix.h.

template<typename T>
void GenMatrix< T >::SwapValues ( GenMatrix< T > *  other  )  [inline]

Swaps all values in this matrix with values in the other.

This is different from Swap, because Swap will only change what these point to.

Parameters:
other an identically sized vector to swap values with

Definition at line 944 of file matrix.h.

template<typename T>
void GenMatrix< T >::WeakCopy ( const GenMatrix< T > &  other  )  [inline]

Makes this a weak copy or alias of the other.

This is identical to Alias.

Definition at line 709 of file matrix.h.

template<typename T>
void GenMatrix< T >::WeakCopy ( const GenMatrix< T > &  other  )  [inline]

Makes this a weak copy or alias of the other.

This is identical to Alias.

Definition at line 709 of file matrix.h.


The documentation for this class was generated from the following files:
Generated on Mon Jan 24 12:04:40 2011 for FASTlib by  doxygen 1.6.3