Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

Matrix.h File Reference

Detailed Description

Real vectors, square lower triangular, square upper triangular, symmetric and rectangular matrices stored in row major order. Barebones naive implementation with no checking of dimensional compatibility. All operations implemented as straightforward C-style loops with no optimizations. To check subscripting bounds #define SUBSCRIPT_CHECK.

Matrix indices can be based on an arbitrary bases a,b. This means that the indices used with the subscripting operators are

where rows and cols are the number of rows and columns respectively. This feature allows the use of the natural indices from the application domain and will be referred to as "natural indexation" in each application. The subscripting operators take care of the necessary translations to the actual array indices. The index bases are irrelevant if the underlying data array is accessed directly through the data pointers.

For matrices allocated in row major order the loops for the product AB' have a better memory access pattern (row dot row) than the loops for the product AB (row dot column). There is very little difference in low dimensions but for 1000 by 1000 matrices AB' is already three times faster than AB.

Thus we provide both the operator *= multiplying this on the right B (slower) and the operator ^= which multiplies on the right with B'.

Definition in file Matrix.h.

#include <string>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cmath>
#include "TypedefsMacros.h"
#include "jama/jama_eig.h"
#include "Array.h"

Go to the source code of this file.


class  Vector
class  UpperTriangular
class  LowerTriangular
class  Rectangular
struct  ProductType
struct  ProductType< S, MatrixType, MatrixType >
class  Matrix
class  UTRMatrix
class  UTRRealMatrix
class  UTRMatrixSequence
class  MatrixSequence


typedef Vector< RealRealVector
typedef Matrix< Real, Rectangular<
Real > > 
typedef Matrix< Real, LowerTriangular<
Real > > 


template<typename S> S relativeError (S exact, S approx, S epsilon)
template<class S> std::ostream & operator<< (std::ostream &os, const Vector< S > &v)
template<typename S, typename MatrixBaseType> std::ostream & operator<< (std::ostream &os, const Matrix< S, MatrixBaseType > &A)
JAMA::Eigenvalue< Real > * eigenDecomposition (const UTRRealMatrix &C)
RealMatrixrank_Reduced_Root (const UTRRealMatrix &C, int r)
void factorAnalysis (const UTRRealMatrix &C, int r)
void factorizationTest (const UTRRealMatrix &C, int r, string message="")

Typedef Documentation

typedef Vector<Real> RealVector

Definition at line 392 of file Matrix.h.

Referenced by Ball::boundaryProjection(), and BrownianVectorProcess::BrownianVectorProcess().

typedef Matrix< Real,Rectangular<Real> > RealMatrix

Definition at line 1266 of file Matrix.h.

Referenced by MatrixSequence::getMatrix().

typedef Matrix< Real,LowerTriangular<Real> > LTRRealMatrix

Definition at line 1267 of file Matrix.h.

Function Documentation

template<typename S>
S relativeError   exact,

The relative error in percent of an approximation to an exact value, positive if the approx > exact negative otherwise. Type S must support -(S&) and comparison ">".

S real scalar type (float, double, long double).
exact true value.
approx approximation.
epsilon zero rounded up to epsilon to avoid division by zero.

Definition at line 97 of file Matrix.h.

Referenced by Matrix< Real, UpperTriangular< Real > >::testEquals(), and Vector< Real >::testEquals().

template<class S>
std::ostream& operator<< std::ostream &    os,
const Vector< S > &    v

print Vector

Definition at line 386 of file Matrix.h.

template<typename S, typename MatrixBaseType>
std::ostream& operator<< std::ostream &    os,
const Matrix< S, MatrixBaseType > &    A

print matrix

Definition at line 1239 of file Matrix.h.

JAMA::Eigenvalue<Real>* eigenDecomposition const UTRRealMatrix   C

JAMA object containing eigenvalues (sorted ascending) and ON matrix of associated eigenvectors of the symmetric matrix of which C is the upper half.

RealMatrix& rank_Reduced_Root const UTRRealMatrix   C,
int    r

Let D be the symmetric matrix with upper half C. This function computes the matrix R which best approximates D as a product RR' and has rank r. The matrix R is computed by diagonalizing D, setting all but the r largest eigenvalues equal to zero and taking the square root of the remaining eigenvalues. Template parameter S is the type of the matrix entries and must be a scalar type (float, double, long double).

Maintains the row index base of C, columns indexed from zero.

void factorAnalysis const UTRRealMatrix   C,
int    r

C is interpreted as a multinormal covariance matrix. This method prints how much variability is captured by the 5 largest eigenvalues of C.

void factorizationTest const UTRRealMatrix   C,
int    r,
string    message = ""

Let D be the symmetric matrix with upper half C. D must be positive semidefinite. Computes the best approximate factorization , where R has rank r and returns the relative error in the trace norm

message short description of test.

Generated on Mon Sep 22 02:16:32 2003 for Libor-Library by doxygen1.3-rc3