Matrix. More...

#include <rmatrix.h>

Inheritance diagram for RMatrix:
[legend]
Collaboration diagram for RMatrix:
[legend]

Public Member Functions

int Compare (const RMatrix &matrix) const
 
RCursor< RVectorGetLines (void) const
 
virtual tType GetType (void) const
 
virtual void Init (double val)
 
virtual double operator() (size_t i, size_t j) const
 
virtual double & operator() (size_t i, size_t j)
 
RMatrixoperator*= (const double arg)
 
RMatrixoperator*= (const RMatrix &matrix)
 
RMatrixoperator+= (const RMatrix &matrix)
 
RMatrixoperator-= (const RMatrix &matrix)
 
RMatrixoperator/= (const double arg)
 
RMatrixoperator= (const RMatrix &matrix)
 
const RVectoroperator[] (size_t i) const
 
RVectoroperator[] (size_t i)
 
 RMatrix (size_t size)
 
 RMatrix (size_t lines, size_t cols)
 
 RMatrix (const RMatrix &matrix)
 
void Symetrize (void)
 
virtual void VerifySize (size_t newlines, size_t newcols, bool fill=false, double val=NAN)
 
virtual ~RMatrix (void)
 
- Public Member Functions inherited from RGenericMatrix
virtual void Add (size_t i, size_t j, double val)
 
virtual void Clear (double val=NAN, bool clean=false)
 
int Compare (const RGenericMatrix &matrix) const
 
size_t GetNbCols (void) const
 
size_t GetNbLines (void) const
 
RGenericMatrixoperator= (const RGenericMatrix &matrix)
 
template<class S >
void Print (S &stream, const RString &name, const char *format="%E", size_t colsize=12) const
 
 RGenericMatrix (size_t size)
 
 RGenericMatrix (size_t lines, size_t cols)
 
 RGenericMatrix (const RGenericMatrix &matrix)
 
virtual ~RGenericMatrix (void)
 

Protected Member Functions

virtual void Create (void)
 
void TestThis (void) const
 
- Protected Member Functions inherited from RContainer< RVector, true, false >
void Clear (size_t m=0, size_t i=0, bool force=false)
 
int Compare (const RContainer< RVector, true, false > &) const
 
void Copy (const RContainer< RVector, a, false > &src)
 
void DeletePtr (const TUse &tag, bool sortkey, bool del, size_t min=0, size_t max=0)
 
void DeletePtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0)
 
void DeletePtr (const TUse &tag, size_t min=0, size_t max=0)
 
void DeletePtrAt (size_t pos, bool shift, bool del)
 
void DeletePtrAt (size_t pos, bool shift)
 
void DeletePtrAt (size_t pos)
 
void Exchange (size_t pos1, size_t pos2)
 
size_t GetIncNb (void) const
 
size_t GetIndex (const TUse &tag, bool &find, size_t min=0, size_t max=0) const
 
RVectorGetInsertPtr (const TUse &tag, size_t min=0, size_t max=0)
 
RVectorGetInsertPtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0)
 
RVectorGetInsertPtrAt (const TUse &tag, size_t pos)
 
size_t GetMaxNb (void) const
 
size_t GetMaxPos (void) const
 
size_t GetNb (void) const
 
RVectorGetPtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) const
 
RVectorGetPtr (const TUse &tag, size_t min=0, size_t max=0) const
 
const RVectorGetPtrAt (size_t idx) const
 
RVectorGetPtrAt (size_t idx)
 
RContainer< RVector, false,
false > * 
GetPtrs (const TUse &tag, size_t min=0, size_t max=0) const
 
size_t GetTab (const void **tab, size_t min=0, size_t max=0) const
 
size_t GetTab (void **tab, size_t min=0, size_t max=0)
 
size_t GetTab (const RVector **tab, size_t min=0, size_t max=0) const
 
size_t GetTab (RVector **tab, size_t min=0, size_t max=0)
 
void InsertPtr (RVector *ins, bool del=false, size_t min=0, size_t max=0)
 
void InsertPtrAt (RVector *ins, size_t pos, bool del)
 
void InsertPtrAt (RVector *ins, size_t pos)
 
void Inter (const iRContainer< RVector > &src1, const iRContainer< RVector > &src2)
 
bool IsIn (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) const
 
bool IsIn (const TUse &tag, size_t min=0, size_t max=0) const
 
RContaineroperator+= (const RContainer< RVector, a, o > &src)
 
RContaineroperator= (const RContainer< RVector, true, false > &src)
 
RContaineroperator= (const RContainer< RVector, false, false > &src)
 
const RVectoroperator[] (size_t idx) const
 
RVectoroperator[] (size_t idx)
 
 RContainer (const RContainer< RVector, true, false > &src)
 
 RContainer (const RContainer< RVector, false, false > &src)
 
 RContainer (size_t m, size_t i=0)
 
void ReOrder (int sortOrder(const void *, const void *))
 
void ReOrder (int sortOrder(const void *, const void *), size_t min, size_t max)
 
void ReOrder (void)
 
void Shift (size_t idx, bool reverse)
 
void Transfer (RContainer< RVector, a, o > &src)
 
void Union (const iRContainer< RVector > &src1, const iRContainer< RVector > &src2)
 
bool VerifyIndex (size_t idx) const
 
void VerifyTab (size_t max=0)
 
virtual ~RContainer (void)
 
- Protected Member Functions inherited from iRContainer< C >
iRContainerAdd (const iRContainer< C > &src)
 
void Create (const iRContainer< C > &src)
 
void DeepCopy (const iRContainer< C > &src)
 
iRContainerNormalCopy (const iRContainer< C > &src)
 
void Clear (size_t m=0, size_t i=0, bool force=false)
 
void Copy (const iRContainer< C > &src)
 
void DeletePtr (const TUse &tag, bool sortkey, bool del, size_t min=0, size_t max=0)
 
void DeletePtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0)
 
void DeletePtr (const TUse &tag, size_t min=0, size_t max=0)
 
void DeletePtrAt (size_t pos, bool shift)
 
void DeletePtrAt (size_t pos)
 
void DeletePtrAt (size_t pos, bool shift, bool del)
 
void Exchange (size_t pos1, size_t pos2)
 
size_t GetIncNb (void) const
 
size_t GetIndex (const TUse &tag, bool &find, size_t min=0, size_t max=0) const
 
size_t GetIndex (bool order, const TUse &tag, bool &find, size_t min=0, size_t max=0) const
 
C * GetInsertPtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0)
 
C * GetInsertPtr (const TUse &tag, size_t min=0, size_t max=0)
 
C * GetInsertPtrAt (const TUse &tag, size_t pos)
 
size_t GetMaxNb (void) const
 
size_t GetMaxPos (void) const
 
size_t GetNb (void) const
 
C * GetPtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) const
 
C * GetPtr (const TUse &tag, size_t min=0, size_t max=0) const
 
const C * GetPtrAt (size_t idx) const
 
C * GetPtrAt (size_t idx)
 
size_t GetTab (const C **tab, size_t min=0, size_t max=0) const
 
size_t GetTab (C **tab, size_t min=0, size_t max=0)
 
size_t GetTab (const void **tab, size_t min=0, size_t max=0) const
 
size_t GetTab (void **tab, size_t min=0, size_t max=0)
 
void InsertPtr (C *ins, bool del=false, size_t min=0, size_t max=0)
 
void InsertPtrAt (C *ins, size_t pos, bool del)
 
void InsertPtrAt (C *ins, size_t pos)
 
void Inter (const iRContainer< C > &src1, const iRContainer< C > &src2)
 
bool IsIn (const TUse &tag, size_t min=0, size_t max=0) const
 
bool IsIn (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) const
 
iRContaineroperator+= (const iRContainer< C > &src)
 
iRContaineroperator= (const iRContainer< C > &src)
 
const C * operator[] (size_t idx) const
 
C * operator[] (size_t idx)
 
void ReOrder (int sortOrder(const void *, const void *), size_t min, size_t max)
 
void ReOrder (int sortOrder(const void *, const void *))
 
void ReOrder (void)
 
void Shift (size_t idx, bool reverse)
 
void Transfer (iRContainer< C > &src)
 
void Union (const iRContainer< C > &src1, const iRContainer< C > &src2)
 
bool VerifyIndex (size_t idx) const
 
void VerifyTab (size_t max=0)
 
virtual ~iRContainer (void)
 

Protected Attributes

bool MustCreate
 
- Protected Attributes inherited from RGenericMatrix
size_t NbCols
 
size_t NbLines
 
- Protected Attributes inherited from iRContainer< C >
size_t IncPtr
 
size_t LastPtr
 
size_t MaxPtr
 
size_t NbPtr
 
C ** Tab
 

Additional Inherited Members

- Public Types inherited from RGenericMatrix
enum  tType {
  tNormal, tDiagonal, tLowerTriangular, tUpperTriangular,
  tSymmetric, tSparse, tSparseSymmetric, tMax
}
 
- Static Protected Member Functions inherited from RContainer< RVector, true, false >
static int SortOrder (const void *a, const void *b)
 
- Static Protected Member Functions inherited from iRContainer< C >
static int SortOrder (const void *a, const void *b)
 

Detailed Description

Matrix.

The RMatrix class provides a representation of a matrix as a given number of vector, each vector representing a line

Here are some examples:

RMatrix a(2,2);
RMatrix b(2,2);
a(0,0)=1; a(0,1)=2;
a(1,0)=2; a(0,1)=2;
b(0,0)=3; b(0,1)=2;
b(1,1)=1; b(1,1)=4;
c=a+b;
c=a-b;
c=a*b;
c=(2*a)+(b*a);
RCursor<RVector> Lines(c.GetLines());
for(Lines.Start();!Lines.End();Lines.Next())
{
RNumCursor<double> Cols(Lines()->GetCols());
for(Cols.Start();!Cols.End();Cols.Next())
cout<<Cols()<<"\t";
cout<<endl;
}

Constructor & Destructor Documentation

RMatrix ( size_t  size)

Construct a square matrix of a given size.

Parameters
sizeSize of the matrix.
RMatrix ( size_t  lines,
size_t  cols 
)

Construct a matrix (L,C).

Parameters
linesInitial number of lines.
colsInitial number of columns.
RMatrix ( const RMatrix matrix)

Construct a matrix from another one.

Parameters
matrixMatrix.
virtual ~RMatrix ( void  )
virtual

Destruct the matrix.

Member Function Documentation

int Compare ( const RMatrix matrix) const

Compare method used by RContainer.

Parameters
matrixMatrix to compare with.
Returns
always -1.
virtual void Create ( void  )
protectedvirtual

Create the matrix. The method should always put MustCreate to false.

Reimplemented in RLowerTriangularMatrix.

void TestThis ( void  ) const
protected

Test if the matrix must be created.

virtual void Init ( double  val)
virtual

Initialize the matrix with a given value.

Parameters
valValue to assign.

Reimplemented from RGenericMatrix.

virtual void VerifySize ( size_t  newlines,
size_t  newcols,
bool  fill = false,
double  val = NAN 
)
virtual

Verify if the matrix has a given size, and increase them if necessary.

Parameters
newlinesNew line number.
newcolsNew column number.
fillElements must be filled with a value.
valValue used eventually to fill the elements created.

Implements RGenericMatrix.

Reimplemented in RLowerTriangularMatrix.

virtual tType GetType ( void  ) const
virtual

Get the type of the matrix.

Implements RGenericMatrix.

Reimplemented in RLowerTriangularMatrix, and RSymmetricMatrix.

RCursor<RVector> GetLines ( void  ) const

Get the number of lines in the matrix.

void Symetrize ( void  )

Make the matrix symmetric by copying the "left-upper" part in the "right-bottom" part.

virtual double operator() ( size_t  i,
size_t  j 
) const
virtual

Return a specific element of the matrix (const version).

Parameters
iLine number of the element.
jColumn number of the element.

Implements RGenericMatrix.

Reimplemented in RLowerTriangularMatrix, and RSymmetricMatrix.

virtual double& operator() ( size_t  i,
size_t  j 
)
virtual

Return a specific element of the matrix (const version).

Parameters
iLine number of the element.
jColumn number of the element.

Implements RGenericMatrix.

Reimplemented in RLowerTriangularMatrix, and RSymmetricMatrix.

const RVector* operator[] ( size_t  i) const

Return the vector at a given line from the matrix (const version).

Parameters
iLine number of the vector.
RVector* operator[] ( size_t  i)

Return the vector at a given line from the matrix.

Parameters
iLine number of the vector.
RMatrix& operator= ( const RMatrix matrix)

Assign operator.

Parameters
matrixMatrix.
RMatrix& operator+= ( const RMatrix matrix)

Add a matrix to the current one.

Parameters
matrixMatrix to add.
RMatrix& operator-= ( const RMatrix matrix)

Subtract a matrix from the current one.

Parameters
matrixMatrix to subtract.
RMatrix& operator*= ( const double  arg)

Multiply a matrix with a given number.

Parameters
argNumber.
RMatrix& operator/= ( const double  arg)

Divide a matrix with a given number.

Parameters
argNumber.
RMatrix& operator*= ( const RMatrix matrix)

Multiply a matrix with the current one. It is important to remember that the matrix multiplication is not communitative. So the next code defines two different matrixes TempA and TempB.

void Test(RMatrix &A,RMatrix &B)
{
RMatrix TempA(A);
RMatrix TempB(B);
TempA*=B;
TempB*=A;
}
Parameters
matrixMatrix to multiply.

Member Data Documentation

bool MustCreate
protected

Matrix must be initialized. If MustCreate is false, Create() must be called. It must be verify in each method.