>
>#include <rw/dltrimat.h> // DoubleLowerTriMat #include <rw/fltrimat.h> // FloatLowerTriMat #include <rw/cltrimat.h> // DComplexLowerTriMat DoubleLowerTriMat d;
A lower triangular matrix is 0 below the diagonal. The classes {TYPE}LowerTriMat encapsulate lower triangular matrices.
>#include <rw/cltrimat.h> main() { DComplexLowerTriMat L(5,5); L.leadingSubmatrix(2).zero(); }>
The matrix is stored row by row. For example, the matrix:
is stored as follows:
[ A11 A12 A22 A13 A23 A33 ... A1n A2n A3n ... Ann ]
The mapping between the array and storage vector is as follows:
>
DoubleLowerTriMat(); FloatLowerTriMat(); DComplexLowerTriMat();
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.
DoubleLowerTriMat(const DoubleLowerTriMat& A); FloatLowerTriMat(const FloatLowerTriMat& A); DComplexLowerTriMat(const DComplexLowerTriMat& A);
Builds 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.
DoubleLowerTriMat(unsigned n, unsigned n); FloatLowerTriMat(unsigned n, unsigned n); DComplexLowerTriMat(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.
DoubleLowerTriMat(const RWMathVec<double>& vd, unsigned n, unsigned n); FloatLowerTriMat(const RWMathVec<float>& vd, unsigned n, unsigned n); DComplexLowerTriMat(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.
DComplexLowerTriMat(const DoubleLowerTriMat& re); DComplexLowerTriMat(const DoubleLowerTriMat& re,
const DoubleLowerTriMat& im);
Constructs a complex matrix from the real and imaginary parts supplied. If no imaginary part is supplied, it is assumed to be 0.
DoubleLowerTriMat(const FloatLowerTriMat&);
Constructs a copy of the argument matrix with double precision entries.
ROFloatRef FloatLowerTriMat::bcref(int i, int j); RODoubleRef DoubleLowerTriMat::bcref(int i, int j); RODComplexRef DComplexLowerTriMat::bcref(int i, int j);
Returns a reference to the ijth element of the matrix, after doing bounds checking.
void FloatLowerTriMat::bcset(int i, int j, float x); void DoubleLowerTriMat::bcset(int i, int j, double x); void DComplexLowerTriMat::bcset(int i, int j,
Sets the ijth element of the matrix equal to x, after doing bounds checking.
float FloatLowerTriMat::bcval(int i, int j); double DoubleLowerTriMat::bcval(int i, int j); DComplex DComplexLowerTriMat::bcval(int i, int j);
Returns the value of the ijth element of the matrix, after doing bounds checking.
unsigned FloatLowerTriMat::binaryStoreSize(); unsigned DoubleLowerTriMat::binaryStoreSize(); unsigned DComplexLowerTriMat::binaryStoreSize();
Returns the number of bytes that it would take to write the matrix to a file using saveOn.
unsigned FloatLowerTriMat::cols(); unsigned DoubleLowerTriMat::cols(); unsigned DComplexLowerTriMat::cols();
Returns the number of columns in the matrix.
FloatLowerTriMat FloatLowerTriMat::copy(); DoubleLowerTriMat DoubleLowerTriMat::copy(); DComplexLowerTriMat DComplexLowerTriMat::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* FloatLowerTriMat::data(); double* DoubleLowerTriMat::data(); DComplex* DComplexLowerTriMat::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> FloatLowerTriMat::dataVec(); RWMathVec<double> DoubleLowerTriMat::dataVec(); RWMathVec<DComplex> DComplexLowerTriMat::dataVec();
Returns the matrix's data vector. This is where the explicitly stored entries in the matrix are kept.
FloatLowerTriMat FloatLowerTriMat::deepCopy(); DoubleLowerTriMat DoubleLowerTriMat::deepCopy(); DComplexLowerTriMat DComplexLowerTriMat::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 FloatLowerTriMat::deepenShallowCopy(); void DoubleLowerTriMat::deepenShallowCopy(); void DComplexLowerTriMat::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.
FloatLowerTriMat FloatLowerTriMat::leadingSubmatrix(int k); DoubleLowerTriMat DoubleLowerTriMat::leadingSubmatrix(int k); DComplexLowerTriMat DComplexLowerTriMat::leadingSubmatrix(int k);
Returns the k x k upper left corner of the matrix. The submatrix and the matrix share the same data.
void FloatLowerTriMat::printOn(ostream&); void DoubleLowerTriMat::printOn(ostream&); void DComplexLowerTriMat::printOn(ostream&);
Prints the matrix to an output stream in human readable format.
ROFloatRef FloatLowerTriMat::ref(int i, int j); RODoubleRef DoubleLowerTriMat::ref(int i, int j); RODComplexRef DComplexLowerTriMat::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.
FloatLowerTriMat FloatLowerTriMat::reference(FloatLowerTriMat&); DoubleLowerTriMat DoubleLowerTriMat::reference(DoubleLowerTriMat&); DComplexLowerTriMat DComplexLowerTriMat::reference(DComplexLowerTriMat&);
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, you can use the operator= member operator.
void DoubleLowerTriMat::resize(unsigned n, unsigned n); void FloatLowerTriMat::resize(unsigned n, unsigned n); void DComplexLowerTriMat::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 DoubleLowerTriMat::restoreFrom(RWFile&); void FloatLowerTriMat::restoreFrom(RWFile&); void DComplexLowerTriMat::restoreFrom(RWFile&);
Reads in a matrix from an RWFile. The matrix must have been stored to the file using the saveOn member function.
void DoubleLowerTriMat::restoreFrom(RWvistream&); void FloatLowerTriMat::restoreFrom(RWvistream&); void DComplexLowerTriMat::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 FloatLowerTriMat::rows(); unsigned DoubleLowerTriMat::rows(); unsigned DComplexLowerTriMat::rows();
Returns the number of rows in the matrix.
void DoubleLowerTriMat::saveOn(RWFile&); void FloatLowerTriMat::saveOn(RWFile&); void DComplexLowerTriMat::saveOn(RWFile&);
Stores a matrix to an RWFile. The matrix can be read using the restoreFrom member function.
void DoubleLowerTriMat::saveOn(RWvostream&); void FloatLowerTriMat::saveOn(RWvostream&); void DComplexLowerTriMat::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 FloatLowerTriMat::scanFrom(istream&); void DoubleLowerTriMat::scanFrom(istream&); void DComplexLowerTriMat::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 lower triangle of the matrix is used.
3x3 [ 4 0 0 -5 9 0 -7 -5 3 ]
void FloatLowerTriMat::set(int i, int j, float x); void DoubleLowerTriMat::set(int i, int j, double x); void DComplexLowerTriMat::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 FloatLowerTriMat::val(int i, int j); double DoubleLowerTriMat::val(int i, int j); DComplex DComplexLowerTriMat::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.
FloatLowerTriMat FloatLowerTriMat::zero(); DoubleLowerTriMat DoubleLowerTriMat::zero(); DComplexLowerTriMat DComplexLowerTriMat::zero();
Sets every element of the matrix to 0.
RODoubleRef FloatLowerTriMat::operator()(int i, int j); double FloatLowerTriMat::operator()(int i, int j) const; ROFloatRef DoubleLowerTriMat::operator()(int i, int j); float DoubleLowerTriMat::operator()int i, int j) const; RODComplexRef DComplexLowerTriMat::operator()(int i, int j); DComplex DComplexLowerTriMat::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.
DoubleLowerTriMat& operator=(const DoubleLowerTriMat& A); FloatLowerTriMat& operator=(const FloatLowerTriMat& A); DComplexLowerTriMat& operator=(const DComplexLowerTriMat& 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.
DoubleLowerTriMat& operator==(const DoubleLowerTriMat& A); FloatLowerTriMat& operator==(const FloatLowerTriMat& A); DComplexLowerTriMat& operator==(const DComplexLowerTriMat& A); DoubleLowerTriMat& operator!=(const DoubleLowerTriMat& A); FloatLowerTriMat& operator!=(const FloatLowerTriMat& A); DComplexLowerTriMat& operator!=(const DComplexLowerTriMat& 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.
DoubleLowerTriMat& operator*=(double x); FloatLowerTriMat& operator*=(float x); DComplexLowerTriMat& operator*=(DComplex x); DoubleLowerTriMat& operator/=(double x); FloatLowerTriMat& operator/=(float x); DComplexLowerTriMat& operator/=(DComplex x);
Performs the indicated operation on each element of the matrix.
DoubleLowerTriMat& operator+=(const DoubleLowerTriMat& A); FloatLowerTriMat& operator+=(const FloatLowerTriMat& A); DComplexLowerTriMat& operator+=(const DComplexLowerTriMat& A); DoubleLowerTriMat& operator-=(const DoubleLowerTriMat& A); FloatLowerTriMat& operator-=(const FloatLowerTriMat& A); DComplexLowerTriMat& operator-=(const DComplexLowerTriMat& A); DoubleLowerTriMat& operator*=(const DoubleLowerTriMat& A); FloatLowerTriMat& operator*=(const FloatLowerTriMat& A); DComplexLowerTriMat& operator*=(const DComplexLowerTriMat& A); DoubleLowerTriMat& operator/=(const DoubleLowerTriMat& A); FloatLowerTriMat& operator/=(const FloatLowerTriMat& A); DComplexLowerTriMat& operator/=(const DComplexLowerTriMat& A);
Performs element-by-element arithmetic on the data in the matrix. 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.
DoubleLowerTriMat operator+(const DoubleLowerTriMat&); FloatLowerTriMat operator+(const FloatLowerTriMat&); DComplexLowerTriMat operator+(const DComplexLowerTriMat&); DoubleLowerTriMat operator-(const DoubleLowerTriMat&); FloatLowerTriMat operator-(const FloatLowerTriMat&); DComplexLowerTriMat operator-(const DComplexLowerTriMat&);
Unary plus and minus operators. Each operator returns a copy of the matrix or its negation.
DoubleLowerTriMat operator+(const DoubleLowerTriMat&,
const DoubleLowerTriMat&); FloatLowerTriMat operator+(const FloatLowerTriMat&,
const FloatLowerTriMat&); DComplexLowerTriMat operator+(const DComplexLowerTriMat&,
const DComplexLowerTriMat&); DoubleLowerTriMat operator-(const DoubleLowerTriMat&,
const DoubleLowerTriMat&); FloatLowerTriMat operator-(const FloatLowerTriMat&,
const FloatLowerTriMat&); DComplexLowerTriMat operator-(const DComplexLowerTriMat&,
const DComplexLowerTriMat&); DoubleLowerTriMat operator*(const DoubleLowerTriMat&,
const DoubleLowerTriMat&); FloatLowerTriMat operator*(const FloatLowerTriMat&,
const FloatLowerTriMat&); DComplexLowerTriMat operator*(const DComplexLowerTriMat&,
const DComplexLowerTriMat&); DoubleLowerTriMat operator/(const DoubleLowerTriMat&,
const DoubleLowerTriMat&); FloatLowerTriMat operator/(const FloatLowerTriMat&,
const FloatLowerTriMat&); DComplexLowerTriMat operator/(const DComplexLowerTriMat&,
const DComplexLowerTriMat&);
Performs element-by-element operations on the arguments. To do inner product matrix multiplication, you can use the product global function.
DoubleLowerTriMat operator*(double,
const DoubleLowerTriMat&); DoubleLowerTriMat operator*(const DoubleLowerTriMat&,
double); FloatLowerTriMat operator*(float,const FloatLowerTriMat&); FloatLowerTriMat operator*(const FloatLowerTriMat&,float); DComplexLowerTriMat operator*(DComplex,
const DComplexLowerTriMat&); DComplexLowerTriMat operator*(const DComplexLowerTriMat&,
DComplex); DoubleLowerTriMat operator/(const DoubleLowerTriMat&,
double); FloatLowerTriMat operator/(const FloatLowerTriMat&,float); DComplexLowerTriMat operator/(const DComplexLowerTriMat&,
DComplex);
Performs element-by-element operations on the arguments.
ostream& operator<<(ostream& s, const DoubleLowerTriMat&); ostream& operator<<(ostream& s, const FloatLowerTriMat&); ostream& operator<<(ostream& s, const DComplexLowerTriMat&);
Writes the matrix to the stream. This is equivalent to calling the printOn member function.
istream& operator>>(istream& s, const DoubleLowerTriMat&); istream& operator>>(istream& s, const FloatLowerTriMat&); istream& operator>>(istream& s, const DComplexLowerTriMat&);
Reads the matrix from the stream. This is equivalent to calling the scanFrom member function.
DoubleLowerTriMat abs(const DoubleLowerTriMat&); FloatLowerTriMat abs(const FloatLowerTriMat&); DoubleLowerTriMat abs(const DComplexLowerTriMat&);
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.
DoubleLowerTriMat arg(const DComplexLowerTriMat& A);
Returns a matrix where each element is the argument of the corresponding element in the matrix A.
DComplexLowerTriMat conj(const DComplexLowerTriMat& A);
Returns a matrix where each element is the complex conjugate of the corresponding element in the matrix A.
DoubleLowerTriMat imag(const DComplexLowerTriMat& A);
Returns a matrix where each element is the imaginary part of the corresponding element in the matrix A.
double maxValue(const DoubleLowerTriMat&); float maxValue(const FloatLowerTriMat&); double minValue(const DoubleLowerTriMat&); float minValue(const FloatLowerTriMat&);
Returns the maximum or minimum entry in the matrix.
DoubleLowerTriMat norm(const DComplexLowerTriMat& A);
Returns a matrix where each element is the norm (magnitude) of the corresponding element in the matrix A.
RWMathVec<double> product(const DoubleLowerTriMat& A,
const RWMathVec<double>& x); RWMathVec<float> product(const FloatLowerTriMat& A,
const RWMathVec<float>& x); RWMathVec<DComplex> product(const DComplexLowerTriMat& A,
const RWMathVec<DComplex>& x);
Returns the inner product (matrix-vector product) of A and x.
RWMathVec<double> product(const RWMathVec<double>& x,
const DoubleLowerTriMat& A); RWMathVec<float> product(const RWMathVec<float>& x,
const FloatLowerTriMat& A); RWMathVec<DComplex> product(const RWMathVec<DComplex>& x,
const DComplexLowerTriMat& A);
Returns the inner product (matrix-vector product) of x and A. This is equal to the product of A transpose and x.
DoubleLowerTriMat real(const DComplexLowerTriMat& A);
Returns a matrix where each element is the real part of the corresponding element in the matrix A.
FloatLowerTriMat toFloat(const DoubleLowerTriMat&);
Converts a matrix from double to float precision. The conversion is done using a constructor.
DoubleLowerTriMat toLowerTriMat(const RWGenMat<double>&); FloatLowerTriMat toLowerTriMat(const RWGenMat<float>&); DComplexLowerTriMat toLowerTriMat(const RWGenMat<DComplex>&);
Extracts the lower triangular part of a square matrix.
DoubleUpperTriMat transpose(const DoubleLowerTriMat&); FloatUpperTriMat transpose(const FloatLowerTriMat&); DComplexUpperTriMat transpose(const DComplexLowerTriMat&);
Returns the transpose of the argument matrix. The returned matrix references the same data as the argument matrix.
©Copyright 1999, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.