>
>#include <rw/dhermmat.h> // DComplexHermMat DComplexHermMat H;
The class DComplexHermMat encapsulates a Hermitian matrix. A Hermitian matrix is defined by the requirement that Aij = conj(Aji). This strict definition implies that the diagonal elements have 0 imaginary parts. The Rogue Wave classes relax this definition along the diagonal so that diagonal elements can have nonzero imaginary parts.
>#include <rw/chermmat.h> #include <rw/dsymmat.h> #include <rw/dskewmat.h> main() { DComplexHermMat H(4,4); DoubleSymMat Hreal = real(H); DoubleSkewMat Himag = imag(H); }>
The upper triangle of the matrix is stored in column major order. The lower triangle is then calculated implicitly. The upper triangle is stored in column major order. This storage scheme is used so that the leading part of the matrix is always located in contiguous memory.
For example, given the following matrix:
the data is stored in the following order:
[ A11 A12 A22 A13 A23 A33 ... A1n A2n A3n ... Ann ]
The mapping between the array and the storage vector is as follows:
>
DComplexHermMat();
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.
DComplexHermMat(const DComplexHermMat& 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, you can use either the copy or deepenShallowCopy member functions.
DComplexHermMat(unsigned n, unsigned n);
Defines an uninitialized matrix of size n x n. Both arguments must be equal or a runtime error occurs.
DComplexHermMat(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.
DComplexHermMat(const DoubleSymMat& re); DComplexHermMat(const DoubleSymMat& re, const DoubleSkewMat& im);
Constructs a complex matrix from the real and imaginary parts supplied. If no imaginary part is supplied, the imaginary part is assumed to be 0.
DComplexRef DComplexHermMat::bcref(int i, int j);
Returns a reference to the ijth element of the matrix, after doing bounds checking.
void DComplexHermMat::bcset(int i, int j, DComplex x);
Sets the ijth element of the matrix equal to x, after doing bounds checking.
DComplex DComplexHermMat::bcval(int i, int j);
Returns the value of the ijth element of the matrix, after doing bounds checking.
unsigned DComplexHermMat::binaryStoreSize();
Returns the number of bytes that it would take to write the matrix to a file using saveOn.
unsigned DComplexHermMat::cols();
Returns the number of columns in the matrix.
DComplexHermMat DComplexHermMat::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.
DComplex* DComplexHermMat::data();
Returns a pointer to the first item of data in the vector storing the matrix's data. You can use this to pass the matrix's data to C or FORTRAN subroutines, but be aware that the stride of the data vector may not be 1.
RWMathVec<DComplex> DComplexHermMat::dataVec();
Returns the matrix's data vector. This is where the explicitly stored entries in the matrix are kept.
DComplexHermMat DComplexHermMat::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 DComplexHermMat::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.
DComplexHermMat DComplexHermMat::leadingSubmatrix(int k);
Returns the k x k upper left corner of the matrix. The submatrix and the matrix share the same data.
void DComplexHermMat::makeDiagonalReal();
Sets the imaginary part of the main diagonal to 0, thus ensuring that the matrix satisfies the strict mathematical definition of Hermitian.
void DComplexHermMat::printOn(ostream&);
Prints the matrix to an output stream in human readable format.
CJDComplexRef DComplexHermMat::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.
DComplexHermMat DComplexHermMat::reference(DComplexHermMat&);
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 DComplexHermMat::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 DComplexHermMat::restoreFrom(RWFile&);
Reads in a matrix from an RWFile. The matrix must have been stored to the file using the saveOn member function.
void DComplexHermMat::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 DComplexHermMat::rows();
Returns the number of rows in the matrix.
void DComplexHermMat::saveOn(RWFile&);
Stores a matrix to an RWFile. The matrix can be read using the restoreFrom member function.
void DComplexHermMat::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 DComplexHermMat::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 which could be input. Note that extra white space and any text preceding the dimension specification are ignored. Only the Hermitian part of the matrix is used.
3x3 [ (4,2) (5,2) (7,8) (5,-2) (9,2) (5,3) (7,-8) (5,-3) (3,0) ]
void DComplexHermMat::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.
DComplex DComplexHermMat::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.
DComplexHermMat DComplexHermMat::zero();
Sets every element of the matrix to 0.
CJDComplexRef DComplexHermMat::operator()(int i, int j); DComplex DComplexHermMat::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.
DComplexHermMat& operator=(const DComplexHermMat& 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, you can use the reference member function.
DComplexHermMat& operator==(const DComplexHermMat& A); DComplexHermMat& operator!=(const DComplexHermMat& 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, so matrices that are theoretically equal are not always numerically equal.
DComplexHermMat& operator*=(DComplex x); DComplexHermMat& operator/=(DComplex x);
Performs the indicated operation on each element of the matrix.
DComplexHermMat& operator+=(const DComplexHermMat& A); DComplexHermMat& operator-=(const DComplexHermMat& A); DComplexHermMat& operator*=(const DComplexHermMat& A); DComplexHermMat& operator/=(const DComplexHermMat& 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.
DComplexHermMat operator+(const DComplexHermMat&); DComplexHermMat operator-(const DComplexHermMat&);
Unary plus and minus operators. Each operator returns a copy of the matrix or its negation.
DComplexHermMat operator+(const DComplexHermMat&,
const DComplexHermMat&); DComplexHermMat operator-(const DComplexHermMat&,
const DComplexHermMat&); DComplexHermMat operator*(const DComplexHermMat&,
const DComplexHermMat&); DComplexHermMat operator/(const DComplexHermMat&,
const DComplexHermMat&);
Performs element-by-element operations on the arguments. To do inner product matrix multiplication, use the product global function.
DComplexHermMat operator*(DComplex,const DComplexHermMat&); DComplexHermMat operator*(const DComplexHermMat&,DComplex); DComplexHermMat operator/(DComplex,const DComplexHermMat&); DComplexHermMat operator/(const DComplexHermMat&,DComplex);
Performs element-by-element operations on the arguments.
ostream& operator<<(ostream& s, const DComplexHermMat&);
Writes the matrix to the stream. This is equivalent to calling the printOn member function.
istream& operator>>(istream& s, const DComplexHermMat&);
Reads the matrix from the stream. This is equivalent to calling the scanFrom member function.
DoubleSymMat abs(const DComplexHermMat& A);
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.
DoubleSkewMat arg(const DComplexHermMat& A);
Returns a matrix where each element is the argument of the corresponding element in the matrix A.
DComplexHermMat conj(const DComplexHermMat& A);
Returns a matrix where each element is the complex conjugate of the corresponding element in the matrix A.
DoubleSkewMat imag(const DComplexHermMat& A);
Returns a matrix where each element is the imaginary part of the corresponding element in the matrix A.
DComplexHermMat lowerToHermMat(const RWGenMat<DComplex>& A);
Builds a Hermitian matrix that matches the lower triangular part of A. The upper triangle of A is not referenced.
DoubleSymMat norm(const DComplexHermMat& A);
Returns a matrix where each element is the norm (magnitude) of the corresponding element in the matrix A.
RWMathVec<DComplex> product(const DComplexHermMat& A, const RWMathVec<DComplex>& x);
Returns the inner product (matrix-vector product) of A and x.
RWMathVec<DComplex> product(const RWMathVec<DComplex>& x, const DComplexHermMat& A);
Returns the inner product (matrix-vector product) of x and A. This is equal to the product of A transpose and x.
DoubleSymMat real(const DComplexHermMat& A);
Returns a matrix where each element is the real part of the corresponding element in the matrix A.
DComplexBandMat toHermBandMat(const RWGenMat<DComplex>&, unsigned h);
Extracts the Hermitian part of a band of entries from a square matrix. The main diagonal is extracted, along with h subdiagonals and superdiagonals. If B is this band, the Hermitian part of the band is (B+conj(BT))/2.
DComplexHermMat transpose(const DComplexHermMat&);
Returns the transpose of the argument matrix.
DComplexHermMat upperToHermMat(const RWGenMat<DComplex>& A);
Builds a Hermitian matrix that matches the upper triangular part of A. The lower triangle of A is not referenced.
©Copyright 1999, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.