![]() |
Edinburgh Speech Tools
2.1-release
|
Template vector. More...
#include <include/EST_TVector.h>
Public Member Functions | |
INLINE unsigned int | vcell_pos (unsigned int c, unsigned int cs) const |
The memory access rule, in one place for easy reference. | |
INLINE unsigned int | vcell_pos (unsigned int c) const |
INLINE unsigned int | vcell_pos_1 (unsigned int c) const |
INLINE const T & | fast_a_v (int c) const |
quick method for returning (x[n]) | |
INLINE T & | fast_a_v (int c) |
INLINE const T & | fast_a_1 (int c) const |
INLINE T & | fast_a_1 (int c) |
void | set_values (const T *data, int step, int start_c, int num_c) |
Get and set values from array. | |
void | get_values (T *data, int step, int start_c, int num_c) const |
void | copy (const EST_TVector< T > &a) |
private copy function, called from all other copying functions. | |
void | copy_data (const EST_TVector< T > &a) |
just copy data, no resizing, no size check. | |
void | just_resize (int new_cols, T **old_vals) |
resize the memory and reset the bounds, but don't set values. | |
void | default_vals () |
sets data and length to default values (0 in both cases). | |
EST_TVector () | |
default constructor | |
EST_TVector (const EST_TVector< T > &v) | |
copy constructor | |
EST_TVector (int n) | |
"size" constructor - make vector of size n. | |
EST_TVector (int, T *memory, int offset=0, int free_when_destroyed=0) | |
construct from memory supplied by caller | |
~EST_TVector () | |
destructor. | |
void | resize (int n, int set=1) |
const T * | memory () const |
T * | memory () |
void | set_memory (T *buffer, int offset, int columns, int free_when_destroyed=0) |
EST_TVector & | operator= (const EST_TVector &s) |
assignment operator | |
void | fill (const T &v) |
Fill entire array will value v . | |
void | empty () |
Fill vector with default value. | |
int | operator== (const EST_TVector &v) const |
is true if vectors are equal size and all elements are equal. | |
int | operator!= (const EST_TVector &v) const |
is true if vectors are not equal size or a single elements isn't equal. | |
void | copy_section (T *dest, int offset=0, int num=-1) const |
Copy data in and out. Subclassed by SimpleVector for speed. | |
void | set_section (const T *src, int offset=0, int num=-1) |
void | sub_vector (EST_TVector< T > &sv, int start_c=0, int len=-1) |
Create a sub vector. | |
void | integrity () const |
template<> | |
const EST_DMatrix * | def_val |
template<> | |
EST_DMatrix * | error_return |
template<> | |
const EST_DVector * | def_val |
template<> | |
EST_DVector * | error_return |
template<> | |
const EST_FMatrix * | def_val |
template<> | |
EST_FMatrix * | error_return |
Access | |
Basic access methods for vectors. | |
INLINE int | num_columns () const |
number of items in vector. | |
INLINE int | length () const |
number of items in vector. | |
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 | |
INLINE const T & | a_no_check_1 (int n) const |
read-only const access operator: without bounds checking | |
INLINE T & | a_no_check_1 (int n) |
read/write non-const access operator: without bounds checking | |
const T & | a_check (int n) const |
read-only const access operator: with bounds checking | |
T & | a_check (int n) |
read/write non-const access operator: with bounds checking | |
const T & | a (int n) const |
T & | a (int n) |
const T & | operator() (int n) const |
read-only const access operator: return reference to nth member | |
T & | operator[] (int n) |
read/write non const access operator: return reference to nth member | |
Public Attributes | |
T * | p_memory |
unsigned int | p_num_columns |
Visible shape. | |
unsigned int | p_offset |
How to access the memory. | |
unsigned int | p_column_step |
bool | p_sub_matrix |
Static Public Attributes | |
static const T * | def_val = &def_val_item_ptr |
default value, used for filling matrix after resizing | |
static T * | error_return = &error_return_item_ptr |
Friends | |
class | EST_TMatrix< T > |
Matrix must be friend to set up subvectors. | |
ostream & | operator<< (ostream &st, const EST_TVector< T > &m) |
print out vector. | |
Template vector.
T | Type of vector elements |
This serves as a base class for a vector of type T
. This acts as a higher level version of a normal C array as defined as float *x
, etc.
The vector can be resized after declaration, access can be with or without bounds checking. Round brackets denote read-only access (for consts) while square brackets are for read-write access. In both cases references are returned.
The standard operators () and [] should be thought of as having no bounds checking, though they may do so optionally as a compile time option. The methods EST_TVector::a_check and EST_TVector::a_nocheck provide explicit boundary checking/nonchecking, both const and non-const versions are provided.
Access through () and [] are guaranteed to be as fast as standard C arrays (assuming a reasonable optimizing compiler).
To instantiate a template for a a vector of type FooBar
The EST library already has template vector instantiations for int
, float
, double
and EST_String. Also types are defined for them in EST_types.h as EST_IVector, EST_FVector, EST_DVector and EST_StrVector for int
s, float
s, doubles
s and EST_String respectively.
Definition at line 145 of file EST_TVector.h.
void EST_TVector< T >::resize | ( | int | n, |
int | set = 1 |
||
) |
resize vector. If set=1
, then the current values in the vector are preserved up to the new length n
. If the new length exceeds the old length, the rest of the vector is filled with the def_val
Definition at line 196 of file EST_TVector.cc.
|
inline |
For when you absolutely have to have access to the memory.
Definition at line 239 of file EST_TVector.h.
T* EST_TVector< T >::p_memory |
Pointer to the start of the vector. The start of allocated memory is p_memory-p_offset.
Definition at line 152 of file EST_TVector.h.
|
static |
A reference to this variable is returned if you try and access beyond the bounds of the matrix. The value is undefined, but you can check for the reference you get having the same address as this variable to test for an error.
Definition at line 228 of file EST_TVector.h.