wxEcMath - Official documentation  0.6.4
Public Member Functions | List of all members
wxEcMatrix Class Reference

Handles a matrix with basic operations. More...

#include <ec_matrix.h>

Public Member Functions

 wxEcMatrix (unsigned int line, unsigned int column, double *data=NULL)
 
 ~wxEcMatrix ()
 
void Destroy ()
 
wxString DumpAsString ()
 
void CopyFromMatrix (wxEcMatrix &source)
 
void SetDimensionality (unsigned int line, unsigned int column)
 
void SetDimensionality (wxEcUPoint size)
 
wxEcUPoint GetDimensionality ()
 
bool IsSameDimensionality (wxEcMatrix *ref)
 
bool SetValue (unsigned int line, unsigned int column, double value, bool checkboundaries=true)
 
double GetValue (unsigned int line, unsigned int column, bool checkboundaries=true)
 
double * GetCellPointer (unsigned int line, unsigned int column, bool checkboundaries=true)
 
double * GetData ()
 
void SetData (double *source)
 
bool ExchangeLines (unsigned int line1, unsigned int line2)
 
bool ExchangeColumns (unsigned int column1, unsigned int column2)
 
void Clear (double defaultvalue=0.0)
 
bool Identity ()
 
bool Hadamard ()
 
bool Hilbert ()
 
bool GaussianFilter (unsigned char radius, double sigma)
 
bool LaplacianOfGaussianFilter (unsigned char radius, double sigma)
 
void Transpose ()
 
void Factor (double factor)
 
void AddConstant (double constant)
 
double Sum ()
 
unsigned int ReplaceValue (double oldvalue, double newvalue)
 
double Determinant ()
 
bool GaussianElimination (wxEcMatrix *solution=NULL)
 
wxEcMatrixSubMatrix (unsigned int topline, unsigned int leftcolumn, unsigned int nbline, unsigned int nbcolumn)
 
bool Join (wxEcMatrix &matrix)
 
void ApplyMatrix (wxEcMatrix *matrix)
 
double Convolve (wxEcMatrix *lefthandside)
 
wxEcMatrix operator+ (wxEcMatrix &mat)
 
wxEcMatrix operator- (wxEcMatrix &mat)
 
wxEcMatrix operator* (wxEcMatrix &mat)
 
void operator<< (wxEcMatrix &mat)
 
bool operator== (wxEcMatrix &mat)
 
bool operator!= (wxEcMatrix &mat)
 

Detailed Description

Handles a matrix with basic operations.

Constructor & Destructor Documentation

wxEcMatrix::wxEcMatrix ( unsigned int  line,
unsigned int  column,
double *  data = NULL 
)

The default constructor. Matrix will be nulled or duplicated from *data.

Parameters
lineNumber of lines.
columnNumber of columns.
dataPointer to an array[] of doubles which will be recopied to initialize the object. Parameter is ignored if NULL.
wxEcMatrix::~wxEcMatrix ( )

The default destructor.

Member Function Documentation

void wxEcMatrix::AddConstant ( double  constant)

Adds a constant to each cell of the matrix.

Parameters
constantThe value to add.
void wxEcMatrix::ApplyMatrix ( wxEcMatrix matrix)
inline

This function is equivalent to "matrix = filter * matrix" but is safer in the sense that no new wxEcMatrix is allocated. This function is useful when dealing with linear transformations. The current matrix will be edited.

Parameters
matrixA pointer related to the filter to apply.
void wxEcMatrix::Clear ( double  defaultvalue = 0.0)

Fills the matrix with zeros (by default) or with the parameter.

Parameters
defaultvalueNew value of the cells.
double wxEcMatrix::Convolve ( wxEcMatrix lefthandside)
inline

Convolution of two matrixes of the same size is a special multiplication, it returns a double. Currently, you can't convolve matrixes of different size.

See also
http://en.wikipedia.org/wiki/Convolution
Parameters
lefthandsideMatrix used to convolve.
Returns
The result of the computation as a double.
void wxEcMatrix::CopyFromMatrix ( wxEcMatrix source)

Duplicates the data obtained from an external matrix.

Parameters
sourceThe matrix from which data will be extracted.
void wxEcMatrix::Destroy ( )

Frees the matrix, causing the memory to be freed.

double wxEcMatrix::Determinant ( )

Computes the determinant of the matrix. It must be square.

Returns
The determinant, or 0 if the matrix is not square.
Remarks
This function allocates a lot of memory because of wxEcMatrix::SubMatrix. The function frees the memory, so be careful depending on how big the matrix is.
wxString wxEcMatrix::DumpAsString ( )

Returns the matrix in a string. Ends of lines are composed with #10.

bool wxEcMatrix::ExchangeColumns ( unsigned int  column1,
unsigned int  column2 
)

Exchange two columns.

Parameters
column1The first column starting from 1.
column2The second column starting from 1.
Returns
true on success, else false.
bool wxEcMatrix::ExchangeLines ( unsigned int  line1,
unsigned int  line2 
)

Exchange two lines.

Parameters
line1The first line starting from 1.
line2The second line starting from 1.
Returns
true on success, else false.
void wxEcMatrix::Factor ( double  factor)

Applies a factor to each cell of the matrix.

Parameters
factorThe factor used to adjust the values.
bool wxEcMatrix::GaussianElimination ( wxEcMatrix solution = NULL)

Gaussian elimination is an algotithm solving systems of linear equations. The last column of the matrix should be the result of each equation. The determinant of the system will be calculated : if equal to 0, the function will return false because there is an infinite amount of solutions.

See also
http://en.wikipedia.org/wiki/Gaussian_elimination
Parameters
solutionA pointer to a matrix that will contain the result if not NULL. This parameter cannot be this.
Returns
true on success, else false.
See also
wxEcMatrix::Determinant()
bool wxEcMatrix::GaussianFilter ( unsigned char  radius,
double  sigma 
)

A gaussian filter is a matrix obtained with the gaussian function. The result is symetrical.

See also
http://en.wikipedia.org/wiki/Gaussian_blur
Parameters
radiusThe dimension of the square matrix will be 2*radius+1.
sigmaA deviation used for the calculation.
Returns
true if the matrix has been correctly initialized, else false.
double * wxEcMatrix::GetCellPointer ( unsigned int  line,
unsigned int  column,
bool  checkboundaries = true 
)

Gets a pointer of the desired cell of the matrix.

Parameters
lineThe line starting from 1.
columnThe column starting from 1.
checkboundariesBy default, the boundaries are checked. For many functions will not do it, just for speed.
Returns
NULL if the coordinates are not correct, else the right pointer.
Remarks
The next cell is not "pointer+1" but "pointer+sizeof(double)".
double* wxEcMatrix::GetData ( )
inline

Returns a pointer of the one-dimension array containing the data. The orientation is top->bottom and left->right.

wxEcUPoint wxEcMatrix::GetDimensionality ( )

Returns the current dimensions as wxEcUPoint.

Returns
X is the number of lines, Y is the number of columns.
double wxEcMatrix::GetValue ( unsigned int  line,
unsigned int  column,
bool  checkboundaries = true 
)

Gets the value of a cell.

Parameters
lineThe line starting from 1.
columnThe column starting from 1.
checkboundariesIf true, parameters will be checked against errors.
Returns
The value as double, 0 if not found.
bool wxEcMatrix::Hadamard ( )

Sets the matrix as defined by Hadamard. The matrix is symetrical

Returns
true on success if the matrix is square, else false
bool wxEcMatrix::Hilbert ( )

Sets the matrix as defined by Hilbert. The matrix is symetrical.

Returns
true on success if the matrix is square, else false
bool wxEcMatrix::Identity ( )

Square matrix with ones on the main diagonal and zeros elsewhere.

Returns
true if the matrix is square, else false.
bool wxEcMatrix::IsSameDimensionality ( wxEcMatrix ref)

Compares the dimensions of the current matrix with the ones of ref.

Returns
true if the dimensions are equal, else false.
bool wxEcMatrix::Join ( wxEcMatrix matrix)

This function sticks a matrix to the right-hand size of the current matrix. Diagram : Join([A],[B]) –> [AB]. The number of lines must be equal.

Parameters
matrixMatrix to stick.
Returns
true on success, false if the dimensions are not correct.
See also
Operator <<
bool wxEcMatrix::LaplacianOfGaussianFilter ( unsigned char  radius,
double  sigma 
)

A laplacian of gaussian filter is related to GaussianFilter() and is implemented when processing images digitally.

Parameters
radiusThe dimension of the square matrix will be 2*radius+1.
sigmaA deviation used for the calculation.
Returns
true if the matrix has been correctly initialized, else false.
bool wxEcMatrix::operator!= ( wxEcMatrix mat)
inline

Compares two matrixes.

wxEcMatrix wxEcMatrix::operator* ( wxEcMatrix mat)
inline

Multiply two matrixes and return an instancied result. The number of columns of the left one must be the number of lines of the right one. Else no operation will occur.

Remarks
This operator is optimized for speed. No boundaries check is performed.
wxEcMatrix wxEcMatrix::operator+ ( wxEcMatrix mat)
inline

Sums two matrixes. If the dimensions are not the same, nothing will happen.

Remarks
This operator is optimized for speed. No boundaries check is performed.
wxEcMatrix wxEcMatrix::operator- ( wxEcMatrix mat)
inline

Substract two matrixes of the same dimensions. Else no operation will occur.

Remarks
This operator is optimized for speed. No boundaries check is performed.
void wxEcMatrix::operator<< ( wxEcMatrix mat)
inline
bool wxEcMatrix::operator== ( wxEcMatrix mat)
inline

Compares two matrixes.

unsigned int wxEcMatrix::ReplaceValue ( double  oldvalue,
double  newvalue 
)

Replace a value by another one, applicable to the whole matrix.

Returns
The number of cells replaced.
void wxEcMatrix::SetData ( double *  source)
inline

Copies values into the matrix from an external source of data.

Remarks
The same amount of cells will be copied. Make sure your array is of the right dimension. Once done, you can destroy your array because no link will be established.
void wxEcMatrix::SetDimensionality ( unsigned int  line,
unsigned int  column 
)

Set the new dimensions of the matrix. This one will be filled with 0.

Parameters
lineNew number of lines.
columnNew number of columns.
Warning
If line or column is null, the dimension will be forced to 3x3.
void wxEcMatrix::SetDimensionality ( wxEcUPoint  size)

Another way to change the size of the matrix.

Parameters
sizeA size encoded as wxEcUPoint.
bool wxEcMatrix::SetValue ( unsigned int  line,
unsigned int  column,
double  value,
bool  checkboundaries = true 
)

Sets the value of a cell of the matrix.

Parameters
lineThe line starting from 1.
columnThe column starting from 1.
valueThe value to store at the given coordinate.
checkboundariesIf true, parameters will be checked against errors.
wxEcMatrix * wxEcMatrix::SubMatrix ( unsigned int  topline,
unsigned int  leftcolumn,
unsigned int  nbline,
unsigned int  nbcolumn 
)

Returns the submatrix of a matrix.

Parameters
toplinePosition of the first line, starting from 1.
leftcolumnPosition of the first column, starting from 1.
nblineNumber of lines the submatrix will contain.
nbcolumnNumber of columns the submatrix will contain.
Returns
The allocated submatrix given by its pointer. If the parameters are incorrect, the result will be NULL.
Warning
You must free the result once you don't need it anymore.
double wxEcMatrix::Sum ( )

Sums the values contained in the matrix.

void wxEcMatrix::Transpose ( )

Transposes the matrix : lines and columns will be inverted.


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



Documentation generated with Doxygen 1.8.10
Hosted on :
Get wxEcMath at SourceForge.net