SourcePro C++ 12.0 |
SourcePro® C++ API Reference Guide |
SourcePro C++ Documentation Home |
Encapsulates tridiagonal matrices. More...
#include <rw/lapack/trdgmat.h>
Public Member Functions | |
RWTriDiagMat () | |
RWTriDiagMat (unsigned n, unsigned nAgain) | |
RWTriDiagMat (const RWMathVec< TypeT > &data, unsigned n, unsigned nAgain) | |
RWTriDiagMat (const RWTriDiagMat< TypeT > &rhs) | |
RWTriDiagMat (const typename rw_linear_algebra_traits< TypeT >::generic_tri_diag_mat &re) | |
RWTriDiagMat (const RWTriDiagMat< double > &re, const RWTriDiagMat< double > &im) | |
~RWTriDiagMat () | |
unsigned | rows () const |
unsigned | cols () const |
unsigned | bandwidth () const |
unsigned | lowerBandwidth () const |
unsigned | upperBandwidth () const |
unsigned | halfBandwidth () const |
TypeT | val (int i, int j) const |
TypeT | set (int i, int j, TypeT x) |
RWRORef< TypeT > | ref (int i, int j) |
TypeT | bcval (int i, int j) const |
TypeT | bcset (int i, int j, TypeT x) |
RWRORef< TypeT > | bcref (int i, int j) |
RWTriDiagMat< TypeT > | leadingSubmatrix (int k) |
RWMathVec< TypeT > | diagonal (int j=0) const |
RWMathVec< TypeT > | bcdiagonal (int j=0) const |
RWTriDiagMat< TypeT > & | reference (RWTriDiagMat< TypeT > &m) |
void | zero () |
RWTriDiagMat< TypeT > | copy () const |
RWTriDiagMat< TypeT > | deepCopy () const |
void | deepenShallowCopy () |
RWMathVec< TypeT > | dataVec () |
const RWMathVec< TypeT > & | dataVec () const |
TypeT * | data () |
const TypeT * | data () const |
void | resize (unsigned m, unsigned n) |
void | scanFrom (std::istream &is) |
void | printOn (std::ostream &os) const |
void | restoreFrom (RWvistream &is) |
void | saveOn (RWvostream &os) const |
void | restoreFrom (RWFile &f) |
void | saveOn (RWFile &f) const |
unsigned | binaryStoreSize () const |
RWRORef< TypeT > | operator() (int i, int j) |
TypeT | operator() (int i, int j) const |
bool | operator== (const RWTriDiagMat< TypeT > &X) |
bool | operator!= (const RWTriDiagMat< TypeT > &X) |
RWTriDiagMat< TypeT > & | operator= (const RWTriDiagMat< TypeT > &A) |
RWTriDiagMat< TypeT > & | operator+= (const RWTriDiagMat< TypeT > &m) |
RWTriDiagMat< TypeT > & | operator-= (const RWTriDiagMat< TypeT > &m) |
RWTriDiagMat< TypeT > & | operator*= (const RWTriDiagMat< TypeT > &m) |
RWTriDiagMat< TypeT > & | operator*= (TypeT) |
RWTriDiagMat< TypeT > & | operator/= (const RWTriDiagMat< TypeT > &m) |
RWTriDiagMat< TypeT > & | operator/= (TypeT) |
Related Functions | |
(Note that these are not member functions.) | |
template<class TypeT > | |
RWTriDiagMat< TypeT > | operator- (const RWTriDiagMat< TypeT > &m) |
template<class TypeT > | |
RWTriDiagMat< TypeT > | operator+ (const RWTriDiagMat< TypeT > &m) |
template<class TypeT > | |
RWTriDiagMat< TypeT > | operator* (const RWTriDiagMat< TypeT > &, const RWTriDiagMat< TypeT > &) |
template<class TypeT > | |
RWTriDiagMat< TypeT > | operator/ (const RWTriDiagMat< TypeT > &, const RWTriDiagMat< TypeT > &) |
template<class TypeT > | |
RWTriDiagMat< TypeT > | operator+ (const RWTriDiagMat< TypeT > &, const RWTriDiagMat< TypeT > &) |
template<class TypeT > | |
RWTriDiagMat< TypeT > | operator- (const RWTriDiagMat< TypeT > &, const RWTriDiagMat< TypeT > &) |
template<class TypeT > | |
RWTriDiagMat< TypeT > | operator* (const RWTriDiagMat< TypeT > &A, TypeT x) |
template<class TypeT > | |
RWTriDiagMat< TypeT > | operator* (TypeT x, const RWTriDiagMat< TypeT > &A) |
template<class TypeT > | |
RWTriDiagMat< TypeT > | operator/ (const RWTriDiagMat< TypeT > &A, TypeT x) |
template<class TypeT > | |
std::ostream & | operator<< (std::ostream &s, const RWTriDiagMat< TypeT > &m) |
template<class TypeT > | |
std::istream & | operator>> (std::istream &s, RWTriDiagMat< TypeT > &m) |
template<class TypeT > | |
RWTriDiagMat< TypeT > | transpose (const RWTriDiagMat< TypeT > &) |
template<class TypeT > | |
RWMathVec< TypeT > | product (const RWTriDiagMat< TypeT > &A, const RWMathVec< TypeT > &x) |
template<class TypeT > | |
RWMathVec< TypeT > | product (const RWMathVec< TypeT > &x, const RWTriDiagMat< TypeT > &A) |
template<class TypeT > | |
RWTriDiagMat< TypeT > | toTriDiagMat (const RWGenMat< TypeT > &A) |
template<class TypeT > | |
RWTriDiagMat< typename rw_numeric_traits< TypeT > ::norm_type > | abs (const RWTriDiagMat< TypeT > &M) |
RWTriDiagMat< DComplex > | conj (const RWTriDiagMat< DComplex > &A) |
RWTriDiagMat< double > | real (const RWTriDiagMat< DComplex > &A) |
RWTriDiagMat< double > | imag (const RWTriDiagMat< DComplex > &A) |
RWTriDiagMat< double > | norm (const RWTriDiagMat< DComplex > &A) |
RWTriDiagMat< double > | arg (const RWTriDiagMat< DComplex > &A) |
double | minValue (const RWTriDiagMat< double > &A) |
double | maxValue (const RWTriDiagMat< double > &A) |
float | minValue (const RWTriDiagMat< float > &A) |
float | maxValue (const RWTriDiagMat< float > &A) |
The class RWTriDiagMat<T> encapsulates tridiagonal matrices. A tridiagonal matrix is nonzero only on the diagonal, the subdiagonal, and the superdiagonal. It is a banded matrix with upper and lower bandwidth equal to 1.
#include <rw/lapack/trdgmat.h> RWTriDiagMat<double> A;
#include <rw/lapack/trdgmat.h> int main() { RWTriDiagMat<float> m(5,5); m.diagonal() = 1; m.leadingSubmatrix(3).zero(); return 0; }
A tridiagonal matrix is nonzero only along the main diagonal, the subdiagonal, and the superdiagonal:
The matrix is stored in an analogous way to the banded matrix. For convenience, there are some unused locations left in the vector of data. These are indicated as XXX in the following illustration of the storage vector:
[ XXX A11 A21 A12 A22 A32 A23 A33 A43 A34 A44 A54 ... Ann XXX ]
The mapping between the array and storage vector is as follows:
RWTriDiagMat< TypeT >::RWTriDiagMat | ( | ) |
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.
RWTriDiagMat< TypeT >::RWTriDiagMat | ( | unsigned | n, | |
unsigned | nAgain | |||
) |
Defines an uninitialized matrix of size n x n.
RWTriDiagMat< TypeT >::RWTriDiagMat | ( | const RWMathVec< TypeT > & | data, | |
unsigned | n, | |||
unsigned | nAgain | |||
) |
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 data.
RWTriDiagMat< TypeT >::RWTriDiagMat | ( | const RWTriDiagMat< TypeT > & | rhs | ) |
Builds a copy of its argument, rhs. Note that the new matrix references the data of rhs. To construct a matrix with its own copy of the data, you can use either the copy() or deepenShallowCopy() member functions.
RWTriDiagMat< TypeT >::RWTriDiagMat | ( | const typename rw_linear_algebra_traits< TypeT >::generic_tri_diag_mat & | re | ) |
Constructs a complex matrix from the real part supplied. The imaginary part is assumed to be 0.
RWTriDiagMat< TypeT >::RWTriDiagMat | ( | const RWTriDiagMat< double > & | re, | |
const RWTriDiagMat< double > & | im | |||
) |
Constructs a complex matrix from the real and imaginary parts supplied.
RWTriDiagMat< TypeT >::~RWTriDiagMat | ( | ) |
Destructor.
unsigned RWTriDiagMat< TypeT >::bandwidth | ( | ) | const [inline] |
Returns the bandwidth of the matrix. The bandwidth of a tridiagonal matrix is always 3.
RWMathVec<TypeT> RWTriDiagMat< TypeT >::bcdiagonal | ( | int | j = 0 |
) | const |
Returns a reference to the j th diagonal of the matrix, after doing bounds checking. The main diagonal is indexed by 0, the super diagonal by 1, and the subdiagonal by -1.
RWRORef<TypeT> RWTriDiagMat< TypeT >::bcref | ( | int | i, | |
int | j | |||
) |
Returns a reference to the ij th element of the matrix, after doing bounds checking.
TypeT RWTriDiagMat< TypeT >::bcset | ( | int | i, | |
int | j, | |||
TypeT | x | |||
) |
Sets the ij th element of the matrix equal to x, after doing bounds checking.
TypeT RWTriDiagMat< TypeT >::bcval | ( | int | i, | |
int | j | |||
) | const |
Returns the value of the ij th element of the matrix, after doing bounds checking.
unsigned RWTriDiagMat< TypeT >::binaryStoreSize | ( | ) | const |
Returns the number of bytes that it would take to write the matrix to a file using saveOn().
unsigned RWTriDiagMat< TypeT >::cols | ( | ) | const [inline] |
Returns the number of columns in the matrix.
RWTriDiagMat<TypeT> RWTriDiagMat< TypeT >::copy | ( | ) | const |
Creates a copy of this matrix with distinct data. The stride of the data vector in the new matrix is guaranteed to be 1.
const TypeT* RWTriDiagMat< TypeT >::data | ( | void | ) | const [inline] |
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.
TypeT* RWTriDiagMat< TypeT >::data | ( | void | ) | [inline] |
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.
const RWMathVec<TypeT>& RWTriDiagMat< TypeT >::dataVec | ( | ) | const [inline] |
Returns the matrix's data vector. This is where the explicitly stored entries in the matrix are kept.
RWMathVec<TypeT> RWTriDiagMat< TypeT >::dataVec | ( | ) | [inline] |
Returns the matrix's data vector. This is where the explicitly stored entries in the matrix are kept.
RWTriDiagMat<TypeT> RWTriDiagMat< TypeT >::deepCopy | ( | ) | const [inline] |
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 RWTriDiagMat< TypeT >::deepenShallowCopy | ( | ) | [inline] |
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.
RWMathVec< TypeT > RWTriDiagMat< TypeT >::diagonal | ( | int | j = 0 |
) | const [inline] |
Returns a reference to the j th diagonal of the matrix. The main diagonal is indexed by 0, the super diagonal by 1, and the subdiagonal by -1. Bounds checking is done if the preprocessor symbol RWBOUNDS_CHECK
is defined when the header file is read. The member function bcdiagonal() does the same thing with guaranteed bounds checking.
unsigned RWTriDiagMat< TypeT >::halfBandwidth | ( | ) | const [inline] |
Returns the half bandwidth of the matrix. The half bandwidth of a tridiagonal matrix is always 1.
RWTriDiagMat<TypeT> RWTriDiagMat< TypeT >::leadingSubmatrix | ( | int | k | ) |
Returns the k x k upper left corner of the matrix. The submatrix and the matrix share the same data.
unsigned RWTriDiagMat< TypeT >::lowerBandwidth | ( | ) | const [inline] |
Returns the lower bandwidth of the matrix. The lower bandwidth of a tridiagonal matrix is always 1.
bool RWTriDiagMat< TypeT >::operator!= | ( | const RWTriDiagMat< TypeT > & | X | ) | [inline] |
Inquality operator. Returns false
if two matrices have the same size and their elements are all exactly the same. Otherwise this function returns true
. Be aware that floating point arithmetic is not exact; matrices that are theoretically equal are not always numerically equal.
TypeT RWTriDiagMat< TypeT >::operator() | ( | int | i, | |
int | j | |||
) | const [inline] |
Accesses the ij th element. A value is returned, so this operator can be used only for accessing an element. Using this operator is equivalent to calling the val() member function. Bounds checking is done if the preprocessor symbol RWBOUNDS_CHECK
is defined before including the header file.
RWRORef< TypeT > RWTriDiagMat< TypeT >::operator() | ( | int | i, | |
int | j | |||
) | [inline] |
Accesses the ij th element. 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. Bounds checking is done if the preprocessor symbol RWBOUNDS_CHECK
is defined before including the header file.
RWTriDiagMat<TypeT>& RWTriDiagMat< TypeT >::operator*= | ( | TypeT | ) |
Performs the indicated operation on each element of the matrix.
RWTriDiagMat<TypeT>& RWTriDiagMat< TypeT >::operator*= | ( | const RWTriDiagMat< TypeT > & | m | ) |
Performs element-by-element arithmetic on the data in the matrices. This function 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.
RWTriDiagMat<TypeT>& RWTriDiagMat< TypeT >::operator+= | ( | const RWTriDiagMat< TypeT > & | m | ) |
Performs element-by-element arithmetic on the data in the matrices.
RWTriDiagMat<TypeT>& RWTriDiagMat< TypeT >::operator-= | ( | const RWTriDiagMat< TypeT > & | m | ) |
Performs element-by-element arithmetic on the data in the matrices.
RWTriDiagMat<TypeT>& RWTriDiagMat< TypeT >::operator/= | ( | TypeT | ) |
Performs the indicated operation on each element of the matrix.
RWTriDiagMat<TypeT>& RWTriDiagMat< TypeT >::operator/= | ( | const RWTriDiagMat< TypeT > & | m | ) |
Performs element-by-element arithmetic on the data in the matrices.
RWTriDiagMat<TypeT>& RWTriDiagMat< TypeT >::operator= | ( | const RWTriDiagMat< TypeT > & | 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 reference().
bool RWTriDiagMat< TypeT >::operator== | ( | const RWTriDiagMat< TypeT > & | X | ) |
Equality operator. Returns true
if two matrices have the same size and their elements are all exactly the same. Otherwise this function returns false
. Be aware that floating point arithmetic is not exact; matrices that are theoretically equal are not always numerically equal.
void RWTriDiagMat< TypeT >::printOn | ( | std::ostream & | os | ) | const |
Prints the matrix to an output stream in human readable format.
RWRORef< TypeT > RWTriDiagMat< TypeT >::ref | ( | int | i, | |
int | j | |||
) | [inline] |
Returns a reference to the ij th element of the matrix. Bounds checking is done if the preprocessor symbol RWBOUNDS_CHECK
is defined when the header file is read. The member function bcref() does the same thing with guaranteed bounds checking.
RWTriDiagMat<TypeT>& RWTriDiagMat< TypeT >::reference | ( | RWTriDiagMat< TypeT > & | m | ) |
Makes this matrix a reference to the matrix m. 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 operator=().
void RWTriDiagMat< TypeT >::resize | ( | unsigned | m, | |
unsigned | n | |||
) |
Resizes the matrix. Any new entries in the matrix are set to 0. Both arguments must be the same.
void RWTriDiagMat< TypeT >::restoreFrom | ( | RWFile & | f | ) |
void RWTriDiagMat< TypeT >::restoreFrom | ( | RWvistream & | is | ) |
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 RWTriDiagMat< TypeT >::rows | ( | ) | const [inline] |
Returns the number of rows in the matrix.
void RWTriDiagMat< TypeT >::saveOn | ( | RWFile & | f | ) | const |
Stores a matrix to an RWFile. The matrix can be read using the restoreFrom() member function.
void RWTriDiagMat< TypeT >::saveOn | ( | RWvostream & | os | ) | const |
Stores a matrix to an RWvostream, the Rogue Wave virtual output stream class. The matrix can be read using restoreFrom() .
void RWTriDiagMat< TypeT >::scanFrom | ( | std::istream & | is | ) |
Reads a matrix from an input stream. The format of the matrix is the same as the format output by printOn(). 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 upper triangle of the matrix is used.
4x4 [ 4 1 0 0 -5 9 2 0 0 -5 3 9 0 0 4 3 ]
TypeT RWTriDiagMat< TypeT >::set | ( | int | i, | |
int | j, | |||
TypeT | x | |||
) | [inline] |
Sets the ij thelement of the matrix equal to x. Bounds checking is done if the preprocessor symbol RWBOUNDS_CHECK
is defined when the header file is read. The member function bcset() does the same thing with guaranteed bounds checking.
unsigned RWTriDiagMat< TypeT >::upperBandwidth | ( | ) | const [inline] |
Returns the upper bandwidth of the matrix. The upper bandwidth of a tridiagonal matrix is always 1.
TypeT RWTriDiagMat< TypeT >::val | ( | int | i, | |
int | j | |||
) | const [inline] |
Returns the value of the ij th element of the matrix. Bounds checking is done if the preprocessor symbol RWBOUNDS_CHECK
is defined when the header file is read. The member function bcval() does the same thing with guaranteed bounds checking.
void RWTriDiagMat< TypeT >::zero | ( | ) | [inline] |
Sets every element of the matrix to 0.
RWTriDiagMat< typename rw_numeric_traits< TypeT >::norm_type > abs | ( | const RWTriDiagMat< TypeT > & | M | ) | [related] |
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.
RWTriDiagMat< double > arg | ( | const RWTriDiagMat< DComplex > & | A | ) | [related] |
Returns a matrix where each element is the argument of the corresponding element in the matrix A.
RWTriDiagMat< DComplex > conj | ( | const RWTriDiagMat< DComplex > & | A | ) | [related] |
Returns a matrix where each element is the complex conjugate of the corresponding element in the matrix A.
RWTriDiagMat< double > imag | ( | const RWTriDiagMat< DComplex > & | A | ) | [related] |
Returns a matrix where each element is the imaginary part of the corresponding element in the matrix A.
float maxValue | ( | const RWTriDiagMat< float > & | A | ) | [related] |
Returns the maximum entry in the matrix.
double maxValue | ( | const RWTriDiagMat< double > & | A | ) | [related] |
Returns the maximum entry in the matrix.
float minValue | ( | const RWTriDiagMat< float > & | A | ) | [related] |
Returns the minimum entry in the matrix.
double minValue | ( | const RWTriDiagMat< double > & | A | ) | [related] |
Returns the minimum entry in the matrix.
RWTriDiagMat< double > norm | ( | const RWTriDiagMat< DComplex > & | A | ) | [related] |
Returns a matrix where each element is the norm (magnitude) of the corresponding element in the matrix A.
RWTriDiagMat< TypeT > operator* | ( | TypeT | x, | |
const RWTriDiagMat< TypeT > & | A | |||
) | [related] |
Performs element-by-element multiplication on the arguments.
RWTriDiagMat< TypeT > operator* | ( | const RWTriDiagMat< TypeT > & | A, | |
TypeT | x | |||
) | [related] |
Performs element-by-element multiplication on the arguments.
RWTriDiagMat< TypeT > operator* | ( | const RWTriDiagMat< TypeT > & | , | |
const RWTriDiagMat< TypeT > & | ||||
) | [related] |
Performs element-by-element operations on the arguments. To do inner product matrix multiplication, you can use the product() global function.
RWTriDiagMat< TypeT > operator+ | ( | const RWTriDiagMat< TypeT > & | , | |
const RWTriDiagMat< TypeT > & | ||||
) | [related] |
Performs element-by-element addition on the arguments.
RWTriDiagMat< TypeT > operator+ | ( | const RWTriDiagMat< TypeT > & | m | ) | [related] |
Unary plus operator. Returns a copy of the matrix m.
RWTriDiagMat< TypeT > operator- | ( | const RWTriDiagMat< TypeT > & | , | |
const RWTriDiagMat< TypeT > & | ||||
) | [related] |
Performs element-by-element subtraction on the arguments.
RWTriDiagMat< TypeT > operator- | ( | const RWTriDiagMat< TypeT > & | m | ) | [related] |
Unary minus operator. Returns the negation of the matrix m.
RWTriDiagMat< TypeT > operator/ | ( | const RWTriDiagMat< TypeT > & | A, | |
TypeT | x | |||
) | [related] |
Performs element-by-element division on the arguments.
RWTriDiagMat< TypeT > operator/ | ( | const RWTriDiagMat< TypeT > & | , | |
const RWTriDiagMat< TypeT > & | ||||
) | [related] |
Performs element-by-element division on the arguments.
std::ostream & operator<< | ( | std::ostream & | s, | |
const RWTriDiagMat< TypeT > & | m | |||
) | [related] |
Writes the matrix to the stream. This is equivalent to calling the printOn() member function.
std::istream & operator>> | ( | std::istream & | s, | |
RWTriDiagMat< TypeT > & | m | |||
) | [related] |
Reads the matrix from the stream. This is equivalent to calling the scanFrom() member function.
RWMathVec< TypeT > product | ( | const RWMathVec< TypeT > & | x, | |
const RWTriDiagMat< TypeT > & | A | |||
) | [related] |
Returns the inner product (matrix-vector product) of x and A. This is equal to the product of A transpose and x.
RWMathVec< TypeT > product | ( | const RWTriDiagMat< TypeT > & | A, | |
const RWMathVec< TypeT > & | x | |||
) | [related] |
Returns the inner product (matrix-vector product) of A and x.
RWTriDiagMat< double > real | ( | const RWTriDiagMat< DComplex > & | A | ) | [related] |
Returns a matrix where each element is the real part of the corresponding element in the matrix A.
RWTriDiagMat< TypeT > toTriDiagMat | ( | const RWGenMat< TypeT > & | A | ) | [related] |
Extracts the tridiagonal part of a square matrix. The tridiagonal part of a matrix A
consists of the main diagonal, the subdiagonal, and the superdiagonal.
RWTriDiagMat< TypeT > transpose | ( | const RWTriDiagMat< TypeT > & | ) | [related] |
Returns the transpose of the argument matrix. The transpose is made to reference the same data as the argument matrix.
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.