Detailed Description

Matrix of scalars.

This is a wrapper for a plain C array to provide a faudes style interface, incl. token IO, access to individual entries. There is also access to the internal C++ array. Note that libFAUDES does not implement any mathematical operations on matrices. For this purpose, one should employ some external library (e.g. BOOST, alglib, ...) via an appropriate set of wrapper functions.

The token format is as follows:

<Matrix rows="2" columns="5">
1.50 -80 17 90 100
5.23 23 2 -5 13
Matrix(void)
Default constructor - sets dimension to 0x0.

Definition at line 64 of file hyb_parameter.h.

#include <hyb_parameter.h>

Public Member Functions

 Matrix (void)
 Default constructor - sets dimension to 0x0. More...
 
 Matrix (int rc, int cc)
 Constructor by dimension. More...
 
 Matrix (const Matrix &rSrc)
 Copy-constructor. More...
 
 Matrix (const std::string &rFileName)
 Construct from file. More...
 
virtual ~Matrix (void)
 Destructor. More...
 
void Clear (void)
 Clear all. More...
 
Idx Size (void) const
 Get size. More...
 
void RowCount (int rc)
 Set dimension. More...
 
int RowCount (void) const
 Get Dimension. More...
 
void ColumnCount (int cc)
 Set Dimension. More...
 
int ColumnCount (void) const
 Get Dimension. More...
 
void Dimension (int rc, int cc)
 Set Dimension. More...
 
void Zero (int rc=-1, int cc=-1)
 Set to zero matrix. More...
 
void Identity (int dim=-1)
 Set to identity matrix. More...
 
const Scalar::TypeAt (int i, int j) const
 Get entry. More...
 
void At (int i, int j, const Scalar::Type &val)
 Set entry. More...
 
const Scalar::Typeoperator() (int i, int j) const
 Cosmetic access operator. More...
 
Scalar::Typeoperator() (int i, int j)
 Cosmetic access operator. More...
 
void CArray (int rc, int cc, const Scalar::Type *data)
 Set from std C array. More...
 
const Scalar::TypeCArray (void) const
 Access std C array. More...
 
- Public Member Functions inherited from faudes::Type
 Type (void)
 Constructor. More...
 
 Type (const Type &rType)
 Copy constructor. More...
 
virtual ~Type (void)
 Destructor. More...
 
virtual TypeNew (void) const
 Construct on heap. More...
 
virtual TypeCopy (void) const
 Construct on heap. More...
 
virtual const TypeCast (const Type *pOther) const
 Cast other object to this type. More...
 
virtual TypeAssign (const Type &rSrc)
 Assign configuration data from other object. More...
 
virtual Typeoperator= (const Type &rSrc)
 Assign configurationdata from other object. More...
 
virtual bool Equal (const Type &rOther) const
 Test equality of configuration data. More...
 
virtual bool operator== (const Type &rOther) const
 Test equality of configuration data. More...
 
virtual bool operator!= (const Type &rOther) const
 Test equality of configuration data. More...
 
virtual void Name (const std::string &rName)
 Set the objects's name. More...
 
virtual const std::string & Name (void) const
 Get objects's name. More...
 
virtual const std::string & TypeName (void) const
 Get objects's type name. More...
 
void Write (const Type *pContext=0) const
 Write configuration data to console. More...
 
void Write (const std::string &pFileName, const std::string &rLabel="", const Type *pContext=0, std::ios::openmode openmode=std::ios::out|std::ios::trunc) const
 Write configuration data to a file. More...
 
void Write (const std::string &pFileName, std::ios::openmode openmode) const
 Write configuration data to a file. More...
 
void Write (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data to TokenWriter. More...
 
virtual void XWrite (const std::string &pFileName, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data to an XML file. More...
 
void XWrite (const Type *pContext=0) const
 Write configuration data in XML format to concole Note: this write function uses the virtual function DoXWrite(), to be reimplemented by derived classes. More...
 
void XWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data in XML format to TokenWriter. More...
 
std::string ToString (const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data to a string. More...
 
std::string ToText (const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data to a formated string. More...
 
void DWrite (const Type *pContext=0) const
 Write configuration data to console, debugging format. More...
 
void DWrite (const std::string &pFileName, const std::string &rLabel="", const Type *pContext=0, std::ios::openmode openmode=std::ios::out|std::ios::trunc) const
 Write configuration data to a file, debugging format. More...
 
void DWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data in debug format to TokenWriter. More...
 
void SWrite (TokenWriter &rTw) const
 Write statistics comment to TokenWriter. More...
 
void SWrite (void) const
 Write statistics comment to console. More...
 
std::string ToSText (void) const
 Write statistics to a string. More...
 
void Read (const std::string &rFileName, const std::string &rLabel="", const Type *pContext=0)
 Read configuration data from file with label specified. More...
 
void FromString (const std::string &rString, const std::string &rLabel="", const Type *pContext=0)
 Read configuration data from a string. More...
 
void Read (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
 Read configuration data from TokenReader with label sepcified. More...
 

Protected Member Functions

virtual MatrixDoAssign (const Matrix &rSrc)
 Assign from other matrix. More...
 
virtual bool DoEqual (const Matrix &rOther) const
 Test equality. More...
 
virtual void DoWrite (TokenWriter &tw, const std::string &rLabel="", const Type *pContext=0) const
 Write to TokenWriter, see Type::Write for public wrappers. More...
 
virtual void DoSWrite (TokenWriter &tw) const
 Write statistic info to TokenWriter, see Type::SWrite for public wrapper. More...
 
virtual void DoRead (TokenReader &tr, const std::string &rLabel="", const Type *pContext=0)
 Read from TokenReader, see Type::Read for public wrappers. More...
 
- Protected Member Functions inherited from faudes::Type
void DoAssign (const Type &rSrc)
 Assign configuration data from other object. More...
 
bool DoEqual (const Type &rOther) const
 Test equality of configuration data. More...
 
virtual void DoXWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data of this object to TokenWriter in XML format. More...
 
virtual void DoDWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data in debugging format to TokenWriter. More...
 
virtual const TypeDefinitionTypeDefinitionp (void) const
 Get objects's type definition. More...
 
virtual Token XBeginTag (const std::string &rLabel="", const std::string &rFallbackLabel="") const
 

Protected Attributes

int mRC
 
int mCC
 
Scalar::TypempData
 

Constructor & Destructor Documentation

◆ Matrix() [1/4]

Matrix::Matrix ( void  )

Default constructor - sets dimension to 0x0.

Definition at line 33 of file hyb_parameter.cpp.

◆ Matrix() [2/4]

Matrix::Matrix ( int  rc,
int  cc 
)

Constructor by dimension.

Parameters
rcrow count
cccolumn count

Definition at line 41 of file hyb_parameter.cpp.

◆ Matrix() [3/4]

Matrix::Matrix ( const Matrix rSrc)

Copy-constructor.

Definition at line 60 of file hyb_parameter.cpp.

◆ Matrix() [4/4]

Matrix::Matrix ( const std::string &  rFileName)

Construct from file.

Definition at line 69 of file hyb_parameter.cpp.

◆ ~Matrix()

Matrix::~Matrix ( void  )
virtual

Destructor.

Definition at line 79 of file hyb_parameter.cpp.

Member Function Documentation

◆ At() [1/2]

const Scalar::Type & Matrix::At ( int  i,
int  j 
) const

Get entry.

Parameters
irow index.
jcolumn index.
Returns
entry A(i,j)
Exceptions
Exception
  • index out of range (id 700);

Definition at line 194 of file hyb_parameter.cpp.

◆ At() [2/2]

void Matrix::At ( int  i,
int  j,
const Scalar::Type val 
)

Set entry.

Parameters
irow index.
jcolumn index.
valnew value
Exceptions
Exception
  • index out of range (id 700);

Definition at line 204 of file hyb_parameter.cpp.

◆ CArray() [1/2]

void Matrix::CArray ( int  rc,
int  cc,
const Scalar::Type data 
)

Set from std C array.

The provided data must be organized as A(i,j)=data[i*cc+j]. This version takes a copy of the provided data.

Parameters
rcrow count
cccolumn count
datapointer to C array of entries.

Definition at line 236 of file hyb_parameter.cpp.

◆ CArray() [2/2]

const Scalar::Type * Matrix::CArray ( void  ) const

Access std C array.

The data field is organized as A(i,j)=data[i*column_count+j]. Note that for zero row- or column count, this function returns NULL.

Returns
const pointer to internal C array

Definition at line 256 of file hyb_parameter.cpp.

◆ Clear()

void Matrix::Clear ( void  )
virtual

Clear all.

Sets row- and column count to 0;

Reimplemented from faudes::Type.

Definition at line 111 of file hyb_parameter.cpp.

◆ ColumnCount() [1/2]

void Matrix::ColumnCount ( int  cc)

Set Dimension.

Set number of columns and invalidate all entries.

Parameters
cccolumn count

Definition at line 138 of file hyb_parameter.cpp.

◆ ColumnCount() [2/2]

int Matrix::ColumnCount ( void  ) const

Get Dimension.

Returns
column count

Definition at line 167 of file hyb_parameter.cpp.

◆ Dimension()

void Matrix::Dimension ( int  rc,
int  cc 
)

Set Dimension.

Set dimensions and invalidate all entries.

Parameters
rcrow count
cccolumn count

Definition at line 149 of file hyb_parameter.cpp.

◆ DoAssign()

Matrix & Matrix::DoAssign ( const Matrix rSrc)
protectedvirtual

Assign from other matrix.

Parameters
rSrcsource to copy from
Returns
ref to this matrix

Definition at line 85 of file hyb_parameter.cpp.

◆ DoEqual()

bool Matrix::DoEqual ( const Matrix rOther) const
protectedvirtual

Test equality.

Parameters
rOtherOther object to compare with.
Returns
True on match.

Definition at line 100 of file hyb_parameter.cpp.

◆ DoRead()

void Matrix::DoRead ( TokenReader tr,
const std::string &  rLabel = "",
const Type pContext = 0 
)
protectedvirtual

Read from TokenReader, see Type::Read for public wrappers.

The method invokes TokenReader::ReadBegin() to seek the specified section, reads subsequent symbols, and calls matching TokenReader::ReadEnd(). If no section is specified, the section is assumed to start at the current position of the token stream. If the current position is no begin token, the section "Matrix" is read.

Parameters
trReference to TokenReader
rLabelLabel to read, defaults to current begin label or else "Matrix"
pContextWrite context to provide contextual information
Exceptions
Exception
  • IO errors (id 1)
  • token mismatch (id 50)

Reimplemented from faudes::Type.

Definition at line 291 of file hyb_parameter.cpp.

◆ DoSWrite()

void Matrix::DoSWrite ( TokenWriter tw) const
protectedvirtual

Write statistic info to TokenWriter, see Type::SWrite for public wrapper.

Parameters
twReference to TokenWriter
Exceptions
Exception
  • IO errors (id 2)

Reimplemented from faudes::Type.

Definition at line 283 of file hyb_parameter.cpp.

◆ DoWrite()

void Matrix::DoWrite ( TokenWriter tw,
const std::string &  rLabel = "",
const Type pContext = 0 
) const
protectedvirtual

Write to TokenWriter, see Type::Write for public wrappers.

Parameters
twReference to TokenWriter
rLabelLabel of the section to write, defaults to name of set or "Matrix"
pContextWrite context to provide contextual information (ignores)
Exceptions
Exception
  • IO errors (id 2)

Reimplemented from faudes::Type.

Definition at line 261 of file hyb_parameter.cpp.

◆ Identity()

void Matrix::Identity ( int  dim = -1)

Set to identity matrix.

Either provide dimensions, or use the default -1 to maintain dimensions.

Parameters
dimrow and comlumn count

Definition at line 180 of file hyb_parameter.cpp.

◆ operator()() [1/2]

Scalar::Type & Matrix::operator() ( int  i,
int  j 
)

Cosmetic access operator.

Parameters
irow index.
jcolumn index.
Exceptions
Exception
  • index out of range (id 700);

Definition at line 225 of file hyb_parameter.cpp.

◆ operator()() [2/2]

const Scalar::Type & Matrix::operator() ( int  i,
int  j 
) const

Cosmetic access operator.

Parameters
irow index.
jcolumn index.
Exceptions
Exception
  • index out of range (id 700);

Definition at line 215 of file hyb_parameter.cpp.

◆ RowCount() [1/2]

void Matrix::RowCount ( int  rc)

Set dimension.

This will invalidate the entries.

Parameters
rcrow count

Definition at line 126 of file hyb_parameter.cpp.

◆ RowCount() [2/2]

int Matrix::RowCount ( void  ) const

Get Dimension.

Set number of rows and invalidate all entries.

Returns
row count

Definition at line 162 of file hyb_parameter.cpp.

◆ Size()

Idx Matrix::Size ( void  ) const

Get size.

Gets over all number of entries.

Returns
RowCount() * ColumnCount()

Definition at line 120 of file hyb_parameter.cpp.

◆ Zero()

void Matrix::Zero ( int  rc = -1,
int  cc = -1 
)

Set to zero matrix.

Either provide dimensions, or use the default -1 to maintain dimensions.

Parameters
rcrow count
cccolumn count

Definition at line 172 of file hyb_parameter.cpp.

Member Data Documentation

◆ mCC

int faudes::Matrix::mCC
protected

Definition at line 293 of file hyb_parameter.h.

◆ mpData

Scalar::Type* faudes::Matrix::mpData
protected

Definition at line 296 of file hyb_parameter.h.

◆ mRC

int faudes::Matrix::mRC
protected

Definition at line 292 of file hyb_parameter.h.


The documentation for this class was generated from the following files:

libFAUDES 2.32b --- 2024.03.01 --- c++ api documentaion by doxygen