40 #ifndef __EST_TVector_H__
41 #define __EST_TVector_H__
46 #include "EST_rw_status.h"
48 #include "instantiate/EST_TVectorI.h"
58 extern const int EST_CURRENT;
59 extern const int EST_ALL;
62 #ifndef TVECTOR_BOUNDS_CHECKING
63 # define TVECTOR_BOUNDS_CHECKING 0
66 #if TVECTOR_BOUNDS_CHECKING
67 #define A_CHECK a_check
69 #define A_CHECK a_no_check
77 #if defined(__GNUC__) && 0
78 # define fast_a_v_gcc(C) \
80 (((char (*) [sizeof(T)*p_column_step])p_memory) + (C))\
82 # define fast_a_v_x(C) (fast_a_v_gcc(C))
84 # define fast_a_v_x(C) (fast_a_v(C))
159 unsigned int p_column_step;
166 unsigned int cs)
const
167 {
return cs==1?c:c*cs;}
169 INLINE
unsigned int vcell_pos(
unsigned int c)
const
175 INLINE
unsigned int vcell_pos_1(
unsigned int c)
const
181 INLINE
const T &
fast_a_v(
int c)
const {
return p_memory[vcell_pos(c)]; }
183 INLINE T &fast_a_v(
int c) {
return p_memory[vcell_pos(c)]; }
185 INLINE
const T &fast_a_1(
int c)
const {
return p_memory[vcell_pos_1(c)]; }
186 INLINE T &fast_a_1(
int c) {
return p_memory[vcell_pos_1(c)]; }
189 void set_values(
const T *data,
int step,
int start_c,
int num_c);
190 void get_values(T *data,
int step,
int start_c,
int num_c)
const;
198 void just_resize(
int new_cols, T** old_vals);
215 T *memory,
int offset=0,
int free_when_destroyed=0);
235 void resize(
int n,
int set=1);
239 const T *
memory()
const {
return p_memory; }
240 T * memory(){
return p_memory; }
250 INLINE
int length()
const {
return num_columns();}
252 INLINE
int n()
const {
return num_columns();}
255 INLINE
const T &
a_no_check(
int n)
const {
return fast_a_v_x(n); }
266 const T &a_check(
int n)
const;
270 const T &a(
int n)
const {
return A_CHECK(n); }
271 T &a(
int n) {
return A_CHECK(n); }
274 const T &operator () (
int n)
const {
return A_CHECK(n);}
281 T &operator [] (
int n) {
return A_CHECK(n); }
285 void set_memory(T *buffer,
int offset,
int columns,
286 int free_when_destroyed=0);
292 void fill(
const T &v);
301 {
return ! ((*this) == v); }
305 void copy_section(T* dest,
int offset=0,
int num=-1)
const;
306 void set_section(
const T* src,
int offset=0,
int num=-1);
311 friend ostream& operator << (ostream &st, const EST_TVector<T> &m)
314 for (i = 0; i < m.n(); ++i)
315 st << m(i) <<
" "; st << endl;
322 void integrity()
const;
INLINE const T & fast_a_v(int c) const
quick method for returning (x[n])
INLINE T & a_no_check_1(int n)
read/write non-const access operator: without bounds checking
Template Matrix class. This is an extension of the EST_TVector class to two dimensions.
unsigned int p_num_columns
Visible shape.
static const T * def_val
default value, used for filling matrix after resizing
INLINE int length() const
number of items in vector.
INLINE int num_columns() const
number of items in vector.
INLINE unsigned int vcell_pos(unsigned int c, unsigned int cs) const
The memory access rule, in one place for easy reference.
unsigned int p_offset
How to access the memory.
INLINE const T & a_no_check_1(int n) const
read-only const access operator: without bounds checking
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
void empty()
Fill vector with default value.