In file DMatrix.h:

class CDVector: public virtual CVisDVector

Vector class with double precision.

Inheritance:


Public Methods

[more]DIVAMatrixExport void CrossProduct ( const CDVector &v1, const CDVector &v2)
Forms the cross product of two vectors.
[more]DIVAMatrixExport void ElementDivide (const CDVector& vector)
Divide two vectors element-wise.
[more]DIVAMatrixExport void ElementMultiply (const CDVector& vector)
Multiplies two vectors element-wise.
[more]DIVAMatrixExport void Eq (const double B, CDVector& C ) const
Equal - compares a vector and a double.
[more]DIVAMatrixExport void Eq ( const CDVector& B, CDVector& C ) const
Equal - compares a vector and a vector.
[more]DIVAMatrixExport void FromFile ( const CDString& sFilename )
Reads a vector from disk in binary format.
[more]DIVAMatrixExport void FromFile ( FILE *fh )
Reads a vector from disk in binary format.
[more]DIVAMatrixExport void FromMatlab (const CDString& sFilename, const CDString& sName)
Reads a vector from disk in MatLab (.m) format.
[more]DIVAMatrixExport void Ge ( const CDVector& B, CDVector& C ) const
Greater Than or Equal - compares a vector and a vector.
[more]DIVAMatrixExport void Ge (const double B, CDVector& C ) const
Greater Than or Equal - compares a double and a vector.
[more]DIVAMatrixExport void Gt (const double B, CDVector& C ) const
Greater Than - compares a double and a vector.
[more]DIVAMatrixExport void Gt ( const CDVector& B, CDVector& C ) const
Greater Than - compares a vector and a vector.
[more]DIVAMatrixExport void Le ( const CDVector& B, CDVector& C ) const
Less Than or Equal - compares a vector and a vector.
[more]DIVAMatrixExport void Le (const double B, CDVector& C ) const
Less Than or Equal - compares a double and a vector.
[more]DIVAMatrixExport void Log ()
Takes the natural logarithm of each element.
[more]DIVAMatrixExport void Lt ( const CDVector& B, CDVector& C ) const
Less Than - compares a vector and a vector.
[more]DIVAMatrixExport void Lt (const double B, CDVector& C ) const
Less Than - compares a double and a vector.
[more]DIVAMatrixExport double Max () const
Finds the maximum element in the vector.
[more]DIVAMatrixExport double Mean () const
Calculates the mean value of the vector.
[more]DIVAMatrixExport double Min () const
Finds the minimum element in the vector.
[more]DIVAMatrixExport double Min (int& iPos) const
Finds the minimum element in the vector and its position.
[more]DIVAMatrixExport void Ne ( const CDVector& B, CDVector& C ) const
Not Equal - compares a vector and a vector.
[more]DIVAMatrixExport void Ne (const double B, CDVector& C ) const
Not Equal - compares a double and a vector.
[more]DIVAMatrixExport double Norm1 () const
Calculates the one-norm (L1) of the vector.
[more]DIVAMatrixExport double Norm2 () const
Calculates the two-norm (L2) of the vector.
[more]DIVAMatrixExport double NormInf () const
Calculates the infinity-norm (Linf) of the vector.
[more]DIVAMatrixExport void Normalize2 ()
Normalizes the vector to unit length, using the 2-norm.
[more]DIVAMatrixExport void Pow (double dP)
Takes the power 'dP' of each element.
[more]DIVAMatrixExport void Rand ()
Uniformly distributed random numbers.
[more]DIVAMatrixExport void Reverse ()
Reverses the vector.
[more]DIVAMatrixExport double Skewness () const
Calculates the skewness of the vector.
[more]DIVAMatrixExport void Sort ( bool ascending )
Sorts the vector.
[more]DIVAMatrixExport void Sqr ()
Squares each element.
[more]DIVAMatrixExport void Sqrt ()
Takes the square root of each element.
[more]DIVAMatrixExport double Std () const
Calculates the standard deviation of the vector.
[more]DIVAMatrixExport double Sum () const
Calculates the sum of the vector.
[more]DIVAMatrixExport void ToFile ( const CDString& sFilename ) const
Writes the vector to disk in binary format.
[more]DIVAMatrixExport void ToFile ( FILE *fh ) const
Writes the vector to disk in binary format.
[more]DIVAMatrixExport void ToMatlab (const CDString& sFilename, const CDString& sName, const CDString& sComment, bool fAppend) const
Writes the vector to disk in MatLab (.m) format.
[more]DIVAMatrixExport CDString ToString (const bool fNewline) const
Returns a string representing the vector.
[more]DIVAMatrixExport double Var () const
Calculates the variance of the vector.
[more]DIVAMatrixExport CDVector& operator= (double value)
Assignment operator.
[more]DIVAMatrixExport CDVector& operator= (const CVisDVector &vIn)
Assignment operator.
[more]DIVAMatrixExport CDVector& operator= (const CDVector &vIn)
Assignment operator.


Documentation

Vector class with double precision based upon the VisSDK vector class CVisDVector.

oDIVAMatrixExport void CrossProduct( const CDVector &v1, const CDVector &v2)

Forms the cross product of two vectors and store the result in this. If the vector does have the correct size, it will be resized.

Returns:
Nothing.
Parameters:
v1 - Input vector.
v2 - Input vector.
Author:
Mikkel B. Stegmann
Version:
3-16-2001

oDIVAMatrixExport void ElementDivide(const CDVector& vector)

Divide two vectors element-wise. Corresponding MatLab operator "./".

Returns:
Nothing.
Parameters:
vector - The input vector to divide this vector with.
Author:
Rune Fisker
Version:
1-5-1999

oDIVAMatrixExport void ElementMultiply(const CDVector& vector)

Multiplies two vectors element-wise. Corresponding MatLab operator ".*".

Returns:
Nothing.
Parameters:
vector - The input vector to multiply this vector with.
Author:
Rune Fisker
Version:
1-5-1999

oDIVAMatrixExport void Eq(const double B, CDVector& C ) const

Compares of a vector and a double and returns the result as a binary vector i.e.:

C(i) = 1 if A(i) == B C(i) = 0 else

Corresponding MatLab function EQ()

Returns:
Nothing.
Parameters:
B - Input double.
C - Output result vector.
Author:
Lars Pedersen
Version:
7-12-2000

oDIVAMatrixExport void Eq( const CDVector& B, CDVector& C ) const

Compares of a vector and a vector and returns the result as a binary matrix i.e.:

C(i) = 1 if A(i) == B C(i) = 0 else

Corresponding MatLab function EQ()

Returns:
Nothing.
Parameters:
B - Input vector.
C - Output result vector.
Author:
Lars Pedersen
Version:
7-12-2000

oDIVAMatrixExport void FromFile( const CDString& sFilename )

Reads a vector from disk in binary format.

Returns:
Nothing.
Parameters:
sFilename - Input file name.
Author:
Mikkel B. Stegmann
Version:
2-5-2001

oDIVAMatrixExport void FromFile( FILE *fh )

Reads a vector from disk in binary format.

Returns:
Nothing.
Parameters:
fh - Open file handle (opened using fopen())
Author:
Mikkel B. Stegmann
Version:
2-5-2001

oDIVAMatrixExport void FromMatlab(const CDString& sFilename, const CDString& sName)

Reads a vector from disk in MatLab (.m) format into 'this'.

Notice that this should be used for storage a (really) large vectors, due to the computational and i/o overhead induced by the simple MatLab text format.

Also, remember that MatLab can't read (.m) files with lines longer than 4096 bytes.

If no communication with MatLab is needed, but merely to/from disk functionality within a DIVA program, it is suggested to use the fast binary i/o methods ToFile() and FromFile().

Returns:
Nothing.
Parameters:
sFilename - Input file name.
sName - The name to search for (and load) inside the matlab file.
Author:
Henrik Aanęs
Version:
2-5-2001

oDIVAMatrixExport void Ge(const double B, CDVector& C ) const

Compares of a double and a vector and returns the result as a binary matrix i.e.:

C(i) = 1 if A(i) >= B C(i) = 0 else

Corresponding MatLab function GE()

Returns:
Nothing.
Parameters:
B - Input double.
C - Output result vector.
Author:
Lars Pedersen
Version:
7-12-2000

oDIVAMatrixExport void Ge( const CDVector& B, CDVector& C ) const

Compares of a vector and a vector and returns the result as a binary matrix i.e.:

C(i) = 1 if A(i) >= B C(i) = 0 else

Corresponding MatLab function GE()

Returns:
Nothing.
Parameters:
B - Input vector.
C - Output result vector.
Author:
Lars Pedersen
Version:
7-12-2000

oDIVAMatrixExport void Gt(const double B, CDVector& C ) const

Compares of a double and a vector and returns the result as a binary matrix i.e.:

C(i) = 1 if A(i) > B C(i) = 0 else

Corresponding MatLab function GT()

Returns:
Nothing.
Parameters:
B - Input vector.
C - Output result vector.
Author:
Lars Pedersen
Version:
7-12-2000

oDIVAMatrixExport void Gt( const CDVector& B, CDVector& C ) const

Compares of a vector and a vector and returns the result as a binary matrix i.e.:

C(i) = 1 if A(i) > B C(i) = 0 else

Corresponding MatLab function GT()

Returns:
Nothing.
Parameters:
B - Input vector.
C - Output result vector.
Author:
Lars Pedersen
Version:
7-12-2000

oDIVAMatrixExport void Le(const double B, CDVector& C ) const

Compares of a double and a vector and returns the result as a binary matrix i.e.:

C(i) = 1 if A(i) <= B C(i) = 0 else

Corresponding MatLab function LE()

Returns:
Nothing.
Parameters:
B - Input double.
C - Output result vector.
Author:
Lars Pedersen
Version:
7-12-2000

oDIVAMatrixExport void Le( const CDVector& B, CDVector& C ) const

Compares of a vector and a vector and returns the result as a binary matrix i.e.:

C(i) = 1 if A(i) <= B C(i) = 0 else

Corresponding MatLab function LE()

Returns:
Nothing.
Parameters:
B - Input vector.
C - Output result vector.
Author:
Lars Pedersen
Version:
7-12-2000

oDIVAMatrixExport void Log()

Takes the natural logarithm of each element.

Returns:
Nothing.
Author:
Lars Pedersen
Version:
7-12-2000

oDIVAMatrixExport void Lt(const double B, CDVector& C ) const

Compares of a double and a vector and returns the result as a binary matrix i.e.:

C(i) = 1 if A(i) < B C(i) = 0 else

Corresponding MatLab function LT()

Returns:
Nothing.
Parameters:
B - Input double.
C - Output result vector.
Author:
Lars Pedersen
Version:
7-12-2000

oDIVAMatrixExport void Lt( const CDVector& B, CDVector& C ) const

Compares of a vector and a vector and returns the result as a binary matrix i.e.:

C(i) = 1 if A(i) < B C(i) = 0 else

Corresponding MatLab function LT()

Returns:
Nothing.
Parameters:
B - Input vector.
C - Output result vector.
Author:
Lars Pedersen
Version:
7-12-2000

oDIVAMatrixExport double Max() const

Finds the maximum element in the vector.

Returns:
The maximum value of the elements.
Author:
Rune Fisker
Version:
3-5-1999

oDIVAMatrixExport double Mean() const

Calculates the mean value of the vector.

Returns:
The mean value.
Author:
Rune Fisker
Version:
3-5-1999

oDIVAMatrixExport double Min() const

Finds the minimum element in the vector.

Returns:
The minimum value of the elements.
Author:
Rune Fisker
Version:
3-5-1999

oDIVAMatrixExport double Min(int& iPos) const

Finds the minimum element in the vector and its position.

Returns:
The minimum value of the elements and its position.
Author:
Rune Fisker
Version:
1-9-1999

oDIVAMatrixExport void Ne(const double B, CDVector& C ) const

Compares of a double and a vector and returns the result as a binary matrix i.e.:

C(i) = 1 if A(i) != B C(i) = 0 else

Corresponding MatLab function NE()

Returns:
Nothing.
Parameters:
B - Input double.
C - Output result vector.
Author:
Lars Pedersen
Version:
7-12-2000

oDIVAMatrixExport void Ne( const CDVector& B, CDVector& C ) const

Compares of a vector and a vector and returns the result as a binary matrix i.e.:

C(i) = 1 if A(i) != B C(i) = 0 else

Corresponding MatLab function NE()

Returns:
Nothing.
Parameters:
B - Input vector.
C - Output result vector.
Author:
Lars Pedersen
Version:
7-12-2000

oDIVAMatrixExport double Norm1() const

Calculates the one-norm (L1) of the vector. Also known as the city block metric.

L1(v) = |x_1| + |x_2| .. + |x_n|

Returns:
The L1 norm.
Author:
Mikkel B. Stegmann
Version:
2-5-2001

oDIVAMatrixExport double Norm2() const

Calculates the two-norm (L2) of the vector. Also known as the Euclidean length.

L2(v) = sqrt( x_1^2 + x_2^2 .. + x_n^2 )

Returns:
The L2 norm.
Author:
Mikkel B. Stegmann
Version:
2-5-2001

oDIVAMatrixExport double NormInf() const

Calculates the infinity-norm (Linf) of the vector. Also known as the Chebyshev Norm.

Linf(v) = max( |x_1|, |x_2| ... , |x_n| )

Returns:
The L2 norm.
Author:
Mikkel B. Stegmann
Version:
2-5-2001

oDIVAMatrixExport void Normalize2()

Normalizes the vector to unit length, using the 2-norm.

Returns:
Nothing.
Author:
Mikkel B. Stegmann
Version:
2-5-2001

oDIVAMatrixExport void Pow(double dP)

Takes the power 'dP' of each element.

Returns:
Nothing.
Parameters:
dP - The exponent.
Author:
Rune Fisker
Version:
1-5-1999

oDIVAMatrixExport void Rand()

Inserts uniformly distributed random numbers in the range [0;1].

Returns:
Nothing.
Author:
Mikkel B. Stegmann
Version:
3-9-2001

oDIVAMatrixExport void Reverse()

Reverses the vector.

Returns:
Nothing.
Author:
Mikkel B. Stegmann
Version:
3-5-2000

oDIVAMatrixExport double Skewness() const

Calculates the skewness the vector.

Returns:
The skewness.
Author:
Rune Fisker
Version:
3-5-1999

oDIVAMatrixExport void Sort( bool ascending )

Sorts the vector in either ascending (default) or descending order. Implemented using the standard quicksort, qsort().

Returns:
Nothing.
Parameters:
ascending - If true (default) the vector is sorted in ascending order. If false its sorted in descending order.
Author:
Mikkel B. Stegmann
Version:
2-2-2001

oDIVAMatrixExport void Sqr()

Squares each element.

Returns:
Nothing.
Author:
Rune Fisker
Version:
1-5-1999

oDIVAMatrixExport void Sqrt()

Takes the square root of each element.

Returns:
Nothing.
Author:
Rune Fisker
Version:
1-5-1999

oDIVAMatrixExport double Std() const

Calculates the standard deviation the vector.

Returns:
The skewness.
Author:
Rune Fisker
Version:
3-5-1999

oDIVAMatrixExport double Sum() const

Calculates the sum of the vector.

Returns:
The sum.
Author:
Rune Fisker
Version:
3-5-1999

oDIVAMatrixExport void ToFile( const CDString& sFilename ) const

Writes the vector to disk in binary format. Use 'readbin.m' to load such a file into MatLab (placed in the diva/matlab dir).

Returns:
Nothing.
Parameters:
sFilename - Output file name.
Author:
Mikkel B. Stegmann
Version:
2-5-2001

oDIVAMatrixExport void ToFile( FILE *fh ) const

Writes the vector to disk in binary format. Use 'readbin.m' to load such a file into MatLab (placed in the diva/matlab dir).

Returns:
Nothing.
Parameters:
fh - Open file handle (opened using fopen())
Author:
Mikkel B. Stegmann
Version:
2-5-2001

oDIVAMatrixExport void ToMatlab(const CDString& sFilename, const CDString& sName, const CDString& sComment, bool fAppend) const

Writes the vector to disk in MatLab (.m) format. To read the vector into MatLab write e.g. 'my_vector.m' at the MatLab prompt.

Notice that this should be used for storage a (really) large vectors, due to the computational and i/o overhead induced by the simple MatLab text format.

Also, remember that MatLab can't read (.m) files with lines longer than 4096 bytes.

If no communication with MatLab is needed, but merely to/from disk functionality within a DIVA program, it is suggested to use the fast binary i/o methods ToFile() and FromFile().

Returns:
Nothing.
Parameters:
sFilename - Output file name. Should have the extension '.m'.
sName - Name of destination matlab variable.
sComment - Optional comment inside the file.
fAppend - If true, the vector is appended to the file 'sFilename'.
Author:
Henrik Aanęs
Version:
2-5-2001

oDIVAMatrixExport CDString ToString(const bool fNewline) const

Returns a string representing the vector.

Returns:
The output string.
Parameters:
fNewline - If true, the string is terminated with a new line.
Author:
Rune Fisker
Version:
1-5-1999

oDIVAMatrixExport double Var() const

Calculates the variance the vector.

Returns:
The variance.
Author:
Rune Fisker
Version:
3-5-1999

oDIVAMatrixExport CDVector& operator=(const CVisDVector &vIn)

Assignment operator.

Returns:
This.
Parameters:
vIn - Input vector.
Author:
Rune Fisker
Version:
2-5-2001

oDIVAMatrixExport CDVector& operator=(const CDVector &vIn)

Assignment operator.

Returns:
This.
Parameters:
vIn - Input vector.
Author:
Rune Fisker
Version:
2-5-2001

oDIVAMatrixExport CDVector& operator=(double value)

Assignment operator. Sets all element to the input value.

Returns:
This.
Parameters:
vIn - Input double.
Author:
Rune Fisker
Version:
2-5-2001


This class has no child classes.
Author:
Rune Fisker, Mikkel B. Stegmann, Henrik Aanęs, Lars Pedersen et al.
Version:
2-5-2001
See Also:
CDMatrix


Back DIVA Reference Manual The DIVA-Site