83 T *
memory, ptrdiff_t offset,
int free_when_destroyed)
86 set_memory(memory, offset, rows, cols, free_when_destroyed);
135 for(
ssize_t r=start_r, i=0, rp=0; i< num_r; i++, r++, rp+=r_step)
136 for(
ssize_t c=start_c, j=0, cp=0; j< num_c; j++, c++, cp+=c_step)
147 for(
ssize_t r=start_r, i=0, rp=0; i< num_r; i++, r++, rp+=r_step)
148 for(
ssize_t c=start_c, j=0, cp=0; j< num_c; j++, c++, cp+=c_step)
170 EST_error(
"Can't add rows with different number of columns (%d vs %d)",
179 for(
int i=old_num_rows, i1=0; i<
num_rows(); i++, i1++)
191 EST_error(
"Can't add columns with differnet number of rows (%d vs %d)",
200 for(
int i=old_num_columns, i1=0; i<
num_columns(); i++, i1++)
218 EST_error(
"Attempt to resize Sub-Matrix");
220 if (new_cols < 0 || new_rows < 0)
221 EST_error(
"Attempt to resize matrix to negative size: %d x %d",
226 new_m =
new T[new_rows*new_cols];
230 if (old_vals !=
NULL)
257 ptrdiff_t old_offset = this->
p_offset;
272 if (old_vals !=
NULL)
278 old_row_step, old_column_step,
288 for(i=0; i<copy_r; i++)
289 for(j=copy_c; j<new_cols; j++)
292 for(i=copy_r; i<new_rows; i++)
293 for(j=0; j<new_cols; j++)
298 delete [] (old_vals-old_offset);
328 if (filename ==
"-" || filename ==
"")
331 outf =
new std::ofstream(filename);
342 <<
"r="<<((
int)mx_move_pointer(this->
p_memory, T, p_row_step, i))<<
"," 344 <<((
int)(&fast_a_m_gcc(i,j)))
352 if (outf != &std::cout)
365 EST_error(
"Matrix loading not implemented yet.");
373 int free_when_destroyed)
382 ptrdiff_t offset,
int num)
const 394 for (
ssize_t j = offset; j < to; j++)
400 ptrdiff_t offset,
int num)
const 414 for (
ssize_t j = offset; j < to; j++)
421 ptrdiff_t offset,
int num)
const 436 for (
ssize_t i = offset; i < to; i++)
443 ptrdiff_t offset,
int num)
const 460 for (
ssize_t i = offset; i < to; i++)
473 for(
ssize_t j=offset; j<to; j++)
485 for(
ssize_t i=offset; i<to; i++)
492 ptrdiff_t offset,
int num)
507 for(
int j=offset; j<to; j++)
514 ptrdiff_t offset,
int num)
516 int to = num>=0?offset+num:
num_rows();
529 for(
int i=offset; i<to; 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.
EST_DMatrix * error_return
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 +=.
ssize_t num_columns() const
return number of columns
bool EST_matrix_bounds_check(int r, int c, int num_rows, int num_columns, bool set)
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)
ssize_t num_rows() const
return number of rows
const T & a(ssize_t row, ssize_t col) const
void default_vals()
sets data and length to default values (0 in both cases).
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.
void resize(ssize_t n, int set=1)
EST_write_status save(const class EST_String &filename) const
save Matrix to file filename
The file was written successfully.
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.
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
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)
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 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.
void set_memory(T *buffer, int offset, ssize_t columns, int free_when_destroyed=0)
ssize_t p_offset
How to access the memory.
ssize_t p_row_step
How to access the memory.