SLIMMER
|
Templated Base Class for Matrices. More...
#include <SimpleBaseTMat.h>
Public Member Functions | |
SimpleBaseTMat () | |
Default Constructor. | |
virtual | ~SimpleBaseTMat () |
Virtual Destructor. | |
virtual TS2 | MatY () const |
return Y Size of matrix: Number of Rows | |
virtual TS2 | MatX () const |
return X Size of matrix: Number of Columns | |
virtual TS2 | MatXY () const |
return total number of elements in Matrix | |
bool | isSquare () const |
Test if Matrix is Square. | |
bool | SameSize (const SimpleBaseTMat< TM, TS2 > &m) const |
test if Matrix is Same Size as Another | |
virtual void | ReSize (const TS2 matX, const TS2 MATY) |
Resize matrix to Given Dimensions. | |
virtual void | ReSize (const SimpleBaseTMat &src) |
Resize Matrix to match the Size of Another. | |
virtual TM * | operator[] (const TS2 &i) |
Return Pointer to a Row (so second [] selects column) | |
virtual TM & | operator() (const TS2 &i) |
Return Refererce to an Element with a Given Offset. | |
virtual TM | Val (const TS2 i) const |
Return value of a Given Element (keeps class constant) | |
virtual TM | Val (const TS2 i, const TS2 j) const |
Return value of a Given Element (keeps class constant) | |
int | IndexOffset (const int &j, const int &i) const |
void | Null () |
Set to a Null Matrix. | |
void | Identity () |
Set to an identity Matrix. | |
void | Random (const TM &max=1.0, const TM &min=0, long int seed=1234551662) |
Set elements to random Values (uniform Distribution with a given range) | |
void | RandomSym (const TM &max=1.0, const TM &min=0, long int seed=1234551662) |
void | SetAll (const TM &val) |
Set All elements to a Given Value. | |
void | SetAllRow (const int row, const TM &val) |
Set All elements in a Given Row to a Given Value. | |
void | SetAllCol (const int col, const TM &val) |
Set All elements in a Given Column to a Given Value. | |
void | SetRow (const int row, const char *s) |
Set a Row from a char array of numbers. | |
void | SetCol (const int col, const char *s) |
Set a Column from a char array of numbers. | |
void | IndexVals (int start=0) |
void | IndexValsX () |
bool | ValidElements () const |
Test For Valid Elements (no NAN etc) | |
int | ElementsWithinRange (const TM &min, const TM &max) const |
Return Number of Elements within a Range. | |
TM | MaxElement () const |
return Maximum Value in Matrix | |
TM | MinElement () const |
return Minimum Value in Matrix | |
void | TransposeM (const SimpleBaseTMat< TM, TS2 > &v2) |
Set Current Matrix to Transpose of Given matrix. | |
void | TransposeInPlace () |
Transpose Current Matrix in Place (Not implemented for non-square) | |
void | Vec2Mat (const SimpleBaseTVec< TM, TS2 > &v) |
Get Matrix Elements from a Given Vector. | |
void | Mat2Vec (SimpleBaseTVec< TM, TS2 > &v) |
Put Matrix Elements into a Given Vector (resize if can) | |
void | Vec2DiagMat (const SimpleBaseTVec< TM, TS2 > &v) |
Get Diagonal Matrix Elements from a Given Vector (resize if can) | |
template<typename TIN1 , typename TIN2 > | |
void | Outer (const SimpleBaseTVec< TIN1, TS2 > &v1, const SimpleBaseTVec< TIN2, TS2 > &v2) |
outer product of 2 vectors | |
void | DiagMat2Vec (SimpleBaseTVec< TM, TS2 > &v) |
Put Diagonal Matrix Elements into a Given Vector (resize if can) | |
void | NormColumns () |
Normalize the column vectors to length 1. | |
void | NormRows () |
Normalize the row vectors to length 1. | |
TM | Trace () const |
Return Trace for a Square Matrix. | |
TM | Sum () const |
Return Sum of Matrix Elements. | |
TM | SymOffDiag () const |
TM | AsymmetryError () const |
Returns Asymetry of Matrix. | |
TM | FrobeniusNormSQ () const |
TM | NormInf () const |
bool | SymSchur (TM &c, TM &s, const TS2 &p, const TS2 &q) const |
void | LUPSolve (TM *bout, TS2 *perm, TM *b) const |
LUP Solver (Solves (*this)*bout=b, given perm, permutation indexing) | |
void | LUPInvert (SimpleBaseTMat< TM, TS2 > &result, TS2 *perm) const |
LUP Inversion returning result and permutation. | |
void | LUPDecompose (TS2 *perm) |
LU Decomp with partial pivoting returning permutation. (Decomp is done in place--returns U in full, and L with unity diag omitted.) | |
int | JacobiCyclic (SimpleBaseTMat< TM, TS2 > &V, SimpleBaseTVec< TM > &eVal, int maxit=50, int ShowOverun=(1==1), double threshold=0.001, TM convLimit=0.00001) |
Calculate Eigen Vectors and Eigen Values for a Real Symmetric Matrix. | |
template<typename TV , typename TVS > | |
void | ConvolveV (SimpleBaseTVec< TV, TVS > &v1) |
Vertical convolution with a vector. | |
template<typename TV , typename TVS > | |
void | ConvolveH (SimpleBaseTVec< TV, TVS > &v1) |
Horizontal convolution with a vector. | |
void | Print (FILE *fp=stderr) |
Print Matrix in text format to a File pointer. | |
void | PrintOctave (const char *name=NULL, FILE *fp=stderr) |
Print Matrix to text format to allow copy and paste into Octave/Matlab. | |
bool | Save2File (char *filename) |
Save Matrix to a test file. | |
int | ReadFromFileCR (const int nCol, const int nRow, const char *filename) |
Read matrix From a file. |
Templated Base Class for Matrices.
Element type and size type are templated, storage not implemented
Note: Order of indexes in definition with respect to order of access
if you define a mat(MATX,MATY) or mat(NCOL,NROW), access element with mat[Y][X] or mat[row][column]
i.e., Y selects which row you want, X selects the column
int SimpleBaseTMat< TM, TS2 >::JacobiCyclic | ( | SimpleBaseTMat< TM, TS2 > & | V, |
SimpleBaseTVec< TM > & | eVal, | ||
int | maxit = 50 , |
||
int | ShowOverun = (1==1) , |
||
double | threshold = 0.001 , |
||
TM | convLimit = 0.00001 |
||
) | [inline] |
Calculate Eigen Vectors and Eigen Values for a Real Symmetric Matrix.
JACOBI ROTATION of a Real Symmetric Matrix
From Golub and Loan page 430
Returns Matrix of Eigen Vectors and Vector of Eigen values
Includes Ordering of Eigen Vectors Based on Size of Eigen Values
Compatible with recomposition code:
confirmed against Octave eig() function
SimpleVTMat<float, 3,3 > D1,D2,D3,D123;
D1=eVec.Row(0)*(eVec.Row(0).Transpose());
D2=eVec.Row(1)*(eVec.Row(1).Transpose());
D3=eVec.Row(2)*(eVec.Row(2).Transpose());
D123=D1*eVals[0]+D2*eVals[1]+D3*eVals[2];
void SimpleBaseTMat< TM, TS2 >::RandomSym | ( | const TM & | max = 1.0 , |
const TM & | min = 0 , |
||
long int | seed = 1234551662 |
||
) | [inline] |
Set elements to random Values (uniform Distribution with a given range) But Keep as a Symmetric Matrix
TM SimpleBaseTMat< TM, TS2 >::SymOffDiag | ( | ) | const [inline] |
Return Sum of Off Diagonal Elements For Symmetric Matrix Only! need to specialize defintion to ensure matrix shape
bool SimpleBaseTMat< TM, TS2 >::SymSchur | ( | TM & | c, |
TM & | s, | ||
const TS2 & | p, | ||
const TS2 & | q | ||
) | const [inline] |
Symmetric Schurr Decomposition From Golub and Van Loan page 428