yat
0.14.5pre
|
General view into utility::Matrix. More...
#include <yat/classifier/MatrixLookup.h>
Public Types | |
typedef utility::Matrix::value_type | value_type |
typedef utility::Matrix::const_reference | const_reference |
typedef utility::Container2DIterator < const MatrixLookup, const double, const_reference > | const_iterator |
'Read Only' iterator | |
typedef boost::permutation_iterator < utility::Matrix::const_column_iterator, utility::Index::const_iterator > | const_column_iterator |
typedef const_column_iterator | const_row_iterator |
Public Member Functions | |
MatrixLookup (const utility::Matrix &matrix, const bool own=false) | |
MatrixLookup (const utility::Matrix &matrix, const utility::Index &row, const utility::Index &column) | |
MatrixLookup (const utility::Matrix &matrix, const utility::Index &index, const bool row_vectors) | |
MatrixLookup (const MatrixLookup &other) | |
Copy constructor. More... | |
MatrixLookup (const MatrixLookup &ml, const utility::Index &row, const utility::Index &column) | |
Create a sub-MatrixLookup. More... | |
MatrixLookup (const MatrixLookup &ml, const utility::Index &, const bool row_vectors) | |
MatrixLookup (const size_t rows, const size_t columns, const double value=0) | |
MatrixLookup (std::istream &, char sep='\0') | |
The istream constructor. More... | |
virtual | ~MatrixLookup () |
Destructor. More... | |
const_iterator | begin (void) const |
const_column_iterator | begin_column (size_t) const |
const_row_iterator | begin_row (size_t) const |
size_t | columns (void) const |
const_iterator | end (void) const |
const_column_iterator | end_column (size_t) const |
const_row_iterator | end_row (size_t) const |
size_t | rows (void) const |
bool | weighted (void) const |
const_reference | operator() (size_t row, size_t column) const |
const MatrixLookup & | operator= (const MatrixLookup &) |
assigment operator More... | |
Friends | |
class | MatrixLookupWeighted |
Related Functions | |
(Note that these are not member functions.) | |
std::ostream & | operator<< (std::ostream &s, const MatrixLookup &) |
General view into utility::Matrix.
MatrixLookups can be used to create lookups/views into matrices in a more general way than the views supported in the matrix class. The object does not contain any data, but only a pointer to a utility::Matrix and row and columns incices defining which sub-matrix to look into. Each row and each column corresponds to a row and a column in the utility::Matrix, respectively. This design allow for fast creation of sub-matrices, which is a common operation in most traning/validation procedures. The views are const views in the sense that they cannot modify underlying utility::Matrix.
A MatrixLookup can be created directly from a utility::Matrix or from another MatrixLookup. In the latter case, the resulting MatrixLookup is looking directly into the underlying utility::Matrix to avoid multiple lookups.
There is a possibility to set the MatrixLookup as owner of the underlying utility::Matrix. This implies that underlying data is deleted in destructor of MatrixLookup, but only if there is no other owner of the underlying data.
typedef boost::permutation_iterator<utility::Matrix::const_column_iterator, utility::Index::const_iterator> theplu::yat::classifier::MatrixLookup::const_column_iterator |
'Read only' iterator used to iterate over a column
const_reference type is const double&
'Read only' iterator used to iterate over a row
value_type is double
theplu::yat::classifier::MatrixLookup::MatrixLookup | ( | const utility::Matrix & | matrix, |
const bool | own = false |
||
) |
Constructor creating a lookup into the entire matrix.
matrix | underlying matrix |
own | if true MatrixLookup owns its underlying matrix |
theplu::yat::classifier::MatrixLookup::MatrixLookup | ( | const utility::Matrix & | matrix, |
const utility::Index & | row, | ||
const utility::Index & | column | ||
) |
Constructor creating a lookup into a sub-matrix of matrix. The row and column define what sub-matrix to look into, in other words, the created MatrixLookup will fullfill the following: . This also means that number of rows in created MatrixLookup is equal to size of vector row, and number of columns is equal to size of vector column.
theplu::yat::classifier::MatrixLookup::MatrixLookup | ( | const utility::Matrix & | matrix, |
const utility::Index & | index, | ||
const bool | row_vectors | ||
) |
Constructor creating a lookup into a sub-matrix of matrix.
If row_vectors is true the new MatrixLookup will consist of the row vectors defined by index. This means that the created MatrixLookup will fullfill:
If row_vectors is false the new MatrixLookup will be consist of the rolumn vectors defined by index. This means that the created MatrixLookup will fullfill:
theplu::yat::classifier::MatrixLookup::MatrixLookup | ( | const MatrixLookup & | other | ) |
Copy constructor.
If other is owner of underlying data, constructed MatrixLookup will also be set as owner of underlying data.
theplu::yat::classifier::MatrixLookup::MatrixLookup | ( | const MatrixLookup & | ml, |
const utility::Index & | row, | ||
const utility::Index & | column | ||
) |
Create a sub-MatrixLookup.
The Lookup is independent of MatrixLookup ml. The MatrixLookup is created to look directly into the underlying matrix to avoid multiple lookups.
If ml is owner of underlying data, constructed MatrixLookup will also be set as owner of underlying data.
The row and column define what sub-matrix to look into, in other words, the created MatrixLookup will fullfill the following: MatrixLookup(i,j)=ml(row[i],column[j]). This also means that number of rows in created MatrixLookup is equal to size of vector row, and number of columns is equal to size of vector column.
If ml is owner of underlying data, constructed MatrixLookup will also be set as owner of underlying data.
theplu::yat::classifier::MatrixLookup::MatrixLookup | ( | const MatrixLookup & | ml, |
const utility::Index & | , | ||
const bool | row_vectors | ||
) |
Constructor creating a lookup into a sub-matrix of ml. The MatrixLookup is created to look directly into the underlying matrix to avoid multiple lookups.
If row_vectors is true the new MatrixLookup will consist of the row vectors defined by index. This means that the created MatrixLookup will fullfill: MatrixLookup(i,j)=ml(i,index[j])
If row_vectors is false the new MatrixLookup will consist of the rolumn vectors defined by index. This means that the created MatrixLookup will fullfill:
If ml is owner of underlying data, constructed MatrixLookup will also be set as owner of underlying data.
theplu::yat::classifier::MatrixLookup::MatrixLookup | ( | const size_t | rows, |
const size_t | columns, | ||
const double | value = 0 |
||
) |
Constructor creating a MatrixLookup with rows rows, columns columns, and all values are set to value. Created MatrixLookup owns its underlying matrix.
theplu::yat::classifier::MatrixLookup::MatrixLookup | ( | std::istream & | , |
char | sep = '\0' |
||
) |
The istream constructor.
In construction the underlying utility::Matrix is created from the stream using utility::Matrix(std::istream&). The constructed MatrixLookup will be owner of the underlying matrix.
|
virtual |
Destructor.
If ownership is set true and there is no other owner of underlying data, underlying data is deleted.
const_iterator theplu::yat::classifier::MatrixLookup::begin | ( | void | ) | const |
Iterator iterates along a row. When end of row is reached it jumps to beginning of next row.
const_column_iterator theplu::yat::classifier::MatrixLookup::begin_column | ( | size_t | ) | const |
Iterator iterates along a column.
const_row_iterator theplu::yat::classifier::MatrixLookup::begin_row | ( | size_t | ) | const |
Iterator iterates along a column.
size_t theplu::yat::classifier::MatrixLookup::columns | ( | void | ) | const |
const_iterator theplu::yat::classifier::MatrixLookup::end | ( | void | ) | const |
const_column_iterator theplu::yat::classifier::MatrixLookup::end_column | ( | size_t | ) | const |
const_row_iterator theplu::yat::classifier::MatrixLookup::end_row | ( | size_t | ) | const |
const_reference theplu::yat::classifier::MatrixLookup::operator() | ( | size_t | row, |
size_t | column | ||
) | const |
Access operator
const MatrixLookup& theplu::yat::classifier::MatrixLookup::operator= | ( | const MatrixLookup & | ) |
assigment operator
Does only change MatrixLookup not the underlying matrix object. However if the MatrixLookup is owner (and the only owner) of its underlying matrix, that matrix will be deleted here.
size_t theplu::yat::classifier::MatrixLookup::rows | ( | void | ) | const |
bool theplu::yat::classifier::MatrixLookup::weighted | ( | void | ) | const |
|
related |
The output operator MatrixLookup