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)
98 delete [] (p_memory-p_offset);
107 for (
int i = 0; i < num_columns(); ++i)
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)
132 a_no_check(c) = data[p];
142 for(
int i=0, c=start_c, p=0; i<num_c; i++, c++, p+=step)
143 data[p] = a_no_check(c);
165 if (num_columns() != new_cols || p_memory ==
NULL )
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];
176 if (p_memory !=
NULL)
178 if (old_vals !=
NULL)
179 *old_vals = p_memory;
180 else if (!p_sub_matrix)
181 delete [] (p_memory-p_offset);
187 p_num_columns = new_cols;
191 *old_vals = p_memory;
199 T * old_vals = p_memory;
200 int old_cols = num_columns();
201 int old_offset = p_offset;
202 int old_column_step = p_column_step;
204 just_resize(new_cols, &old_vals);
212 else if (old_vals != p_memory)
214 copy_c =
Lof(num_columns(), old_cols);
216 for(i=0; i<copy_c; i++)
218 = old_vals[vcell_pos(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);
243 return *error_return;
260 for(
int i=0; i<num_columns() ; i++)
274 num = num_columns()-offset;
280 for(
int i=0; i<num; i++)
281 dest[i] = a_no_check(offset+i);
288 num = num_columns()-offset;
293 for(
int i=0; i<num; i++)
294 a_no_check(offset+i) = src[i];
299 int start_c,
int len)
302 len = num_columns()-start_c;
308 sv.
p_offset = p_offset + start_c*p_column_step;
317 std::cout <<
"integrity: p_memory=" << p_memory << std::endl;
318 if(p_memory == (T *)0x00080102)
320 std::cout <<
"fatal value!!!\n";
INLINE const T & fast_a_v(int c) const
quick method for returning (x[n])
ssize_t p_num_columns
Visible shape.
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.
bool EST_vector_bounds_check(int c, int num_columns, bool set)
const T & a_check(ssize_t n) const
read-only const access operator: with bounds checking
void default_vals()
sets data and length to default values (0 in both cases).
void resize(ssize_t n, int set=1)
void copy(const EST_TVector< T > &a)
private copy function, called from all other copying functions.
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
~EST_TVector()
destructor.
EST_TVector< T > & copy(EST_TVector< T > a, const EST_TList< T > &in)
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.
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 set_memory(T *buffer, int offset, ssize_t columns, int free_when_destroyed=0)
ssize_t p_offset
How to access the memory.