Edinburgh Speech Tools 2.4-release
 
Loading...
Searching...
No Matches
EST_TMatrix< T > Class Template Reference

#include <include/EST_TMatrix.h>

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

Public Member Functions

 EST_TMatrix ()
 default constructor
 
 EST_TMatrix (const EST_TMatrix< T > &m)
 copy constructor
 
 EST_TMatrix (int rows, int cols)
 "size" constructor
 
 EST_TMatrix (int rows, int cols, T *memory, int offset=0, int free_when_destroyed=0)
 construct from memory supplied by caller
 
 ~EST_TMatrix ()
 EST_TMatrix.
 
access

Basic access methods for matrices.

int num_rows () const
 return number of rows
 
int num_columns () const
 return number of columns
 
INLINE const T & a_no_check (int row, int col) const
 const access with no bounds check, care recommend
 
INLINE T & a_no_check (int row, int col)
 access with no bounds check, care recommend
 
INLINE const T & a_no_check_1 (int row, int col) const
 
INLINE T & a_no_check_1 (int row, int col)
 
const T & a_check (int row, int col) const
 const element access function
 
T & a_check (int row, int col)
 non-const element access function
 
const T & a (int row, int col) const
 
T & a (int row, int col)
 
const T & operator() (int row, int col) const
 const element access operator
 
T & operator() (int row, int col)
 non-const element access operator
 
bool have_rows_before (int n) const
 
bool have_columns_before (int n) const
 
void resize (int rows, int cols, int set=1)
 
void fill (const T &v)
 fill matrix with value v
 
void fill ()
 
EST_TMatrixoperator= (const EST_TMatrix &s)
 assignment operator
 
EST_TMatrixadd_rows (const EST_TMatrix &s)
 The two versions of what might have been operator +=.
 
EST_TMatrixadd_columns (const EST_TMatrix &s)
 
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, int r, int start_c=0, int len=-1)
 Make the vector {\tt rv} a window onto row {\tt r}.
 
void column (EST_TVector< T > &cv, int c, int start_r=0, int len=-1)
 Make the vector {\tt cv} a window onto column {\tt c}.
 
void sub_matrix (EST_TMatrix< T > &sm, int r=0, int numr=EST_ALL, int c=0, int numc=EST_ALL)
 Make the matrix {\tt sm} a window into this matrix.
 
Copy in and out

Copy data between buffers and the matrix.

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

Protected Member Functions

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

Protected Attributes

unsigned int p_num_rows
 Visible shape.
 
unsigned int p_row_step
 How to access the memory.
 

io

Matrix file io.

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

Additional Inherited Members

- Public Attributes inherited from EST_TVector< T >
T * p_memory
 
unsigned int p_num_columns
 Visible shape.
 
unsigned int p_offset
 How to access the memory.
 
unsigned int 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
 
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 91 of file EST_TMatrix.h.

Constructor & Destructor Documentation

◆ EST_TMatrix() [1/4]

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

default constructor

Definition at line 62 of file EST_TMatrix.cc.

◆ EST_TMatrix() [2/4]

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

copy constructor

Definition at line 68 of file EST_TMatrix.cc.

◆ EST_TMatrix() [3/4]

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

"size" constructor

Definition at line 75 of file EST_TMatrix.cc.

◆ EST_TMatrix() [4/4]

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

construct from memory supplied by caller

Definition at line 82 of file EST_TMatrix.cc.

◆ ~EST_TMatrix()

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

EST_TMatrix.

Definition at line 90 of file EST_TMatrix.cc.

Member Function Documentation

◆ mcell_pos() [1/2]

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

Definition at line 101 of file EST_TMatrix.h.

◆ mcell_pos() [2/2]

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

Definition at line 106 of file EST_TMatrix.h.

◆ mcell_pos_1()

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

Definition at line 113 of file EST_TMatrix.h.

◆ fast_a_m() [1/2]

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

quick method for returning {\tt x[m][n]}

Definition at line 121 of file EST_TMatrix.h.

◆ fast_a_m() [2/2]

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

Definition at line 123 of file EST_TMatrix.h.

◆ fast_a_1() [1/2]

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

Definition at line 126 of file EST_TMatrix.h.

◆ fast_a_1() [2/2]

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

Definition at line 128 of file EST_TMatrix.h.

◆ set_values()

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

Get and set values from array.

Definition at line 129 of file EST_TMatrix.cc.

◆ get_values()

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

Definition at line 141 of file EST_TMatrix.cc.

◆ copy()

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.

◆ copy_data()

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.

◆ just_resize()

template<class T >
void EST_TMatrix< T >::just_resize ( int new_rows,
int 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.

◆ default_vals()

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.

◆ num_rows()

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

return number of rows

Definition at line 179 of file EST_TMatrix.h.

◆ num_columns()

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

return number of columns

Definition at line 181 of file EST_TMatrix.h.

◆ a_no_check() [1/2]

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

const access with no bounds check, care recommend

Definition at line 184 of file EST_TMatrix.h.

◆ a_no_check() [2/2]

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

access with no bounds check, care recommend

Definition at line 187 of file EST_TMatrix.h.

◆ a_no_check_1() [1/2]

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

Definition at line 190 of file EST_TMatrix.h.

◆ a_no_check_1() [2/2]

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

Definition at line 191 of file EST_TMatrix.h.

◆ a_check() [1/2]

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

const element access function

Definition at line 113 of file EST_TMatrix.cc.

◆ a_check() [2/2]

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

non-const element access function

Definition at line 100 of file EST_TMatrix.cc.

◆ a() [1/2]

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

Definition at line 198 of file EST_TMatrix.h.

◆ a() [2/2]

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

Definition at line 199 of file EST_TMatrix.h.

◆ operator()() [1/2]

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

const element access operator

Definition at line 202 of file EST_TMatrix.h.

◆ operator()() [2/2]

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

non-const element access operator

Definition at line 204 of file EST_TMatrix.h.

◆ have_rows_before()

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

Definition at line 302 of file EST_TMatrix.cc.

◆ have_columns_before()

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

Definition at line 308 of file EST_TMatrix.cc.

◆ resize()

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

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

Definition at line 250 of file EST_TMatrix.cc.

◆ fill() [1/2]

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.

◆ fill() [2/2]

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

Definition at line 220 of file EST_TMatrix.h.

◆ operator=()

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.

◆ add_rows()

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.

◆ add_columns()

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.

◆ row()

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

Make the vector {\tt rv} a window onto row {\tt r}.

Definition at line 534 of file EST_TMatrix.cc.

◆ column()

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

Make the vector {\tt cv} a window onto column {\tt c}.

Definition at line 556 of file EST_TMatrix.cc.

◆ sub_matrix()

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

Make the matrix {\tt sm} a window into this matrix.

Definition at line 578 of file EST_TMatrix.cc.

◆ copy_row() [1/2]

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

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

Definition at line 381 of file EST_TMatrix.cc.

◆ copy_row() [2/2]

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

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

Definition at line 399 of file EST_TMatrix.cc.

◆ copy_column() [1/2]

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

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

Definition at line 420 of file EST_TMatrix.cc.

◆ copy_column() [2/2]

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

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

Definition at line 442 of file EST_TMatrix.cc.

◆ set_row() [1/3]

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

Copy buf into row {\tt n} of matrix.

Definition at line 466 of file EST_TMatrix.cc.

◆ set_row() [2/3]

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

Definition at line 277 of file EST_TMatrix.h.

◆ set_row() [3/3]

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

Definition at line 490 of file EST_TMatrix.cc.

◆ set_column() [1/3]

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

Copy buf into column {\tt n} of matrix.

Definition at line 478 of file EST_TMatrix.cc.

◆ set_column() [2/3]

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

Definition at line 289 of file EST_TMatrix.h.

◆ set_column() [3/3]

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

Definition at line 512 of file EST_TMatrix.cc.

◆ set_memory()

template<class T >
void EST_TMatrix< T >::set_memory ( T * buffer,
int offset,
int rows,
int 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.

◆ load()

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.

◆ save()

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

save Matrix to file {\tt filename}

Definition at line 324 of file EST_TMatrix.cc.

Friends And Related Symbol Documentation

◆ operator<<

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

print matrix.

Definition at line 313 of file EST_TMatrix.h.

Member Data Documentation

◆ p_num_rows

template<class T >
unsigned int EST_TMatrix< T >::p_num_rows
protected

Visible shape.

Definition at line 96 of file EST_TMatrix.h.

◆ p_row_step

template<class T >
unsigned int EST_TMatrix< T >::p_row_step
protected

How to access the memory.

Definition at line 99 of file EST_TMatrix.h.


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