40 #ifndef __EST_TVector_H__ 41 #define __EST_TVector_H__ 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)) 166 {
return cs==1?c:c*cs;}
188 void set_values(
const T *data,
int step,
int start_c,
int num_c);
189 void get_values(T *data,
int step,
int start_c,
int num_c)
const;
214 T *
memory,
int offset=0,
int free_when_destroyed=0);
285 int free_when_destroyed=0);
291 void fill(
const T &v);
300 {
return ! ((*this) == v); }
304 void copy_section(T* dest,
int offset=0,
int num=-1)
const;
305 void set_section(
const T* src,
int offset=0,
int num=-1);
310 friend std::ostream& operator << (std::ostream &st, const EST_TVector<T> &m)
313 for (i = 0; i < m.n(); ++i)
INLINE ssize_t vcell_pos_1(ssize_t c) const
INLINE const T & fast_a_v(int c) const
quick method for returning (x[n])
ssize_t p_num_columns
Visible shape.
INLINE T & fast_a_1(int c)
Template Matrix class. This is an extension of the EST_TVector class to two dimensions.
void copy_data(const EST_TVector< T > &a)
just copy data, no resizing, no size check.
INLINE ssize_t num_columns() const
number of items in vector.
void fill(const T &v)
Fill entire array will value v.
int operator!=(const EST_TVector &v) const
is true if vectors are not equal size or a single elements isn't equal.
INLINE T & fast_a_v(int c)
INLINE const T & a_no_check(ssize_t n) const
read-only const access operator: without bounds checking
const T & a_check(ssize_t n) const
read-only const access operator: with bounds checking
const T & a(ssize_t n) const
void default_vals()
sets data and length to default values (0 in both cases).
const T & operator()(ssize_t n) const
read-only const access operator: return reference to nth member
INLINE T & a_no_check_1(ssize_t n)
read/write non-const access operator: without bounds checking
static const T * def_val
default value, used for filling matrix after resizing
INLINE T & a_no_check(ssize_t n)
read/write non-const access operator: without bounds checking
INLINE ssize_t vcell_pos(ssize_t c) const
void resize(ssize_t n, int set=1)
void copy(const EST_TVector< T > &a)
private copy function, called from all other copying functions.
INLINE ssize_t length() const
number of items in vector.
void set_section(const T *src, int offset=0, int num=-1)
void get_values(T *data, int step, int start_c, int num_c) const
INLINE ssize_t vcell_pos(ssize_t c, ssize_t cs) const
The memory access rule, in one place for easy reference.
~EST_TVector()
destructor.
T & operator[](ssize_t n)
read/write non const access operator: return reference to nth member
void sub_vector(EST_TVector< T > &sv, int start_c=0, int len=-1)
Create a sub vector.
void just_resize(int new_cols, T **old_vals)
resize the memory and reset the bounds, but don't set values.
EST_TVector & operator=(const EST_TVector &s)
assignment operator
void set_values(const T *data, int step, int start_c, int num_c)
Get and set values from array.
void copy_section(T *dest, int offset=0, int num=-1) const
Copy data in and out. Subclassed by SimpleVector for speed.
INLINE const T & fast_a_1(int c) const
INLINE const T & a_no_check_1(ssize_t n) const
read-only const access operator: without bounds checking
EST_TVector()
default constructor
INLINE ssize_t n() const
number of items in vector.
int operator==(const EST_TVector &v) const
is true if vectors are equal size and all elements are equal.
void empty()
Fill vector with default value.
void set_memory(T *buffer, int offset, ssize_t columns, int free_when_destroyed=0)
ssize_t p_offset
How to access the memory.