SourcePro® 2023.1 |
SourcePro® API Reference Guide |
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 | bandwidth () const |
RWMathVec< TypeT > | bcdiagonal (int j=0) const |
RWRORef< TypeT > | bcref (int i, int j) |
TypeT | bcset (int i, int j, TypeT x) |
TypeT | bcval (int i, int j) const |
unsigned | binaryStoreSize () const |
unsigned | cols () const |
RWTriDiagMat< TypeT > | copy () const |
TypeT * | data () |
const TypeT * | data () const |
RWMathVec< TypeT > | dataVec () |
const RWMathVec< TypeT > & | dataVec () const |
RWTriDiagMat< TypeT > | deepCopy () const |
void | deepenShallowCopy () |
RWMathVec< TypeT > | diagonal (int j=0) const |
unsigned | halfBandwidth () const |
RWTriDiagMat< TypeT > | leadingSubmatrix (int k) |
unsigned | lowerBandwidth () const |
bool | operator!= (const RWTriDiagMat< TypeT > &X) |
RWRORef< TypeT > | operator() (int i, int j) |
TypeT | operator() (int i, int j) const |
RWTriDiagMat< TypeT > & | operator*= (const RWTriDiagMat< TypeT > &m) |
RWTriDiagMat< TypeT > & | operator*= (TypeT) |
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 > &A) |
bool | operator== (const RWTriDiagMat< TypeT > &X) |
void | printOn (std::ostream &os) const |
RWRORef< TypeT > | ref (int i, int j) |
RWTriDiagMat< TypeT > & | reference (RWTriDiagMat< TypeT > &m) |
void | resize (unsigned m, unsigned n) |
void | restoreFrom (RWvistream &is) |
void | restoreFrom (RWFile &f) |
unsigned | rows () const |
void | saveOn (RWvostream &os) const |
void | saveOn (RWFile &f) const |
void | scanFrom (std::istream &is) |
TypeT | set (int i, int j, TypeT x) |
unsigned | upperBandwidth () const |
TypeT | val (int i, int j) const |
void | zero () |
Related Functions | |
(Note that these are not member functions.) | |
template<class TypeT > | |
RWTriDiagMat< typename rw_numeric_traits< TypeT >::norm_type > | abs (const RWTriDiagMat< TypeT > &M) |
RWTriDiagMat< double > | arg (const RWTriDiagMat< DComplex > &A) |
RWTriDiagMat< DComplex > | conj (const RWTriDiagMat< DComplex > &A) |
RWTriDiagMat< double > | imag (const RWTriDiagMat< DComplex > &A) |
double | maxValue (const RWTriDiagMat< double > &A) |
float | maxValue (const RWTriDiagMat< float > &A) |
double | minValue (const RWTriDiagMat< double > &A) |
float | minValue (const RWTriDiagMat< float > &A) |
RWTriDiagMat< double > | norm (const RWTriDiagMat< DComplex > &A) |
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 > &m) |
template<class TypeT > | |
RWTriDiagMat< TypeT > | operator+ (const RWTriDiagMat< TypeT > &, const RWTriDiagMat< TypeT > &) |
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 > &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 > | |
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) |
RWTriDiagMat< double > | real (const RWTriDiagMat< DComplex > &A) |
template<class TypeT > | |
RWTriDiagMat< TypeT > | toTriDiagMat (const RWGenMat< TypeT > &A) |
template<class TypeT > | |
RWTriDiagMat< TypeT > | transpose (const RWTriDiagMat< TypeT > &) |
The class RWTriDiagMat 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.
A tridiagonal matrix is nonzero only along the main diagonal, the subdiagonal, and the superdiagonal:
\[ \begin{bmatrix} A_{11} & A_{12} & 0 & 0 & ... & & & \\ A_{21} & A_{22} & A_{23} & 0 & 0 & ... & & \\ 0 & A_{32} & A_{33} & A_{34} & 0 & 0 & ... & \\ 0 & 0 & A_{43} & A_{44} & A_{45} & 0 & 0 & ... \\ 0 & 0 & 0 & A_{54} & A_{55} & A_{56} & 0 & 0 \\ . & & & & & & & \\ . & & & & & & & \\ . & & & & & & & \\ \end{bmatrix} \]
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:
\[ A(i+1,j+1) \rightarrow vec [ i + 1 + j*2 ] \]
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.
|
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().
|
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.
|
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.
|
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.
|
inline |
Returns the matrix's data vector. This is where the explicitly stored entries in the matrix are kept.
|
inline |
Returns the matrix's data vector. This is where the explicitly stored entries in the matrix are kept.
|
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.
|
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.
|
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.
|
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.
|
inline |
Returns the lower bandwidth of the matrix. The lower bandwidth of a tridiagonal matrix is always 1.
|
inline |
Inequality 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.
|
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.
|
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.
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*= | ( | 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 > & | 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 > & | 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.
|
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 | ( | 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.
void RWTriDiagMat< TypeT >::restoreFrom | ( | RWFile & | f | ) |
|
inline |
Returns the number of rows in the matrix.
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 >::saveOn | ( | RWFile & | f | ) | const |
Stores a matrix to an RWFile. The matrix can be read using the restoreFrom() member function.
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.
|
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.
|
inline |
Returns the upper bandwidth of the matrix. The upper bandwidth of a tridiagonal matrix is always 1.
|
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.
|
inline |
Sets every element of the matrix to 0.
|
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.
|
related |
Returns a matrix where each element is the argument of the corresponding element in the matrix A.
|
related |
Returns a matrix where each element is the complex conjugate of the corresponding element in the matrix A.
|
related |
Returns a matrix where each element is the imaginary part of the corresponding element in the matrix A.
|
related |
Returns the maximum entry in the matrix.
|
related |
Returns the maximum entry in the matrix.
|
related |
Returns the minimum entry in the matrix.
|
related |
Returns the minimum entry in the matrix.
|
related |
Returns a matrix where each element is the norm (magnitude) of the corresponding element in the matrix A.
|
related |
Performs element-by-element operations on the arguments. To do inner product matrix multiplication, you can use the product() global function.
|
related |
Performs element-by-element multiplication on the arguments.
|
related |
Performs element-by-element multiplication on the arguments.
|
related |
Unary plus operator. Returns a copy of the matrix m.
|
related |
Performs element-by-element addition on the arguments.
|
related |
Unary minus operator. Returns the negation of the matrix m.
|
related |
Performs element-by-element subtraction on the arguments.
|
related |
Performs element-by-element division on the arguments.
|
related |
Performs element-by-element division on the arguments.
|
related |
Writes the matrix to the stream. This is equivalent to calling the printOn() member function.
|
related |
Reads the matrix from the stream. This is equivalent to calling the scanFrom() member function.
|
related |
Returns the inner product (matrix-vector product) of A and x.
|
related |
Returns the inner product (matrix-vector product) of x and A. This is equal to the product of A transpose and x.
|
related |
Returns a matrix where each element is the real part of the corresponding element in the matrix 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.
|
related |
Returns the transpose of the argument matrix. The transpose is made to reference the same data as the argument matrix.
Copyright © 2023 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |