libcrn
3.9.5
A document image processing library
|
Base matrix class. More...
#include <CRNMatrix.h>
Public Member Functions | |
Matrix (size_t nrow, size_t ncol, const T &value=T(0)) | |
Constructor. More... | |
Matrix (const std::vector< std::vector< T >> &m) | |
Constructor from std::vector matrix. More... | |
Matrix (const std::vector< T > &vect, Orientation ori=Orientation::VERTICAL) | |
Constructor from std::vector 1D vector. More... | |
Matrix (std::vector< T > &&vect, Orientation ori=Orientation::VERTICAL) | |
Constructor from std::vector 1D vector. More... | |
virtual | ~Matrix () override=default |
Destructor. More... | |
Matrix (const Matrix &)=default | |
template<typename Y > | |
Matrix (const Matrix< Y > &m) | |
Matrix (Matrix &&)=default | |
Matrix & | operator= (const Matrix &)=default |
Matrix & | operator= (Matrix &&)=default |
void | Swap (Matrix &m) |
size_t | GetRows () const noexcept |
Returns the number of rows. More... | |
size_t | GetCols () const noexcept |
Returns the number of columns. More... | |
const T & | At (size_t pos) const noexcept |
T & | At (size_t pos) noexcept |
const T & | At (size_t r, size_t c) const noexcept |
T & | At (size_t r, size_t c) noexcept |
void | SetAll (const T &v) |
Set all elements. More... | |
void | Negative () |
Change sign for all elements. More... | |
void | SetRow (size_t r, const std::vector< T > &row) |
Sets the values of a row. More... | |
void | SetColum (size_t c, const std::vector< T > &col) |
Sets the values of a column. More... | |
void | IncreaseElement (size_t r, size_t c, const T &delta) |
Increases the value of an element. More... | |
void | IncreaseRow (size_t r, const T &v) |
Increase one row from matrix. More... | |
void | IncreaseColumn (size_t c, const T &v) |
Increase one column from matrix. More... | |
Matrix & | operator+= (const Matrix &m) |
Matrix & | operator-= (const Matrix &m) |
Matrix & | operator*= (const Matrix &m) |
bool | operator== (const Matrix &m) const |
bool | operator!= (const Matrix &m) const |
Matrix & | operator*= (double d) |
Scaling. More... | |
Matrix & | operator/= (double d) |
Scaling. More... | |
void | MultRow (size_t r, double v) |
Scale one row from matrix. More... | |
void | MultColumn (size_t c, double v) |
Scale one column from matrix. More... | |
void | CenterColumns () |
Centers all columns by subtracting the mean for each column. More... | |
void | ReduceColumns (bool centered=true) |
Reduces all columns by dividing by the standard deviation of each column. More... | |
void | SwapRows (size_t r1, size_t r2) |
Swap two rows in matrix. More... | |
void | SwapColumns (size_t c1, size_t c2) |
Swap two columns in matrix. More... | |
void | NormalizeForConvolution () |
Normalizes the matrix to be used for convolution. More... | |
TypeInfo< T >::SumType | CumulateCells () const |
T | GetMin () const |
T | GetMax () const |
std::pair< size_t, size_t > | Argmin () const |
std::pair< size_t, size_t > | Argmax () const |
Matrix | MakeTranspose () |
Create transposition. More... | |
virtual Matrix & | Transpose () |
Inplace transposition. More... | |
Matrix | MakeRowAsColumn (size_t r) const |
Creates a column matrix from a row. More... | |
Matrix | MakeRow (size_t r) const |
Extract a row from current matrix. More... | |
Matrix | MakeColumn (size_t k) const |
Extracts one column from matrix. More... | |
size_t | ArgmaxInRow (size_t r) const |
Returns the row index of the maximal element in a row. More... | |
size_t | ArgmaxInColumn (size_t c) const |
Returns the row index of the maximal element in a column. More... | |
size_t | CountNullCellsInRow (size_t r) const |
Counts null cells in row. More... | |
size_t | CountNullCellsInColumn (size_t c) const |
Counts null cells in column. More... | |
size_t | CountNullCells () const |
Matrix | MakeColumnMeans () const |
Matrix | MakeColumnDeviations (const Matrix &means) const |
Matrix | MakeColumnDeviations (bool zero_means=false) const |
standard deviation of patterns stored as the rows of a data matrix More... | |
Matrix | MakeCovariance () const |
T * | operator[] (size_t r) |
Returns a row. More... | |
const T * | operator[] (size_t r) const |
Returns a row. More... | |
const std::vector< T > & | Std () const &noexcept |
std::vector< T > | Std ()&& |
template<typename IMG > | |
IMG | ToImage () const |
Converts to image. More... | |
String | ToString () const |
Prints matrix into a string. More... | |
![]() | |
virtual | ~Object ()=default |
Protected Types | |
using | datatype = std::vector< T > |
Protected Member Functions | |
bool | areValidIndexes (size_t r, size_t c) const |
checks the validity of indexes More... | |
Protected Attributes | |
datatype | data |
size_t | rows |
size_t | cols |
Base matrix class.
Definition at line 43 of file CRNMatrix.h.
|
protected |
Internal data representation
Definition at line 692 of file CRNMatrix.h.
|
inline |
Constructor.
ExceptionDomain | width or height is null |
[in] | nrow | number or rows |
[in] | ncol | number of columns |
[in] | value | default value for elements |
Definition at line 52 of file CRNMatrix.h.
|
inline |
Constructor from std::vector matrix.
ExceptionDimension | empty matrix |
ExceptionInvalidArgument | the argument is not a matrix |
[in] | m | a matrix |
Definition at line 64 of file CRNMatrix.h.
|
inline |
Constructor from std::vector 1D vector.
ExceptionDimension | empty matrix |
ExceptionInvalidArgument | invalid orientation |
[in] | vect | a vector |
[in] | ori | VERTICAL to create a column vector, HORIZONTAL to create a line vector |
Definition at line 88 of file CRNMatrix.h.
|
inline |
Constructor from std::vector 1D vector.
ExceptionDimension | empty matrix |
ExceptionInvalidArgument | invalid orientation |
[in] | vect | a vector |
[in] | ori | VERTICAL to create a column vector, HORIZONTAL to create a line vector |
Definition at line 114 of file CRNMatrix.h.
|
overridevirtualdefault |
Destructor.
|
default |
Definition at line 137 of file CRNMatrix.h.
|
default |
|
inlineprotected |
checks the validity of indexes
Definition at line 690 of file CRNMatrix.h.
|
inline |
Definition at line 451 of file CRNMatrix.h.
|
inline |
Returns the row index of the maximal element in a column.
ExceptionDomain | row out of bounds |
Definition at line 538 of file CRNMatrix.h.
|
inline |
Returns the row index of the maximal element in a row.
ExceptionDomain | row out of bounds |
Definition at line 527 of file CRNMatrix.h.
|
inline |
Definition at line 444 of file CRNMatrix.h.
|
inlinenoexcept |
Definition at line 165 of file CRNMatrix.h.
|
inlinenoexcept |
Definition at line 166 of file CRNMatrix.h.
|
inlinenoexcept |
Definition at line 167 of file CRNMatrix.h.
|
inlinenoexcept |
Definition at line 168 of file CRNMatrix.h.
|
inline |
Centers all columns by subtracting the mean for each column.
Definition at line 342 of file CRNMatrix.h.
|
inline |
Definition at line 585 of file CRNMatrix.h.
|
inline |
Counts null cells in column.
ExceptionDomain | index out of bounds |
[in] | c | column index |
Definition at line 573 of file CRNMatrix.h.
|
inline |
Counts null cells in row.
ExceptionDomain | index out of bounds |
[in] | r | row index |
Definition at line 561 of file CRNMatrix.h.
|
inline |
Definition at line 422 of file CRNMatrix.h.
|
inlinenoexcept |
Returns the number of columns.
Definition at line 163 of file CRNMatrix.h.
|
inline |
Definition at line 438 of file CRNMatrix.h.
|
inline |
Definition at line 432 of file CRNMatrix.h.
|
inlinenoexcept |
|
inline |
Increase one column from matrix.
ExceptionDomain | column out of bounds |
[in] | c | column index |
[in] | v | term to add to column |
Definition at line 255 of file CRNMatrix.h.
|
inline |
Increases the value of an element.
ExceptionDomain | index out of range |
[in] | r | row index |
[in] | c | column index |
[in] | delta | to add |
Definition at line 230 of file CRNMatrix.h.
|
inline |
Increase one row from matrix.
ExceptionDomain | row out of bounds |
[in] | r | row index |
[in] | v | term to add to row |
Definition at line 242 of file CRNMatrix.h.
|
inline |
Extracts one column from matrix.
ExceptionDomain | index out of bounds |
[in] | k | column index |
Definition at line 513 of file CRNMatrix.h.
|
inline |
Definition at line 602 of file CRNMatrix.h.
|
inline |
standard deviation of patterns stored as the rows of a data matrix
[in] | zero_means | indicate if mean values are considered as null or to be computed |
Definition at line 615 of file CRNMatrix.h.
|
inline |
Definition at line 591 of file CRNMatrix.h.
|
inline |
Definition at line 624 of file CRNMatrix.h.
|
inline |
Extract a row from current matrix.
ExceptionDomain | index out of bounds |
[in] | r | row index |
Definition at line 501 of file CRNMatrix.h.
|
inline |
Creates a column matrix from a row.
ExceptionDomain | row out of bounds |
[in] | r | row index |
Definition at line 489 of file CRNMatrix.h.
|
inline |
|
inline |
Scale one column from matrix.
ExceptionDomain | column out of bounds |
[in] | c | column index |
[in] | v | ratio to scale cells of column |
Definition at line 333 of file CRNMatrix.h.
|
inline |
Scale one row from matrix.
ExceptionDomain | row out of bounds |
[in] | r | row index |
[in] | v | ratio to scale cells of row |
Definition at line 320 of file CRNMatrix.h.
|
inline |
Change sign for all elements.
Definition at line 182 of file CRNMatrix.h.
|
inline |
Normalizes the matrix to be used for convolution.
Definition at line 409 of file CRNMatrix.h.
|
inline |
Definition at line 298 of file CRNMatrix.h.
|
inline |
Definition at line 279 of file CRNMatrix.h.
|
inline |
Scaling.
Scale all the cells of the matrix by a given factor
[in] | d | scaling factor |
Definition at line 306 of file CRNMatrix.h.
|
inline |
Definition at line 263 of file CRNMatrix.h.
|
inline |
Definition at line 271 of file CRNMatrix.h.
|
inline |
Scaling.
Scale all the cells of the matrix by a given factor
[in] | factor | scaling factor |
Definition at line 313 of file CRNMatrix.h.
|
default |
|
default |
|
inline |
Definition at line 292 of file CRNMatrix.h.
|
inline |
Returns a row.
[in] | r | The row number. |
Definition at line 648 of file CRNMatrix.h.
|
inline |
Returns a row.
[in] | r | The row number. |
Definition at line 655 of file CRNMatrix.h.
|
inline |
Reduces all columns by dividing by the standard deviation of each column.
[in] | centered | are the data centered? |
Definition at line 358 of file CRNMatrix.h.
|
inline |
Set all elements.
[in] | v | value to set all cells |
Definition at line 173 of file CRNMatrix.h.
|
inline |
Sets the values of a column.
ExceptionDomain | index out of range |
ExceptionDimension | argument has incorrect size |
[in] | c | column index |
[in] | col | the column to copy |
Definition at line 213 of file CRNMatrix.h.
|
inline |
Sets the values of a row.
ExceptionDomain | index out of range |
ExceptionDimension | argument has incorrect size |
[in] | r | row index |
[in] | row | the row to copy |
Definition at line 196 of file CRNMatrix.h.
|
inlinenoexcept |
Definition at line 658 of file CRNMatrix.h.
|
inline |
Definition at line 660 of file CRNMatrix.h.
|
inline |
Definition at line 146 of file CRNMatrix.h.
|
inline |
Swap two columns in matrix.
ExceptionDomain | index out of bounds |
[in] | c1 | one column index |
[in] | c2 | another column index |
Definition at line 399 of file CRNMatrix.h.
|
inline |
Swap two rows in matrix.
ExceptionDomain | index out of bounds |
[in] | r1 | one row index |
[in] | r2 | another row index |
Definition at line 385 of file CRNMatrix.h.
Converts to image.
Definition at line 663 of file CRNMatrix.h.
|
inline |
Prints matrix into a string.
Definition at line 673 of file CRNMatrix.h.
|
inlinevirtual |
Inplace transposition.
Reimplemented in crn::SquareMatrixDouble.
Definition at line 472 of file CRNMatrix.h.
|
protected |
dimensions of the matrix
Definition at line 694 of file CRNMatrix.h.
|
protected |
rows, cols
Definition at line 693 of file CRNMatrix.h.
|
protected |
Definition at line 694 of file CRNMatrix.h.