simple 2D matrix class, provides access via operator (int,int) More...
#include <matrix.hh>
Public Types | |
typedef T | elem_t |
type of elements | |
typedef std::vector< elem_t > ::size_type | size_type |
size type (from underlying vector) | |
typedef std::pair< size_type, size_type > | size_pair_type |
type for pair of sizes | |
Public Member Functions | |
Matrix () | |
Matrix (size_type xdim, size_type ydim, const elem_t *from=0L) | |
size_pair_type | sizes () const |
void | resize (size_type xdim, size_type ydim) |
const elem_t & | operator() (size_type i, size_type j) const |
elem_t & | operator() (size_type i, size_type j) |
const elem_t | get (size_type i, size_type j) const |
void | set (size_type i, size_type j, const elem_t &x) |
void | fill (const elem_t &val) |
Fill the whole matrix with the given value. | |
void | clear () |
template<class UnaryOperator > | |
void | transform (UnaryOperator f) |
Protected Member Functions | |
size_type | addr (size_type i, size_type j) const |
Protected Attributes | |
std::vector< elem_t > | mat_ |
vector storing the matrix entries | |
size_type | xdim_ |
first dimension | |
size_type | ydim_ |
second dimension |
simple 2D matrix class, provides access via operator (int,int)
LocARNA::Matrix< T >::Matrix | ( | ) | [inline] |
Empty constructor
LocARNA::Matrix< T >::Matrix | ( | size_type | xdim, |
size_type | ydim, | ||
const elem_t * | from = 0L |
||
) | [inline] |
Construct with dimensions, optionally initialize from array
xdim | first dimension of matrix |
ydim | second dimension of matrix |
from | pointer to array of elements |
size_type LocARNA::Matrix< T >::addr | ( | size_type | i, |
size_type | j | ||
) | const [inline, protected] |
Computes address/index in 1D vector from 2D matrix indices
i | first index |
j | second index |
void LocARNA::Matrix< T >::clear | ( | ) | [inline] |
Clear the matrix
void LocARNA::Matrix< T >::fill | ( | const elem_t & | val | ) | [inline] |
Fill the whole matrix with the given value.
val | value assigned to each entry |
Reimplemented in LocARNA::RMatrix< elem_t >.
const elem_t LocARNA::Matrix< T >::get | ( | size_type | i, |
size_type | j | ||
) | const [inline] |
Read access to matrix element
i | |
j |
const elem_t& LocARNA::Matrix< T >::operator() | ( | size_type | i, |
size_type | j | ||
) | const [inline] |
Read access to matrix element
i | |
j |
elem_t& LocARNA::Matrix< T >::operator() | ( | size_type | i, |
size_type | j | ||
) | [inline] |
Read/write access to matrix element
i | |
j |
void LocARNA::Matrix< T >::resize | ( | size_type | xdim, |
size_type | ydim | ||
) | [inline] |
Resize both dimensions
xdim | first dimension |
ydim | second dimension |
void LocARNA::Matrix< T >::set | ( | size_type | i, |
size_type | j, | ||
const elem_t & | x | ||
) | [inline] |
Write access to matrix element
i | |
j | |
x | element value |
size_pair_type LocARNA::Matrix< T >::sizes | ( | ) | const [inline] |
Access size
void LocARNA::Matrix< T >::transform | ( | UnaryOperator | f | ) | [inline] |
Transform matrix in place due to applying a given function to each element
f | function object |