ModErn Text Analysis
META Enumerates Textual Applications
Public Types | Public Member Functions | Private Attributes | List of all members
meta::util::dense_matrix< T > Class Template Reference

Simple wrapper class for representing a dense matrix laid out in row-major order (that is, its internal representation is a linear array of the rows). More...

#include <dense_matrix.h>

Public Types

using row_iterator = typename std::vector< T >::iterator
 
using const_row_iterator = typename std::vector< T >::const_iterator
 

Public Member Functions

 dense_matrix ()=default
 Default constructed matrices are empty.
 
 dense_matrix (const dense_matrix &)=default
 dense_matrix may be copy constructed.
 
 dense_matrix (dense_matrix &&)=default
 dense_matrix may be move constructed.
 
dense_matrixoperator= (const dense_matrix &)=default
 dense_matrix may be copy assigned.
 
dense_matrixoperator= (dense_matrix &&)=default
 dense_matrix may be move assigned.
 
 dense_matrix (uint64_t rows, uint64_t columns)
 Constructs a dense_matrix with the specified number of rows and columns. More...
 
void resize (uint64_t rows, uint64_t columns)
 Resizes the dense_matrix to have the specified number of rows and columns. More...
 
T & operator() (uint64_t row, uint64_t column)
 Obtains the column-th element of the row-th row. More...
 
const T & operator() (uint64_t row, uint64_t column) const
 Obtains the column-th element of the row-th row. More...
 
row_iterator begin (uint64_t row)
 
const_row_iterator begin (uint64_t row) const
 
row_iterator end (uint64_t row)
 
const_row_iterator end (uint64_t row) const
 
uint64_t rows () const
 
uint64_t columns () const
 

Private Attributes

std::vector< T > storage_
 the underlying storage for the matrix
 
uint64_t columns_
 the number of columns in the matrix
 

Detailed Description

template<class T>
class meta::util::dense_matrix< T >

Simple wrapper class for representing a dense matrix laid out in row-major order (that is, its internal representation is a linear array of the rows).

Constructor & Destructor Documentation

template<class T >
meta::util::dense_matrix< T >::dense_matrix ( uint64_t  rows,
uint64_t  columns 
)

Constructs a dense_matrix with the specified number of rows and columns.

Construction of the matrix value-initializes all elements (just as std::vector does), which ensures that elements are set to 0 when T is a numeric type.

Parameters
rowsThe desired number of rows
columnsThe desired number of columns

Member Function Documentation

template<class T >
void meta::util::dense_matrix< T >::resize ( uint64_t  rows,
uint64_t  columns 
)

Resizes the dense_matrix to have the specified number of rows and columns.

All elements are reset to be value initialized, not just new ones!

Parameters
rowsThe desired new number of rows
columnsThe desired number of columns
template<class T >
T & meta::util::dense_matrix< T >::operator() ( uint64_t  row,
uint64_t  column 
)

Obtains the column-th element of the row-th row.

Parameters
rowThe row index
columnThe column index
Returns
a reference to the element at that position
template<class T >
const T & meta::util::dense_matrix< T >::operator() ( uint64_t  row,
uint64_t  column 
) const

Obtains the column-th element of the row-th row.

Parameters
rowThe row index
columnThe column index
Returns
a const reference to the element at that position
template<class T >
auto meta::util::dense_matrix< T >::begin ( uint64_t  row)
Parameters
rowThe row index
Returns
an iterator over the row-th row
template<class T >
auto meta::util::dense_matrix< T >::begin ( uint64_t  row) const
Parameters
rowThe row index
Returns
a const iterator over the row-th row
template<class T >
auto meta::util::dense_matrix< T >::end ( uint64_t  row)
Parameters
rowThe row index
Returns
an iterator to the end of the row-th row
template<class T >
auto meta::util::dense_matrix< T >::end ( uint64_t  row) const
Parameters
rowThe row index
Returns
an iterator to the end of the row-th row
template<class T >
uint64_t meta::util::dense_matrix< T >::rows ( ) const
Returns
the number of rows in the matrix
template<class T >
uint64_t meta::util::dense_matrix< T >::columns ( ) const
Returns
the number of columns in the matrix

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