DoubleMatrix Class Reference

DoubleMatrix Class This represent a 2D matrix of double values. More...

Public Member Functions

 DoubleMatrix (unsigned int rows, unsigned int cols, bool isinternal=false)
 Construct an empty matrix of dimension size.
 
 DoubleMatrix (const DoubleMatrix &src)
 Copy-Constructor.
 
 DoubleMatrix (unsigned int rows, unsigned int cols, bool temp, unsigned int dummy)
 This is a special constructor used for copy a DoubleMatrix and mark it as temporary for speed-up calculation.
 
 ~DoubleMatrix ()
 Destructor.
 
doubleRefat (unsigned int row, unsigned int col)
 Return a reference to element at position (row, col)
 
double at (unsigned int row, unsigned int col) const
 Return a Const reference to element at position (row, col)
 
unsigned int cols () const
 Returns the numbers of Columns.
 
DoubleVectorcolumn (unsigned int c)
 Return the i-th column of the Matrix.
 
DoubleVector column (unsigned int c) const
 Return the i-th column of the Matrix (Const version)
 
DoubleMatrixcopyValues (const DoubleMatrix &src)
 Copy the values from source honoring fixed elements (i.e.
 
DoubleMatrixcopyValues (const DoubleMatrix &src, unsigned int srcRowOffset, unsigned int srcColOffset, unsigned int thisRowOffset, unsigned int thisColOffset)
 Copy the values from source honoring fixed elements starting from the offsets specified (i.e.
 
DoubleMatrixcopyValues (const DoubleMatrix &src, unsigned int srcRowOffset, unsigned int srcColOffset, unsigned int thisRowOffset, unsigned int thisColOffset, unsigned int rowStride, unsigned int colStride)
 Copy the values from source honoring fixed elements starting from the offsets specified (i.e.
 
DoubleMatrixdetach ()
 If the current data is shared by other objects, this method will create a new copy of the data not shared by other objects.
 
bool isSteady (unsigned int i, unsigned int j) const
 Return true if the [i][j]-th value is a steady value.
 
bool operator!= (const DoubleMatrix &right) const
 Not-Equal Operator.
 
const DoubleMatrix operator% (const DoubleMatrix &right) const
 operator % (element-by-element multiplication)
 
DoubleMatrixoperator%= (const DoubleMatrix &right)
 operator %= (element-by-element multiplication)
 
const DoubleMatrix operator* (const DoubleMatrix &right) const
 operator * (matrix multiplication)
 
const DoubleMatrix operator+ (const DoubleMatrix &right) const
 operator +
 
DoubleMatrixoperator+= (const DoubleMatrix &right)
 operator +=
 
const DoubleMatrix operator- (const DoubleMatrix &right) const
 operator -
 
DoubleMatrixoperator-= (const DoubleMatrix &right)
 operator -=
 
const DoubleMatrix operator/ (const DoubleMatrix &right) const
 operator / (element-by-element)
 
DoubleMatrixoperator/= (const DoubleMatrix &right)
 operator /= (element-by-element)
 
DoubleMatrixoperator= (const DoubleMatrix &src)
 Behaves as a CopyConstructor: this do a completely substitution of underlying data so, it does not honor fixed elements, hence it substitute all informations taking also the new information about fixed element in src.
 
bool operator== (const DoubleMatrix &right) const
 Equal Operator.
 
DoubleVectoroperator[] (unsigned int row)
 Indexing operator

 
DoubleVector operator[] (unsigned int row) const
 Indexing operator (Const Version)

 
DoubleMatrixresize (unsigned int rows, unsigned int cols)
 Resize the matrix.
 
DoubleVectorrow (unsigned int r)
 Return the i-th row of the Matrix (this behaves like operator[])
 
DoubleVector row (unsigned int r) const
 Return the i-th row of the Matrix (Const version) (this behaves like operator[])
 
unsigned int rows () const
 Returns the numbers of Row.
 
DoubleMatrixsetAll (const double value)
 Set all values to value This method honor the steady values...
 
DoubleMatrixsetIdentity ()
 Set all diagonal values to 1 and others to zero This method honor the steady values...
 
unsigned int size () const
 Returns the total numbers of elements (Rows*Columns)
 
DoubleMatrixsteady (unsigned int i, unsigned int j)
 Fix the [i][j]-th value, hence the [i][j]-th value will never change anymore until unsteady is called.
 
DoubleMatrixunsteady (unsigned int i, unsigned int j)
 Reallow the modification of [i][j]-th value.
 
DoubleMatrixzeroing ()
 Set all values to zero This method honor the steady values...
 

Detailed Description

DoubleMatrix Class This represent a 2D matrix of double values.

Description
The DoubleMatrix use an implicit-sharing mechanism based on copy-on-write
Warnings
This class is also used by other class for structuring their underlyng data. In these case, changing the structure of a DoubleMatrix using directly the assign operator= can result in uncoerent state of the object owning the DoubleMatrix. There special constructor that takes a boolean value, isinternal, for flag such situations. When a user attempt to call the operator= on a DoubleMatrix with isinternal flag on an Exception will be throw.

Definition at line 43 of file matrices.h.

Constructor & Destructor Documentation

DoubleMatrix ( unsigned int  rows,
unsigned int  cols,
bool  isinternal = false 
)
inline

Construct an empty matrix of dimension size.

Definition at line 46 of file matrices.h.

DoubleMatrix ( const DoubleMatrix src)
inline

Copy-Constructor.

Definition at line 75 of file matrices.h.

DoubleMatrix ( unsigned int  rows,
unsigned int  cols,
bool  temp,
unsigned int  dummy 
)
inline

This is a special constructor used for copy a DoubleMatrix and mark it as temporary for speed-up calculation.

It's intended for internal use only DON'T USE UNLESS YOUR ARE VERY CONFIDENT on How the special temporary DoubleMatrix are used

Definition at line 111 of file matrices.h.

~DoubleMatrix ( )
inline

Destructor.

Definition at line 141 of file matrices.h.

Member Function Documentation

doubleRef& at ( unsigned int  row,
unsigned int  col 
)
inline

Return a reference to element at position (row, col)

Warning
Boundary check activated only when FARSA_DEBUG if defined

Definition at line 325 of file matrices.h.

double at ( unsigned int  row,
unsigned int  col 
) const
inline

Return a Const reference to element at position (row, col)

Warning
Boundary check activated only when FARSA_DEBUG if defined

Definition at line 336 of file matrices.h.

unsigned int cols ( ) const
inline

Returns the numbers of Columns.

Definition at line 159 of file matrices.h.

Referenced by farsa::amul(), farsa::deltarule(), and farsa::mul().

DoubleVector& column ( unsigned int  c)
inline

Return the i-th column of the Matrix.

Definition at line 378 of file matrices.h.

Referenced by NormLinker::update().

DoubleVector column ( unsigned int  c) const
inline

Return the i-th column of the Matrix (Const version)

Definition at line 386 of file matrices.h.

DoubleMatrix& copyValues ( const DoubleMatrix src)
inline

Copy the values from source honoring fixed elements (i.e.

: the fixed element of this remains unchanged )

Note
this method does not check the dimension of the two matrices, but behaves safely calculating the minimal boundaries between source and destination, and it will copy only values in that range

Definition at line 225 of file matrices.h.

Referenced by DoubleMatrix::resize().

DoubleMatrix& copyValues ( const DoubleMatrix src,
unsigned int  srcRowOffset,
unsigned int  srcColOffset,
unsigned int  thisRowOffset,
unsigned int  thisColOffset 
)
inline

Copy the values from source honoring fixed elements starting from the offsets specified (i.e.

: the fixed element of this remains unchanged )

Parameters
srcRowOffsetis the row offset from which the values are read from the src matrix
srcColOffsetis the col offset from which the values are read from the src matrix
thisRowOffsetis the row offset on which the values from the src matrix are placed
thisColOffsetis the row offset on which the values from the src matrix are placed
Note
this method does not check the dimension of the two vectors, but behaves safely like the copyValues method

Definition at line 247 of file matrices.h.

DoubleMatrix& copyValues ( const DoubleMatrix src,
unsigned int  srcRowOffset,
unsigned int  srcColOffset,
unsigned int  thisRowOffset,
unsigned int  thisColOffset,
unsigned int  rowStride,
unsigned int  colStride 
)
inline

Copy the values from source honoring fixed elements starting from the offsets specified (i.e.

: the fixed element of this remains unchanged )

Parameters
srcRowOffsetis the row offset from which the values are read from the src matrix
srcColOffsetis the col offset from which the values are read from the src matrix
thisRowOffsetis the row offset on which the values from the src matrix are placed
thisColOffsetis the row offset on which the values from the src matrix are placed
rowStrideis the stride; stride zero is not allowed, stride == 1 behaves like copyValues without stride, stride > 1 it jump 'stride' rows when coping, leaving the jumped values unchanged
colStrideis the stride; stride zero is not allowed, stride == 1 behaves like copyValues without stride, stride > 1 it jump 'stride' columuns when coping, leaving the jumped values unchanged
Note
this method does not check the dimension of the two matrices, but behaves safely like the copyValues method

Definition at line 275 of file matrices.h.

DoubleMatrix& detach ( )
inline

If the current data is shared by other objects, this method will create a new copy of the data not shared by other objects.

Definition at line 294 of file matrices.h.

bool isSteady ( unsigned int  i,
unsigned int  j 
) const
inline

Return true if the [i][j]-th value is a steady value.

Definition at line 420 of file matrices.h.

bool operator!= ( const DoubleMatrix right) const
inline

Not-Equal Operator.

Definition at line 178 of file matrices.h.

const DoubleMatrix operator% ( const DoubleMatrix right) const
inline

operator % (element-by-element multiplication)

Warning
Dimensionality check activated only when FARSA_DEBUG is defined

Definition at line 537 of file matrices.h.

DoubleMatrix& operator%= ( const DoubleMatrix right)
inline

operator %= (element-by-element multiplication)

Warning
Dimensionality check activated only when FARSA_DEBUG is defined

Definition at line 621 of file matrices.h.

const DoubleMatrix operator* ( const DoubleMatrix right) const
inline

operator * (matrix multiplication)

Warning
Dimensionality check activated only when FARSA_DEBUG is defined
It always allocate a new matrix on memory

Definition at line 516 of file matrices.h.

References DoubleMatrix::zeroing().

const DoubleMatrix operator+ ( const DoubleMatrix right) const
inline

operator +

Warning
Dimensionality check activated only when FARSA_DEBUG is defined

Definition at line 461 of file matrices.h.

DoubleMatrix& operator+= ( const DoubleMatrix right)
inline

operator +=

Warning
Dimensionality check activated only when FARSA_DEBUG is defined

Definition at line 591 of file matrices.h.

const DoubleMatrix operator- ( const DoubleMatrix right) const
inline

operator -

Warning
Dimensionality check activated only when DEBUG is defined

Definition at line 488 of file matrices.h.

DoubleMatrix& operator-= ( const DoubleMatrix right)
inline

operator -=

Warning
Dimensionality check activated only when FARSA_DEBUG is defined

Definition at line 606 of file matrices.h.

const DoubleMatrix operator/ ( const DoubleMatrix right) const
inline

operator / (element-by-element)

Warning
Dimensionality check activated only when FARSA_DEBUG is defined

Definition at line 564 of file matrices.h.

DoubleMatrix& operator/= ( const DoubleMatrix right)
inline

operator /= (element-by-element)

Warning
Dimensionality check activated only when DEBUG is defined

Definition at line 636 of file matrices.h.

DoubleMatrix& operator= ( const DoubleMatrix src)
inline

Behaves as a CopyConstructor: this do a completely substitution of underlying data so, it does not honor fixed elements, hence it substitute all informations taking also the new information about fixed element in src.


If you want copy only DoubleMatrix's values use copy method

Warning
If the isinternal flag is true, then the operator= will raise the AssignmentNotAllowed

Definition at line 198 of file matrices.h.

bool operator== ( const DoubleMatrix right) const
inline

Equal Operator.

Definition at line 167 of file matrices.h.

DoubleVector& operator[] ( unsigned int  row)
inline

Indexing operator

Warning
Boundary check activated only when FARSA_DEBUG if defined

Definition at line 346 of file matrices.h.

DoubleVector operator[] ( unsigned int  row) const
inline

Indexing operator (Const Version)

Warning
Boundary check activated only when FARSA_DEBUG if defined

Definition at line 356 of file matrices.h.

DoubleMatrix& resize ( unsigned int  rows,
unsigned int  cols 
)
inline

Resize the matrix.

Warning
If the isinternal flag is true, then the resize will raise the ResizeNotAllowed

Definition at line 184 of file matrices.h.

References DoubleMatrix::copyValues().

DoubleVector& row ( unsigned int  r)
inline

Return the i-th row of the Matrix (this behaves like operator[])

Definition at line 363 of file matrices.h.

DoubleVector row ( unsigned int  r) const
inline

Return the i-th row of the Matrix (Const version) (this behaves like operator[])

Definition at line 371 of file matrices.h.

unsigned int rows ( ) const
inline

Returns the numbers of Row.

Definition at line 155 of file matrices.h.

Referenced by farsa::amul(), farsa::deltarule(), and farsa::mul().

DoubleMatrix& setAll ( const double  value)
inline

Set all values to value This method honor the steady values...

hence that values will remain at the same values

Definition at line 429 of file matrices.h.

DoubleMatrix& setIdentity ( )
inline

Set all diagonal values to 1 and others to zero This method honor the steady values...

hence that values will remain at the same values

Definition at line 439 of file matrices.h.

unsigned int size ( ) const
inline

Returns the total numbers of elements (Rows*Columns)

Definition at line 163 of file matrices.h.

DoubleMatrix& steady ( unsigned int  i,
unsigned int  j 
)
inline

Fix the [i][j]-th value, hence the [i][j]-th value will never change anymore until unsteady is called.

Warning
Boundary check activated only when FARSA_DEBUG if defined

Definition at line 396 of file matrices.h.

Referenced by MatrixLinker::connectRandom(), MatrixLinker::disconnect(), and MatrixLinker::disconnectAll().

DoubleMatrix& unsteady ( unsigned int  i,
unsigned int  j 
)
inline

Reallow the modification of [i][j]-th value.

Warning
Boundary check activated only when FARSA_DEBUG if defined

Definition at line 409 of file matrices.h.

Referenced by MatrixLinker::connect(), MatrixLinker::connectAll(), MatrixLinker::connectRandom(), MatrixLinker::disconnect(), and MatrixLinker::disconnectAll().

DoubleMatrix& zeroing ( )
inline

Set all values to zero This method honor the steady values...

hence that values will remain at the same values

Definition at line 451 of file matrices.h.

Referenced by MatrixLinker::MatrixLinker(), and DoubleMatrix::operator*().


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