LocARNA-1.8.11
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
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 >:
Inheritance graph
[legend]
Collaboration diagram for LocARNA::RMatrix< elem_t >:
Collaboration graph
[legend]

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. More...
 
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. More...
 
- Public Member Functions inherited from LocARNA::Matrix< elem_t >
 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. More...
 
void clear ()
 
void transform (UnaryOperator f)
 

Protected Member Functions

size_type addr (size_type i, size_type j) const
 
- Protected Member Functions inherited from LocARNA::Matrix< elem_t >
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
 
- Protected Attributes inherited from LocARNA::Matrix< elem_t >
std::vector< elem_tmat_
 vector storing the matrix entries
 
size_type xdim_
 first dimension
 
size_type ydim_
 second dimension
 

Additional Inherited Members

- Public Types inherited from LocARNA::Matrix< elem_t >
typedef elem_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_typesize_pair_type
 type for pair of sizes
 

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
inlineprotected

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
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: