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

Simple matrix class with restriction to a range. More...

#include <matrices.hh>

Inheritance diagram for LocARNA::RMatrix< elem_t >:
LocARNA::Matrix< elem_t >

List of all members.

Public Member Functions

 RMatrix ()
void resize (size_type xdim, size_type ydim)
void restrict (size_type xl, size_type xr, size_type yl, size_type yr)
 Set new restricted range.
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.

Protected Member Functions

size_type addr (size_type i, size_type j) const

Protected Attributes

size_type xl_
 left end of restriction in first dimension
size_type xr_
 right end of restriction in first dimension
size_type yl_
 left end of restriction in second dimension
size_type yr_
 right end of restriction in second dimension
size_type xfactor_
 factor for index calculation
size_type offset_
 offset for index calculation

Detailed Description

template<class elem_t>
class LocARNA::RMatrix< elem_t >

Simple matrix class with restriction to a range.

The matrix features a fix maximal range [0..n]x[0..m]. It can be restricted to [xl..xr]x[yl..yr]. After such a restriction, the matrix is invalidated and can only be used with indices (i,j): xl<=i<=xr and yl<=j<=yr

Note:
I planned to use this for the M matrices in LocARNA to optimize locality. However, I didn't see a performance improvement (maybe for very large instances?)

Constructor & Destructor Documentation

template<class elem_t >
LocARNA::RMatrix< elem_t >::RMatrix ( ) [inline]

Construct as 0x0-matrix


Member Function Documentation

template<class elem_t >
size_type LocARNA::RMatrix< elem_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 elem_t >
void LocARNA::RMatrix< elem_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 from LocARNA::Matrix< elem_t >.

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

Read access to matrix element

Parameters:
i
j
Returns:
entry (i,j)
Note:
: redefine since we don't want to use polymorphism
template<class elem_t >
const elem_t& LocARNA::RMatrix< elem_t >::operator() ( size_type  i,
size_type  j 
) const [inline]

Read access to matrix element

Parameters:
i
j
Returns:
entry (i,j)
Note:
: redefine since we don't want to use polymorphism
template<class elem_t >
elem_t& LocARNA::RMatrix< elem_t >::operator() ( size_type  i,
size_type  j 
) [inline]

Read/write access to matrix element

Parameters:
i
j
Returns:
reference to entry (i,j)
Note:
: redefine since we don't want to use polymorphism
template<class elem_t >
void LocARNA::RMatrix< elem_t >::resize ( size_type  xdim,
size_type  ydim 
) [inline]

Resize matrix

Reserves memory in sufficient size and removes any existing restrictions

Parameters:
xdim
ydim
template<class elem_t >
void LocARNA::RMatrix< elem_t >::restrict ( size_type  xl,
size_type  xr,
size_type  yl,
size_type  yr 
) [inline]

Set new restricted range.

Parameters:
xl
xr
yl
yr
template<class elem_t >
void LocARNA::RMatrix< elem_t >::set ( size_type  i,
size_type  j,
const elem_t x 
) [inline]

Write access to matrix element

Parameters:
i
j
xelement value
Note:
: redefine since we don't want to use polymorphism

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