Represents a symmetric matrix. More...
#include <rw/lapack/symmat.h>
Public Member Functions | |
RWSymMat () | |
RWSymMat (const RWSymMat< TypeT > &A) | |
RWSymMat (unsigned n, unsigned nAgain) | |
RWSymMat (unsigned n, unsigned nAgain, TypeT initval) | |
RWSymMat (const RWMathVec< TypeT > &data, unsigned n, unsigned nAgain) | |
RWSymMat (const typename rw_linear_algebra_traits< TypeT >::generic_sym_mat &re) | |
RWSymMat (const RWSymMat< double > &re, const RWSymMat< double > &im) | |
RWSymMat< TypeT > | apply (typename rw_linear_algebra_traits< TypeT >::lapkFunType func) const |
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 |
RWSymMat< TypeT > | copy () const |
TypeT * | data () |
RWMathVec< TypeT > | dataVec () |
RWSymMat< TypeT > | deepCopy () const |
void | deepenShallowCopy () |
RWSymMat< TypeT > | leadingSubmatrix (int k) |
bool | operator!= (const RWSymMat< TypeT > &X) |
TypeT & | operator() (int i, int j) |
TypeT | operator() (int i, int j) const |
RWSymMat< TypeT > & | operator*= (const RWSymMat< TypeT > &A) |
RWSymMat< TypeT > & | operator*= (TypeT x) |
RWSymMat< TypeT > & | operator++ () |
RWSymMat< TypeT > & | operator+= (TypeT x) |
RWSymMat< TypeT > & | operator+= (const RWSymMat< TypeT > &A) |
RWSymMat< TypeT > & | operator-- () |
RWSymMat< TypeT > & | operator-= (TypeT x) |
RWSymMat< TypeT > & | operator-= (const RWSymMat< TypeT > &A) |
RWSymMat< TypeT > & | operator/= (const RWSymMat< TypeT > &A) |
RWSymMat< TypeT > & | operator/= (TypeT x) |
RWSymMat< TypeT > & | operator= (const RWSymMat< TypeT > &A) |
RWSymMat< TypeT > & | operator= (TypeT x) |
bool | operator== (const RWSymMat< TypeT > &X) |
void | printOn (std::ostream &) const |
TypeT & | ref (int i, int j) |
RWSymMat< TypeT > & | reference (RWSymMat< TypeT > &m) |
void | resize (unsigned n, unsigned nAgain) |
void | restoreFrom (RWvistream &) |
void | restoreFrom (RWFile &) |
unsigned | rows () const |
void | saveOn (RWvostream &) const |
void | saveOn (RWFile &) const |
void | scanFrom (std::istream &) |
TypeT | set (int i, int j, TypeT x) |
TypeT | val (int i, int j) const |
void | zero () |
Related Functions | |
(Note that these are not member functions.) | |
template<class TypeT > | |
RWSymMat< typename rw_numeric_traits< TypeT >::norm_type > | abs (const RWSymMat< TypeT > &M) |
RWSymMat< double > | arg (const RWSymMat< DComplex > &A) |
RWSymMat< float > | atan2 (const RWSymMat< float > &, const RWSymMat< float > &) |
RWSymMat< double > | atan2 (const RWSymMat< double > &, const RWSymMat< double > &) |
RWSymMat< DComplex > | conj (const RWSymMat< DComplex > &A) |
RWSymMat< double > | imag (const RWSymMat< DComplex > &A) |
template<class TypeT > | |
RWSymMat< TypeT > | lowerToSymMat (const RWGenMat< TypeT > &A) |
double | maxValue (const RWSymMat< double > &A) |
float | maxValue (const RWSymMat< float > &A) |
double | minValue (const RWSymMat< double > &A) |
float | minValue (const RWSymMat< float > &A) |
RWSymMat< double > | norm (const RWSymMat< DComplex > &A) |
template<class TypeT > | |
RWSymMat< TypeT > | operator* (const RWSymMat< TypeT > &, const RWSymMat< TypeT > &) |
template<class TypeT > | |
RWSymMat< TypeT > | operator* (const RWSymMat< TypeT > &A, TypeT x) |
template<class TypeT > | |
RWSymMat< TypeT > | operator* (TypeT x, const RWSymMat< TypeT > &A) |
template<class TypeT > | |
RWSymMat< TypeT > | operator+ (const RWSymMat< TypeT > &) |
template<class TypeT > | |
RWSymMat< TypeT > | operator+ (const RWSymMat< TypeT > &, const RWSymMat< TypeT > &) |
template<class TypeT > | |
RWSymMat< TypeT > | operator+ (const RWSymMat< TypeT > &A, TypeT x) |
template<class TypeT > | |
RWSymMat< TypeT > | operator+ (TypeT x, const RWSymMat< TypeT > &A) |
template<class TypeT > | |
RWSymMat< TypeT > | operator- (const RWSymMat< TypeT > &) |
template<class TypeT > | |
RWSymMat< TypeT > | operator- (const RWSymMat< TypeT > &, const RWSymMat< TypeT > &) |
template<class TypeT > | |
RWSymMat< TypeT > | operator- (const RWSymMat< TypeT > &A, TypeT x) |
template<class TypeT > | |
RWSymMat< TypeT > | operator- (TypeT x, const RWSymMat< TypeT > &A) |
template<class TypeT > | |
RWSymMat< TypeT > | operator/ (const RWSymMat< TypeT > &, const RWSymMat< TypeT > &) |
template<class TypeT > | |
RWSymMat< TypeT > | operator/ (const RWSymMat< TypeT > &A, TypeT x) |
template<class TypeT > | |
RWSymMat< TypeT > | operator/ (TypeT x, const RWSymMat< TypeT > &A) |
template<class TypeT > | |
std::ostream & | operator<< (std::ostream &s, const RWSymMat< TypeT > &m) |
template<class TypeT > | |
std::istream & | operator>> (std::istream &s, RWSymMat< TypeT > &m) |
template<class TypeT > | |
RWMathVec< TypeT > | product (const RWSymMat< TypeT > &A, const RWMathVec< TypeT > &x) |
template<class TypeT > | |
RWMathVec< TypeT > | product (const RWMathVec< TypeT > &x, const RWSymMat< TypeT > &A) |
RWSymMat< double > | real (const RWSymMat< DComplex > &A) |
template<class TypeT > | |
RWSymMat< TypeT > | toSymMat (const RWGenMat< TypeT > &A) |
template<class TypeT > | |
RWSymMat< TypeT > | transpose (const RWSymMat< TypeT > &) |
template<class TypeT > | |
RWSymMat< TypeT > | upperToSymMat (const RWGenMat< TypeT > &A) |
The class RWSymMat represents symmetric matrices. A symmetric matrix is defined by the requirement that \( A_{ij} = A_{ji} \), and so a symmetric matrix is equal to its transpose.
The upper triangle of the matrix is stored in column major order. The lower triangle is then calculated implicitly. This storage scheme was chosen so that the leading part of the matrix was always located in contiguous memory.
For example, given the following symmetric matrix:
\[ \begin{bmatrix} A_{11} & A_{12} & A_{13} & \dots & A_{1n} \\ A_{12} & A_{22} & A_{23} & \dots & A_{2n} \\ A_{13} & A_{23} & A_{33} & \dots & A_{3n} \\ \vdots \\ A_{1n} & A_{2n} & A_{3n} & \dots & A_{nn} \end{bmatrix} \]
The data is stored in the following order:
\[ \left[ \begin{array}{cccccccccccc} A_{11} & A_{12} & A_{22} & A_{13} & A_{23} & A_{33} & \dots & A_{1n} & A_{2n} & A_{3n} & \dots & A_{nn} \end{array} \right] \]
The mapping between the array and storage vector is as follows:
\[ A(i+1, j+1) \to \begin{cases} \text{vec}[j(j+1)/2+i], & i \leq j \\ \text{vec}[i(i+1)/2+j], & j \leq i \end{cases} \]
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.
Builds a copy of its parameter, 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.
Defines an uninitialized matrix of size n x nAgain. Both parameters must be equal or a runtime error occurs. This constructor is used, rather than a constructor that takes only a single parameter, to avoid type conversion problems.
Defines a matrix of size n x nAgain where each element is initialized to initval. Both parameters must be equal or a runtime error occurs.
RWSymMat< TypeT >::RWSymMat | ( | const RWMathVec< TypeT > & | data, |
unsigned | n, | ||
unsigned | nAgain | ||
) |
Constructs a size n x nAgain 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.
RWSymMat< TypeT >::RWSymMat | ( | const typename rw_linear_algebra_traits< TypeT >::generic_sym_mat & | re | ) |
Constructs a complex matrix from the real part supplied. Imaginary part is assumed to be 0
.
RWSymMat< TypeT >::RWSymMat | ( | const RWSymMat< double > & | re, |
const RWSymMat< double > & | im | ||
) |
Constructs a complex matrix from the real and imaginary parts supplied.
RWSymMat<TypeT> RWSymMat< TypeT >::apply | ( | typename rw_linear_algebra_traits< TypeT >::lapkFunType | func | ) | const |
Returns the result of applying the passed function func to every element in the matrix. If TypeT
is DComplex, func takes and returns a DComplex. For all other TypeT
, func takes and returns a double
.
TypeT& RWSymMat< TypeT >::bcref | ( | int | i, |
int | j | ||
) |
Returns a reference to the ij th element of the matrix, after doing bounds checking.
TypeT RWSymMat< TypeT >::bcset | ( | int | i, |
int | j, | ||
TypeT | x | ||
) |
Sets the ij th element of the matrix equal to x, after doing bounds checking.
TypeT RWSymMat< TypeT >::bcval | ( | int | i, |
int | j | ||
) | const |
Returns the value of the ij th element of the matrix, after doing bounds checking.
unsigned RWSymMat< 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.
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.
Returns the matrix's data vector. This is where the explicitly stored entries in the matrix are kept.
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.
Returns the k x k upper left corner of the matrix. The submatrix and the matrix share the same data.
Boolean operator. 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.
|
inline |
Accesses the ij th element when self is not a const
matrix. A reference type is returned, so this operator can be used for assigning or accessing an element. 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 when self is a const
matrix. 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.
Performs element-by-element arithmetic on the data in the matrices.
Performs the indicated operation on each element of the matrix.
Increments each element in the matrix.
Performs the indicated operation on each element of the matrix.
Performs element-by-element arithmetic on the data in the matrices.
Decrements each element in the matrix.
Performs the indicated operation on each element of the matrix.
Performs element-by-element arithmetic on the data in the matrices.
Performs element-by-element arithmetic on the data in the matrices.
Performs the indicated operation on each element of the matrix.
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.
Sets each element in the matrix equal to x.
Boolean operator. 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.
void RWSymMat< TypeT >::printOn | ( | std::ostream & | ) | 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.
Makes this matrix a reference to the parameter 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 RWSymMat< TypeT >::resize | ( | unsigned | n, |
unsigned | nAgain | ||
) |
Resizes the matrix. Any new entries in the matrix are set to 0
. Both parameters must be the same.
void RWSymMat< TypeT >::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.
|
inline |
Returns the number of rows in the matrix.
void RWSymMat< TypeT >::saveOn | ( | RWvostream & | ) | const |
Stores a matrix to an RWvostream, the Rogue Wave virtual output stream class. The matrix can be read using the restoreFrom() member function.
Stores a matrix to an RWFile. The matrix can be read using the restoreFrom() member function.
void RWSymMat< TypeT >::scanFrom | ( | std::istream & | ) |
Reads a matrix from an input stream. The format of the matrix is the same as the format output by the printOn() 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 symmetric part of the matrix is used.
|
inline |
Sets the ij th element 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 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 parameter. 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.
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 formed by applying the appropriate function to corresponding elements of the parameter matrices.
|
related |
Returns a matrix where each element is formed by applying the appropriate function to corresponding elements of the parameter matrices.
Returns a matrix where each element is the complex conjugate of the corresponding element in the matrix A.
Returns a matrix where each element is the imaginary part of the corresponding element in the matrix A.
Builds a symmetric matrix that matches the lower triangular part of A. The upper triangle of A is not referenced.
|
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.
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 parameters. To do inner product matrix multiplication, you can use the product() global function.
Performs element-by-element operations on the parameters.
Performs element-by-element operations on the parameters.
Unary plus operator. Returns a copy of the matrix.
|
related |
Performs element-by-element operations on the parameters.
Performs element-by-element operations on the parameters.
Performs element-by-element operations on the parameters.
Unary minus operator. Returns negation of the matrix.
|
related |
Performs element-by-element operations on the parameters.
Performs element-by-element operations on the parameters.
Performs element-by-element operations on the parameters.
|
related |
Performs element-by-element operations on the parameters.
Performs element-by-element operations on the parameters.
Performs element-by-element operations on the parameters.
|
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.
Returns a matrix where each element is the real part of the corresponding element in the matrix A.
Extracts the symmetric part of a square matrix. The symmetric part of matrix A is \( (A+A^{T})/2 \).
Returns the transpose of the parameter matrix. Since a symmetric matrix is its own transpose, this function just returns itself.
Copyright © 2021 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |