44#include "EST_TVector.h"
45#include "EST_matrix_support.h"
46#include "EST_cutils.h"
82 T *
memory,
int offset,
int free_when_destroyed)
86 set_memory(
memory, offset,
n, free_when_destroyed);
96 if (
p_memory != NULL && !p_sub_matrix)
112void EST_TVector<T>::set_memory(T *buffer,
int offset,
int columns,
113 int free_when_destroyed)
115 if (p_memory != NULL && !p_sub_matrix)
116 delete [] (p_memory-p_offset);
118 p_memory = buffer-offset;
120 p_num_columns = columns;
122 p_sub_matrix = !free_when_destroyed;
131 for(
int i=0, c=start_c, p=0; i<num_c; i++, c++, p+=step)
137void EST_TVector<T>::get_values(T *data,
142 for(
int i=0, c=start_c, p=0; i<num_c; i++, c++, p+=step)
143 data[p] = a_no_check(c);
168 EST_error(
"Attempt to resize Sub-Vector");
171 EST_error(
"Attempt to resize vector to negative size: %d",
174 new_m =
new T[new_cols];
178 if (old_vals != NULL)
180 else if (!p_sub_matrix)
202 int old_column_step = p_column_step;
216 for(i=0; i<copy_c; i++)
224 for(i=copy_c; i<new_cols; i++)
225 a_no_check(i) = *def_val;
228 if (old_vals && old_vals != p_memory && !p_sub_matrix)
229 delete [] (old_vals-old_offset);
276 if (!EST_vector_bounds_check(num+offset-1,
num_columns(), FALSE))
280 for(
int i=0; i<num; i++)
285void EST_TVector<T>::set_section(
const T* src,
int offset,
int num)
288 num = num_columns()-offset;
290 if (!EST_vector_bounds_check(num+offset-1, num_columns(), FALSE))
293 for(
int i=0; i<num; i++)
299 int start_c,
int len)
304 if (sv.
p_memory != NULL && ! sv.p_sub_matrix)
307 sv.p_sub_matrix = TRUE;
310 sv.p_column_step=p_column_step;
315void EST_TVector<T>::integrity()
const
317 cout <<
"integrity: p_memory=" << p_memory << endl;
318 if(p_memory == (T *)0x00080102)
320 cout <<
"fatal value!!!\n";
unsigned int p_offset
How to access the memory.
INLINE const T & fast_a_v(int c) const
quick method for returning (x[n])
const T & a_check(int n) const
read-only const access operator: with bounds checking
void just_resize(int new_cols, T **old_vals)
resize the memory and reset the bounds, but don't set values.
void resize(int n, int set=1)
void default_vals()
sets data and length to default values (0 in both cases).
EST_TVector & operator=(const EST_TVector &s)
assignment operator
void copy_data(const EST_TVector< T > &a)
just copy data, no resizing, no size check.
INLINE int num_columns() const
number of items in vector.
void copy_section(T *dest, int offset=0, int num=-1) const
Copy data in and out. Subclassed by SimpleVector for speed.
void copy(const EST_TVector< T > &a)
private copy function, called from all other copying functions.
unsigned int p_num_columns
Visible shape.
INLINE int 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.
EST_TVector()
default constructor
void sub_vector(EST_TVector< T > &sv, int start_c=0, int len=-1)
Create a sub vector.
void fill(const T &v)
Fill entire array will value <parameter>v</parameter>.
~EST_TVector()
destructor.
INLINE const T & a_no_check(int n) const
read-only const access operator: without bounds checking
INLINE unsigned int vcell_pos(unsigned int c, unsigned int cs) const
void set_values(const T *data, int step, int start_c, int num_c)
Get and set values from array.