In file DVector/DVector.hh:

class DVector

Data Vector class.

Inheritance:


Public Classes

enum DVType
DVector data type enumeration.

Public Fields

typedef unsigned long size_type
Size and index data type.

Public Methods

DVector (void)
Default constructor.
virtual ~DVector ()
Destructor.
virtual DVector* clone (void) const
Duplicate a DVector.
virtual void Erase (size_type inx, size_type length)
Erase a subset of a vector.
virtual DVector* Extract (size_type length) const
Extract a subset of a vector.
virtual DVector* Extract (size_type inx, size_type length) const
Extract a subset of a vector.
virtual DVector* Extract (size_type inx, size_type length, size_type inc) const
Extract a subset of a vector.
virtual DVType getType (void) const
Get the data type
const char* getTypeName (void) const
Get the data type name.
bool S_data (void) const
Test for short int data.
bool I_data (void) const
Test for float data.
bool F_data (void) const
Test for float data.
bool D_data (void) const
Test for float data.
bool C_data (void) const
Test for fComplex data.
virtual size_type getSize (void) const
Get the size of a data word.
virtual size_type getLength (void) const
Get the data length.
virtual size_type capacity (void) const
Get the vector capacity
virtual void ReSize (size_type len)
Expand the vector storage.
virtual void reserve (size_type len)
Insure a minimum number of words.
virtual void* refData (void)
Get a pointer to the data.
virtual const void* refData (void) const
Get a constant pointer to the data.
virtual size_type getData (size_type inx, size_type Ndata, short Data[]) const
Copy/Convert data into a short integer array.
virtual size_type getData (size_type inx, size_type Ndata, int Data[]) const
Copy/Convert data into a float array.
virtual size_type getData (size_type inx, size_type Ndata, float Data[]) const
Copy/Convert data into a float array.
virtual size_type getData (size_type inx, size_type Ndata, double Data[]) const
Copy/Convert data into a float array.
virtual size_type getData (size_type inx, size_type Ndata, fComplex Data[]) const
Copy/Convert data into a complex array.
virtual short getShort (size_type inx) const
Get one data word.
virtual int getInt (size_type inx) const
Get one data word.
virtual float getFloat (size_type inx) const
Get one data word.
virtual double getDouble (size_type inx) const
Get one data word.
virtual fComplex getCplx (size_type inx) const
Get one data word.
virtual double getMaximum (void) const
Maximum data value.
virtual double getMinimum (void) const
Minimum data value.
virtual size_type getNBetween (double low, double high) const
Number of entries greater than limit.
virtual size_type getNGreater (double limit) const
Number of entries greater than limit.
virtual size_type getNLess (double limit) const
Number of entries less than limit.
virtual DVector& insert (size_type inx, const DVector& v, size_type inx2=0, size_type N=0)
Inset data from a vector into the curret vector.
virtual DVector& replace (size_type inx, size_type N, const DVector& v, size_type inv, size_type Nv)
Replace data from a sub-vector into the curret vector.
DVector& replace (size_type inx, size_type N, const DVector& v)
Replace data from a vector into the curret vector.
virtual DVector& add (size_type inx, const DVector& v, size_type inx2=0, size_type N=0)
Add two vectors
virtual DVector& bias (size_type inx, double x, size_type N=0)
Add a constant to a vector
virtual DVector& sub (size_type inx, const DVector& v, size_type inx2=0, size_type N=0)
Subtract two vectors
virtual DVector& mpy (size_type inx, const DVector& v, size_type inx2=0, size_type N=0)
Multiply two vectors
virtual DVector& scale (size_type inx, double x, size_type N=0)
Multiply a vector by a constant
virtual DVector& div (size_type inx, const DVector& v, size_type inx2=0, size_type N=0)
Divide two vectors
virtual double dot (size_type inx, const DVector& v, size_type inx2=0, size_type N=0) const
Inner product
virtual fComplex cdot (size_type inx, const DVector& v, size_type inx2=0, size_type N=0) const
Comples inner product.
virtual double VSum (size_type inx=0, size_type N=0) const
Sum N data words.
virtual fComplex CSum (size_type inx=0, size_type N=0) const
Sum N data words.
virtual double operator* (const DVector& rhs) const
Inner product.
virtual DVector& operator = (const DVector& rhs)
Assignment operator.
virtual bool operator== (const DVector& rhs) const
Comparison operator.
virtual DVector& operator+= (const DVector& rhs)
Add a DVector.
virtual DVector& operator-= (const DVector& rhs)
Subtract a DVector.
virtual DVector& operator+= (double rhs)
Bias a DVector.
DVector& operator-= (double rhs)
Bias a DVector (negative).
virtual DVector& operator*= (double rhs)
Scale a DVector.
virtual DVector& operator/= (double rhs)
Scale a DVector (divide).
virtual DVector& operator*= (const DVector& rhs)
Element by element multiplication of DVector.
virtual DVector& operator/= (const DVector& rhs)
Divide by a DVector.
virtual std::ostream& Dump (std::ostream& out) const
Dump the vector contents.
void Append (size_type N, const short* data)
Append short integer data to a vector.
void Append (size_type N, const int* data)
Append integer data to a vector.
void Append (size_type N, const float* data)
Append float data to a vector.
void Append (size_type N, const double* data)
Append double float data to a vector.
void Append (size_type N, const fComplex* data)
Append complex data to a vector.
void Append (const DVector& data)
Append a DVector to a DVector.
void Clear (void)
Clear a DVector.
virtual void Conjugate (void)
Conjugate a DVector.
virtual void Extend (size_type N)
Extend a DVector.

Documentation

The data vector holds a variable length data vector of arbitrary type. Methods are provided to convert data to a requested type independent of the internal representation of the data. DVector are primarily used for time and frequency series.
enum DVType
DVType enumerates the data types that may be held by a DVector. Some of the data vector types may not be implemented.

typedef unsigned long size_type
Data type used internally for size and index variables.

DVector(void)
Initialize the base class element, the data length.

virtual ~DVector()
Null base class destructor.

virtual DVector* clone(void) const
An instance of a class derived from DVector is duplicated and a pointer to the duplicate is returned. All data are copied.
Returns:
a pointer to the DVector clone.

virtual void Erase(size_type inx, size_type length)
Erase a substring from the vector.
Parameters:
inx - Index of first element to be extracted.
length - Number of data elements to be extracted.

virtual DVector* Extract(size_type length) const
A substring starting at the first element is extracted from the DVector. The substring length is forced to be valid.
Returns:
a pointer to a new DVector containing the extracted data.
Parameters:
length - number of data elements to be extracted.

virtual DVector* Extract(size_type inx, size_type length) const
A substring is extracted from the DVector. The substring length is forced to be valid.
Returns:
a pointer to a new DVector containing the extracted data.
Parameters:
inx - index of first element to be extracted
length - number of data elements to be extracted.

virtual DVector* Extract(size_type inx, size_type length, size_type inc) const
A substring is extracted and decimated from the DVector. The extracted vector contains the elements defined by DVector[N*inc] where N is all the integers 0 <= N < length.
Returns:
pointer to the extracted data vector.
Parameters:
inx - Starting index of the substring to be extracted
length - Number of elements to be extracted
inc - Index increment between successive extracted elements.

virtual DVType getType(void) const
Return the data vector type as a DVector::DVType code.
Returns:
a data vector type code.

const char* getTypeName(void) const
Get the data type name as a constant character string.
Returns:
pointer to a constant character array containing the data type name.

bool S_data(void) const
Test if the vector data type is t_short.
Returns:
true if the vector data contains short integers.

bool I_data(void) const
Test if the vector data type is t_float.
Returns:
true if the vector data contains floats.

bool F_data(void) const
Test if the vector data type is t_float.
Returns:
true if the vector data contains floats.

bool D_data(void) const
Test if the vector data type is t_float.
Returns:
true if the vector data contains floats.

bool C_data(void) const
Test if the vector data type is t_complex.
Returns:
true if the vector data type is t_complex.

virtual size_type getSize(void) const
Get the number of bytes in a data word.
Returns:
The number of bytes in a data word.

virtual size_type getLength(void) const
Get the number of data elements in the vector.
Returns:
The data vector length.

virtual size_type capacity(void) const
Return the capacity of the data vector in data words.
Returns:
Number of words that can fit in the vector.

virtual void ReSize(size_type len)
Resize insures that there is sufficient storage allocated for len data items. No memory is release if the current allocation is greater than the requested size. The vector data are copied if the vector storage must be reallocated. The current data length is set to the specified length on return but any new data remain uninitialized.
Parameters:
len - Minimum number of words that must be available,

virtual void reserve(size_type len)
A data vector of the specified length is allocated. The current data length remains the same. If the present data vector is already greater than or equal to the specified length the data vector is not reallocated. If reallocation occurs, the current data may be copied to the front of the new vector. The vector is not reserved for write access.
Parameters:
len - Number of words to reserve.

virtual void* refData(void)
Get a pointer to the data array. Note that because the DVector uses internal copy on write data storage, the data can be moved by any manipulation of the data.
Returns:
void pointer to the data array.

virtual const void* refData(void) const
Get a constant pointer to the data array. Note that because the DVector uses internal copy-on-write data storage, the data can be moved by any manipulation of the data.
Returns:
constant void pointer to the data array.

virtual size_type getData(size_type inx, size_type Ndata, short Data[]) const
Copy data into a short integer output array. If the DVector has a different type than the output array, the data are converted to the output type.
Returns:
number of data words actually copied.
Parameters:
inx - Starting index of data to be copied.
Ndata - Maximum number of data words to be copied.
Data - Output short integer array.

virtual size_type getData(size_type inx, size_type Ndata, int Data[]) const
Copy data into an integer output array. If the DVector has a different type than the output array, the data are converted to the output type.
Returns:
number of data words actually copied.
Parameters:
inx - Starting index of data to be copied.
Ndata - Maximum number of data words to be copied.
Data - Output integer array.

virtual size_type getData(size_type inx, size_type Ndata, float Data[]) const
Copy data into a float output array. If the DVector has a different type than the output array, the data are converted to the output type.
Returns:
number of data words actually copied.
Parameters:
inx - Starting index of data to be copied.
Ndata - Maximum number of data words to be copied.
Data - Output float array.

virtual size_type getData(size_type inx, size_type Ndata, double Data[]) const
Copy data into a double float output array. If the DVector has a different type than the output array, the data are converted to the output type.
Returns:
number of data words actually copied.
Parameters:
inx - Starting index of data to be copied.
Ndata - Maximum number of data words to be copied.
Data - Output double float array.

virtual size_type getData(size_type inx, size_type Ndata, fComplex Data[]) const
Copy data into a complex output array. If the DVector has a different type than the output array, the data are converted to the output type.
Returns:
number of data words actually copied.
Parameters:
inx - Starting index of data to be copied.
Ndata - Maximum number of data words to be copied.
Data - Output complex array.

virtual short getShort(size_type inx) const
A specified data word is picked up from the DVector, converted to a short integer and returned. No validity checking is made on the index.
Returns:
value of selected word converted if necessary to short integer.
Parameters:
inx - Index into the data vector of the word to be returned.

virtual int getInt(size_type inx) const
A specified data word is picked up from the DVector, converted to an integer and returned. No validity checking is made on the index.
Returns:
value of selected word converted if necessary to integer.
Parameters:
inx - Index into the data vector of the word to be returned.

virtual float getFloat(size_type inx) const
A specified data word is picked up from the DVector, converted to a float and returned. No validity checking is made on the index.
Returns:
value of selected work converted if necessary to float.
Parameters:
inx - Index into the data vector of the word to be returned.

virtual double getDouble(size_type inx) const
A specified data word is picked up from the DVector, converted to a double float and returned. No validity checking is made on the index.
Returns:
value of selected word converted if necessary to double.
Parameters:
inx - Index into the data vector of the word to be returned.

virtual fComplex getCplx(size_type inx) const
A specified data word is picked up from the DVector, converted to a complex and returned. No validity checking is made on the index.
Returns:
value of selected work converted if necessary to complex.
Parameters:
inx - Index into the data vector of the word to be returned.

virtual double getMaximum(void) const
Return the largest entry. If the vector is complex, the largest real part is returned.
Returns:
Largest data value.

virtual double getMinimum(void) const
Return the smallest entry. If the vector is complex, the smallest real part is returned.
Returns:
Smallest data value.

virtual size_type getNBetween(double low, double high) const
Count the number of entries between two specified limits. If the vector is complex, the real part is compared.
Returns:
Number of entries greater than limit.
Parameters:
limit - Lower limit of entries to be counted.

virtual size_type getNGreater(double limit) const
Count the number of entries with value greater than the specified limit. If the vector is complex, the real part is compared.
Returns:
Number of entries greater than limit.
Parameters:
limit - Lower limit of entries to be counted.

virtual size_type getNLess(double limit) const
Count the number of entries with value less than the specified limit. If the vector is complex, the real part is compared.
Returns:
Number of entries less than limit.
Parameters:
limit - Upper limit of entries to be counted.

virtual DVector& insert(size_type inx, const DVector& v, size_type inx2=0, size_type N=0)
Insert N values starting at inx2 of the argument vector into the current vector starting at index inx.
Returns:
Reference to the result vector.
Parameters:
inx - Index of the insertion point of the current vector.
v - Vector containing data to be inserted.
inx2 - index in v of the data to be inserted.
N - Number of words to be inserted

virtual DVector& replace(size_type inx, size_type N, const DVector& v, size_type inv, size_type Nv)
Replace N values starting at inx of the current vector with nV values starting at index inv of the argument vector. Note that the sub-strings must be within the range of the vectors, 0 <= inx+N < len and 0 <= inv+Nv < v.len.
Returns:
Reference to the result vector.
Parameters:
inx - Index of the insertion point of the current vector.
N - Number of words to be replaced
v - Vector containing data to be inserted.
inv - index in v of the data to be inserted.
Nv - Number of words to be inserted

DVector& replace(size_type inx, size_type N, const DVector& v)
Replace N values starting at inx of the current vector with N2 values starting at index inx2 of the argument vector.
Returns:
Reference to the result vector.
Parameters:
inx - Index of the insertion point of the current vector.
N - Number of words to be replaced
v - Vector containing data to be inserted.

virtual DVector& add(size_type inx, const DVector& v, size_type inx2=0, size_type N=0)
Add N values in the addend vector to the current vector starting at index inx of the current vector and inx2 of the addend vector.
Returns:
Reference to the result vector.
Parameters:
inx - Index of the first element in this vector to be added.
v - Vector to be added
inx2 - index in the
N - Number of words to be added

virtual DVector& bias(size_type inx, double x, size_type N=0)
Add a constant to N values of the current vector starting at index inx.
Returns:
Reference to the result vector.
Parameters:
inx - Index of the first element in this vector to be added.
x - Constant to be added
N - Number of words to be added

virtual DVector& sub(size_type inx, const DVector& v, size_type inx2=0, size_type N=0)
Subtract N values in the subtrahend vector from the current vector starting at index inx of the current vector and inx2 of the subtrahend vector.
Returns:
Reference to the result vector.
Parameters:
inx - Index of the first element in this vector to be added.
v - Vector to be added
inx2 - index in the
N - Number of words to be added

virtual DVector& mpy(size_type inx, const DVector& v, size_type inx2=0, size_type N=0)
Multiply N values in the current vector starting at index inx by the values starting at inx2 of the multiplier vector.
Returns:
Reference to the result vector.
Parameters:
inx - Index of the first element in this vector to be added.
v - Vector to be added
inx2 - index in the
N - Number of words to be added

virtual DVector& scale(size_type inx, double x, size_type N=0)
Multiply N values of the current vector starting at index inx by a constant.
Returns:
Reference to the result vector.
Parameters:
inx - Index of the first element in this vector to be added.
x - Constant to be added
N - Number of words to be added

virtual DVector& div(size_type inx, const DVector& v, size_type inx2=0, size_type N=0)
Divide N values starting at index inx of the current vector by the values starting at inx2 of the divisor vector.
Returns:
Reference to the result vector.
Parameters:
inx - Index of the first element in this vector to be added.
v - Vector to be added
inx2 - index in the
N - Number of words to be added

virtual double dot(size_type inx, const DVector& v, size_type inx2=0, size_type N=0) const
Inner product between two substrings.
Returns:
Reference to the result vector.
Parameters:
inx - Index of the first element in this vector to be added.
v - Vector to be added
inx2 - index in the
N - Number of words to be added

virtual fComplex cdot(size_type inx, const DVector& v, size_type inx2=0, size_type N=0) const
Complex intter p roduct of two subvectors.
Returns:
Reference to the result vector.
Parameters:
inx - Index of the first element in this vector to be added.
v - Vector to be added
inx2 - index in the
N - Number of words to be added

virtual double VSum(size_type inx=0, size_type N=0) const
All words in a specified range are converted to double and summed.
Returns:
Sum of specified data vector.
Parameters:
inx - Index into the data vector of first word to be summed.
N - Number of words to be summed.

virtual fComplex CSum(size_type inx=0, size_type N=0) const
All words in a specified range are converted to complex and summed.
Returns:
Sum of specified data vector.
Parameters:
inx - Index into the data vector of first word to be summed.
N - Number of words to be summed.

virtual double operator*(const DVector& rhs) const
Calculate the inner (dot) product of two DVectors. The inner product is defined as the sum of the products of the corresponding elements, i.e. . If the right hand side operand is complex, it is conjugated before the multiplication.
Returns:
The dot product of two DVectors.
Parameters:
rhs - DVector to be multiplied by the other.

virtual DVector& operator =(const DVector& rhs)
The data from the rhs DVector is converted and copied to the lhs DVector. The original data in the lhs DVector are lost.
Returns:
reference to the modified DVector.
Parameters:
rhs - Constant DVector whose value is copied.

virtual bool operator==(const DVector& rhs) const
The data from the rhs DVector is converted and compared to the lhs DVector. The original data are untouched.
Returns:
reference to the modified DVector.
Parameters:
rhs - Constant DVector whose value is copied.

virtual DVector& operator+=(const DVector& rhs)
The data in the rhs DVector are added to the data of the lhs DVector on an element by element basis.
Returns:
reference to the modified DVector.
Parameters:
rhs - DVector whose data are added.

virtual DVector& operator-=(const DVector& rhs)
The data in the rhs DVector are subtracted from the data of the lhs DVector on an element by element basis.
Returns:
reference to the modified DVector.
Parameters:
rhs - DVector whose data are subtracted.

virtual DVector& operator+=(double rhs)
The right hand side (rhs) constant is added to each element of the left hand side DVector.
Returns:
reference to the resulting DVector.
Parameters:
rhs - Scalar constant to be added to each element.

DVector& operator-=(double rhs)
The right hand side constant (rhs) is subtracted to each element of the left hand side DVector.
Returns:
reference to the resulting DVector.
Parameters:
rhs - Scalar constant to be subtracted from each element.

virtual DVector& operator*=(double rhs)
Each element of the lhs DVector is multiplied by the rhs constant.
Returns:
reference to the resulting DVector.
Parameters:
rhs - Scalar constant each element is multiplied by.

virtual DVector& operator/=(double rhs)
Each element of the lhs DVector is divided by the rhs constant.
Returns:
reference to the resulting DVector.
Parameters:
rhs - Scalar constant each element is divided by.

virtual DVector& operator*=(const DVector& rhs)
Each element of the lhs DVector is multiplied by the corresponding element of rhs.
Returns:
Reference to the resulting DVector.
Parameters:
rhs - Multiplier DVector.

virtual DVector& operator/=(const DVector& rhs)
Each element of the lhs DVector is divided by the corresponding element of rhs.
Returns:
Reference to the resulting DVector.
Parameters:
rhs - Denominator DVector.

virtual std::ostream& Dump(std::ostream& out) const
A formatted dump of the DVector contents is written to a specified stream.
Returns:
Reference to the output stream.
Parameters:
str - Output stream that is to receive the formatted dump.

void Append(size_type N, const short* data)
Data from a short integer array are converted to the DVector type and appended to the data vector.
Parameters:
N - Number of data words to append to the DVector.
data - short integer data array.

void Append(size_type N, const int* data)
Data from an integer array are converted to the DVector type and appended to the data vector.
Parameters:
N - Number of data words to append to the DVector.
data - integer data to be appended to the DVector.

void Append(size_type N, const float* data)
Data from a float array are converted to the DVector type and appended to the data vector.
Parameters:
N - Number of data words to append to the DVector.
data - float data to be appended to the DVector.

void Append(size_type N, const double* data)
Data from a double float array are converted to the DVector type and appended to the data vector.
Parameters:
N - Number of data words to append to the DVector.
data - double float data to be appended to the DVector.

void Append(size_type N, const fComplex* data)
Data from a complex array are converted to the DVector type and appended to the data vector.
Parameters:
N - Number of data words to append to the DVector.
data - complex data to be appended to the DVector.

void Append(const DVector& data)
Data from the specified DVector are appended to the object vector. The appended data will be converted to the object type if necessary.
Parameters:
data - DVector containing data to be appended.

void Clear(void)
The current data length is set to zero. No allocated memory is released.

virtual void Conjugate(void)
Replace each element of the vector with it's complex conjugate.

virtual void Extend(size_type N)
The data vector is extended to the specified length. New data words are filled with zeros. If the current data length is greater than the requested length, no action is taken (i.e. the vector is not shortened). Use ReSize to reduce the vector length or to extend the vector with uninitialized data.
Parameters:
N - New size for the data vector.


This class has no child classes.
Author:
John G. Zweizig
Version:
2.1; Last modified: May 19, 2004

alphabetic index hierarchy of classes


Please send questions and comments to zweizig_j@ligo.caltech.edu


generated by doc++