yat  0.16pre
Public Types | Public Member Functions | Friends | Related Functions | List of all members
theplu::yat::classifier::MatrixLookup Class Reference

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_referenceconst_iterator
 'Read Only' iterator
 
typedef boost::permutation_iterator< utility::Matrix::const_column_iterator, utility::Index::const_iteratorconst_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 MatrixLookupoperator= (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 &)
 

Detailed Description

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.

See also
MatrixLookupWeighted

Member Typedef Documentation

'Read only' iterator used to iterate over a column

const_reference type is const double&

Since
New in yat 0.5

'Read only' iterator used to iterate over a row

value_type is double

Since
New in yat 0.5

Constructor & Destructor Documentation

theplu::yat::classifier::MatrixLookup::MatrixLookup ( const utility::Matrix matrix,
const bool  own = false 
)

Constructor creating a lookup into the entire matrix.

Parameters
matrixunderlying matrix
ownif true MatrixLookup owns its underlying matrix
Note
If own is true and matrix is already owned by some other object, this will lead to matrix having multiple owners without the owners being aware of each other. Consequently multiple deletion will occur.
If matrix goes out of scope or is deleted, the MatrixLookup becomes invalid and the result of further use is undefined.
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: $ MatrixLookup(i,j)=matrix(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.

Note
If matrix goes out of scope or is deleted, the MatrixLookup becomes invalid and the result of further use is undefined.
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: $ MatrixLookup(i,j)=matrix(i,index[j]) $

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: $ MatrixLookup(i,j)=matrix(index[i],j) $

Note
If matrix goes out of scope or is deleted, the MatrixLookup becomes invalid and the result of further use is undefined.
Deprecated:
Provided for backward compatibility with the 0.6 API. Use MatrixLookup(const utility::Matrix&, const utility::Index&, const utility::Index&)
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.

Note
If underlying matrix goes out of scope or is deleted, the MatrixLookup becomes invalid and the result of further use is undefined.
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.

Note
If underlying matrix goes out of scope or is deleted, the MatrixLookup becomes invalid and the result of further use is undefined.
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: $ MatrixLookup(i,j) = ml(index[i],j) $

If ml is owner of underlying data, constructed MatrixLookup will also be set as owner of underlying data.

Note
If underlying matrix goes out of scope or is deleted, the MatrixLookup becomes invalid and the result of further use is undefined.
Deprecated:
Provided for backgroundColor compatibility with the 0.6 API. Use MatrixLookup(const MatrixLookup&, const utility::Index&, const utility::Index&)
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.

See also
Matrix(istream&) for details.
virtual theplu::yat::classifier::MatrixLookup::~MatrixLookup ( )
virtual

Destructor.

If ownership is set true and there is no other owner of underlying data, underlying data is deleted.

Member Function Documentation

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.

Returns
const_iterator pointing to upper-left element.
const_column_iterator theplu::yat::classifier::MatrixLookup::begin_column ( size_t  ) const

Iterator iterates along a column.

Returns
iterator pointing to first element of column i.
const_row_iterator theplu::yat::classifier::MatrixLookup::begin_row ( size_t  ) const

Iterator iterates along a column.

Returns
const_iterator pointing to first element of column i.
size_t theplu::yat::classifier::MatrixLookup::columns ( void  ) const
Returns
number of columns
const_iterator theplu::yat::classifier::MatrixLookup::end ( void  ) const
Returns
const_iterator pointing to end of matrix
const_column_iterator theplu::yat::classifier::MatrixLookup::end_column ( size_t  ) const
Returns
const_iterator pointing to end of column i
const_row_iterator theplu::yat::classifier::MatrixLookup::end_row ( size_t  ) const
Returns
const_iterator pointing to end of row i
const_reference theplu::yat::classifier::MatrixLookup::operator() ( size_t  row,
size_t  column 
) const

Access operator

Returns
element
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
Returns
number of rows
bool theplu::yat::classifier::MatrixLookup::weighted ( void  ) const
Returns
false

Friends And Related Function Documentation

std::ostream & operator<< ( std::ostream &  s,
const MatrixLookup  
)
related

The output operator MatrixLookup


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

Generated on Wed Aug 15 2018 02:22:39 for yat by  doxygen 1.8.11