Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages  

rdMtx Class Reference

A class for performing vector and matrix operations. More...

#include <rdMtx.h>

List of all members.

Static Public Member Functions

double Angle (const double *aV1, const double *aV2)
 Find the angle between two vectors: theta = acos( aV1*aV2/(|aV1|*|aV2|)).

double Normalize (int aN, const double aV[], double rV[])
 Normalize a vector.

double Magnitude (int aN, const double aV[])
 Compute the magnitude of a vector.

double DotProduct (int aN, const double aV1[], const double aV2[])
 Compute the dot product of two vectors.

int CrossProduct (double *aV1, double *aV2, double *aV)
 Compute the cross product of two vectors.

void Interpolate (int aN, double aT1, double *aY1, double aT2, double *aY2, double t, double *aY)
 Linearly interpolate or extrapolate an array of data.

double Interpolate (double aT1, double aY1, double aT2, double aY2, double t)
 Linearly interpolate or extrapolate two data points.

void Translate (double aX, double aY, double aZ, const double aP[3], double rP[3])
 Translate a point by a specified amount.

void Rotate (int aXYZ, double aRadians, const double aP[3], double rP[3])
 Rotate a point about the X, Y, or Z axis by a specified amount.

void Rotate (const double aAxis[3], double aRadians, const double aP[3], double rP[3])
 Rotate a point about a specified axis by a specified amount.

void RotateDeg (int aXYZ, double aDegrees, const double aP[3], double rP[3])
 Rotate a point about the X axis by a specified amount.

void RotateDeg (const double aAxis[3], double aDegrees, const double aP[3], double rP[3])
 Rotate a point about a specified axis by a specified amount.

int Identity (int aNR, double *rI)
 Assign a square matrix to the identidy matrix: rI = I.

int Assign (int aNR, int aNC, double aScalar, double *rM)
 Assign all elements of a matrix to a specified value: rMij = aScalar.

int Assign (int aNR, int aNC, const double *aM, double *rM)
 Assign two matrices: rM = aM.

int Add (int aNR, int aNC, const double *aM1, double aScalar, double *aM)
 Add a scalar to a matrix.

int Add (int aNR, int aNC, const double *aM1, const double *aM2, double *aM)
 Add two matrices.

int Subtract (int aNR, int aNC, const double *aM1, const double *aM2, double *aM)
 Subtract two matrices.

int Multiply (int aNR, int aNC, const double *aM, double aScalar, double *rM)
 Multiply a matrix by a scalar.

int Multiply (int aNR1, int aNCR, int aNC2, const double *aM1, const double *aM2, double *aM)
 Multiply two matrices.

int Invert (int aN, const double *aM, double *aMInv)
 Compute the inverse of a matrix.

int Transpose (int aNR, int aNC, const double *aM, double *aMT)
 Transpose a matrix.

void Print (int aNR, int aNC, const double *aM, int aPrecision=8)
 Print a matrix.

int FindIndex (int aStartIndex, double aTime, int aNT, double *aT)
 Starting at aIndex, move through the array aT and find the index of the element whose value is closest to but less than aTime.

int FindIndexLess (int aNX, double *aX, double aValue)
 Scan from the beginning of the array, aX, and find the index of the element such that the element's value is less than or equal to aValue and the next element's value is greater than aValue.

int FindIndexGreater (int aNX, double *aX, double aValue)
 Scan from the end of the array, aX, and find the index of the element such that the element's value is greater than or equal to aValue and such that the next element's value is less than aValue.

int ComputeIndex (int i2, int n1, int i1)
 Compute the index for an element of a three dimensional matrix as though the matrix were laid out in one dimension.

int ComputeIndex (int i3, int n2, int i2, int n1, int i1)
 Compute the index for an element of a three dimensional matrix as though the matrix were laid out in one dimension.

void GetDim3 (int n3, int n2, int n1, int i2, int i1, double *m, double *a)
 Get elements *,i2,i1 of a three dimensional matrix as an array, where * varies along the 3rd dimension, i2 the 2nd, and i1 the 1st.

void SetDim3 (int n3, int n2, int n1, int i2, int i1, double *m, double *a)
 Set elements *,i2,i1 of a three dimensional matrix to the values in array a, where * varies along the 3rd dimension, i2 the 2nd, and i1 the 1st.

int EnsureWorkSpaceCapacity (int aN)
 Ensure that the work space is at least of size aN.

int EnsurePointerSpaceCapacity (int aN)
 Ensure that the pointer spaces is at least of size aN.

void FreeWorkAndPointerSpaces ()
 Free the work and pointer spaces.


Static Private Attributes

int _PSpaceSize = 0
int _WSpaceSize = 0
double ** _P1Space = NULL
double ** _P2Space = NULL
double * _WSpace = NULL


Detailed Description

A class for performing vector and matrix operations.

Most all the methods in this class are static.


Member Function Documentation

int rdMtx::Add int  aNR,
int  aNC,
const double *  aM1,
const double *  aM2,
double *  aM
[static]
 

Add two matrices.

If the arguments are not valid, then a -1 is returned. Othersise, 0 is returned.

It is permissible for aM to coincide with either aM1 or aM2.

int rdMtx::Add int  aNR,
int  aNC,
const double *  aM1,
double  aScalar,
double *  aM
[static]
 

Add a scalar to a matrix.

If the arguments are not valid, then a -1 is returned. Othersise, 0 is returned.

It is permissible for aM to coincide with aM1.

double rdMtx::Angle const double *  aV1,
const double *  aV2
[static]
 

Find the angle between two vectors: theta = acos( aV1*aV2/(|aV1|*|aV2|)).

Parameters:
aV1 Vector 1.
aV2 Vector 2.
Returns:
Angle between two vectors in radians.

int rdMtx::Assign int  aNR,
int  aNC,
const double *  aM,
double *  rM
[static]
 

Assign two matrices: rM = aM.

Parameters:
aNR Number of rows in the matrices.
aNC Number of columns in the matrices.
aM Input matrix.
rM Ouput matrix (rM = aM).
Returns:
0 on success, -1 on error.

int rdMtx::Assign int  aNR,
int  aNC,
double  aScalar,
double *  rM
[static]
 

Assign all elements of a matrix to a specified value: rMij = aScalar.

It is permissible for

Parameters:
aNR Number of rows in the matrix.
aNC Number of columns in the matrix.
aScalar Scalar value to which to set the element of the matrix.
rM Ouput matrix (rMij = aScalar for all i,j).
Returns:
0 on success, -1 on error.

int rdMtx::CrossProduct double *  aV1,
double *  aV2,
double *  aV
[static]
 

Compute the cross product of two vectors.

If the arguments are not valid (aR=aS=NULL), -1 is returned.

double rdMtx::DotProduct int  aN,
const double  aV1[],
const double  aV2[]
[static]
 

Compute the dot product of two vectors.

If the arguments are not valid (aV1=aV2=NULL), 0.0 is returned.

int rdMtx::EnsurePointerSpaceCapacity int  aN  )  [static]
 

Ensure that the pointer spaces is at least of size aN.

If the capacity could not be increased to aN, -1 is returned. Otherwise, 0 is returned.

int rdMtx::EnsureWorkSpaceCapacity int  aN  )  [static]
 

Ensure that the work space is at least of size aN.

If the capacity could not be increased to aN, -1 is returned. Otherwise, 0 is returned.

int rdMtx::FindIndex int  aStartIndex,
double  aTime,
int  aNT,
double *  aT
[static]
 

Starting at aIndex, move through the array aT and find the index of the element whose value is closest to but less than aTime.

It is assumed that the array aT is monotonically increasing and has at least 2 elements.

If aTime lies outside the interval of aT, the index of either the first point or second to last point is returned depending on whether aTime is below or above the interval of aT.

-1 is if an error is encountered.

int rdMtx::FindIndexGreater int  aNX,
double *  aX,
double  aValue
[static]
 

Scan from the end of the array, aX, and find the index of the element such that the element's value is greater than or equal to aValue and such that the next element's value is less than aValue.

If no value in the array is less than aValue, the index of the first element in the array is returned.

If no value in the array is greater than or equal to aValue, -1 is returned.

int rdMtx::FindIndexLess int  aNX,
double *  aX,
double  aValue
[static]
 

Scan from the beginning of the array, aX, and find the index of the element such that the element's value is less than or equal to aValue and the next element's value is greater than aValue.

If no value in the array is greater than aValue, the index of the last element in the array is returned.

If no value in the array is less than or equal to aValue, -1 is returned.

void rdMtx::GetDim3 int  n3,
int  n2,
int  n1,
int  i2,
int  i1,
double *  m,
double *  a
[static]
 

Get elements *,i2,i1 of a three dimensional matrix as an array, where * varies along the 3rd dimension, i2 the 2nd, and i1 the 1st.

The first dimension is the dimension which varies most rapidly when the data is laid out in a one dimensional array, and the second dimension is the one which varies second most rapidly, and so on.

For now, it is assumed that parameter a has enough memory allocated to hold the array.

int rdMtx::Identity int  aNR,
double *  rI
[static]
 

Assign a square matrix to the identidy matrix: rI = I.

The matrix must be square.

Parameters:
aN Dimension of the matrix (aN=nRows, aN=nCols).
rI Ouput identity matrix (rI = I).
Returns:
0 on success, -1 on error.

int rdMtx::Invert int  aN,
const double *  aM,
double *  aMInv
[static]
 

Compute the inverse of a matrix.

If the arguments are not valid (aM==NULL), then -1 is returned. If the matrix is not invertible, then -2 is returned. Othersise, 0 is returned.

It is permissible for aM to overlap in memory with aMInv.

double rdMtx::Magnitude int  aN,
const double  aV[]
[static]
 

Compute the magnitude of a vector.

Parameters:
aV Vector.
Returns:
Square root of the dot product aV*aV.

int rdMtx::Multiply int  aNR1,
int  aNCR,
int  aNC2,
const double *  aM1,
const double *  aM2,
double *  aM
[static]
 

Multiply two matrices.

If the arguments are not valid (aM1,aM2,aM==NULL), then a -1 is returned. Othersise, 0 is returned.

It is permissible for aM to overlap with either aM1 or aM2.

int rdMtx::Multiply int  aNR,
int  aNC,
const double *  aM,
double  aScalar,
double *  rM
[static]
 

Multiply a matrix by a scalar.

It is permissible for aM and rM to coincide in memory.

Parameters:
aNR Number of rows in aM.
aNC Number of columns in aM.
aM Matirx laid out in memory as aM[aNR][aNC].
aScalar Scalar value by which to multiply aM.
rM Result of aScalar * aM.
Returns:
-1 if an error is encountered, 0 otherwise.

double rdMtx::Normalize int  aN,
const double  aV[],
double  rV[]
[static]
 

Normalize a vector.

If aV has a magnitude of zero, all elements of rV are set to 0.0. It is permissible for aV and rV to coincide in memory.

Parameters:
aV Vector to be normalized.
rV Result of the normalization.
Returns:
Magnitude of aV.

void rdMtx::Rotate const double  aAxis[3],
double  aRadians,
const double  aP[3],
double  rP[3]
[static]
 

Rotate a point about a specified axis by a specified amount.

Parameters:
aAxis Axis about which to rotate. The axis is not assumed to be a unit vector; however, if the axis is the zero vector, no rotation is performed.
aRadians Amount of rotation in radians.
aP Point to rotate.
rP Rotated point. aP and rP may coincide in memory.

void rdMtx::Rotate int  aXYZ,
double  aRadians,
const double  aP[3],
double  rP[3]
[static]
 

Rotate a point about the X, Y, or Z axis by a specified amount.

Parameters:
aXYZ Specify whether to rotate about the X (aXYZ=0), Y (aXYZ=1), or Z (aXYZ=2) axes. If aXYZ is not 0, 1, or 2, no rotation is performed.
aRadians Amount of rotation in radians.
aP Point to rotate.
rP Rotated point. aP and rP may coincide in memory.

void rdMtx::RotateDeg const double  aAxis[3],
double  aDegrees,
const double  aP[3],
double  rP[3]
[static]
 

Rotate a point about a specified axis by a specified amount.

Parameters:
aAxis Axis about which to rotate.
aDegrees Amount of rotation in degrees.
aP Point to rotate.
rP Rotated point. aP and rP may coincide in memory.

void rdMtx::RotateDeg int  aXYZ,
double  aDegrees,
const double  aP[3],
double  rP[3]
[static]
 

Rotate a point about the X axis by a specified amount.

Parameters:
aXYZ Specify whether to rotate about the X (aXYZ=0), Y (aXYZ=1), or Z (aXYZ=2) axis. If aXYZ is not 0, 1, or 2, no rotation is performed.
aDegrees Amount of rotation in degrees.
aP Point to rotate.
rP Rotated point. aP and rP may coincide in memory.

void rdMtx::SetDim3 int  n3,
int  n2,
int  n1,
int  i2,
int  i1,
double *  m,
double *  a
[static]
 

Set elements *,i2,i1 of a three dimensional matrix to the values in array a, where * varies along the 3rd dimension, i2 the 2nd, and i1 the 1st.

The first dimension is the dimension which varies most rapidly when the data is laid out in a one dimensional array, and the second dimension is the one which varies second most rapidly, and so on.

int rdMtx::Subtract int  aNR,
int  aNC,
const double *  aM1,
const double *  aM2,
double *  aM
[static]
 

Subtract two matrices.

If the arguments are not valid, then a -1 is returned. Othersise, 0 is returned.

It is permissible for aM to coincide with either aM1 or aM2.

void rdMtx::Translate double  aX,
double  aY,
double  aZ,
const double  aP[3],
double  rP[3]
[static]
 

Translate a point by a specified amount.

Parameters:
aX Amount to translate in the X direction.
aY Amount to translate in the Y direction.
aZ Amount to translate in the Z direction.
aP Point to translate.
rP Translated point. aP and rP may coincide in memory.

int rdMtx::Transpose int  aNR,
int  aNC,
const double *  aM,
double *  aMT
[static]
 

Transpose a matrix.

If the arguments are invalid (e.g.,aM==NULL), then a -1 is returned. Othersise, 0 is returned.

It is permissible for aM to overlap in memory with aMT.


The documentation for this class was generated from the following files:
Generated on Wed Aug 20 02:17:12 2003 for Simulation Software by doxygen1.3