SourcePro® API Reference Guide

 
List of all members | Public Types | Public Member Functions | Friends | Related Functions
RWGenMat< T > Class Template Reference

A templatized general matrix class. More...

#include <rw/math/genmat.h>

Inherits RWMatView.

Public Types

typedef RWGenMatConstIterator< T > const_iterator
 
typedef std::reverse_iterator< const_iteratorconst_reverse_iterator
 
typedef RWGenMatIterator< T > iterator
 
typedef rw_numeric_traits< T >::mathFunType mathFunType
 
typedef rw_numeric_traits< T >::mathFunType2 mathFunType2
 
typedef rw_numeric_traits< T >::norm_type norm_type
 
typedef rw_numeric_traits< T >::promote_type promote_type
 
typedef std::reverse_iterator< iteratorreverse_iterator
 

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_typeapply2 (mathFunType2 f) const
 
iterator begin (RWDataView::Storage storage=RWDataView::COLUMN_MAJOR)
 
const_iterator begin (RWDataView::Storage storage=RWDataView::COLUMN_MAJOR) const
 
size_t binaryStoreSize () const
 
const_iterator cbegin (RWDataView::Storage storage=RWDataView::COLUMN_MAJOR) const
 
const_iterator cend (RWDataView::Storage storage=RWDataView::COLUMN_MAJOR) 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
 
const_reverse_iterator crbegin (RWDataView::Storage storage=RWDataView::COLUMN_MAJOR) const
 
const_reverse_iterator crend (RWDataView::Storage storage=RWDataView::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)
 
iterator end (RWDataView::Storage storage=RWDataView::COLUMN_MAJOR)
 
const_iterator end (RWDataView::Storage storage=RWDataView::COLUMN_MAJOR) const
 
 operator RWGenMat< promote_type > ()
 
bool operator!= (const RWGenMat< T > &v) const
 
T & operator() (int i, int j)
 
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 T &s)
 
RWGenMat< T > & operator*= (const RWGenMat< T > &v)
 
RWGenMat< T > & operator++ ()
 
void operator++ (int)
 
RWGenMat< T > & operator+= (const T &s)
 
RWGenMat< T > & operator+= (const RWGenMat< T > &v)
 
RWGenMat< T > & operator-- ()
 
void operator-- (int)
 
RWGenMat< T > & operator-= (const T &s)
 
RWGenMat< T > & operator-= (const RWGenMat< T > &v)
 
RWGenMat< T > & operator/= (const T &s)
 
RWGenMat< T > & operator/= (const RWGenMat< T > &v)
 
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
 
RWGenMatPick< T > pick (const RWIntVec &v1, const RWIntVec &v2)
 
const RWGenMatPick< T > pick (const RWIntVec &v1, const RWIntVec &v2) const
 
reverse_iterator rbegin (RWDataView::Storage storage=RWDataView::COLUMN_MAJOR)
 
const_reverse_iterator rbegin (RWDataView::Storage storage=RWDataView::COLUMN_MAJOR) const
 
RWGenMat< T > & reference (const RWGenMat< T > &m)
 
reverse_iterator rend (RWDataView::Storage storage=RWDataView::COLUMN_MAJOR)
 
const_reverse_iterator rend (RWDataView::Storage storage=RWDataView::COLUMN_MAJOR) const
 
void reshape (size_t m, size_t n, Storage s=COLUMN_MAJOR)
 
void resize (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
 

Friends

RWGenMat< double > imag (const RWGenMat< DComplex > &)
 
RWGenMat< double > real (const RWGenMat< DComplex > &)
 

Related Functions

(Note that these are not member functions.)

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< signed char > abs (const RWGenMat< signed char > &M)
 
template<class T >
RWGenMat< T > acos (const RWGenMat< T > &x)
 
RWGenMat< double > arg (const RWGenMat< DComplex > &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)
 
RWGenMat< DComplexconj (const RWGenMat< DComplex > &x)
 
RWGenMat< DComplexconjTransposeProduct (const RWGenMat< DComplex > &A, const RWGenMat< DComplex > &B)
 
template<class T >
RWGenMat< T > cos (const RWGenMat< T > &x)
 
template<class T >
RWGenMat< T > cosh (const RWGenMat< T > &x)
 
template<class T >
determinant (const RWGenMat< T > &A)
 
template<class T >
RWGenMat< T > elementProduct (const RWGenMat< T > &A, const RWGenMat< T > &B)
 
template<class T >
RWGenMat< T > exp (const RWGenMat< T > &x)
 
template<class T >
RWGenMat< T > floor (const RWGenMat< T > &x)
 
double frobNorm (const RWGenMat< DComplex > &)
 
double frobNorm (const RWGenMat< double > &)
 
float frobNorm (const RWGenMat< float > &)
 
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 > &)
 
template<class T >
RWGenMat< T > log (const RWGenMat< T > &x)
 
template<class T >
RWGenMat< T > log10 (const RWGenMat< T > &x)
 
template<class T >
void maxIndex (const RWGenMat< T > &, int *i, int *j)
 
double maxNorm (const RWGenMat< DComplex > &)
 
double maxNorm (const RWGenMat< double > &)
 
float maxNorm (const RWGenMat< float > &)
 
template<class T >
maxValue (const RWGenMat< T > &)
 
template<class T >
mean (const RWGenMat< T > &x)
 
template<class T >
void minIndex (const RWGenMat< T > &, int *i, int *j)
 
template<class T >
minValue (const RWGenMat< T > &)
 
RWGenMat< double > norm (const RWGenMat< DComplex > &x)
 
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)
 
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 > &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 T &s)
 
template<class T >
RWGenMat< T > operator+ (const T &s, 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 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 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 >
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 > 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 >
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 > 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)
 
template<class T >
RWGenMat< T > tan (const RWGenMat< T > &x)
 
template<class T >
RWGenMat< T > tanh (const RWGenMat< T > &x)
 
RWGenMat< signed char > 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)
 
template<class T >
RWGenMat< T > transpose (const RWGenMat< T > &x)
 
template<class T >
RWGenMat< T > transposeProduct (const RWGenMat< T > &A, const RWGenMat< T > &B)
 
double variance (const RWGenMat< DComplex > &x)
 
double variance (const RWGenMat< double > &x)
 
float variance (const RWGenMat< float > &x)
 

Detailed Description

template<class T>
class RWGenMat< T >

Class RWGenMat is a templatized general matrix class.

Synopsis
#include <rw/math/genmat.h>
template<class T>
RWGenMat<T> matrix;
Example
#include <rw/math/genmat.h>
int main()
{
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
}
See also
RWConvertGenMat

Member Typedef Documentation

template<class T>
typedef RWGenMatConstIterator<T> RWGenMat< T >::const_iterator

A type that provides a const random-access iterator over the elements in the container.

template<class T>
typedef std::reverse_iterator<const_iterator> RWGenMat< T >::const_reverse_iterator

A type that provides a const random-access, reverse-order iterator over the elements in the container.

template<class T>
typedef RWGenMatIterator<T> RWGenMat< T >::iterator

A type that provides a random-access iterator over the elements in the container.

template<class T>
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.

template<class T>
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.

template<class T>
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.

template<class T>
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.

template<class T>
typedef std::reverse_iterator<iterator> RWGenMat< T >::reverse_iterator

A type that provides a random-access, reverse-order iterator over the elements in the container.

Constructor & Destructor Documentation

template<class T>
RWGenMat< T >::RWGenMat ( )
inline

Constructs a 0 x 0 (null) matrix, useful for declaring vectors of matrices. This matrix, like any other matrix, can subsequently be reshaped or resized. See member functions reshape() and resize().

template<class T>
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.

template<class T>
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.

template<class T>
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.

template<class T>
RWGenMat< T >::RWGenMat ( const char *  s,
Storage  = COLUMN_MAJOR 
)

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.

template<class T>
RWGenMat< T >::RWGenMat ( const RWGenMat< T > &  a)
inline

Copy constructor. The new matrix and the old matrix both view the same data.

template<class T>
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.

template<class T>
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.

template<class T>
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.

Member Function Documentation

template<class T>
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.

template<class 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.

template<class T>
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.

Warning
Binary difference and comparison operators between a ROW_MAJOR iterator and a COLUMN_MAJOR iterator have unpredictable results.
template<class 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.

Warning
Binary difference and comparison operators between a ROW_MAJOR iterator and a COLUMN_MAJOR iterator have unpredictable results.
template<class T>
size_t RWGenMat< T >::binaryStoreSize ( ) const

Returns the number of bytes required to store the matrix to an RWFile using member function saveOn(RWFile&).

template<class T>
const_iterator RWGenMat< T >::cbegin ( 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.

Warning
Binary difference and comparison operators between a ROW_MAJOR iterator and a COLUMN_MAJOR iterator have unpredictable results.
template<class T>
const_iterator RWGenMat< T >::cend ( 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.

Warning
Binary difference and comparison operators between a ROW_MAJOR iterator and a COLUMN_MAJOR iterator have unpredictable results.
template<class T >
const RWMathVec< T > RWGenMat< T >::col ( int  j) const
inline

Returns a vector that views a column of the matrix.

template<class T >
RWMathVec< T > RWGenMat< T >::col ( int  j)
inline

Returns a vector that views a column of the matrix.

template<class T>
size_t RWGenMat< T >::cols ( ) const
inline

Returns the number of columns of the matrix.

template<class T>
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).

template<class T>
RWGenMat<T> RWGenMat< T >::copy ( Storage  s = COLUMN_MAJOR) const

Returns a copy with distinct instance variables. The optional storage indicator determines whether the matrix is stored in ROW_MAJOR or COLUMN_MAJOR order.

template<class T>
const_reverse_iterator RWGenMat< T >::crbegin ( 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.

Warning
Binary difference and comparison operators between a ROW_MAJOR iterator and a COLUMN_MAJOR iterator have unpredictable results.
template<class T>
const_reverse_iterator RWGenMat< T >::crend ( RWDataView::Storage  storage = RWDataView::COLUMN_MAJOR) const
inline

Returns an iterator that points to one element before the first 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.

Warning
Binary difference and comparison operators between a ROW_MAJOR iterator and a COLUMN_MAJOR iterator have unpredictable results.
template<class T>
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.

template<class T>
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.

template<class T>
RWGenMat<T> RWGenMat< T >::deepCopy ( Storage  s = COLUMN_MAJOR) const

Alias for copy().

template<class T>
void RWGenMat< T >::deepenShallowCopy ( Storage  s = COLUMN_MAJOR)

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.

template<class T>
const RWMathVec<T> RWGenMat< T >::diagonal ( int  idiag = 0) const

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.

template<class T>
RWMathVec<T> RWGenMat< T >::diagonal ( int  idiag = 0)

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.

template<class T>
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.

Warning
Binary difference and comparison operators between a ROW_MAJOR iterator and a COLUMN_MAJOR iterator have unpredictable results.
template<class T>
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.

Warning
Binary difference and comparison operators between a ROW_MAJOR iterator and a COLUMN_MAJOR iterator have unpredictable results.
template<class T>
RWGenMat< T >::operator RWGenMat< promote_type > ( )
inline

Implicit conversion operator to rw_numeric_traits::promote_type.

template<class T>
bool RWGenMat< T >::operator!= ( const RWGenMat< T > &  v) const

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.

template<class T >
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.

template<class T >
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.

template<class T >
RWMathVec< T > RWGenMat< T >::operator() ( int  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.

template<class T >
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.

template<class T >
RWMathVec< T > RWGenMat< T >::operator() ( const RWSlice 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.

template<class T >
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.

template<class T >
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.

template<class T >
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.

template<class T>
RWGenMat<T>& RWGenMat< T >::operator*= ( const T &  s)

Assignment by multiplication operator with conventional meaning. The expression u *= s implies \(u_{ij} = u_{ij} * s\).

template<class T>
RWGenMat<T>& RWGenMat< T >::operator*= ( const RWGenMat< T > &  v)

Assignment by multiplication operator with conventional meaning. The expression u *= v implies \(u_{ij} = u_{ij} * v_{ij}\). The RWGenMat objects must conform, that is, have the same dimensions.

template<class T>
RWGenMat<T>& RWGenMat< T >::operator++ ( )

Increments each element of self.

template<class T>
void RWGenMat< T >::operator++ ( int  )
inline

Increments each element of self. This overload is invoked if the operator is used as a postfix operator.

template<class T>
RWGenMat<T>& RWGenMat< T >::operator+= ( const T &  s)

Assignment by addition operator with conventional meaning. The expression u += s implies \(u_{ij} = u_{ij}+ s\).

template<class T>
RWGenMat<T>& RWGenMat< T >::operator+= ( const RWGenMat< T > &  v)

Assignment by addition operator with conventional meaning. The expression u += v implies \(u_{ij} = u_{ij} + v_{ij}\). The RWGenMat objects must conform, that is, have the same dimensions.

template<class T>
RWGenMat<T>& RWGenMat< T >::operator-- ( )

Decrements each element of self.

template<class T>
void RWGenMat< T >::operator-- ( int  )
inline

Decrements each element of self. This overload is invoked if the operator is used as a postfix operator.

template<class T>
RWGenMat<T>& RWGenMat< T >::operator-= ( const T &  s)

Assignment by subtraction operator with conventional meaning. The expression u -= s implies \(u_{ij} = u_{ij} - s\).

template<class T>
RWGenMat<T>& RWGenMat< T >::operator-= ( const RWGenMat< T > &  v)

Assignment by subtraction operator with conventional meaning. The expression u -= v implies \(u_{ij} = u_{ij} - v_{ij}\). The RWGenMat objects must conform, that is, have the same dimensions.

template<class T>
RWGenMat<T>& RWGenMat< T >::operator/= ( const T &  s)

Assignment by division operator with conventional meaning. The expression u /= s implies \(u_{ij} = u_{ij} / s\).

template<class T>
RWGenMat<T>& RWGenMat< T >::operator/= ( const RWGenMat< T > &  v)

Assignment by division operator with conventional meaning. The expression u /= v implies \(u_{ij} = u_{ij} / v_{ij}\). The RWGenMat objects must conform, that is, have the same dimensions.

template<class T>
RWGenMat<T>& RWGenMat< T >::operator= ( const RWGenMat< T > &  v)

Assignment operator with conventional meaning. The expression u = v implies \(u_{ij} = v_{ij}\). The RWGenMat objects must conform, that is, have the same dimensions.

template<class T>
RWGenMat<T>& RWGenMat< T >::operator= ( const RWGenMatPick< T > &  v)

Assignment operator with conventional meaning. The expression u = v implies \(u_{ij} = v_{ij}\). The RWGenMat objects must conform, that is, have the same dimensions.

template<class T>
RWGenMat<T>& RWGenMat< T >::operator= ( const T &  s)

Assignment operator with conventional meaning. The expression u = s implies \(u_{ij} = s\).

template<class T>
bool RWGenMat< T >::operator== ( const RWGenMat< T > &  ) const

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.

template<class T>
RWGenMatPick<T> RWGenMat< T >::pick ( const RWIntVec v1,
const RWIntVec v2 
)

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.

template<class T>
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.

template<class T>
reverse_iterator RWGenMat< T >::rbegin ( RWDataView::Storage  storage = RWDataView::COLUMN_MAJOR)
inline

Returns an iterator that points to the element in the last row and last 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.

Warning
Binary difference and comparison operators between a ROW_MAJOR iterator and a COLUMN_MAJOR iterator have unpredictable results.
template<class T>
const_reverse_iterator RWGenMat< T >::rbegin ( 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.

Warning
Binary difference and comparison operators between a ROW_MAJOR iterator and a COLUMN_MAJOR iterator have unpredictable results.
template<class T>
RWGenMat<T>& RWGenMat< T >::reference ( const RWGenMat< T > &  m)

Makes self a view of the data contained in m. The view currently associated with the matrix is lost.

template<class T>
reverse_iterator RWGenMat< T >::rend ( RWDataView::Storage  storage = RWDataView::COLUMN_MAJOR)
inline

Returns an iterator that points to one element before the first 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.

Warning
Binary difference and comparison operators between a ROW_MAJOR iterator and a COLUMN_MAJOR iterator have unpredictable results.
template<class T>
const_reverse_iterator RWGenMat< T >::rend ( 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.

Warning
Binary difference and comparison operators between a ROW_MAJOR iterator and a COLUMN_MAJOR iterator have unpredictable results.
template<class T>
void RWGenMat< T >::reshape ( size_t  m,
size_t  n,
Storage  s = COLUMN_MAJOR 
)

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.

template<class T>
void RWGenMat< T >::resize ( size_t  m,
size_t  n,
Storage  s = COLUMN_MAJOR 
)

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.

template<class T>
void RWGenMat< T >::restoreFrom ( RWFile ,
Storage  s = COLUMN_MAJOR 
)

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:

template<class T>
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:

template<class T >
const RWMathVec< T > RWGenMat< T >::row ( int  i) const
inline

Returns a vector that views a row of the matrix.

template<class T >
RWMathVec< T > RWGenMat< T >::row ( int  i)
inline

Returns a vector that views a row of the matrix.

template<class T>
size_t RWGenMat< T >::rows ( ) const
inline

Return the number of rows of the matrix.

template<class T>
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).

template<class T>
void RWGenMat< T >::saveOn ( RWFile ) const

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&);
template<class T>
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:

template<class T>
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.

template<class 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:

A(RWRange(n-1,0), RWRange(0,n-1))

Friends And Related Function Documentation

template<class T>
RWGenMat< double > abs ( const RWGenMat< DComplex > &  M)
related

Returns the absolute values of each element.

Example
#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);
std::cout << b;
return 0;
}

Program Output:

5x1 [
1.2
2.4
1.2
0.8
4.5
]

See the example in abs(const RWGenMat<double>&)

Note
The absolute value of a complex number is of type double. Therefore, if abs() is invoked for class RWGenMat<DComplex>, a vector of class RWGenMat<double> is returned.
template<class T>
RWGenMat< double > abs ( const RWGenMat< double > &  M)
related

Returns the absolute values of each element.

Example
#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);
std::cout << b;
return 0;
}

Program Output:

5x1 [
1.2
2.4
1.2
0.8
4.5
]
template<class T>
RWGenMat< float > abs ( const RWGenMat< float > &  M)
related

Returns the absolute values of each element.

Example
#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);
std::cout << b;
return 0;
}

Program Output:

5x1 [
1.2
2.4
1.2
0.8
4.5
]

See the example in abs(const RWGenMat<double>&)

Note
The absolute value of a complex number is of type 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>&)

template<class T>
RWGenMat< int > abs ( const RWGenMat< int > &  M)
related

Returns the absolute values of each element.

Example
#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);
std::cout << b;
return 0;
}

Program Output:

5x1 [
1.2
2.4
1.2
0.8
4.5
]

See the example in abs(const RWGenMat<double>&)

Note
The absolute value of a complex number is of type 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>&)

template<class T>
RWGenMat< signed char > abs ( const RWGenMat< signed char > &  M)
related

Returns the absolute values of each element.

Example
#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);
std::cout << b;
return 0;
}

Program Output:

5x1 [
1.2
2.4
1.2
0.8
4.5
]

See the example in abs(const RWGenMat<double>&)

Note
The absolute value of a complex number is of type 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>&)

template<class T >
RWGenMat< T > acos ( const RWGenMat< T > &  x)
related

Returns arc cosines y such that \(y_{i} = cos^{-1} (x_{i})\). The yi (in radians) are in the range \(0 < y_{i} \leq \pi\), for elements xi with absolute values \(|x_{i}| \leq 1\).

template<class T>
RWGenMat< double > arg ( const RWGenMat< DComplex > &  x)
related

Returns the arguments ai (in radians) of x in the range \(-\pi < a_{i} \leq \pi\), where \(a_{i} = tan^{-1}{[Im(x_{i})/Re(x_{i})]}\). Multiple valued functions of complex arguments, such as sqrt() and log(), are therefore constrained to their principle value.

template<class T >
RWGenMat< T > asin ( const RWGenMat< T > &  x)
related

Takes x as an argument and returns arc sines y such that \(y_{i} = sin^{-1}(x_{i})\). The yi (in radians) are in the range \(-\pi/2 < y_{i} \leq \pi/2\), for elements xi with absolute values \(|x_{i}| \leq 1\).

template<class T >
RWGenMat< T > atan ( const RWGenMat< T > &  x)
related

Takes x and returns y of arc tangents (in radians), such that \(y_{i} = tan^{-1}x_{i}\), where \(-\pi/2 < y_{i} \leq \pi/2\).

template<class T >
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 \(z_{i} = tan^{-1} ( x_{i}/y_{i})\). For each element i, the expression \(atan2(x_{i}, y_{i})\) is mathematically equivalent to:

\[ tan^{-1}\left(\frac{x_i}{y_i}\right) \]

At least one of the arguments xi or yi must be nonzero.

template<class T >
RWGenMat< T > ceil ( const RWGenMat< T > &  x)
related

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].

template<class T>
RWGenMat< DComplex > conj ( const RWGenMat< DComplex > &  x)
related

Takes complex x as an argument and returns the complex conjugates \(x^{*}\). For example, if \(x_{i} = (2.3, 1.4)\), then \(x_{i}^{*} = (2.3, -1.4)\).

template<class T>
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.

Note
Calling this function is equivalent to calling C = product(conj(transpose(A)), B).
template<class T >
RWGenMat< T > cos ( const RWGenMat< T > &  x)
related

Takes x as an argument and returns y such that \(y_{i} = cos(x_{i})\). The xi are in radians. For complex arguments, the complex cosine is returned.

template<class T >
RWGenMat< T > cosh ( const RWGenMat< T > &  x)
related

Takes x as an argument and returns hyperbolic cosines y such that \(y_{i} = cosh(x_{i})\). For complex arguments, the complex hyperbolic cosine is returned.

template<class T >
T determinant ( const RWGenMat< T > &  A)
related

Returns the determinant of the matrix from which an LU factorization A is constructed.

template<class T >
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:

\[ C_{ij} = A_{ij}B_{ij} \]

template<class T >
RWGenMat< T > exp ( const RWGenMat< T > &  x)
related

Takes an argument x and returns y such that:

\[ y_i = e^{x_i} \]

If class T is complex, the complex exponential is returned.

template<class T >
RWGenMat< T > floor ( const RWGenMat< T > &  x)
related

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].

template<class T>
double frobNorm ( const RWGenMat< DComplex > &  )
related

Computes the Frobenius norm, which is the square root of the sum of squares of its entries. For a matrix, the formula is:

\[ \left \| A \right \|_{\text{Frob}} = \sqrt{\sum_{i=0}^{M-1} \sum_{j=0}^{N-1} \left | \text{a}_{ij} \right |^2} \]

template<class T>
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:

\[ \left \| A \right \|_{\text{Frob}} = \sqrt{\sum_{i=0}^{M-1} \sum_{j=0}^{N-1} \left | \text{a}_{ij} \right |^2} \]

template<class T>
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:

\[ \left \| A \right \|_{\text{Frob}} = \sqrt{\sum_{i=0}^{M-1} \sum_{j=0}^{N-1} \left | \text{a}_{ij} \right |^2} \]

template<class T>
RWGenMat< double > imag ( const RWGenMat< DComplex > &  )
friend

Takes complex x as an argument and returns y containing the imaginary parts \(y_{i} = Im(x_{i})\). 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), ...
template<class T>
double l1Norm ( const RWGenMat< DComplex > &  )
related

The function l1Norm()is the maximum of the l1Norms of its columns:

\[ \left \| A \right \|_1 = \begin{array}{c c} \scriptstyle max \\ \scriptstyle j=0,...,N-1 \end{array} \sum_{i=0}^{N-1}\left | a_i \right | \]

template<class T>
double l1Norm ( const RWGenMat< double > &  )
related

The function l1Norm()is the maximum of the l1Norms of its columns:

\[ \left \| A \right \|_1 = \begin{array}{c c} \scriptstyle max \\ \scriptstyle j=0,...,N-1 \end{array} \sum_{i=0}^{N-1}\left | a_i \right | \]

template<class T>
float l1Norm ( const RWGenMat< float > &  )
related

The function l1Norm()is the maximum of the l1Norms of its columns:

\[ \left \| A \right \|_1 = \begin{array}{c c} \scriptstyle max \\ \scriptstyle j=0,...,N-1 \end{array} \sum_{i=0}^{N-1}\left | a_i \right | \]

template<class T>
double linfNorm ( const RWGenMat< DComplex > &  )
related

The function l1Norm()is the maximum of the l1fNorms of its rows:

\[ \left \| xA \right \|_{\infty} = \begin{array}{c c} \scriptstyle max \\ \scriptstyle i=0,...,N-1 \end{array} \sum_{j=0}^{N-1}\left | a_{ij} \right | \]

template<class T>
double linfNorm ( const RWGenMat< double > &  )
related

The function l1Norm()is the maximum of the l1fNorms of its rows:

\[ \left \| xA \right \|_{\infty} = \begin{array}{c c} \scriptstyle max \\ \scriptstyle i=0,...,N-1 \end{array} \sum_{j=0}^{N-1}\left | a_{ij} \right | \]

template<class T>
float linfNorm ( const RWGenMat< float > &  )
related

The function l1Norm()is the maximum of the l1fNorms of its rows:

\[ \left \| xA \right \|_{\infty} = \begin{array}{c c} \scriptstyle max \\ \scriptstyle i=0,...,N-1 \end{array} \sum_{j=0}^{N-1}\left | a_{ij} \right | \]

template<class T >
RWGenMat< T > log ( const RWGenMat< T > &  x)
related

Takes x as an argument and returns natural logarithms y such that \(y_{i}=log(x_{i})\). The arguments xi must not be 0. For complex arguments, the principal value of the complex natural logarithm is returned.

template<class T >
RWGenMat< T > log10 ( const RWGenMat< T > &  x)
related

Takes x as an argument and returns base 10 logarithms y such that \(y_{i}=log_{10}(x_{i})\). The arguments xi must not be 0.

template<class T >
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().

template<class T>
double maxNorm ( const RWGenMat< DComplex > &  )
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.

template<class T>
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.

template<class T>
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.

template<class T >
T maxValue ( const RWGenMat< T > &  )
related

Return the maximum value.

template<class T >
T mean ( const RWGenMat< T > &  x)
related

Takes an RWGenMat as an argument and returns <x>, the mean value, where:

\[ \langle x \rangle = \frac{1}{n}\sum_{i=0}^{n-1}x_i \]

For example, if x = [1, 4, 3, 4], then <x> = 3.

template<class T >
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().

template<class T >
T minValue ( const RWGenMat< T > &  )
related

Return the minimum value.

template<class T>
RWGenMat< double > norm ( const RWGenMat< DComplex > &  x)
related

Takes complex x as an argument and returns real y containing the norm:

\[ y_{i} = [Re(x_{i})]^{2} + [Im(x_{i})]^{2} \]

template<class T >
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.

template<class T >
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.

template<class T >
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.

template<class T >
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 w = u * v implies \(w_{ij} = u_{ij} * v_{ij}\). The two RWGenMat objects must conform, that is, have the same numbers of rows and columns, or an exception with value RWMATH_MNMATCH occurs.

template<class T >
RWGenMat< T > operator* ( const RWGenMat< T > &  u,
const T &  s 
)
related

Multiplication operator, which is applied element-by-element. For instance, for matrices u, w, and scalar s, the expression w = u * s implies \(w_{ij} = u_{ij} * s\).

template<class T >
RWGenMat< T > operator* ( const T &  s,
const RWGenMat< T > &  v 
)
related

Multiplication operator, which is applied element-by-element. For instance, for matrices v, w, and scalar s, the expression w = s * v implies \(w_{ij} = s * v_{ij}\).

template<class T >
RWGenMat< T > operator+ ( const RWGenMat< T > &  v)
related

Unary plus operator, which is applied element-by-element. For instance, for matrices v, and w, the expression w = +v implies \(w_{ij} = + v_{ij}\).

template<class T >
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 w = u + v implies \(w_{ij} = u_{ij} + v_{ij}\). The two RWGenMat objects must conform, that is, have the same numbers of rows and columns, or an exception with value RWMATH_MNMATCH occurs.

template<class T >
RWGenMat< T > operator+ ( const RWGenMat< T > &  u,
const T &  s 
)
related

Addition operator, which is applied element-by-element. For instance, for matrices u, w, and scalar s, the expression w = u + s implies \(w_{ij} = u_{ij} + s\).

template<class T >
RWGenMat< T > operator+ ( const T &  s,
const RWGenMat< T > &  v 
)
related

Addition operator, which is applied element-by-element. For instance, for matrices v, w, and scalar s, the expression w = s + v implies \(w_{ij} = s + v_{ij}\).

template<class T >
RWGenMat< T > operator- ( const RWGenMat< T > &  v)
related

Unary minus operator, which is applied element-by-element. For instance, for matrices v, and w, the expression w = -v implies \(w_{ij} = - v_{ij}\).

template<class T >
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 w = u - v implies \(w_{ij} = u_{ij} - v_{ij}\). The two RWGenMat objects must conform, that is, have the same numbers of rows and columns, or an exception with value RWMATH_MNMATCH occurs.

template<class T >
RWGenMat< T > operator- ( const T &  s,
const RWGenMat< T > &  v 
)
related

Subtraction operator, which is applied element-by-element. For instance, for matrices v, w, and scalar s, the expression w = s - v implies \(w_{ij} = s - v_{ij}\).

template<class T >
RWGenMat< T > operator- ( const RWGenMat< T > &  u,
const T &  s 
)
related

Subtraction operator, which is applied element-by-element. For instance, for matrices u, w, and scalar s, the expression w = u - s implies \(w_{ij} = u_{ij} - s\).

template<class T >
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 w = u / v implies \(w_{ij} = u_{ij} / v_{ij}\). The two RWGenMat objects must conform, that is, have the same numbers of rows and columns, or an exception with value RWMATH_MNMATCH occurs.

template<class T >
RWGenMat< T > operator/ ( const T &  s,
const RWGenMat< T > &  v 
)
related

Division operator, which is applied element-by-element. For instance, for matrices v, w, and scalar s, the expression w = s / v implies \(w_{ij} = s / v_{ij}\).

template<class T >
RWGenMat< T > operator/ ( const RWGenMat< T > &  u,
const T &  s 
)
related

Division operator, which is applied element-by-element. For instance, for matrices u, w, and scalar s, the expression w = u / s implies \(w_{ij} = u_{ij} / s\).

template<class T >
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 ].

template<class T >
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.

template<class T >
RWGenMat< T > pow ( const RWGenMat< T > &  x,
const RWGenMat< T > &  y 
)
related

The function pow() takes two arguments: pow( x, y ).

Returns z such that:

\[ z_i = (x_i)^{y_i} \]

If the number of elements in x does not match the number of elements in y, an exception with value RWMATH_MNMATCH will occur.

template<class T >
RWGenMat< T > pow ( const RWGenMat< T > &  x,
y 
)
related

The function pow() takes two arguments: pow( x, y ).

Returns z such that:

\[ z_i = (x_i)^{y} \]

template<class T >
RWGenMat< T > pow ( x,
const RWGenMat< T > &  y 
)
related

The function pow() takes two arguments: pow( x, y ).

Returns z such that:

\[ z_i = (x)^{y_i} \]

template<class T >
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:

\[ y_i = \sum_{j=0}^{n-1} A_{ij}v_j \]

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.

template<class T >
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:

\[ C_{ij} = \sum_{k=0}^{P-1} A_{ik}B_{kj} \]

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.

template<class T>
RWGenMat< double > real ( const RWGenMat< DComplex > &  )
friend

Takes a complex argument x and returns real y containing the real part \(y_{i}=Re(x_{i})\). 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), ...
template<class T >
RWGenMat< T > sin ( const RWGenMat< T > &  x)
related

The function sin() takes x as an argument and returns y such that \(y_{i} = sin(x_{i})\). The xi are in radians. For complex classes, the complex sine is returned.

template<class T >
RWGenMat< T > sinh ( const RWGenMat< T > &  x)
related

The function sinh() takes x as an argument and returns y such that \(y_{i} = sinh(x_{i})\). For complex classes, the complex hyperbolic sine is returned.

template<class T >
RWGenMat< T > sqrt ( const RWGenMat< T > &  x)
related

The square root function. Takes x as an argument and returns y such that \(y_{i} = (x_{i})^{1/2}\). For complex classes, the principal value of the complex square root is returned.

template<class T >
RWGenMat< T > tan ( const RWGenMat< T > &  x)
related

The function tan() takes argument x and returns y such that \(y_{i} = tan(x_{i})\).

template<class T >
RWGenMat< T > tanh ( const RWGenMat< T > &  x)
related

The function tanh() takes argument x and returns y such that \(y_{i} = tanh(x_{i})\).

template<class T>
RWGenMat< signed char > toChar ( const RWGenMat< int > &  V)
related

Converts an RWGenMat<int> instance into a corresponding RWGenMat<signed char> instance. Note that this is a narrowing operation; high order bits are removed.

See also
RWConvertGenMat
template<class T>
RWGenMat< float > toFloat ( const RWGenMat< double > &  V)
related

Converts an RWGenMat<double> instance into a corresponding RWGenMat<float> instance. Note that this is a narrowing operation; high order bits are removed.

See also
RWConvertGenMat
template<class T>
RWGenMat< int > toInt ( const RWGenMat< double > &  V)
related

Converts an RWGenMat<double> instance into a corresponding RWGenMat<int> instance. Note that truncation occurs.

See also
RWConvertGenMat
template<class T>
RWGenMat< int > toInt ( const RWGenMat< float > &  V)
related

Converts an RWGenMat<float> instance into a corresponding RWGenMat<int> instance. Note that truncation occurs.

See also
RWConvertGenMat
template<class T >
RWGenMat< T > transpose ( const RWGenMat< T > &  x)
related

Takes a matrix x as an argument and returns the transpose \(y_{ik} = x_{ki}\). 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.

template<class T >
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:

\[ C_{np} = \sum_{m=0}^M A_{mn}B_{mp} \]

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:

C = product( transpose(A), B);
template<class T>
double variance ( const RWGenMat< DComplex > &  x)
related

Takes a matrix x as an argument and returns its variance y as in:

\[ y=\frac{1}{N}\sum_{i=0}^{N-1}(x_i-<x>)^2 \]

where <x> is the mean of the matrix and N is the number of rows times columns. Note that this is the biased variance.

template<class T>
double variance ( const RWGenMat< double > &  x)
related

Takes a matrix x as an argument and returns its variance y as in:

\[ y=\frac{1}{N}\sum_{i=0}^{N-1}(x_i-<x>)^2 \]

where <x> is the mean of the matrix and N is the number of rows times columns. Note that this is the biased variance.

template<class T>
float variance ( const RWGenMat< float > &  x)
related

Takes a matrix x as an argument and returns its variance y as in:

\[ y=\frac{1}{N}\sum_{i=0}^{N-1}(x_i-<x>)^2 \]

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 © 2023 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.