>
>#include <rw/dskewmat.h> // DoubleSkewMat #include <rw/fskewmat.h> // FloatSkewMat #include <rw/cskewmat.h> // DComplexSkewMat DoubleSkewMat A;
The classes {TYPE}SkewMat encapsulate skew symmetric matrices. A skew symmetric matrix is defined by the requirement that Aij = -Aji. This strict definition implies that the diagonal entries must be 0. This requirement is relaxed by the Rogue Wave skew symmetric matrix classes, which require only that Aij = -Aji for the off-diagonal elements; in other words, the diagonal need not be 0. Skew symmetric matrices with nonzero diagonals are sometimes useful, for example, as rotation matrices in computer graphics applications.
>#include <rw/fskewmat.h> main() { FloatSkewMat T(3,3); RWMathVec<float> x(3); RWMathVec<float> Tx = product(T,x); }>
The upper triangle of the matrix is stored in column major order. The lower triangle is then calculated implicitly.
The data is stored in the following order:
[ A11 A12 A22 A13 A23 A33 ... A1n A2n A3n ... Ann ]
The mapping between the array and storage vector is as follows:
>
DoubleSkewMat(); FloatSkewMat(); DComplexSkewMat();
Default constructor. Builds a matrix of size 0 x 0. This constructor is necessary to declare a matrix with no explicit constructor or to declare an array of matrices.
DoubleSkewMat(const DoubleSkewMat& A); FloatSkewMat(const FloatSkewMat& A); DComplexSkewMat(const DComplexSkewMat& A);
Build a copy of its argument, A. Note that the new matrix references A's data. To construct a matrix with its own copy of the data, use either the copy or deepenShallowCopy member functions.
DoubleSkewMat(unsigned n, unsigned n); FloatSkewMat(unsigned n, unsigned n); DComplexSkewMat(unsigned n, unsigned n);
Defines an uninitialized matrix of size n x n. Both arguments must be equal or a runtime error occurs. This constructor is used, rather than a constructor that takes only a single argument, to avoid type conversion problems.
DoubleSkewMat(const RWMathVec<double>& vd, unsigned n, unsigned n); FloatSkewMat(const RWMathVec<float>& vd, unsigned n, unsigned n); DComplexSkewMat(const RWMathVec<DComplex>& vd, unsigned n, unsigned n);
Constructs a size n x n matrix using the data in the passed vector. This data must be stored in the format described in the Storage Scheme section. The resultant matrix references the data in vector vd.
DComplexSkewMat(const DoubleSkewMat& re); DComplexSkewMat(const DoubleSkewMat& re, const DoubleSymMat& im);
Constructs a complex matrix from the real and imaginary parts supplied. If no imaginary part is supplied, it is assumed to be 0. Note that the imaginary part of a complex skew-symmetric matrix is symmetric, not skew-symmetric.
DoubleSkewMat(const FloatSkewMat&);
Constructs a copy of the argument matrix with double precision entries.
NGFloatRef FloatSkewMat::bcref(int i, int j); NGDoubleRef DoubleSkewMat::bcref(int i, int j); NGDComplexRef DComplexSkewMat::bcref(int i, int j);
Returns a reference to the ijth element of the matrix, after doing bounds checking.
void FloatSkewMat::bcset(int i, int j, float x); void DoubleSkewMat::bcset(int i, int j, double x); void DComplexSkewMat::bcset(int i, int j, DComplex x);
Sets the ijth element of the matrix equal to x, after doing bounds checking.
float FloatSkewMat::bcval(int i, int j); double DoubleSkewMat::bcval(int i, int j); DComplex DComplexSkewMat::bcval(int i, int j);
Returns the value of the ijth element of the matrix, after doing bounds checking.
unsigned FloatSkewMat::binaryStoreSize(); unsigned DoubleSkewMat::binaryStoreSize(); unsigned DComplexSkewMat::binaryStoreSize();
Returns the number of bytes that it would take to write the matrix to a file using saveOn.
unsigned FloatSkewMat::cols(); unsigned DoubleSkewMat::cols(); unsigned DComplexSkewMat::cols();
Returns the number of columns in the matrix.
FloatSkewMat FloatSkewMat::copy(); DoubleSkewMat DoubleSkewMat::copy(); DComplexSkewMat DComplexSkewMat::copy();
Creates a copy of this matrix with distinct data. The stride of the data vector in the new matrix is guaranteed to be 1.
float* FloatSkewMat::data(); double* DoubleSkewMat::data(); DComplex* DComplexSkewMat::data();
Returns a pointer to the first item of data in the vector storing the matrix's data. You can use this (with caution!) to pass the matrix's data to C or FORTRAN subroutines. Be aware that the stride of the data vector may not be 1.
RWMathVec<float> FloatSkewMat::dataVec(); RWMathVec<double> DoubleSkewMat::dataVec(); RWMathVec<DComplex> DComplexSkewMat::dataVec();
Returns the matrix's data vector. This is where the explicitly stored entries in the matrix are kept.
FloatSkewMat FloatSkewMat::deepCopy(); DoubleSkewMat DoubleSkewMat::deepCopy(); DComplexSkewMat DComplexSkewMat::deepCopy();
Creates a copy of this matrix with distinct data. The stride of the data vector in the new matrix is guaranteed to be 1.
void FloatSkewMat::deepenShallowCopy(); void DoubleSkewMat::deepenShallowCopy(); void DComplexSkewMat::deepenShallowCopy();
Ensures that the data in the matrix is not shared by any other matrix or vector. Also ensures that the stride in the data vector is equal to 1. If necessary, a new copy of the data vector is made.
FloatSkewMat FloatSkewMat::leadingSubmatrix(int k); DoubleSkewMat DoubleSkewMat::leadingSubmatrix(int k); DComplexSkewMat DComplexSkewMat::leadingSubmatrix(int k);
Returns the k x k upper left corner of the matrix. The submatrix and the matrix share the same data.
void FloatSkewMat::printOn(ostream&); void DoubleSkewMat::printOn(ostream&); void DComplexSkewMat::printOn(ostream&);
Prints the matrix to an output stream in human readable format.
NGFloatRef FloatSkewMat::ref(int i, int j); NGDoubleRef DoubleSkewMat::ref(int i, int j); NGDComplexRef DComplexSkewMat::ref(int i, int j);
Returns a reference to the ijth element of the matrix. Bounds checking is done if the preprocessor symbol BOUNDS_CHECK is defined when the header file is read. The member function bcref does the same thing with guaranteed bounds checking.
FloatSkewMat FloatSkewMat::reference(FloatSkewMat&); DoubleSkewMat DoubleSkewMat::reference(DoubleSkewMat&); DComplexSkewMat DComplexSkewMat::reference(DComplexSkewMat&);
Makes this matrix a reference to the argument matrix. The two matrices share the same data. The matrices do not have to be the same size before calling reference. To copy a matrix into another of the same size, use the operator= member operator.
void DoubleSkewMat::resize(unsigned n, unsigned n); void FloatSkewMat::resize(unsigned n, unsigned n); void DComplexSkewMat::resize(unsigned n, unsigned n);
Resizes the matrix. Any new entries in the matrix are set to 0. Both arguments must be the same.
void DoubleSkewMat::restoreFrom(RWFile&); void FloatSkewMat::restoreFrom(RWFile&); void DComplexSkewMat::restoreFrom(RWFile&);
Reads in a matrix from an RWFile. The matrix must have been stored to the file using the saveOn member function.
void DoubleSkewMat::restoreFrom(RWvistream&); void FloatSkewMat::restoreFrom(RWvistream&); void DComplexSkewMat::restoreFrom(RWvistream&);
Reads in a matrix from an RWvistream, the Rogue Wave virtual input stream class. The matrix must have been stored to the stream using the saveOn member function.
unsigned FloatSkewMat::rows(); unsigned DoubleSkewMat::rows(); unsigned DComplexSkewMat::rows();
Returns the number of rows in the matrix.
void DoubleSkewMat::saveOn(RWFile&); void FloatSkewMat::saveOn(RWFile&); void DComplexSkewMat::saveOn(RWFile&);
Stores a matrix to an RWFile. The matrix can be read using the restoreFrom member function.
void DoubleSkewMat::saveOn(RWvostream&); void FloatSkewMat::saveOn(RWvostream&); void DComplexSkewMat::saveOn(RWvostream&);
Stores a matrix to an RWvostream, the Rogue Wave virtual output stream class. The matrix can be read using the restoreFrom member function.
void FloatSkewMat::scanFrom(istream&); void DoubleSkewMat::scanFrom(istream&); void DComplexSkewMat::scanFrom(istream&);
Reads a matrix from an input stream. The format of the matrix is the same as the format output by the printTo member function. Below is a sample matrix that could be input. Note that extra white space and any text preceding the dimension specification are ignored. Only the skew symmetric part of the matrix is used.
3x3 [ 4 5 7 -5 9 5 -7 -5 3 ]
void FloatSkewMat::set(int i, int j, float x); void DoubleSkewMat::set(int i, int j, double x); void DComplexSkewMat::set(int i, int j, DComplex x);
Sets the ijth element of the matrix equal to x. Bounds checking is done if the preprocessor symbol BOUNDS_CHECK is defined when the header file is read. The member function bcset does the same thing with guaranteed bounds checking.
float FloatSkewMat::val(int i, int j); double DoubleSkewMat::val(int i, int j); DComplex DComplexSkewMat::val(int i, int j);
Returns the value of the ijth element of the matrix. Bounds checking is done if the preprocessor symbol BOUNDS_CHECK is defined when the header file is read. The member function bcval does the same thing with guaranteed bounds checking.
FloatSkewMat FloatSkewMat::zero(); DoubleSkewMat DoubleSkewMat::zero(); DComplexSkewMat DComplexSkewMat::zero();
Sets every element of the matrix to 0.
NGDoubleRef FloatSkewMat::operator()(int i, int j); double FloatSkewMat::operator()(int i, int j) const; NGFloatRef DoubleSkewMat::operator()(int i, int j); float DoubleSkewMat::operator()(int i, int j) const; NGDComplexRef DComplexSkewMat::operator()(int i, int j); DComplex DComplexSkewMat::operator()(int i, int j) const;
Accesses the ijth element. If the matrix is not a const matrix, a reference type is returned, so this operator can be used for assigning or accessing an element. In this case, using this operator is equivalent to calling the ref member function. If the matrix is a const matrix, a value is returned, so this operator can be used only for accessing an element. In this case, using this operator is equivalent to calling the val member function. Bounds checking is done if the preprocessor symbol BOUNDS_CHECK is defined before including the header file.
DoubleSkewMat& operator=(const DoubleSkewMat& A); FloatSkewMat& operator=(const FloatSkewMat& A); DComplexSkewMat& operator=(const DComplexSkewMat& A);
Sets the matrix elements equal to the elements of A. The two matrices must be the same size. To make the matrix reference the same data as A, use the reference member function.
DoubleSkewMat& operator==(const DoubleSkewMat& A); FloatSkewMat& operator==(const FloatSkewMat& A); DComplexSkewMat& operator==(const DComplexSkewMat& A); DoubleSkewMat& operator!=(const DoubleSkewMat& A); FloatSkewMat& operator!=(const FloatSkewMat& A); DComplexSkewMat& operator!=(const DComplexSkewMat& A);
Boolean operators. Two matrices are considered equal if they have the same size and their elements are all exactly the same. Be aware that floating point arithmetic is not exact; matrices that are theoretically equal are not always numerically equal.
DoubleSkewMat& operator*=(double x); FloatSkewMat& operator*=(float x); DComplexSkewMat& operator*=(DComplex x); DoubleSkewMat& operator/=(double x); FloatSkewMat& operator/=(float x); DComplexSkewMat& operator/=(DComplex x);
Performs the indicated operation on each element of the matrix.
DoubleSkewMat& operator+=(const DoubleSkewMat& A); FloatSkewMat& operator+=(const FloatSkewMat& A); DComplexSkewMat& operator+=(const DComplexSkewMat& A); DoubleSkewMat& operator-=(const DoubleSkewMat& A); FloatSkewMat& operator-=(const FloatSkewMat& A); DComplexSkewMat& operator-=(const DComplexSkewMat& A); DoubleSkewMat& operator*=(const DoubleSkewMat& A); FloatSkewMat& operator*=(const FloatSkewMat& A); DComplexSkewMat& operator*=(const DComplexSkewMat& A); DoubleSkewMat& operator/=(const DoubleSkewMat& A); FloatSkewMat& operator/=(const FloatSkewMat& A); DComplexSkewMat& operator/=(const DComplexSkewMat& A);
Performs element-by-element arithmetic on the data in the matrices. In particular, note that operator*= does element-by-element multiplication, not inner-product style matrix multiplication. You can use the product global function to do matrix-matrix inner product multiplication.
DoubleSkewMat operator+(const DoubleSkewMat&); FloatSkewMat operator+(const FloatSkewMat&); DComplexSkewMat operator+(const DComplexSkewMat&); DoubleSkewMat operator-(const DoubleSkewMat&); FloatSkewMat operator-(const FloatSkewMat&); DComplexSkewMat operator-(const DComplexSkewMat&);
Unary plus and minus operators. Each operator returns a copy of the matrix or its negation.
DoubleSkewMat operator+(const DoubleSkewMat&,
const DoubleSkewMat&); FloatSkewMat operator+(const FloatSkewMat&,
const FloatSkewMat&); DComplexSkewMat operator+(const DComplexSkewMat&,
const DComplexSkewMat&); DoubleSkewMat operator-(const DoubleSkewMat&,
const DoubleSkewMat&); FloatSkewMat operator-(const FloatSkewMat&,
const FloatSkewMat&); DComplexSkewMat operator-(const DComplexSkewMat&,
const DComplexSkewMat&); DoubleSkewMat operator*(const DoubleSkewMat&,
const DoubleSkewMat&); FloatSkewMat operator*(const FloatSkewMat&,
const FloatSkewMat&); DComplexSkewMat operator*(const DComplexSkewMat&,
const DComplexSkewMat&); DoubleSkewMat operator/(const DoubleSkewMat&,
const DoubleSkewMat&); FloatSkewMat operator/(const FloatSkewMat&,
const FloatSkewMat&); DComplexSkewMat operator/(const DComplexSkewMat&,
const DComplexSkewMat&);
Performs element-by-element operations on the arguments. To do inner product matrix multiplication, you can use the product global function.
DoubleSkewMat operator*(double,const DoubleSkewMat&); DoubleSkewMat operator*(const DoubleSkewMat&,double); FloatSkewMat operator*(float,const FloatSkewMat&); FloatSkewMat operator*(const FloatSkewMat&,float); DComplexSkewMat operator*(DComplex,const DComplexSkewMat&); DComplexSkewMat operator*(const DComplexSkewMat&,DComplex); DoubleSkewMat operator/(double,const DoubleSkewMat&); DoubleSkewMat operator/(const DoubleSkewMat&,double); FloatSkewMat operator/(float,const FloatSkewMat&); FloatSkewMat operator/(const FloatSkewMat&,float); DComplexSkewMat operator/(DComplex,const DComplexSkewMat&); DComplexSkewMat operator/(const DComplexSkewMat&,DComplex);
Performs element-by-element operations on the arguments.
ostream& operator<<(ostream& s, const DoubleSkewMat&); ostream& operator<<(ostream& s, const FloatSkewMat&); ostream& operator<<(ostream& s, const DComplexSkewMat&);
Writes the matrix to the stream. This is equivalent to calling the printOn member function.
istream& operator>>(istream& s, const DoubleSkewMat&); istream& operator>>(istream& s, const FloatSkewMat&); istream& operator>>(istream& s, const DComplexSkewMat&);
Reads the matrix from the stream. This is equivalent to calling the scanFrom member function.
DoubleSymMat abs(const DoubleSkewMat&); FloatSymMat abs(const FloatSkewMat&); DoubleSymMat abs(const DComplexSkewMat&);
Returns a matrix whose entries are the absolute value of the argument. The absolute value of a complex number is considered to be the sum of the absolute values of its real and imaginary parts. To get the norm of a complex matrix, you can use the norm function.
DComplexSkewMat conj(const DComplexSkewMat& A);
Returns a matrix where each element is the complex conjugate of the corresponding element in the matrix A.
DoubleSymMat imag(const DComplexSkewMat& A);
Returns a matrix where each element is the imaginary part of the corresponding element in the matrix A.
DoubleSkewMat norm(const DComplexSkewMat& A);
Returns a matrix where each element is the norm (magnitude) of the corresponding element in the matrix A.
RWMathVec<double> product(const DoubleSkewMat& A, const RWMathVec<double>& x); RWMathVec<float> product(const FloatSkewMat& A, const RWMathVec<float>& x); RWMathVec<DComplex> product(const DComplexSkewMat& A,const RWMathVec<DComplex>& x);
Returns the inner product (matrix-vector product) of A and x.
RWMathVec<double> product(const RWMathVec<double>& x, const DoubleSkewMat& A); RWMathVec<float> product(const RWMathVec<float>& x, const FloatSkewMat& A); RWMathVec<DComplex> product(const RWMathVec<DComplex>& x,
const DComplexSkewMat& A);
Returns the inner product (matrix-vector product) of x and A. This is equal to the product of A transpose and x.
DoubleSkewMat real(const DComplexSkewMat& A);
Returns a matrix where each element is the real part of the corresponding element in the matrix A.
FloatSkewMat toFloat(const DoubleSkewMat&);
Converts a matrix from double to float precision. The conversion is done using a constructor.
DoubleSymMat toSkewMat(const RWGenMat<double>&, RWBoolean keepMainDiag=TRUE); FloatSymMat toSkewMat(const RWGenMat<float>&, RWBoolean keepMainDiag=TRUE); DComplexSymMat toSkewMat(const RWGenMat<DComplex>&,RWBoolean keepMainDiag=TRUE);
Extracts the skew symmetric part of a square matrix. The skew symmetric part of a matrix A is (A-AT)/2. If the argument keepMainDiag is set to TRUE (as is the default) then the main diagonal of A is kept, even though it should be 0 according to the strict mathematical definition of skew-symmetry.
DoubleSkewMat transpose(const DoubleSkewMat&); FloatSkewMat transpose(const FloatSkewMat&); DComplexSkewMat transpose(const DComplexSkewMat&);
Returns the transpose of the argument matrix.
©Copyright 1999, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.