Edinburgh Speech Tools  2.1-release
EST_TMatrix< T > Class Template Reference

Template Matrix class. This is an extension of the EST_TVector class to two dimensions. More...

#include <include/EST_TMatrix.h>

Inheritance diagram for EST_TMatrix< T >:
Collaboration diagram for EST_TMatrix< T >:

Public Member Functions

 EST_TMatrix ()
 default constructor More...
 
 EST_TMatrix (const EST_TMatrix< T > &m)
 copy constructor More...
 
 EST_TMatrix (ssize_t rows, ssize_t cols)
 "size" constructor More...
 
 EST_TMatrix (ssize_t rows, ssize_t cols, T *memory, ptrdiff_t offset=0, int free_when_destroyed=0)
 construct from memory supplied by caller More...
 
 ~EST_TMatrix ()
 EST_TMatrix. More...
 
bool have_rows_before (ssize_t n) const
 
bool have_columns_before (ssize_t n) const
 
void resize (ssize_t rows, ssize_t cols, ssize_t set=1)
 
void fill (const T &v)
 fill matrix with value v More...
 
void fill ()
 
EST_TMatrixoperator= (const EST_TMatrix &s)
 assignment operator More...
 
EST_TMatrixadd_rows (const EST_TMatrix &s)
 The two versions of what might have been operator +=. More...
 
EST_TMatrixadd_columns (const EST_TMatrix &s)
 
access

Basic access methods for matrices.

ssize_t num_rows () const
 return number of rows More...
 
ssize_t num_columns () const
 return number of columns More...
 
INLINE const T & a_no_check (ssize_t row, ssize_t col) const
 const access with no bounds check, care recommend More...
 
INLINE T & a_no_check (ssize_t row, ssize_t col)
 access with no bounds check, care recommend More...
 
INLINE const T & a_no_check_1 (ssize_t row, ssize_t col) const
 
INLINE T & a_no_check_1 (ssize_t row, ssize_t col)
 
const T & a_check (ssize_t row, ssize_t col) const
 const element access function More...
 
T & a_check (ssize_t row, ssize_t col)
 non-const element access function More...
 
const T & a (ssize_t row, ssize_t col) const
 
T & a (ssize_t row, ssize_t col)
 
const T & operator() (ssize_t row, ssize_t col) const
 const element access operator More...
 
T & operator() (ssize_t row, ssize_t col)
 non-const element access operator More...
 
Sub-Matrix/Vector Extraction

All of these return matrices and vectors which share memory with the original, so altering values them alters the original.

void row (EST_TVector< T > &rv, ssize_t r, ssize_t start_c=0, int len=-1)
 Make the vector rv a window onto row r More...
 
void column (EST_TVector< T > &cv, ssize_t c, ssize_t start_r=0, int len=-1)
 Make the vector cv a window onto column c More...
 
void sub_matrix (EST_TMatrix< T > &sm, ssize_t r=0, ptrdiff_t numr=EST_ALL, ssize_t c=0, ptrdiff_t numc=EST_ALL)
 Make the matrix sm a window into this matrix. More...
 
Copy in and out

Copy data between buffers and the matrix.

void copy_row (ssize_t r, T *buf, ptrdiff_t offset=0, int num=-1) const
 
void copy_row (ssize_t r, EST_TVector< T > &t, ptrdiff_t offset=0, int num=-1) const
 
void copy_column (ssize_t c, T *buf, ptrdiff_t offset=0, int num=-1) const
 
void copy_column (ssize_t c, EST_TVector< T > &t, ptrdiff_t offset=0, int num=-1) const
 
void set_row (ssize_t n, const T *buf, ptrdiff_t offset=0, int num=-1)
 
void set_row (ssize_t n, const EST_TVector< T > &t, ptrdiff_t offset=0, int num=-1)
 
void set_row (ssize_t r, const EST_TMatrix< T > &from, ssize_t from_r, ssize_t from_offset=0, ptrdiff_t offset=0, int num=-1)
 
void set_column (ssize_t n, const T *buf, ptrdiff_t offset=0, int num=-1)
 
void set_column (ssize_t n, const EST_TVector< T > &t, ptrdiff_t offset=0, int num=-1)
 
void set_column (ssize_t c, const EST_TMatrix< T > &from, ssize_t from_c, ssize_t from_offset=0, ptrdiff_t offset=0, int num=-1)
 
void set_memory (T *buffer, ptrdiff_t offset, ssize_t rows, ssize_t columns, int free_when_destroyed=0)
 
- Public Member Functions inherited from EST_TVector< T >
INLINE ssize_t vcell_pos (ssize_t c, ssize_t cs) const
 The memory access rule, in one place for easy reference. More...
 
INLINE ssize_t vcell_pos (ssize_t c) const
 
INLINE ssize_t vcell_pos_1 (ssize_t c) const
 
INLINE const T & fast_a_v (int c) const
 quick method for returning (x[n]) More...
 
INLINE T & fast_a_v (int c)
 
INLINE const T & fast_a_1 (int c) const
 
INLINE T & fast_a_1 (int c)
 
void set_values (const T *data, int step, int start_c, int num_c)
 Get and set values from array. More...
 
void get_values (T *data, int step, int start_c, int num_c) const
 
void copy (const EST_TVector< T > &a)
 private copy function, called from all other copying functions. More...
 
void copy_data (const EST_TVector< T > &a)
 just copy data, no resizing, no size check. More...
 
void just_resize (int new_cols, T **old_vals)
 resize the memory and reset the bounds, but don't set values. More...
 
void default_vals ()
 sets data and length to default values (0 in both cases). More...
 
 EST_TVector ()
 default constructor More...
 
 EST_TVector (const EST_TVector< T > &v)
 copy constructor More...
 
 EST_TVector (ssize_t n)
 "size" constructor - make vector of size n. More...
 
 EST_TVector (int, T *memory, int offset=0, int free_when_destroyed=0)
 construct from memory supplied by caller More...
 
 ~EST_TVector ()
 destructor. More...
 
void resize (ssize_t n, int set=1)
 
const T * memory () const
 
T * memory ()
 
void set_memory (T *buffer, int offset, ssize_t columns, int free_when_destroyed=0)
 
EST_TVectoroperator= (const EST_TVector &s)
 assignment operator More...
 
void fill (const T &v)
 Fill entire array will value v. More...
 
void empty ()
 Fill vector with default value. More...
 
int operator== (const EST_TVector &v) const
 is true if vectors are equal size and all elements are equal. More...
 
int operator!= (const EST_TVector &v) const
 is true if vectors are not equal size or a single elements isn't equal. More...
 
void copy_section (T *dest, int offset=0, int num=-1) const
 Copy data in and out. Subclassed by SimpleVector for speed. More...
 
void set_section (const T *src, int offset=0, int num=-1)
 
void sub_vector (EST_TVector< T > &sv, int start_c=0, int len=-1)
 Create a sub vector. More...
 
void integrity () const
 
template<>
const EST_DMatrixdef_val
 
template<>
EST_DMatrixerror_return
 
template<>
const EST_DVectordef_val
 
template<>
EST_DVectorerror_return
 
template<>
const EST_FMatrixdef_val
 
template<>
EST_FMatrixerror_return
 
INLINE ssize_t num_columns () const
 number of items in vector. More...
 
INLINE ssize_t length () const
 number of items in vector. More...
 
INLINE ssize_t n () const
 number of items in vector. More...
 
INLINE const T & a_no_check (ssize_t n) const
 read-only const access operator: without bounds checking More...
 
INLINE T & a_no_check (ssize_t n)
 read/write non-const access operator: without bounds checking More...
 
INLINE const T & a_no_check_1 (ssize_t n) const
 read-only const access operator: without bounds checking More...
 
INLINE T & a_no_check_1 (ssize_t n)
 read/write non-const access operator: without bounds checking More...
 
const T & a_check (ssize_t n) const
 read-only const access operator: with bounds checking More...
 
T & a_check (ssize_t n)
 read/write non-const access operator: with bounds checking More...
 
const T & a (ssize_t n) const
 
T & a (ssize_t n)
 
const T & operator() (ssize_t n) const
 read-only const access operator: return reference to nth member More...
 
T & operator[] (ssize_t n)
 read/write non const access operator: return reference to nth member More...
 

Protected Member Functions

INLINE ssize_t mcell_pos (ssize_t r, ssize_t c, ssize_t rs, ssize_t cs) const
 
INLINE ssize_t mcell_pos (ssize_t r, ssize_t c) const
 
INLINE ssize_t mcell_pos_1 (ssize_t r, ssize_t c) const
 
INLINE const T & fast_a_m (ssize_t r, ssize_t c) const
 quick method for returning x[m][n] More...
 
INLINE T & fast_a_m (ssize_t r, ssize_t c)
 
INLINE const T & fast_a_1 (ssize_t r, ssize_t c) const
 
INLINE T & fast_a_1 (ssize_t r, ssize_t c)
 
void set_values (const T *data, ssize_t r_step, ssize_t c_step, ssize_t start_r, ssize_t num_r, ssize_t start_c, ssize_t num_c)
 Get and set values from array. More...
 
void get_values (T *data, ssize_t r_step, ssize_t c_step, ssize_t start_r, ssize_t num_r, ssize_t start_c, ssize_t num_c) const
 
void copy (const EST_TMatrix< T > &a)
 private resize and copy function. More...
 
void copy_data (const EST_TMatrix< T > &a)
 just copy data, no resizing, no size check. More...
 
void just_resize (ssize_t new_rows, ssize_t new_cols, T **old_vals)
 resize the memory and reset the bounds, but don't set values. More...
 
void default_vals ()
 sets data and length to default values (0 in both cases). More...
 

Protected Attributes

ssize_t p_num_rows
 Visible shape. More...
 
ssize_t p_row_step
 How to access the memory. More...
 

Matrix file input / output

EST_read_status load (const class EST_String &filename)
 load Matrix from file - Not currently implemented. More...
 
EST_write_status save (const class EST_String &filename) const
 save Matrix to file filename More...
 
std::ostream & operator<< (std::ostream &st, const EST_TMatrix< T > &a)
 print matrix. More...
 

Additional Inherited Members

- Public Attributes inherited from EST_TVector< T >
T * p_memory
 
ssize_t p_num_columns
 Visible shape. More...
 
ssize_t p_offset
 How to access the memory. More...
 
ssize_t p_column_step
 
bool p_sub_matrix
 
- Static Public Attributes inherited from EST_TVector< T >
static const T * def_val = &def_val_item_ptr
 default value, used for filling matrix after resizing More...
 
static T * error_return = &error_return_item_ptr
 

Detailed Description

template<class T>
class EST_TMatrix< T >

Template Matrix class. This is an extension of the EST_TVector class to two dimensions.

See also
matrix_example
EST_TVector

Definition at line 89 of file EST_TMatrix.h.

Constructor & Destructor Documentation

template<class T >
EST_TMatrix< T >::EST_TMatrix ( )

default constructor

Definition at line 62 of file EST_TMatrix.cc.

template<class T>
EST_TMatrix< T >::EST_TMatrix ( const EST_TMatrix< T > &  m)

copy constructor

Definition at line 68 of file EST_TMatrix.cc.

template<class T>
EST_TMatrix< T >::EST_TMatrix ( ssize_t  rows,
ssize_t  cols 
)

"size" constructor

Definition at line 75 of file EST_TMatrix.cc.

template<class T>
EST_TMatrix< T >::EST_TMatrix ( ssize_t  rows,
ssize_t  cols,
T *  memory,
ptrdiff_t  offset = 0,
int  free_when_destroyed = 0 
)

construct from memory supplied by caller

Definition at line 82 of file EST_TMatrix.cc.

template<class T >
EST_TMatrix< T >::~EST_TMatrix ( )

EST_TMatrix.

Definition at line 90 of file EST_TMatrix.cc.

Member Function Documentation

template<class T>
INLINE ssize_t EST_TMatrix< T >::mcell_pos ( ssize_t  r,
ssize_t  c,
ssize_t  rs,
ssize_t  cs 
) const
inlineprotected

Definition at line 99 of file EST_TMatrix.h.

template<class T>
INLINE ssize_t EST_TMatrix< T >::mcell_pos ( ssize_t  r,
ssize_t  c 
) const
inlineprotected

Definition at line 104 of file EST_TMatrix.h.

template<class T>
INLINE ssize_t EST_TMatrix< T >::mcell_pos_1 ( ssize_t  r,
ssize_t  c 
) const
inlineprotected

Definition at line 111 of file EST_TMatrix.h.

template<class T>
INLINE const T& EST_TMatrix< T >::fast_a_m ( ssize_t  r,
ssize_t  c 
) const
inlineprotected

quick method for returning x[m][n]

Definition at line 119 of file EST_TMatrix.h.

template<class T>
INLINE T& EST_TMatrix< T >::fast_a_m ( ssize_t  r,
ssize_t  c 
)
inlineprotected

Definition at line 121 of file EST_TMatrix.h.

template<class T>
INLINE const T& EST_TMatrix< T >::fast_a_1 ( ssize_t  r,
ssize_t  c 
) const
inlineprotected

Definition at line 124 of file EST_TMatrix.h.

template<class T>
INLINE T& EST_TMatrix< T >::fast_a_1 ( ssize_t  r,
ssize_t  c 
)
inlineprotected

Definition at line 126 of file EST_TMatrix.h.

template<class T>
void EST_TMatrix< T >::set_values ( const T *  data,
ssize_t  r_step,
ssize_t  c_step,
ssize_t  start_r,
ssize_t  num_r,
ssize_t  start_c,
ssize_t  num_c 
)
protected

Get and set values from array.

Definition at line 129 of file EST_TMatrix.cc.

template<class T>
void EST_TMatrix< T >::get_values ( T *  data,
ssize_t  r_step,
ssize_t  c_step,
ssize_t  start_r,
ssize_t  num_r,
ssize_t  start_c,
ssize_t  num_c 
) const
protected

Definition at line 141 of file EST_TMatrix.cc.

template<class T>
void EST_TMatrix< T >::copy ( const EST_TMatrix< T > &  a)
protected

private resize and copy function.

Definition at line 153 of file EST_TMatrix.cc.

template<class T>
void EST_TMatrix< T >::copy_data ( const EST_TMatrix< T > &  a)
protected

just copy data, no resizing, no size check.

Definition at line 119 of file EST_TMatrix.cc.

template<class T>
void EST_TMatrix< T >::just_resize ( ssize_t  new_rows,
ssize_t  new_cols,
T **  old_vals 
)
protected

resize the memory and reset the bounds, but don't set values.

Definition at line 209 of file EST_TMatrix.cc.

template<class T >
void EST_TMatrix< T >::default_vals ( )
protected

sets data and length to default values (0 in both cases).

Definition at line 54 of file EST_TMatrix.cc.

template<class T>
ssize_t EST_TMatrix< T >::num_rows ( ) const
inline

return number of rows

Definition at line 177 of file EST_TMatrix.h.

template<class T>
ssize_t EST_TMatrix< T >::num_columns ( ) const
inline

return number of columns

Definition at line 179 of file EST_TMatrix.h.

template<class T>
INLINE const T& EST_TMatrix< T >::a_no_check ( ssize_t  row,
ssize_t  col 
) const
inline

const access with no bounds check, care recommend

Definition at line 182 of file EST_TMatrix.h.

template<class T>
INLINE T& EST_TMatrix< T >::a_no_check ( ssize_t  row,
ssize_t  col 
)
inline

access with no bounds check, care recommend

Definition at line 185 of file EST_TMatrix.h.

template<class T>
INLINE const T& EST_TMatrix< T >::a_no_check_1 ( ssize_t  row,
ssize_t  col 
) const
inline

Definition at line 188 of file EST_TMatrix.h.

template<class T>
INLINE T& EST_TMatrix< T >::a_no_check_1 ( ssize_t  row,
ssize_t  col 
)
inline

Definition at line 189 of file EST_TMatrix.h.

template<class T >
const T & EST_TMatrix< T >::a_check ( ssize_t  row,
ssize_t  col 
) const

const element access function

Definition at line 113 of file EST_TMatrix.cc.

template<class T >
T & EST_TMatrix< T >::a_check ( ssize_t  row,
ssize_t  col 
)

non-const element access function

Definition at line 100 of file EST_TMatrix.cc.

template<class T>
const T& EST_TMatrix< T >::a ( ssize_t  row,
ssize_t  col 
) const
inline

Definition at line 196 of file EST_TMatrix.h.

template<class T>
T& EST_TMatrix< T >::a ( ssize_t  row,
ssize_t  col 
)
inline

Definition at line 197 of file EST_TMatrix.h.

template<class T>
const T& EST_TMatrix< T >::operator() ( ssize_t  row,
ssize_t  col 
) const
inline

const element access operator

Definition at line 200 of file EST_TMatrix.h.

template<class T>
T& EST_TMatrix< T >::operator() ( ssize_t  row,
ssize_t  col 
)
inline

non-const element access operator

Definition at line 202 of file EST_TMatrix.h.

template<class T >
bool EST_TMatrix< T >::have_rows_before ( ssize_t  n) const

Definition at line 302 of file EST_TMatrix.cc.

template<class T >
bool EST_TMatrix< T >::have_columns_before ( ssize_t  n) const

Definition at line 308 of file EST_TMatrix.cc.

template<class T >
void EST_TMatrix< T >::resize ( ssize_t  rows,
ssize_t  cols,
ssize_t  set = 1 
)

resize matrix. If set=1, then the current values in the matrix are preserved up to the new size n. If the new size exceeds the old size, the rest of the matrix is filled with the def_val

Definition at line 250 of file EST_TMatrix.cc.

template<class T>
void EST_TMatrix< T >::fill ( const T &  v)

fill matrix with value v

Definition at line 314 of file EST_TMatrix.cc.

template<class T>
void EST_TMatrix< T >::fill ( )
inline

Definition at line 218 of file EST_TMatrix.h.

template<class T >
EST_TMatrix< T > & EST_TMatrix< T >::operator= ( const EST_TMatrix< T > &  s)

assignment operator

Definition at line 160 of file EST_TMatrix.cc.

template<class T >
EST_TMatrix< T > & EST_TMatrix< T >::add_rows ( const EST_TMatrix< T > &  s)

The two versions of what might have been operator +=.

Definition at line 167 of file EST_TMatrix.cc.

template<class T >
EST_TMatrix< T > & EST_TMatrix< T >::add_columns ( const EST_TMatrix< T > &  s)

Definition at line 188 of file EST_TMatrix.cc.

template<class T>
void EST_TMatrix< T >::row ( EST_TVector< T > &  rv,
ssize_t  r,
ssize_t  start_c = 0,
int  len = -1 
)

Make the vector rv a window onto row r

Definition at line 534 of file EST_TMatrix.cc.

template<class T>
void EST_TMatrix< T >::column ( EST_TVector< T > &  cv,
ssize_t  c,
ssize_t  start_r = 0,
int  len = -1 
)

Make the vector cv a window onto column c

Definition at line 556 of file EST_TMatrix.cc.

template<class T>
void EST_TMatrix< T >::sub_matrix ( EST_TMatrix< T > &  sm,
ssize_t  r = 0,
ptrdiff_t  numr = EST_ALL,
ssize_t  c = 0,
ptrdiff_t  numc = EST_ALL 
)

Make the matrix sm a window into this matrix.

Definition at line 578 of file EST_TMatrix.cc.

template<class T>
void EST_TMatrix< T >::copy_row ( ssize_t  r,
T *  buf,
ptrdiff_t  offset = 0,
int  num = -1 
) const

Copy row r of matrix to buf. buf should be pre-malloced to the correct size.

Definition at line 381 of file EST_TMatrix.cc.

template<class T>
void EST_TMatrix< T >::copy_row ( ssize_t  r,
EST_TVector< T > &  t,
ptrdiff_t  offset = 0,
int  num = -1 
) const

Copy row r of matrix to buf. buf should be pre-malloced to the correct size.

Definition at line 399 of file EST_TMatrix.cc.

template<class T>
void EST_TMatrix< T >::copy_column ( ssize_t  c,
T *  buf,
ptrdiff_t  offset = 0,
int  num = -1 
) const

Copy column c of matrix to buf. buf should be pre-malloced to the correct size.

Definition at line 420 of file EST_TMatrix.cc.

template<class T>
void EST_TMatrix< T >::copy_column ( ssize_t  c,
EST_TVector< T > &  t,
ptrdiff_t  offset = 0,
int  num = -1 
) const

Copy column c of matrix to buf. buf should be pre-malloced to the correct size.

Definition at line 442 of file EST_TMatrix.cc.

template<class T>
void EST_TMatrix< T >::set_row ( ssize_t  n,
const T *  buf,
ptrdiff_t  offset = 0,
int  num = -1 
)

Copy buf into row n of matrix.

Definition at line 466 of file EST_TMatrix.cc.

template<class T>
void EST_TMatrix< T >::set_row ( ssize_t  n,
const EST_TVector< T > &  t,
ptrdiff_t  offset = 0,
int  num = -1 
)
inline

Definition at line 275 of file EST_TMatrix.h.

template<class T>
void EST_TMatrix< T >::set_row ( ssize_t  r,
const EST_TMatrix< T > &  from,
ssize_t  from_r,
ssize_t  from_offset = 0,
ptrdiff_t  offset = 0,
int  num = -1 
)

Definition at line 490 of file EST_TMatrix.cc.

template<class T>
void EST_TMatrix< T >::set_column ( ssize_t  n,
const T *  buf,
ptrdiff_t  offset = 0,
int  num = -1 
)

Copy buf into column n of matrix.

Definition at line 478 of file EST_TMatrix.cc.

template<class T>
void EST_TMatrix< T >::set_column ( ssize_t  n,
const EST_TVector< T > &  t,
ptrdiff_t  offset = 0,
int  num = -1 
)
inline

Definition at line 287 of file EST_TMatrix.h.

template<class T>
void EST_TMatrix< T >::set_column ( ssize_t  c,
const EST_TMatrix< T > &  from,
ssize_t  from_c,
ssize_t  from_offset = 0,
ptrdiff_t  offset = 0,
int  num = -1 
)

Definition at line 512 of file EST_TMatrix.cc.

template<class T>
void EST_TMatrix< T >::set_memory ( T *  buffer,
ptrdiff_t  offset,
ssize_t  rows,
ssize_t  columns,
int  free_when_destroyed = 0 
)

For when you absolutely have to have access to the memory.

Definition at line 371 of file EST_TMatrix.cc.

template<class T>
EST_read_status EST_TMatrix< T >::load ( const class EST_String filename)

load Matrix from file - Not currently implemented.

Definition at line 360 of file EST_TMatrix.cc.

template<class T>
EST_write_status EST_TMatrix< T >::save ( const class EST_String filename) const

save Matrix to file filename

Definition at line 324 of file EST_TMatrix.cc.

Friends And Related Function Documentation

template<class T>
std::ostream& operator<< ( std::ostream &  st,
const EST_TMatrix< T > &  a 
)
friend

print matrix.

Definition at line 310 of file EST_TMatrix.h.

Member Data Documentation

template<class T>
ssize_t EST_TMatrix< T >::p_num_rows
protected

Visible shape.

Definition at line 94 of file EST_TMatrix.h.

template<class T>
ssize_t EST_TMatrix< T >::p_row_step
protected

How to access the memory.

Definition at line 97 of file EST_TMatrix.h.


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