SourcePro C++ 12.0 |
SourcePro® C++ API Reference Guide |
SourcePro C++ Documentation Home |
A templatized general matrix class. More...
#include <rw/math/genmat.h>
Inherits RWMatView.
Public Types | |
typedef RWGenMatIterator< T > | iterator |
typedef RWGenMatConstIterator< T > | const_iterator |
typedef rw_numeric_traits< T > ::promote_type | promote_type |
typedef rw_numeric_traits< T > ::norm_type | norm_type |
typedef rw_numeric_traits< T > ::mathFunType | mathFunType |
typedef rw_numeric_traits< T > ::mathFunType2 | mathFunType2 |
Public Member Functions | |
RWGenMat () | |
RWGenMat (size_t m, size_t n, RWUninitialized, Storage s=COLUMN_MAJOR) | |
RWGenMat (size_t m, size_t n, RWTRand< RWRandGenerator > &r, Storage=COLUMN_MAJOR) | |
RWGenMat (size_t m, size_t n, const T &initval, Storage storage=COLUMN_MAJOR) | |
RWGenMat (const char *s, Storage=COLUMN_MAJOR) | |
RWGenMat (const RWGenMat< T > &a) | |
RWGenMat (const T *dat, size_t m, size_t n, Storage=COLUMN_MAJOR) | |
RWGenMat (const RWMathVec< T > &vec, size_t m, size_t s, Storage=COLUMN_MAJOR) | |
RWGenMat (const RWGenMat< double > &re, const RWGenMat< double > &im, Storage=COLUMN_MAJOR) | |
RWGenMat< T > | apply (mathFunType f) const |
RWGenMat< norm_type > | apply2 (mathFunType2 f) const |
iterator | begin (RWDataView::Storage storage=RWDataView::COLUMN_MAJOR) |
const_iterator | begin (RWDataView::Storage storage=RWDataView::COLUMN_MAJOR) const |
iterator | end (RWDataView::Storage storage=RWDataView::COLUMN_MAJOR) |
const_iterator | end (RWDataView::Storage storage=RWDataView::COLUMN_MAJOR) const |
size_t | binaryStoreSize () const |
const RWMathVec< T > | col (int) const |
RWMathVec< T > | col (int) |
size_t | cols () const |
int | colStride () const |
RWGenMat< T > | copy (Storage s=COLUMN_MAJOR) const |
T * | data () |
const T * | data () const |
RWGenMat< T > | deepCopy (Storage s=COLUMN_MAJOR) const |
void | deepenShallowCopy (Storage s=COLUMN_MAJOR) |
const RWMathVec< T > | diagonal (int idiag=0) const |
RWMathVec< T > | diagonal (int idiag=0) |
RWGenMatPick< T > | pick (const RWIntVec &v1, const RWIntVec &v2) |
const RWGenMatPick< T > | pick (const RWIntVec &v1, const RWIntVec &v2) const |
RWGenMat< T > & | reference (const RWGenMat< T > &m) |
void | resize (size_t m, size_t n, Storage s=COLUMN_MAJOR) |
void | reshape (size_t m, size_t n, Storage s=COLUMN_MAJOR) |
void | restoreFrom (RWFile &, Storage s=COLUMN_MAJOR) |
void | restoreFrom (RWvistream &, Storage s=COLUMN_MAJOR) |
const RWMathVec< T > | row (int) const |
RWMathVec< T > | row (int) |
size_t | rows () const |
int | rowStride () const |
void | saveOn (RWFile &) const |
void | saveOn (RWvostream &) const |
RWMathVec< T > | slice (int i, int j, size_t n, int rowstride, int colstride) const |
RWGenMat< T > | slice (int i, int j, size_t m, size_t n, int rowstr1, int colstr1, int rowstr2, int colstr2) const |
T & | operator() (int i, int j) |
T | operator() (int i, int j) const |
RWMathVec< T > | operator() (int i, const RWSlice &j) |
const RWMathVec< T > | operator() (int i, const RWSlice &j) const |
RWMathVec< T > | operator() (const RWSlice &i, int j) |
const RWMathVec< T > | operator() (const RWSlice &i, int j) const |
RWGenMat< T > | operator() (const RWSlice &i, const RWSlice &j) |
const RWGenMat< T > | operator() (const RWSlice &i, const RWSlice &j) const |
RWGenMat< T > & | operator= (const RWGenMat< T > &v) |
RWGenMat< T > & | operator= (const RWGenMatPick< T > &v) |
RWGenMat< T > & | operator= (const T &s) |
bool | operator== (const RWGenMat< T > &) const |
bool | operator!= (const RWGenMat< T > &v) const |
RWGenMat< T > & | operator+= (const T &s) |
RWGenMat< T > & | operator-= (const T &s) |
RWGenMat< T > & | operator*= (const T &s) |
RWGenMat< T > & | operator/= (const T &s) |
RWGenMat< T > & | operator+= (const RWGenMat< T > &v) |
RWGenMat< T > & | operator-= (const RWGenMat< T > &v) |
RWGenMat< T > & | operator*= (const RWGenMat< T > &v) |
RWGenMat< T > & | operator/= (const RWGenMat< T > &v) |
RWGenMat< T > & | operator++ () |
RWGenMat< T > & | operator-- () |
void | operator++ (int) |
void | operator-- (int) |
operator RWGenMat< promote_type > () | |
Friends | |
RWGenMat< double > | real (const RWGenMat< DComplex > &) |
RWGenMat< double > | imag (const RWGenMat< DComplex > &) |
Related Functions | |
(Note that these are not member functions.) | |
template<class T > | |
T | determinant (const RWGenMat< T > &A) |
template<class T > | |
RWGenMat< T > | operator- (const RWGenMat< T > &v) |
template<class T > | |
RWGenMat< T > | operator+ (const RWGenMat< T > &v) |
template<class T > | |
RWGenMat< T > | operator+ (const RWGenMat< T > &u, const RWGenMat< T > &v) |
template<class T > | |
RWGenMat< T > | operator- (const RWGenMat< T > &u, const RWGenMat< T > &v) |
template<class T > | |
RWGenMat< T > | operator* (const RWGenMat< T > &u, const RWGenMat< T > &v) |
template<class T > | |
RWGenMat< T > | elementProduct (const RWGenMat< T > &A, const RWGenMat< T > &B) |
template<class T > | |
RWGenMat< T > | operator/ (const RWGenMat< T > &u, const RWGenMat< T > &v) |
template<class T > | |
RWGenMat< T > | operator+ (const RWGenMat< T > &u, const T &s) |
template<class T > | |
RWGenMat< T > | operator- (const T &s, const RWGenMat< T > &v) |
template<class T > | |
RWGenMat< T > | operator* (const RWGenMat< T > &u, const T &s) |
template<class T > | |
RWGenMat< T > | operator/ (const T &s, const RWGenMat< T > &v) |
template<class T > | |
std::ostream & | operator<< (std::ostream &s, const RWGenMat< T > &m) |
template<class T > | |
std::istream & | operator>> (std::istream &s, RWGenMat< T > &v) |
template<class T > | |
RWGenMat< T > | operator* (const T &s, const RWGenMat< T > &v) |
template<class T > | |
RWGenMat< T > | operator+ (const T &s, const RWGenMat< T > &v) |
template<class T > | |
RWGenMat< T > | operator- (const RWGenMat< T > &u, const T &s) |
template<class T > | |
RWGenMat< T > | operator/ (const RWGenMat< T > &u, const T &s) |
RWGenMat< double > | abs (const RWGenMat< DComplex > &M) |
RWGenMat< double > | abs (const RWGenMat< double > &M) |
RWGenMat< float > | abs (const RWGenMat< float > &M) |
RWGenMat< int > | abs (const RWGenMat< int > &M) |
RWGenMat< SChar > | abs (const RWGenMat< SChar > &M) |
template<class T > | |
void | maxIndex (const RWGenMat< T > &, int *i, int *j) |
template<class T > | |
void | minIndex (const RWGenMat< T > &, int *i, int *j) |
template<class T > | |
T | maxValue (const RWGenMat< T > &) |
template<class T > | |
T | minValue (const RWGenMat< T > &) |
template<class T > | |
RWMathVec< T > | product (const RWGenMat< T > &A, const RWMathVec< T > &v) |
template<class T > | |
RWGenMat< T > | product (const RWGenMat< T > &A, const RWGenMat< T > &B) |
template<class T > | |
RWGenMat< T > | transpose (const RWGenMat< T > &x) |
template<class T > | |
RWGenMat< T > | cos (const RWGenMat< T > &x) |
template<class T > | |
RWGenMat< T > | cosh (const RWGenMat< T > &x) |
template<class T > | |
RWGenMat< T > | exp (const RWGenMat< T > &x) |
template<class T > | |
T | mean (const RWGenMat< T > &x) |
template<class T > | |
RWGenMat< T > | pow (const RWGenMat< T > &x, const RWGenMat< T > &y) |
template<class T > | |
RWGenMat< T > | pow (const RWGenMat< T > &x, T y) |
template<class T > | |
RWGenMat< T > | pow (T x, const RWGenMat< T > &y) |
template<class T > | |
RWGenMat< T > | sin (const RWGenMat< T > &x) |
template<class T > | |
RWGenMat< T > | sinh (const RWGenMat< T > &x) |
template<class T > | |
RWGenMat< T > | sqrt (const RWGenMat< T > &x) |
double | variance (const RWGenMat< DComplex > &x) |
double | variance (const RWGenMat< double > &x) |
float | variance (const RWGenMat< float > &x) |
template<class T > | |
RWGenMat< T > | acos (const RWGenMat< T > &x) |
template<class T > | |
RWGenMat< T > | asin (const RWGenMat< T > &x) |
template<class T > | |
RWGenMat< T > | atan (const RWGenMat< T > &x) |
template<class T > | |
RWGenMat< T > | atan2 (const RWGenMat< T > &x, const RWGenMat< T > &y) |
template<class T > | |
RWGenMat< T > | ceil (const RWGenMat< T > &x) |
template<class T > | |
RWGenMat< T > | floor (const RWGenMat< T > &x) |
template<class T > | |
RWGenMat< T > | log (const RWGenMat< T > &x) |
template<class T > | |
RWGenMat< T > | log10 (const RWGenMat< T > &x) |
template<class T > | |
RWGenMat< T > | tan (const RWGenMat< T > &x) |
template<class T > | |
RWGenMat< T > | tanh (const RWGenMat< T > &x) |
RWGenMat< double > | arg (const RWGenMat< DComplex > &x) |
RWGenMat< DComplex > | conj (const RWGenMat< DComplex > &x) |
RWGenMat< double > | norm (const RWGenMat< DComplex > &x) |
template<class T > | |
RWGenMat< T > | transposeProduct (const RWGenMat< T > &A, const RWGenMat< T > &B) |
RWGenMat< DComplex > | conjTransposeProduct (const RWGenMat< DComplex > &A, const RWGenMat< DComplex > &B) |
RWGenMat< SChar > | toChar (const RWGenMat< int > &V) |
RWGenMat< float > | toFloat (const RWGenMat< double > &V) |
RWGenMat< int > | toInt (const RWGenMat< double > &V) |
RWGenMat< int > | toInt (const RWGenMat< float > &V) |
double | l1Norm (const RWGenMat< DComplex > &) |
double | l1Norm (const RWGenMat< double > &) |
float | l1Norm (const RWGenMat< float > &) |
double | linfNorm (const RWGenMat< DComplex > &) |
double | linfNorm (const RWGenMat< double > &) |
float | linfNorm (const RWGenMat< float > &) |
double | frobNorm (const RWGenMat< DComplex > &) |
double | frobNorm (const RWGenMat< double > &) |
float | frobNorm (const RWGenMat< float > &) |
double | maxNorm (const RWGenMat< DComplex > &) |
double | maxNorm (const RWGenMat< double > &) |
float | maxNorm (const RWGenMat< float > &) |
template<class T > | |
RWGenMat< T > | operator% (const RWGenMat< T > &A, const RWGenMat< T > &B) |
template<class T > | |
RWMathVec< T > | operator% (const RWGenMat< T > &A, const RWMathVec< T > &x) |
template<class T > | |
RWMathVec< T > | operator% (const RWMathVec< T > &x, const RWGenMat< T > &A) |
Class RWGenMat<T> is a templatized general matrix class.
#include <rw/math/genmat.h> template<class T> RWGenMat<T> matrix;
#include <rw/math/genmat.h> int main() { RWGenMat<int> A(3,5,rwUninitialized), B(5,2,rwUninitialized); A = 3; // Set all elements in A to 3 B(RWAll,0) = 1; // Set first column of B to 1 B(RWAll,1) = 3; // Set second column of B to 3 RWGenMat<int> AB = product(A,B); }
typedef RWGenMatConstIterator<T> RWGenMat< T >::const_iterator |
Typedef for a random access const
iterator.
typedef RWGenMatIterator<T> RWGenMat< T >::iterator |
Typedef for a random access iterator.
typedef rw_numeric_traits<T>::mathFunType RWGenMat< T >::mathFunType |
Typedef for the function pointer used in the method apply(). For more information, see rw_numeric_traits<T>::mathFunType.
typedef rw_numeric_traits<T>::mathFunType2 RWGenMat< T >::mathFunType2 |
Typedef for the function pointer used in the method apply2(). For more information, see rw_numeric_traits<T>::mathFunType2.
typedef rw_numeric_traits<T>::norm_type RWGenMat< T >::norm_type |
Typedef for the usual return type of numerical norm
-like functions. For more information, see rw_numeric_traits<T>::norm_type.
typedef rw_numeric_traits<T>::promote_type RWGenMat< T >::promote_type |
Typedef for the promotion type. For more information, see rw_numeric_traits<T>::promote_type.
RWGenMat< T >::RWGenMat | ( | size_t | m, | |
size_t | n, | |||
RWUninitialized | , | |||
Storage | s = COLUMN_MAJOR | |||
) | [inline] |
Constructs a matrix with a specified number of rows and columns. The optional storage indicator determines whether the matrix is stored in ROW_MAJOR
or COLUMN_MAJOR
order. The RWUninitialized type is an enumeration type with only one value, rwUninitialized. The rwUninitialized argument is used to distinguish the last dimension size from an initial value.
RWGenMat< T >::RWGenMat | ( | size_t | m, | |
size_t | n, | |||
RWTRand< RWRandGenerator > & | r, | |||
Storage | = COLUMN_MAJOR | |||
) |
Constructs a matrix with m rows and n columns. Initialized with random numbers generated by r. The optional storage indicator determines whether the matrix is stored in ROW_MAJOR
or COLUMN_MAJOR
order.
RWGenMat< T >::RWGenMat | ( | size_t | m, | |
size_t | n, | |||
const T & | initval, | |||
Storage | storage = COLUMN_MAJOR | |||
) | [inline] |
Constructs a matrix with a specified number of rows and columns. Initializes each matrix element to initval. The optional storage indicator determines whether the matrix is stored in ROW_MAJOR
or COLUMN_MAJOR
order.
Constructs a matrix from the null terminated character string s. The format of the character string is the same as that expected by the global operator operator>> described in this entry. The optional storage indicator determines whether the matrix is stored in ROW_MAJOR
or COLUMN_MAJOR
order.
Copy constructor. The new matrix and the old matrix both view the same data.
RWGenMat< T >::RWGenMat | ( | const T * | dat, | |
size_t | m, | |||
size_t | n, | |||
Storage | = COLUMN_MAJOR | |||
) |
A matrix with m rows and n columns is constructed, using the data in the vector dat as initial data. A copy of dat is made. The vector dat must have at least n * m elements. The optional storage indicator determines whether the matrix is stored in ROW_MAJOR
or COLUMN_MAJOR
order.
RWGenMat< T >::RWGenMat | ( | const RWMathVec< T > & | vec, | |
size_t | m, | |||
size_t | s, | |||
Storage | = COLUMN_MAJOR | |||
) |
A matrix with m rows and n columns is constructed, using the data in the vector v. The matrix is a new view of the same data as v, so no copy of the data is made. The optional storage indicator determines whether the matrix is stored in ROW_MAJOR
or COLUMN_MAJOR
order. If the vector does not have length m times n, an exception of type MATX_NUMBERPOINTS
is thrown.
RWGenMat< T >::RWGenMat | ( | const RWGenMat< double > & | re, | |
const RWGenMat< double > & | im, | |||
Storage | = COLUMN_MAJOR | |||
) |
A complex matrix is constructed from the double precision matrices re and im, with the real part of the matrix equal to re and the imaginary part equal to im. A new copy of the data is made. The optional storage indicator determines whether the matrix is stored in ROW_MAJOR
or COLUMN_MAJOR
order.
RWGenMat<T> RWGenMat< T >::apply | ( | mathFunType | f | ) | const |
Returns the result of applying the passed function to every element in the matrix. A function of type RWGenMat<T>::mathFunType takes and returns a T
. A function of type RWGenMat<T>::mathFunType2 takes a T
and returns an RWGenMat<T>::norm_type. For a description of this type, see rw_numeric_traits<T> .
RWGenMat<norm_type> RWGenMat< T >::apply2 | ( | mathFunType2 | f | ) | const |
Returns the result of applying the passed function to every element in the matrix. A function of type RWGenMat<T>::mathFunType takes and returns a T
. A function of type RWGenMat<T>::mathFunType2 takes a T
and returns an RWGenMat<T>::norm_type. For a description of this type, see rw_numeric_traits<T> .
const_iterator RWGenMat< T >::begin | ( | RWDataView::Storage | storage = RWDataView::COLUMN_MAJOR |
) | const [inline] |
Returns an iterator that points to the element in the first row and first column of self. The optional storage specifier determines the order in which the iterator traverses the elements of the matrix; the specifier is independent of the storage format of the matrix. A COLUMN_MAJOR
iterator proceeds down each column while a ROW_MAJOR
iterator proceeds along rows.
ROW_MAJOR
iterator and a COLUMN_MAJOR
iterator have unpredictable results. iterator RWGenMat< T >::begin | ( | RWDataView::Storage | storage = RWDataView::COLUMN_MAJOR |
) | [inline] |
Returns an iterator that points to the element in the first row and first column of self. The optional storage specifier determines the order in which the iterator traverses the elements of the matrix; the specifier is independent of the storage format of the matrix. A COLUMN_MAJOR
iterator proceeds down each column while a ROW_MAJOR
iterator proceeds along rows.
ROW_MAJOR
iterator and a COLUMN_MAJOR
iterator have unpredictable results. size_t RWGenMat< T >::binaryStoreSize | ( | ) | const |
Returns the number of bytes required to store the matrix to an RWFile using member function saveOn(RWFile&).
Returns a vector that views a column of the matrix.
Returns a vector that views a column of the matrix.
size_t RWGenMat< T >::cols | ( | ) | const [inline] |
Returns the number of columns of the matrix.
int RWGenMat< T >::colStride | ( | ) | const [inline] |
Returns the stride to move through the data from one column to the next. Could be computed as &A(i,j+1)-&A(i,j)
.
Returns a copy with distinct instance variables. The function copy() is a synonym for deepCopy().The optional storage indicator determines whether the matrix is stored in ROW_MAJOR
or COLUMN_MAJOR
order.
const T* RWGenMat< T >::data | ( | void | ) | const [inline] |
Returns a pointer to the start of a matrix's data. Should be used with care, as this function accesses the matrix's data directly.
T* RWGenMat< T >::data | ( | void | ) | [inline] |
Returns a pointer to the start of a matrix's data. Should be used with care, as this function accesses the matrix's data directly.
Returns a copy with distinct instance variables. The function copy() is a synonym for deepCopy().The optional storage indicator determines whether the matrix is stored in ROW_MAJOR
or COLUMN_MAJOR
order.
Invoking deepenShallowCopy() for a matrix guarantees that there is only one reference to that object and that its data are in contiguous storage. The optional storage indicator determines whether the matrix is stored in ROW_MAJOR
or COLUMN_MAJOR
order.
Returns the diagonal elements of the matrix as a vector, with optional bounds checking. The default idiag = 0
implies the main diagonal; idiag = n
implies n
diagonal slices up from center; idiag = -n
implies n
diagonal slices down.
Returns the diagonal elements of the matrix as a vector, with optional bounds checking. The default idiag = 0
implies the main diagonal; idiag = n
implies n
diagonal slices up from center; idiag = -n
implies n
diagonal slices down.
const_iterator RWGenMat< T >::end | ( | RWDataView::Storage | storage = RWDataView::COLUMN_MAJOR |
) | const [inline] |
Returns an iterator that points to one element past the last element in the matrix. The optional storage specifier determines the order in which the iterator traverses the elements of the matrix; the specifier is independent of the storage format of the matrix. A COLUMN_MAJOR
iterator proceeds down each column, while a ROW_MAJOR
iterator proceeds along rows.
ROW_MAJOR
iterator and a COLUMN_MAJOR
iterator have unpredictable results. iterator RWGenMat< T >::end | ( | RWDataView::Storage | storage = RWDataView::COLUMN_MAJOR |
) | [inline] |
Returns an iterator that points to one element past the last element in the matrix. The optional storage specifier determines the order in which the iterator traverses the elements of the matrix; the specifier is independent of the storage format of the matrix. A COLUMN_MAJOR
iterator proceeds down each column, while a ROW_MAJOR
iterator proceeds along rows.
ROW_MAJOR
iterator and a COLUMN_MAJOR
iterator have unpredictable results. RWGenMat< T >::operator RWGenMat< promote_type > | ( | ) | [inline] |
Implicit conversion operator to rw_numeric_traits<T>::promote_type.
Returns true
if self and the argument are equivalent (or not equivalent). That is, they must have the same number of rows as well as columns, and each element in self must equal the corresponding element in the argument.
const RWGenMat< T > RWGenMat< T >::operator() | ( | const RWSlice & | i, | |
const RWSlice & | j | |||
) | const [inline] |
Subscripting operator for the matrix, with optional bounds checking. Bounds checking is enabled by defining the preprocessor macro RWBOUNDS_CHECK
before including the header file. All subscripting operators return a new view of the same data as the matrix being subscripted. An object of type RWRange or RWToEnd, the global object RWAll, or a character string may be substituted for an RWSlice.
RWGenMat< T > RWGenMat< T >::operator() | ( | const RWSlice & | i, | |
const RWSlice & | j | |||
) | [inline] |
Subscripting operator for the matrix, with optional bounds checking. Bounds checking is enabled by defining the preprocessor macro RWBOUNDS_CHECK
before including the header file. All subscripting operators return a new view of the same data as the matrix being subscripted. An object of type RWRange or RWToEnd, the global object RWAll, or a character string may be substituted for an RWSlice.
const RWMathVec< T > RWGenMat< T >::operator() | ( | const RWSlice & | i, | |
int | j | |||
) | const [inline] |
Subscripting operator for the matrix, with optional bounds checking. Bounds checking is enabled by defining the preprocessor macro RWBOUNDS_CHECK
before including the header file. All subscripting operators return a new view of the same data as the matrix being subscripted. An object of type RWRange or RWToEnd, the global object RWAll, or a character string may be substituted for an RWSlice.
Subscripting operator for the matrix, with optional bounds checking. Bounds checking is enabled by defining the preprocessor macro RWBOUNDS_CHECK
before including the header file. All subscripting operators return a new view of the same data as the matrix being subscripted. An object of type RWRange or RWToEnd, the global object RWAll, or a character string may be substituted for an RWSlice.
const RWMathVec< T > RWGenMat< T >::operator() | ( | int | i, | |
const RWSlice & | j | |||
) | const [inline] |
Subscripting operator for the matrix, with optional bounds checking. Bounds checking is enabled by defining the preprocessor macro RWBOUNDS_CHECK
before including the header file. All subscripting operators return a new view of the same data as the matrix being subscripted. An object of type RWRange or RWToEnd, the global object RWAll, or a character string may be substituted for an RWSlice.
Subscripting operator for the matrix, with optional bounds checking. Bounds checking is enabled by defining the preprocessor macro RWBOUNDS_CHECK
before including the header file. All subscripting operators return a new view of the same data as the matrix being subscripted. An object of type RWRange or RWToEnd, the global object RWAll, or a character string may be substituted for an RWSlice.
T RWGenMat< T >::operator() | ( | int | i, | |
int | j | |||
) | const [inline] |
Subscripting operator for the matrix, with optional bounds checking. Bounds checking is enabled by defining the preprocessor macro RWBOUNDS_CHECK
before including the header file. All subscripting operators return a new view of the same data as the matrix being subscripted. An object of type RWRange or RWToEnd, the global object RWAll, or a character string may be substituted for an RWSlice.
T & RWGenMat< T >::operator() | ( | int | i, | |
int | j | |||
) | [inline] |
Subscripting operator for the matrix, with optional bounds checking. Bounds checking is enabled by defining the preprocessor macro RWBOUNDS_CHECK
before including the header file. All subscripting operators return a new view of the same data as the matrix being subscripted. An object of type RWRange or RWToEnd, the global object RWAll, or a character string may be substituted for an RWSlice.
Assignment by multiplication operator with conventional meaning. The expression implies . The RWGenMat objects must conform, that is, have the same dimensions.
Assignment by multiplication operator with conventional meaning. The expression implies .
void RWGenMat< T >::operator++ | ( | int | ) | [inline] |
Increments each element of self. This overload is invoked if the operator is used as a postfix operator.
Assignment by addition operator with conventional meaning. The expression implies . The RWGenMat objects must conform, that is, have the same dimensions.
Assignment by addition operator with conventional meaning. The expression implies .
void RWGenMat< T >::operator-- | ( | int | ) | [inline] |
Decrements each element of self. This overload is invoked if the operator is used as a postfix operator.
Assignment by subtraction operator with conventional meaning. The expression implies . The RWGenMat objects must conform, that is, have the same dimensions.
Assignment by subtraction operator with conventional meaning. The expression implies .
Assignment by division operator with conventional meaning. The expression implies . The RWGenMat objects must conform, that is, have the same dimensions.
Assignment by division operator with conventional meaning. The expression implies .
Assignment operator with conventional meaning. The expression implies .
Assignment operator with conventional meaning. The expression implies . The RWGenMat objects must conform, that is, have the same dimensions.
Assignment operator with conventional meaning. The expression implies . The RWGenMat objects must conform, that is, have the same dimensions.
Returns true
if self and the argument are equivalent (or not equivalent). That is, they must have the same number of rows as well as columns, and each element in self must equal the corresponding element in the argument.
const RWGenMatPick<T> RWGenMat< T >::pick | ( | const RWIntVec & | v1, | |
const RWIntVec & | v2 | |||
) | const |
Returns a matrix pick. The results can be used as an lvalue. You can think of the "picked" submatrix as specifying an intersection of the rows listed in v1 and the columns listed in v2. Before using this function, you must include the header file rw\math\matpick.h
.
Returns a matrix pick. The results can be used as an lvalue. You can think of the "picked" submatrix as specifying an intersection of the rows listed in v1 and the columns listed in v2. Before using this function, you must include the header file rw\math\matpick.h
.
Makes self a view of the data contained in m. The view currently associated with the matrix is lost.
Changes the size of the matrix to m rows and n columns. After reshaping, the contents of the matrix are undefined; that is, they can be garbage, and probably will be. The optional storage indicator determines whether the matrix is stored in ROW_MAJOR
or COLUMN_MAJOR
order.
Changes the size of the matrix to m rows and n columns, adding 0s or truncating as necessary. The optional storage indicator determines whether the matrix is stored in ROW_MAJOR
or COLUMN_MAJOR
order.
void RWGenMat< T >::restoreFrom | ( | RWvistream & | , | |
Storage | s = COLUMN_MAJOR | |||
) |
Restores self from a virtual stream. The optional storage indicator determines whether the matrix is stored in ROW_MAJOR
or COLUMN_MAJOR
order. To use these functions with a user-defined type T, the corresponding operator >>
must be defined:
RWvistream& operator>>(RWvistream&, T&);
Restores self from an RWFile. The optional storage indicator determines whether the matrix is stored in ROW_MAJOR
or COLUMN_MAJOR
order. To use these functions with a user-defined type T, the corresponding operator >>
must be defined:
RWFile& operator>>(RWFile&, T&);
Returns a vector that views a row of the matrix.
Returns a vector that views a row of the matrix.
size_t RWGenMat< T >::rows | ( | ) | const [inline] |
Return the number of rows of the matrix.
int RWGenMat< T >::rowStride | ( | ) | const [inline] |
Returns the stride required to move through the data from one row to the next. Could be computed as &A(i+1,j)-&A(i,j)
.
void RWGenMat< T >::saveOn | ( | RWvostream & | ) | const |
Stores self to a virtual stream. If T is a user-defined type, the shift operator<<
must be defined:
RWvostream& operator<<(RWvostream&, const T&);
Stores self in a binary format to an RWFile. If T is a user-defined type, the shift operator<<
must be defined:
RWFile& operator<<(RWFile&, const T&);
RWGenMat<T> RWGenMat< T >::slice | ( | int | i, | |
int | j, | |||
size_t | m, | |||
size_t | n, | |||
int | rowstr1, | |||
int | colstr1, | |||
int | rowstr2, | |||
int | colstr2 | |||
) | const [inline] |
Returns a matrix that views a slice of the matrix. The slice begins at element i, j and contains m rows and n columns. The increment between successive elements in the slice's row is rowstr1 rows and colstr1 columns. The increment between successive elements in the slice's column is rowstr2 rows and colstr2 columns. For example:
A.slice(n-1,0, n,n, -1,0, 0,1)
returns a view of the n x n matrix A
upside down. A more readable way to accomplish this is:
RWMathVec<T> RWGenMat< T >::slice | ( | int | i, | |
int | j, | |||
size_t | n, | |||
int | rowstride, | |||
int | colstride | |||
) | const [inline] |
Returns a vector that views a slice of the matrix. The slice begins at element i,j and extends for n elements. The increment between successive elements in the vector is rowstride rows and colstride columns. For example:
A.slice(n-1,0, n, -1,1)
is a view of the diagonal from the bottom left to top right corners of the n x n matrix A
.
Returns the absolute values of each element.See the example in abs(const RWGenMat<double>&)
double
. Therefore, if abs() is invoked for class RWGenMat<DComplex> , a vector of class RWGenMat<double> is returned. See the example in abs(const RWGenMat<double>&)
Returns the absolute values of each element.See the example in abs(const RWGenMat<double>&)
double
. Therefore, if abs() is invoked for class RWGenMat<DComplex> , a vector of class RWGenMat<double> is returned. See the example in abs(const RWGenMat<double>&)
Returns the absolute values of each element.See the example in abs(const RWGenMat<double>&)
double
. Therefore, if abs() is invoked for class RWGenMat<DComplex> , a vector of class RWGenMat<double> is returned. See the example in abs(const RWGenMat<double>&)
Returns the absolute values of each element.
#include <rw/math/genmat.h> #include <iostream> const double adata[] = {1.2,2.4,-1.2,0.8,-4.5}; int main() { RWGenMat<double> a(adata,5, 1, 1); RWGenMat<double> b = abs(a); std::cout << b; return 0; }
Program Output:
5x1 [ 1.2 2.4 1.2 0.8 4.5 ]
Returns the absolute values of each element.
See the example in abs(const RWGenMat<double>&)
double
. Therefore, if abs() is invoked for class RWGenMat<DComplex> , a vector of class RWGenMat<double> is returned. Returns arc cosines y
such that . The yi
(in radians) are in the range , for elements xi with absolute values .
Takes x as an argument and returns arc sines y
such that . The yi
(in radians) are in the range , for elements xi with absolute values .
Takes x and returns y
of arc tangents (in radians), such that , where .
RWGenMat< T > atan2 | ( | const RWGenMat< T > & | x, | |
const RWGenMat< T > & | y | |||
) | [related] |
Takes two arguments and returns quadrant correct arc tangents z
(in radians), such that . For each element i
, the expression is mathematically equivalent to:
At least one of the arguments xi or yi must be nonzero.
Takes x as an argument and returns y
such that yi
corresponds to the next integer greater than or equal to xi. For example, if x = [ -1.3, 4.3, 7.9]
then y = [ -1, 5, 8].
Takes complex x as an argument and returns the complex conjugates . For example, if , then .
RWGenMat< DComplex > conjTransposeProduct | ( | const RWGenMat< DComplex > & | A, | |
const RWGenMat< DComplex > & | B | |||
) | [related] |
Takes a matrix A (of M
rows by N
columns) and a matrix B (of M
rows by P
columns) as arguments and returns a matrix C
(of N
rows by P
columns) which is equal to conj(A)TB
, that is, the inner product of the conjugate transpose of A with B.
If the number of rows in A does not match the number of rows in B, an exception with value RWLAPK_MATMATPROD
occurs.
C = product(conj(transpose(A)), B)
. Takes x as an argument and returns y
such that . The xi are in radians. For complex arguments, the complex cosine is returned.
Takes x as an argument and returns hyperbolic cosines y
such that . For complex arguments, the complex hyperbolic cosine is returned.
T determinant | ( | const RWGenMat< T > & | A | ) | [related] |
Returns the determinant of the matrix from which an LU factorization A is constructed.
RWGenMat< T > elementProduct | ( | const RWGenMat< T > & | A, | |
const RWGenMat< T > & | B | |||
) | [related] |
Takes two matrices, A and B, and returns a matrix C
such that:
Takes an argument x and returns y
such that:
If class T
is complex, the complex exponential is returned.
Takes x as an argument and returns y
such that yi
corresponds to the largest integer less than or equal to xi. For example, if x = [ 1.3, 4.4, -3.2]
, then y = [ 1, 4, -4].
float frobNorm | ( | const RWGenMat< float > & | ) | [related] |
Computes the Frobenius norm, which is the square root of the sum of squares of its entries. For a matrix, the formula is:
double frobNorm | ( | const RWGenMat< double > & | ) | [related] |
Computes the Frobenius norm, which is the square root of the sum of squares of its entries. For a matrix, the formula is:
Computes the Frobenius norm, which is the square root of the sum of squares of its entries. For a matrix, the formula is:
Takes complex x as an argument and returns y
containing the imaginary parts . With most versions of complex, the results can be used as an l-value:
RWGenMat<DComplex> v(5, 0); // (0, 0), (0, 0), ... imag(v) = 1.0; // (0, 1), (0, 1), ...
float l1Norm | ( | const RWGenMat< float > & | ) | [related] |
The function l1Norm()is the maximum of the l1Norms
of its columns:
double l1Norm | ( | const RWGenMat< double > & | ) | [related] |
The function l1Norm()is the maximum of the l1Norms
of its columns:
The function l1Norm()is the maximum of the l1Norms
of its columns:
float linfNorm | ( | const RWGenMat< float > & | ) | [related] |
The function l1Norm()is the maximum of the l1fNorms
of its rows:
double linfNorm | ( | const RWGenMat< double > & | ) | [related] |
The function l1Norm()is the maximum of the l1fNorms
of its rows:
The function l1Norm()is the maximum of the l1fNorms
of its rows:
Takes x as an argument and returns natural logarithms y
such that . The arguments xi must not be 0. For complex arguments, the principal value of the complex natural logarithm is returned.
Takes x as an argument and returns base 10 logarithms y
such that . The arguments xi must not be 0.
void maxIndex | ( | const RWGenMat< T > & | , | |
int * | i, | |||
int * | j | |||
) | [related] |
Return the index
of the maximum element of the vector. If instead you want the maximum value
use function maxValue().
float maxNorm | ( | const RWGenMat< float > & | ) | [related] |
Returns the value of the element with largest absolute value. Note that this is not a norm in the mathematical sense of the word.
double maxNorm | ( | const RWGenMat< double > & | ) | [related] |
Returns the value of the element with largest absolute value. Note that this is not a norm in the mathematical sense of the word.
Returns the value of the element with largest absolute value. Note that this is not a norm in the mathematical sense of the word.
T maxValue | ( | const RWGenMat< T > & | ) | [related] |
Return the maximum value.
T mean | ( | const RWGenMat< T > & | x | ) | [related] |
Takes an RWGenMat as an argument and returns <x>, the mean value, where:
For example, if x = [1, 4, 3, 4]
, then <x> = 3
.
void minIndex | ( | const RWGenMat< T > & | , | |
int * | i, | |||
int * | j | |||
) | [related] |
Return the index
of the minimum element of the vector. If instead you want the minimum value
use function minValue().
T minValue | ( | const RWGenMat< T > & | ) | [related] |
Return the minimum value.
Takes complex x as an argument and returns real y
containing the norm:
.
RWMathVec< T > operator% | ( | const RWMathVec< T > & | x, | |
const RWGenMat< T > & | A | |||
) | [related] |
Conventional mathematical linear algebra multiplication operator; that is, the i,j
element of the result of a matrix product AB is the dot product of the ith
row of A and the jth
column of B.
RWMathVec< T > operator% | ( | const RWGenMat< T > & | A, | |
const RWMathVec< T > & | x | |||
) | [related] |
Conventional mathematical linear algebra multiplication operator; that is, the i,j
element of the result of a matrix product AB is the dot product of the ith
row of A and the jth
column of B.
RWGenMat< T > operator% | ( | const RWGenMat< T > & | A, | |
const RWGenMat< T > & | B | |||
) | [related] |
Conventional mathematical linear algebra multiplication operator; that is, the i,j
element of the result of a matrix product AB is the dot product of the ith
row of A and the jth
column of B.
Multiplication operator, which is applied element-by-element. For instance, for matrices v, w
, and scaler s, the expression implies .
Multiplication operator, which is applied element-by-element. For instance, for matrices u, w
, and scaler s, the expression implies .
RWGenMat< T > operator* | ( | const RWGenMat< T > & | u, | |
const RWGenMat< T > & | v | |||
) | [related] |
Multiplication operator, which is applied element-by-element. For instance, for matrices u
, v, and w
, the expression implies . The two RWGenMat objects must conform, that is, have the same numbers of rows and columns, or an exception with value RWMATH_MNMATCH
occurs.
Addition operator, which is applied element-by-element. For instance, for matrices v, w
, and scaler s, the expression implies .
Addition operator, which is applied element-by-element. For instance, for matrices u, w
, and scaler s, the expression implies .
RWGenMat< T > operator+ | ( | const RWGenMat< T > & | u, | |
const RWGenMat< T > & | v | |||
) | [related] |
Addition operator, which is applied element-by-element. For instance, for matrices u
, v, and w
, the expression implies . The two RWGenMat objects must conform, that is, have the same numbers of rows and columns, or an exception with value RWMATH_MNMATCH
occurs.
Unary plus operator, which is applied element-by-element. For instance, for matrices v, and w
, the expression implies .
Subtraction operator, which is applied element-by-element. For instance, for matrices u, w
, and scaler s, the expression implies .
Subtraction operator, which is applied element-by-element. For instance, for matrices v, w
, and scaler s, the expression implies .
RWGenMat< T > operator- | ( | const RWGenMat< T > & | u, | |
const RWGenMat< T > & | v | |||
) | [related] |
Subtraction operator, which is applied element-by-element. For instance, for matrices u
, v, and w
, the expression implies . The two RWGenMat objects must conform, that is, have the same numbers of rows and columns, or an exception with value RWMATH_MNMATCH
occurs.
Unary minus operator, which is applied element-by-element. For instance, for matrices v, and w
, the expression implies .
Division operator, which is applied element-by-element. For instance, for matrices u, w
, and scaler s, the expression implies .
Division operator, which is applied element-by-element. For instance, for matrices v, w
, and scaler s, the expression implies .
RWGenMat< T > operator/ | ( | const RWGenMat< T > & | u, | |
const RWGenMat< T > & | v | |||
) | [related] |
Division operator, which is applied element-by-element. For instance, for matrices u
, v, and w
, the expression implies . The two RWGenMat objects must conform, that is, have the same numbers of rows and columns, or an exception with value RWMATH_MNMATCH
occurs.
std::ostream & operator<< | ( | std::ostream & | s, | |
const RWGenMat< T > & | m | |||
) | [related] |
Outputs a matrix m to std::ostream s. First, the number of rows and columns is output, then the values, separated by spaces, are output row by row, beginning with a left bracket [ and terminating with a right bracket
].
std::istream & operator>> | ( | std::istream & | s, | |
RWGenMat< T > & | v | |||
) | [related] |
Reads a matrix v from istream s. First, the number of rows and columns is read, then the matrix values, separated by white space, row-by-row. If the sequence of numbers begins with a left bracket [ , the operator reads to a matching right bracket
]. If no bracket is present, it reads to end of file. The matrix v is stored in
COLUMN_MAJOR
order.
The function pow() takes two arguments: pow( x, y ).
Returns z
such that:
If the number of elements in x does not match the number of elements in y, an exception with value RWMATH_MNMATCH
will occur.
RWGenMat< T > product | ( | const RWGenMat< T > & | A, | |
const RWGenMat< T > & | B | |||
) | [related] |
Returns the inner product of its two arguments. Takes two matrices A and B returns:
The function checks to make sure that the number of columns in A equals the number of rows in B. Otherwise, an exception with value MATX_MATMATPROD
occurs.
RWMathVec< T > product | ( | const RWGenMat< T > & | A, | |
const RWMathVec< T > & | v | |||
) | [related] |
Returns the inner product of its two arguments. Takes a matrix A and a vector v as arguments returns:
The function checks to make sure that the number of columns in A equals the number of elements in v. Otherwise, an exception with value MATX_MATVECPROD
occurs.
Takes a complex argument x and returns real y
containing the real part . With most versions of complex, the results can be used as an l-value:
RWGenMat<DComplex> v(5, 0); // (0, 0), (0, 0), ... real(v) = 1.0; // (1, 0), (1, 0), ...
The function sin() takes x as an argument and returns y
such that . The xi are in radians. For complex classes, the complex sine is returned.
The function sinh() takes x as an argument and returns y
such that . For complex classes, the complex hyperbolic sine is returned.
The square root function. Takes x as an argument and returns y
such that . For complex classes, the principal value of the complex square root is returned.
The function tan() takes argument x and returns y
such that .
The function tanh() takes argument x and returns y
such that .
Converts an RWGenMat<int> instance into a corresponding RWGenMat<signed char> instance. Note that this is a narrowing operation; high order bits are removed.
Converts an RWGenMat<double> instance into a corresponding RWGenMat<float> instance. Note that this is a narrowing operation; high order bits are removed.
Converts an RWGenMat<float> instance into a corresponding RWGenMat<int> instance. Note that truncation occurs.
Converts an RWGenMat<double> instance into a corresponding RWGenMat<int> instance. Note that truncation occurs.
Takes a matrix x as an argument and returns the transpose . The matrix returned is a new view of the same data as the argument matrix. Use RWGenMat::copy() or RWGenMat::deepenShallowCopy() to make the views distinct.
RWGenMat< T > transposeProduct | ( | const RWGenMat< T > & | A, | |
const RWGenMat< T > & | B | |||
) | [related] |
Takes a matrix A (of M
rows by N
columns) and a matrix B (of M
rows by P
columns) as arguments, and returns a matrix C
(of N
rows by P
columns) that is equal to ATB, that is, the inner product of the transpose of A with B:
If the number of rows in A does not match the number of rows in B, an exception with value RWLAPK_MATMATPROD
occurs.
Note that calling this function is equivalent to calling:
float variance | ( | const RWGenMat< float > & | x | ) | [related] |
Takes a matrix x as an argument and returns its variance y
as in:
where <x> is the mean of the matrix and
N
is the number of rows times columns. Note that this is the biased variance.
double variance | ( | const RWGenMat< double > & | x | ) | [related] |
Takes a matrix x as an argument and returns its variance y
as in:
where <x> is the mean of the matrix and
N
is the number of rows times columns. Note that this is the biased variance.
© 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.