Public Member Functions | Public Attributes

util::rectangle Struct Reference

a rectangular region (inside a matrix). More...

#include <util/rect_list.hpp>


Detailed Description

a rectangular region (inside a matrix).

Partition definition rectangle. The total partition weight includes elements on boundaries. i.e. $\sum_{x\_top\_l<=x<=x\_bot\_r,y\_top\_l<=y<=y\_bot\_r} array[x][y]$. NOTE: the first element of the matrix is numbered (1,1) not (0,0)

List of all members.

Public Member Functions

 rectangle ()
 rectangle (int xl, int xh, int yl, int yh)
bool empty () const
template<typename Pr >
bool valid_bound (const Pr &prefixSum) const
 Check if the boundaries of a given rectangle is inside the matrix.
template<typename T , typename Pr >
T get_load (const Pr &prefixSum) const
 computes the load of the rectangle in a prefix sum array.
int get_area () const
 computes the area of the rectangle.

Public Attributes

int x_top_l
 coordinate x - rectangle top left
int y_top_l
 coordinate y - rectangle top left
int x_bot_r
 coordinate x - rectangle bottom right
int y_bot_r
 coordinate y - rectangle bottom right

Constructor & Destructor Documentation

util::rectangle::rectangle (  ) 
util::rectangle::rectangle ( int  xl,
int  xh,
int  yl,
int  yh 
)

Member Function Documentation

bool util::rectangle::empty (  )  const
Returns:
whether the rectangle is empty or not.
int util::rectangle::get_area (  )  const

computes the area of the rectangle.

Returns:
the number of cells in the rectangle.
template<typename T , typename Pr >
T util::rectangle::get_load ( const Pr prefixSum  )  const

computes the load of the rectangle in a prefix sum array.

Parameters:
prefixSum is the 2D prefix sum array to use in this rectangle's weight calculation
Returns:
The total weight of this rectangle $\sum_{x\_top\_l<=x<=x\_bot\_r,y\_top\_l<=y<=y\_bot\_r} array[x][y]$. Notice that array refers to the real array not its prefix sum array representation.
template<typename Pr >
bool util::rectangle::valid_bound ( const Pr prefixSum  )  const

Check if the boundaries of a given rectangle is inside the matrix.

Parameters:
prefixSum the psa
Returns:
whether the partition is in legal bounds or not.

Member Data Documentation

coordinate x - rectangle bottom right

coordinate x - rectangle top left

coordinate y - rectangle bottom right

coordinate y - rectangle top left


The documentation for this struct was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Friends Defines