1 #ifndef LOCARNA_MATRICES_HH 2 #define LOCARNA_MATRICES_HH 34 template <
class elem_t>
55 size_type
addr(size_type i, size_type j)
const {
56 assert(xl_<=i && i<=xr_);
57 assert(yl_<=j && j<=yr_);
59 return i*xfactor_ + j -
offset_;
83 resize(size_type xdim, size_type ydim) {
86 this->
mat_.resize(xdim*ydim);
99 void restrict(size_type xl,size_type xr,size_type yl,size_type yr) {
102 assert(xr<this->
xdim_);
103 assert(yr<this->
ydim_);
112 this->xfactor_ = (yr-yl)+1;
114 this->offset_ =
addr(xl,yl);
152 const elem_t get(size_type i,size_type j)
const {
165 set(size_type i,size_type j,
const elem_t &x) {
177 for (size_type i=xl_; i<
xr_; ++i)
178 for (size_type j=yl_; j<
yr_; ++j)
186 template <
class elem_t>
204 size_t addr(
size_t i,
size_t j)
const {
205 assert(xoff_<=i && i<xoff_+this->
xdim_);
206 assert(yoff_<=j && j<yoff_+this->
ydim_);
207 return i*this->ydim_ + j - off_;
232 resize(
size_t xdim,
size_t ydim,
size_t xoff=0,
size_t yoff=0) {
238 this->
mat_.resize(xdim*ydim);
278 const elem_t get(
size_t i,
size_t j)
const {
291 set(
size_t i,
size_t j,
const elem_t &x) {
301 template <
class elem_t>
317 size_t rot(
size_t x,
size_t r,
size_t d) {
333 size_t addr(
size_t i,
size_t j)
const {
334 assert(xrot_<=i && i<xrot_+this->
xdim_);
335 assert(yrot_<=j && j<yrot_+this->
ydim_);
336 return rot(i,xrot_,this->xdim_)*this->xdim_ + rot(j,yrot_,this->ydim_);
361 resize(
size_t xdim,
size_t ydim,
size_t xrot=0,
size_t yrot=0) {
366 this->
mat_.resize(xdim*ydim);
376 void move(
size_t xrot,
size_t yrot) {
416 const elem_t get(
size_t i,
size_t j)
const {
430 set(
size_t i,
size_t j,
const elem_t &x) {
438 #endif // LOCARNA_MATRICES_HH void fill(const elem_t &val)
Fill the whole matrix with the given value.
Definition: matrices.hh:176
std::vector< elem_t > mat_
vector storing the matrix entries
Definition: matrix.hh:39
size_t addr(size_t i, size_t j) const
Definition: matrices.hh:333
size_type xr_
right end of restriction in first dimension
Definition: matrices.hh:39
size_type offset_
offset for index calculation
Definition: matrices.hh:44
size_type xdim_
first dimension
Definition: matrix.hh:40
Simple matrix class with restriction to a range.
Definition: matrices.hh:35
size_t xrot_
rotation in dimension 1
Definition: matrices.hh:305
size_type yl_
left end of restriction in second dimension
Definition: matrices.hh:40
size_t off_
combined offset for vector access
Definition: matrices.hh:189
size_t yrot_
rotation in dimension 2
Definition: matrices.hh:306
void resize(size_t xdim, size_t ydim, size_t xoff=0, size_t yoff=0)
Definition: matrices.hh:232
size_type addr(size_type i, size_type j) const
Definition: matrices.hh:55
Definition: aligner.cc:17
void move(size_t xrot, size_t yrot)
Definition: matrices.hh:376
A matrix class with rotation.
Definition: matrices.hh:302
size_type ydim_
second dimension
Definition: matrix.hh:41
void restrict(size_type xl, size_type xr, size_type yl, size_type yr)
Set new restricted range.
Definition: matrices.hh:99
elem_t elem_t
type of elements
Definition: matrix.hh:33
size_type yr_
right end of restriction in second dimension
Definition: matrices.hh:41
size_t addr(size_t i, size_t j) const
Computes address/index in 1D vector from 2D matrix indices.
Definition: matrices.hh:204
Simple matrix class with offset.
Definition: matrices.hh:187
size_type xfactor_
factor for index calculation
Definition: matrices.hh:43
size_t xoff_
offset in first dimension
Definition: matrices.hh:190
size_t yoff_
offset in second dimension
Definition: matrices.hh:191
RMatrix()
Definition: matrices.hh:68
simple 2D matrix class, provides access via operator (int,int)
Definition: aligner_impl.hh:19
void resize(size_type xdim, size_type ydim)
Definition: matrices.hh:83
size_t rot(size_t x, size_t r, size_t d)
Definition: matrices.hh:317
size_type xl_
left end of restriction in first dimension
Definition: matrices.hh:38
const elem_t & operator()(size_type i, size_type j) const
Definition: matrices.hh:126
RotMatrix()
Definition: matrices.hh:346
void resize(size_t xdim, size_t ydim, size_t xrot=0, size_t yrot=0)
Definition: matrices.hh:361
OMatrix()
Definition: matrices.hh:217