In file ../include/EST_TMatrix.h:

## template<class T> class EST_TMatrix

> Template Matrix class.

## Inheritance:

### Public Methods

  | 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
  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
  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& | operator () (int row, int col) const const element access operator
  T& | operator () (int row, int col) non-const element access operator
  void | resize (int rows, int cols, int set=1) resize matrix.
  void | fill (const T &v) fill matrix with value v
  EST_TMatrix& | operator= (const EST_TMatrix &s) assignment operator
  EST_TMatrix& | add_rows (const EST_TMatrix &s) The two versions of what might have been operator +=
  | Sub-Matrix/Vector Extraction
  void | row (EST_TVector<T> &rv, int r, int start_c=0, int len=-1) Make the vector `rv` a window onto row `r`
  void | column (EST_TVector<T> &cv, int c, int start_r=0, int len=-1) Make the vector `cv` a window onto column `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 `sm` a window into this matrix
  | Copy in and out
  void | copy_row (int r, T* buf, int offset=0, int num=-1) const Copy row `r` of matrix to `buf`.
  void | 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>.
  void | copy_column (int c, T* buf, int offset=0, int num=-1) const Copy column `c` of matrix to `buf`.
  void | 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>.
  void | set_row (int n, const T* buf, int offset=0, int num=-1) Copy buf into row `n` of matrix.
  void | set_column (int n, const T* buf, int offset=0, int num=-1) Copy buf into column `n` of matrix.
  void | 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
  | 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 `filename`

### Protected Fields

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

### Protected Methods

  INLINE const T& | fast_a_m (int r, int c) const quick method for returning `x[m][n]`
  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 | 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)

### Inherited from EST_TVector:

### Public Fields

T* p_memory
unsigned int p_num_columns
unsigned int p_offset
static const T* def_val
static T* error_return

### Public Methods

INLINE unsigned int vcell_pos(unsigned int c, unsigned int cs) const
INLINE const T& fast_a_v(int c) const
const T* memory() const
void empty()
EST_write_status save(const EST_String &filename)
int operator == (const EST_TVector &v) const
int operator != (const EST_TVector &v) const
void copy_section(T* dest, int offset=0, int num=-1) const
void sub_vector(EST_TVector<T> &sv, int start_c=0, int len=-1)
void integrity() const

## Documentation

> Template Matrix class.

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

`unsigned int p_num_rows`
  Visible shape

`unsigned int p_row_step`
  How to access the memory

`INLINE const T& fast_a_m(int r, int c) const`
  quick method for returning `x[m][n]`

`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 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)

`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

  `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& operator () (int row, int col) const`
    const element access operator

  `T& operator () (int row, int col)`
    non-const element access operator

`void resize(int rows, int cols, int set=1)`
  resize matrix. If `set=1`, then the current values in the matirx 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`

`void fill(const T &v)`
  fill matrix with value v

`EST_TMatrix& operator=(const EST_TMatrix &s)`
  assignment operator

`EST_TMatrix& add_rows(const EST_TMatrix &s)`
  The two versions of what might have been operator +=

`Sub-Matrix/Vector Extraction`
  All of these return matrecies 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 `rv` a window onto row `r`

  `void column(EST_TVector<T> &cv, int c, int start_r=0, int len=-1)`
    Make the vector `cv` a window onto column `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 `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`
    Copy row `r` of matrix to `buf`. `buf` should be pre-malloced to the correct size.

  `void 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.

  `void copy_column(int c, T* buf, int offset=0, int num=-1) const`
    Copy column `c` of matrix to `buf`. `buf` should be pre-malloced to the correct size.

  `void 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.

  `void set_row(int n, const T* buf, int offset=0, int num=-1)`
    Copy buf into row `n` of matrix.

  `void set_column(int n, const T* buf, int offset=0, int num=-1)`
    Copy buf into column `n` of matrix.

  `void 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

`io`
  Matrix file io.
  Friends:
    ostream& operator << (ostream &st,const EST_TMatrix<T> &a)

  `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 `filename`

This class has no child classes.

See Also:
  matrix_example
  EST_TVector

Alphabetic index HTML hierarchy of classes or Java

This page is part of the Edinburgh Speech Tools Library documentation
Copyright University of Edinburgh 1997
Contact: speech_tools@cstr.ed.ac.uk