52 #ifndef TMATRIX_BOUNDS_CHECKING 53 # define TMATRIX_BOUNDS_CHECKING 0 56 #if TMATRIX_BOUNDS_CHECKING 57 #define A_CHECK a_check 59 #define A_CHECK a_no_check 67 #if defined(__GNUC__) && 0 68 # define mx_move_pointer(P, TY, STEP, N) \ 70 ((void *) (((char (*) [sizeof(TY)*STEP])P) + N) ) \ 72 # define fast_a_m_gcc(R,C) \ 73 ( * mx_move_pointer(mx_move_pointer(p_memory,T,p_column_step,C),T,p_row_step,R)) 74 # define fast_a_m_x(R,C) (fast_a_m_gcc(R,C)) 76 # define fast_a_m_x(R,C) (fast_a_m(R,C)) 101 {
return (rs==1?r:(r*rs)) + (cs==1?c:(c*cs));}
165 T *
memory, ptrdiff_t offset=0,
int free_when_destroyed=0);
217 void fill(
const T &v);
252 void copy_row(
ssize_t r, T *buf, ptrdiff_t offset=0,
int num=-1)
const;
273 void set_row(
ssize_t n,
const T *buf, ptrdiff_t offset=0,
int num=-1);
280 ptrdiff_t offset=0,
int num=-1);
292 ptrdiff_t offset=0,
int num=-1);
297 int free_when_destroyed=0);
310 friend std::ostream& operator << (std::ostream &st,const EST_TMatrix<T> &
a)
312 for (i = 0; i < a.
num_rows(); ++i) {
void set_column(ssize_t n, const T *buf, ptrdiff_t offset=0, int num=-1)
bool have_rows_before(ssize_t n) const
bool have_columns_before(ssize_t n) const
ssize_t p_num_columns
Visible shape.
Template Matrix class. This is an extension of the EST_TVector class to two dimensions.
void copy_column(ssize_t c, T *buf, ptrdiff_t offset=0, int num=-1) const
EST_TMatrix & add_rows(const EST_TMatrix &s)
The two versions of what might have been operator +=.
INLINE ssize_t mcell_pos(ssize_t r, ssize_t c, ssize_t rs, ssize_t cs) const
ssize_t num_columns() const
return number of columns
void set_row(ssize_t n, const T *buf, ptrdiff_t offset=0, int num=-1)
INLINE const T & fast_a_m(ssize_t r, ssize_t c) const
quick method for returning x[m][n]
ssize_t p_num_rows
Visible shape.
EST_TMatrix()
default constructor
void copy(const EST_TMatrix< T > &a)
private resize and copy function.
EST_TMatrix & add_columns(const EST_TMatrix &s)
INLINE T & a_no_check(ssize_t row, ssize_t col)
access with no bounds check, care recommend
ssize_t num_rows() const
return number of rows
const T & a(ssize_t row, ssize_t col) const
INLINE const T & a_no_check_1(ssize_t row, ssize_t col) const
const EST_DMatrix * def_val
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
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.
void copy_data(const EST_TMatrix< T > &a)
just copy data, no resizing, no size check.
INLINE T & fast_a_m(ssize_t r, ssize_t c)
EST_write_status save(const class EST_String &filename) const
save Matrix to file filename
INLINE T & fast_a_1(ssize_t r, ssize_t c)
void default_vals()
sets data and length to default values (0 in both cases).
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.
EST_read_status load(const class EST_String &filename)
load Matrix from file - Not currently implemented.
~EST_TMatrix()
EST_TMatrix.
const T & operator()(ssize_t row, ssize_t col) const
const element access operator
INLINE T & a_no_check_1(ssize_t row, ssize_t col)
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
void copy_row(ssize_t r, T *buf, ptrdiff_t offset=0, int num=-1) const
EST_TMatrix & operator=(const EST_TMatrix &s)
assignment operator
void set_row(ssize_t n, const EST_TVector< T > &t, ptrdiff_t offset=0, int num=-1)
INLINE ssize_t mcell_pos_1(ssize_t r, ssize_t c) const
void set_column(ssize_t n, const EST_TVector< T > &t, ptrdiff_t offset=0, int num=-1)
const T & a_check(ssize_t row, ssize_t col) const
const element access function
void set_memory(T *buffer, ptrdiff_t offset, ssize_t rows, ssize_t columns, int free_when_destroyed=0)
INLINE ssize_t mcell_pos(ssize_t r, ssize_t c) const
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
T & a(ssize_t row, ssize_t col)
void resize(ssize_t rows, ssize_t cols, ssize_t set=1)
INLINE const T & a_no_check(ssize_t row, ssize_t col) const
const access with no bounds check, care recommend
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.
INLINE ssize_t n() const
number of items in vector.
ssize_t p_row_step
How to access the memory.
INLINE const T & fast_a_1(ssize_t r, ssize_t c) const