Handles a matrix with basic operations.
More...
#include <ec_matrix.h>
|
| 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) |
|
wxEcMatrix * | SubMatrix (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) |
|
Handles a matrix with basic operations.
wxEcMatrix::wxEcMatrix |
( |
unsigned int |
line, |
|
|
unsigned int |
column, |
|
|
double * |
data = NULL |
|
) |
| |
The default constructor. Matrix will be nulled or duplicated from *data.
- Parameters
-
line | Number of lines. |
column | Number of columns. |
data | Pointer to an array[] of doubles which will be recopied to initialize the object. Parameter is ignored if NULL. |
wxEcMatrix::~wxEcMatrix |
( |
| ) |
|
void wxEcMatrix::AddConstant |
( |
double |
constant | ) |
|
Adds a constant to each cell of the matrix.
- Parameters
-
constant | The 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
-
matrix | A 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
-
defaultvalue | New 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
-
lefthandside | Matrix 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
-
source | The 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.
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
-
column1 | The first column starting from 1. |
column2 | The second column starting from 1. |
- Returns
- true on success, else false.
bool wxEcMatrix::ExchangeLines |
( |
unsigned int |
line1, |
|
|
unsigned int |
line2 |
|
) |
| |
Exchange two lines.
- Parameters
-
line1 | The first line starting from 1. |
line2 | The 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
-
factor | The 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
-
solution | A 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
-
radius | The dimension of the square matrix will be 2*radius+1. |
sigma | A 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
-
line | The line starting from 1. |
column | The column starting from 1. |
checkboundaries | By 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.
double* wxEcMatrix::GetData |
( |
| ) |
|
|
inline |
Returns a pointer of the one-dimension array containing the data. The orientation is top->bottom and left->right.
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
-
line | The line starting from 1. |
column | The column starting from 1. |
checkboundaries | If 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.
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
-
- 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
-
radius | The dimension of the square matrix will be 2*radius+1. |
sigma | A deviation used for the calculation. |
- Returns
- true if the matrix has been correctly initialized, else false.
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.
Sums two matrixes. If the dimensions are not the same, nothing will happen.
Substract two matrixes of the same dimensions. Else no operation will occur.
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.
void wxEcMatrix::SetDimensionality |
( |
unsigned int |
line, |
|
|
unsigned int |
column |
|
) |
| |
Set the new dimensions of the matrix. This one will be filled with 0.
- Parameters
-
line | New number of lines. |
column | New 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
-
bool wxEcMatrix::SetValue |
( |
unsigned int |
line, |
|
|
unsigned int |
column, |
|
|
double |
value, |
|
|
bool |
checkboundaries = true |
|
) |
| |
Sets the value of a cell of the matrix.
- Parameters
-
line | The line starting from 1. |
column | The column starting from 1. |
value | The value to store at the given coordinate. |
checkboundaries | If 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
-
topline | Position of the first line, starting from 1. |
leftcolumn | Position of the first column, starting from 1. |
nbline | Number of lines the submatrix will contain. |
nbcolumn | Number 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: