LocARNA-1.9.2
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
LocARNA::Matrix< T > Class Template Reference

simple 2D matrix class, provides access via operator (int,int) More...

#include <matrix.hh>

List of all members.

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_toperator() (size_type i, size_type j) const
elem_toperator() (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_tmat_
 vector storing the matrix entries
size_type xdim_
 first dimension
size_type ydim_
 second dimension

Detailed Description

template<class T>
class LocARNA::Matrix< T >

simple 2D matrix class, provides access via operator (int,int)


Constructor & Destructor Documentation

template<class T>
LocARNA::Matrix< T >::Matrix ( ) [inline]

Empty constructor

template<class T>
LocARNA::Matrix< T >::Matrix ( size_type  xdim,
size_type  ydim,
const elem_t from = 0L 
) [inline]

Construct with dimensions, optionally initialize from array

Parameters:
xdimfirst dimension of matrix
ydimsecond dimension of matrix
frompointer to array of elements
Note:
if from given and !=0 initialize from array from

Member Function Documentation

template<class T>
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

Parameters:
ifirst index
jsecond index
Returns:
index in vector
Note:
this method is used for all internal access to the vector mat_
template<class T>
void LocARNA::Matrix< T >::clear ( ) [inline]

Clear the matrix

Postcondition:
the matrix is resized to dimensions (0,0)
Note:
behaves like std::vector::clear()
template<class T>
void LocARNA::Matrix< T >::fill ( const elem_t val) [inline]

Fill the whole matrix with the given value.

Parameters:
valvalue assigned to each entry
Postcondition:
all matrix entries are set to val

Reimplemented in LocARNA::RMatrix< elem_t >.

template<class T>
const elem_t LocARNA::Matrix< T >::get ( size_type  i,
size_type  j 
) const [inline]

Read access to matrix element

Parameters:
i
j
Returns:
entry (i,j)
template<class T>
const elem_t& LocARNA::Matrix< T >::operator() ( size_type  i,
size_type  j 
) const [inline]

Read access to matrix element

Parameters:
i
j
Returns:
entry (i,j)
template<class T>
elem_t& LocARNA::Matrix< T >::operator() ( size_type  i,
size_type  j 
) [inline]

Read/write access to matrix element

Parameters:
i
j
Returns:
reference to entry (i,j)
template<class T>
void LocARNA::Matrix< T >::resize ( size_type  xdim,
size_type  ydim 
) [inline]

Resize both dimensions

Parameters:
xdimfirst dimension
ydimsecond dimension
template<class T>
void LocARNA::Matrix< T >::set ( size_type  i,
size_type  j,
const elem_t x 
) [inline]

Write access to matrix element

Parameters:
i
j
xelement value
template<class T>
size_pair_type LocARNA::Matrix< T >::sizes ( ) const [inline]

Access size

Returns:
size of matrix as pair of dimensions
template<class T>
template<class UnaryOperator >
void LocARNA::Matrix< T >::transform ( UnaryOperator  f) [inline]

Transform matrix in place due to applying a given function to each element

Parameters:
ffunction object
Postcondition:
All matrix entries are changed from x to f(x)
Note:
applies f via in place std::transform to all matrix entries

The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends