48#include "EST_rw_status.h"
49#include "EST_TVector.h"
50#include "instantiate/EST_TMatrixI.h"
53#ifndef TMATRIX_BOUNDS_CHECKING
54# define TMATRIX_BOUNDS_CHECKING 0
57#if TMATRIX_BOUNDS_CHECKING
58#define A_CHECK a_check
60#define A_CHECK a_no_check
68#if defined(__GNUC__) && 0
69# define mx_move_pointer(P, TY, STEP, N) \
71 ((void *) (((char (*) [sizeof(TY)*STEP])P) + N) ) \
73# define fast_a_m_gcc(R,C) \
74 ( * mx_move_pointer(mx_move_pointer(p_memory,T,p_column_step,C),T,p_row_step,R))
75# define fast_a_m_x(R,C) (fast_a_m_gcc(R,C))
77# define fast_a_m_x(R,C) (fast_a_m(R,C))
101 INLINE
unsigned int mcell_pos(
int r,
int c,
102 int rs,
int cs)
const
103 {
return (rs==1?r:(r*rs)) + (cs==1?c:(c*cs));}
106 INLINE
unsigned int mcell_pos(
int r,
int c)
const
109 return mcell_pos(r, c,
110 this->p_row_step, this->p_column_step);
113 INLINE
unsigned int mcell_pos_1(
int r,
int c)
const
122 {
return this->
p_memory[mcell_pos(r,c)]; }
124 {
return this->
p_memory[mcell_pos(r,c)]; }
126 INLINE
const T &fast_a_1(
int r,
int c)
const
127 {
return this->
p_memory[mcell_pos_1(r,c)]; }
128 INLINE T &fast_a_1(
int r,
int c)
129 {
return this->
p_memory[mcell_pos_1(r,c)]; }
134 int r_step,
int c_step,
135 int start_r,
int num_r,
136 int start_c,
int num_c
138 void get_values(T *data,
139 int r_step,
int c_step,
140 int start_r,
int num_r,
141 int start_c,
int num_c
150 void just_resize(
int new_rows,
int new_cols, T** old_vals);
167 T *
memory,
int offset=0,
int free_when_destroyed=0);
185 {
return fast_a_m_x(
row,col); }
188 {
return fast_a_m_x(
row,col); }
190 INLINE
const T &a_no_check_1(
int row,
int col)
const {
return fast_a_1(
row,col); }
191 INLINE T &a_no_check_1(
int row,
int col) {
return fast_a_1(
row,col); }
198 const T &a(
int row,
int col)
const {
return A_CHECK(
row,col); }
199 T &a(
int row,
int col) {
return A_CHECK(
row,col); }
208 bool have_rows_before(
int n)
const;
209 bool have_columns_before(
int n)
const;
216 void resize(
int rows,
int cols,
int set=1);
219 void fill(
const T &v);
220 void fill() { fill(*this->
def_val); }
243 int r=0,
int numr=EST_ALL,
244 int c=0,
int numc=EST_ALL);
254 void copy_row(
int r, T *buf,
int offset=0,
int num=-1)
const;
265 void copy_column(
int c, T *buf,
int offset=0,
int num=-1)
const;
275 void set_row(
int n,
const T *buf,
int offset=0,
int num=-1);
282 int offset=0,
int num=-1);
287 void set_column(
int n,
const T *buf,
int offset=0,
int num=-1);
294 int offset=0,
int num=-1);
298 void set_memory(T *buffer,
int offset,
int rows,
int columns,
299 int free_when_destroyed=0);
315 for (i = 0; i < a.
num_rows(); ++i) {
EST_TMatrix & operator=(const EST_TMatrix &s)
assignment operator
void copy_row(int r, T *buf, int offset=0, int num=-1) const
friend ostream & operator<<(ostream &st, const EST_TMatrix< T > &a)
print matrix.
int num_columns() const
return number of columns
EST_read_status load(const class EST_String &filename)
load Matrix from file - Not currently implemented.
unsigned int p_num_rows
Visible shape.
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.
INLINE const T & a_no_check(int row, int col) const
const access with no bounds check, care recommend
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.
void default_vals()
sets data and length to default values (0 in both cases).
void set_row(int n, const T *buf, int offset=0, int num=-1)
INLINE T & a_no_check(int row, int col)
access with no bounds check, care recommend
int num_rows() const
return number of rows
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 copy_data(const EST_TMatrix< T > &a)
just copy data, no resizing, no size check.
void set_memory(T *buffer, int offset, int rows, int columns, int free_when_destroyed=0)
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}.
unsigned int p_row_step
How to access the memory.
const T & a_check(int row, int col) const
const element access function
const T & operator()(int row, int col) const
const element access operator
~EST_TMatrix()
EST_TMatrix.
EST_TMatrix()
default constructor
void copy(const EST_TMatrix< T > &a)
private resize and copy function.
void set_column(int n, const T *buf, int offset=0, int num=-1)
void resize(int rows, int cols, int set=1)
EST_TMatrix & add_rows(const EST_TMatrix &s)
The two versions of what might have been operator +=.
EST_write_status save(const class EST_String &filename) const
save Matrix to file {\tt filename}
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 copy_column(int c, T *buf, int offset=0, int num=-1) const
INLINE const T & fast_a_m(int r, int c) const
quick method for returning {\tt x[m][n]}
unsigned int p_num_columns
Visible shape.
INLINE int n() const
number of items in vector.
static const T * def_val
default value, used for filling matrix after resizing