Proto  3.2
Public Member Functions | Public Attributes | List of all members
Proto::Point Class Reference

Integer Valued Vector. More...

#include <Proto_Point.H>

Public Member Functions

template<typename... vars>
ACCEL_DECORATION void unpack (int D, int i, vars... args)
 
template<>
ACCEL_DECORATION void unpack (int D, int i)
 
Constructors
ACCEL_DECORATION Point ()
 
ACCEL_DECORATION Point (const int(&a_tuple)[DIM])
 C-Array Constructor. More...
 
template<typename... vals>
ACCEL_DECORATION Point (vals... args)
 Variadic Constructor. More...
 
ACCEL_DECORATION Point (const Point &a_pt)
 Copy Constructor. More...
 
Accessors
ACCEL_DECORATION const int & operator[] (unsigned int a_index) const
 Get Component (Const) More...
 
ACCEL_DECORATION int & operator[] (unsigned int a_index)
 Get Component (Non-Const) More...
 
Operators
ACCEL_DECORATION Pointoperator= (const Point &a_rhs)
 Asignment Operator. More...
 
ACCEL_DECORATION bool operator< (const Point &a_rhs) const
 Less-Than Operator. More...
 
ACCEL_DECORATION bool operator== (const Point &a_pt) const
 Equality Operator. More...
 
ACCEL_DECORATION bool operator!= (const Point &a_pt) const
 Inequality Operator. More...
 
ACCEL_DECORATION Point operator+ (const Point &a_rhs) const
 Componentwise Point Addition Operator. More...
 
ACCEL_DECORATION Point operator- (const Point &a_rhs) const
 Componentwise Point Subtraction Operator. More...
 
ACCEL_DECORATION Point operator* (const Point &a_pt) const
 Componentwise Point Multiplication Operator. More...
 
ACCEL_DECORATION Point operator/ (const Point &a_pt) const
 Componentwise Point Division Operator. More...
 
ACCEL_DECORATION Point operator% (const Point &a_pt) const
 Componentwise Point Modulus Operator. More...
 
Point operator+ (int a_value) const
 Scalar Addition Operator. More...
 
Point operator- (int a_value) const
 Scalar Subtraction Operator. More...
 
Point operator* (int a_value) const
 Scalar Multiplication Operator. More...
 
Point operator/ (int a_value) const
 Scalar Division Operator. More...
 
Point operator% (int a_value) const
 Scalar Modulus Operator. More...
 
ACCEL_DECORATION void operator+= (const Point &a_pt)
 In Place Componentwise Addition Operator. More...
 
ACCEL_DECORATION void operator-= (const Point &a_pt)
 In Place Componentwise Subtraction Operator. More...
 
ACCEL_DECORATION void operator*= (const Point &a_pt)
 In Place Componentwise Multiplication Operator. More...
 
ACCEL_DECORATION void operator/= (const Point &a_pt)
 In Place Componentwise Division Operator. More...
 
ACCEL_DECORATION void operator%= (const Point &a_pt)
 In Place Componentwise Modulus Operator. More...
 
void operator+= (int a_n)
 In Place Scalar Addition Operator. More...
 
void operator-= (int a_n)
 In Place Scalar Subtraction Operator. More...
 
void operator*= (int a_n)
 In Place Scalar Multiplication Operator. More...
 
void operator/= (int a_n)
 In Place Scalar Division Operator. More...
 
void operator%= (int a_n)
 In Place Scalar Modulus Operator. More...
 
int dot (const Point &a_rhs) const
 Compute Dot Product. More...
 
Point coarsen (unsigned int a_refRatio) const
 Coarsen Operator. More...
 
ACCEL_DECORATION int sum () const
 Sum Operator. More...
 
int sumAbs () const
 Absolute Value Sum Operator. More...
 
int min () const
 
int max () const
 
Point abs () const
 
bool isotropic () const
 Isotropic Query. More...
 
int codim () const
 Query Codimension. More...
 
std::array< Point, DIM > parallelUnit () const
 Parallel Unit Vectors. More...
 
std::array< Point, DIM > perpUnit () const
 Perpendicular Unit Vectors. More...
 
int firstNonZeroIndex () const
 
int lastNonZeroIndex () const
 
std::vector< int > coords () const
 Coordinates of non-zero entries. More...
 
std::vector< int > perpCoords () const
 Coordinates of zero entries. More...
 
std::vector< Pointsplit () const
 Scaled Unit Vectors. More...
 
std::vector< Pointsubset () const
 
Point dir () const
 Convert Point to Direction. More...
 
size_t linearSize () const
 Linear Size. More...
 
void linearOut (char *a_buf) const
 Linear Out. More...
 
void linearIn (const char *a_buf)
 Linear In. More...
 
Utility
void print () const
 Print Function. More...
 
std::string str () const
 

Static Public Member Functions

Static Methods
static ACCEL_DECORATION Point Ones (int a_scale=1)
 Get Ones. More...
 
static ACCEL_DECORATION Point Unit ()
 Get Unit Point. More...
 
static ACCEL_DECORATION Point Zeros ()
 Get Zeros. More...
 
static ACCEL_DECORATION Point Zeroes ()
 Get Zeros (Pedantic Spelling) More...
 
static ACCEL_DECORATION Point Zero ()
 Get Zeros (Alternate Spelling) More...
 
static ACCEL_DECORATION Point Basis (int a_dir, int a_scale=1)
 Get Basis. More...
 
static ACCEL_DECORATION Point Basis (int a_dir, const Side::LoHiSide a_side)
 Get Basis (Side Argument) More...
 
static ACCEL_DECORATION Point X ()
 
static ACCEL_DECORATION Point Y ()
 
static ACCEL_DECORATION Point Z ()
 
static std::set< PointDirections ()
 
static std::set< PointDirectionsOfCodim (int a_codim)
 

Public Attributes

int m_tuple [DIM]
 Integer coordinates of the Point. More...
 

Detailed Description

Integer Valued Vector.

An element \(\mathbf{p}\in\mathbb{Z}^{DIM}\)

Constructor & Destructor Documentation

◆ Point() [1/4]

ACCEL_DECORATION Proto::Point::Point ( )
inline

Default Constructor Creates the zero Point (0,0,...,0)

Referenced by Point().

◆ Point() [2/4]

ACCEL_DECORATION Proto::Point::Point ( const int(&)  a_tuple[DIM])
inline

C-Array Constructor.

Allows "literal" construction of points using a C-Array

Example:

using namespace Proto;
//DIM=2
Point p = Point({-5,13}); //creates the point (-5,13)
//NB: This will not compile when DIM != 2
Parameters
a_tupleinteger array representing a Point

◆ Point() [3/4]

template<typename... vals>
ACCEL_DECORATION Proto::Point::Point ( vals...  args)
inlineexplicit

Variadic Constructor.

Builds a Point from the first DIM arguments given to this. Any trailing arguments are ignored. This constructor is very useful for building dimensionally independent test code.

Example:

Point p(1,2,3,4,5,6);
if (DIM == 1)
{
std::cout << p << std::endl; //prints (1)
} else if (DIM == 2) {
std::cout << p << std::endl; //prints (1, 2)
} else if (DIM == 3) {
std::cout << p << std::endl; //prints (1, 2, 3)
} //etc.
Parameters
argsAt least DIM integer arguments representing a Point

References ACCEL_DECORATION, Ones(), Point(), and unpack().

◆ Point() [4/4]

ACCEL_DECORATION Proto::Point::Point ( const Point a_pt)
inline

Copy Constructor.

Creates a new point by copying an existing one.

Parameters
a_ptA Point.

Member Function Documentation

◆ Ones()

static ACCEL_DECORATION Point Proto::Point::Ones ( int  a_scale = 1)
inlinestatic

Get Ones.

Returns the unit Point scale*(1,1,...,1)

Parameters
a_scale(Optional) value to scale the vector by (default: 1)

Referenced by Proto::Shift::Ones(), Point(), and Unit().

◆ Unit()

static ACCEL_DECORATION Point Proto::Point::Unit ( )
inlinestatic

Get Unit Point.

Returns the Point (1,1,...,1)

References ACCEL_DECORATION, Ones(), and Zeros().

◆ Zeros()

static ACCEL_DECORATION Point Proto::Point::Zeros ( )
inlinestatic

◆ Zeroes()

static ACCEL_DECORATION Point Proto::Point::Zeroes ( )
inlinestatic

Get Zeros (Pedantic Spelling)

Identical to Zeros() but with alternative spelling.

References Zeros().

◆ Zero()

static ACCEL_DECORATION Point Proto::Point::Zero ( )
inlinestatic

Get Zeros (Alternate Spelling)

Identical to Zeros() but with alternative spelling.

References ACCEL_DECORATION, Basis(), and Zeros().

◆ Basis() [1/2]

static ACCEL_DECORATION Point Proto::Point::Basis ( int  a_dir,
int  a_scale = 1 
)
inlinestatic

Get Basis.

Returns an axis-aligned Point \(\bf{p}: \bf{p}[k] = scale*\delta_{dir}^k\).

Parameters
a_dirA coordinate axis.
a_scale(Optional) value to scale the unit vector by (default: 1)

Referenced by Proto::Shift::Basis(), Proto::Register< T, C, MEM >::dir(), Proto::Box::faceBox(), X(), Y(), Z(), and Zero().

◆ Basis() [2/2]

static ACCEL_DECORATION Point Proto::Point::Basis ( int  a_dir,
const Side::LoHiSide  a_side 
)
inlinestatic

Get Basis (Side Argument)

Returns an axis-aligned Point \(\bf{p}: \bf{p}[k] = s*\delta_{dir}^k\). Where \( s = 1 \) if a_side = Side::Hi and where \( s = -1 \) if a_side = Side::Lo .

Parameters
a_dirA spatial axis (0 for x, 1 for y, etc.)
a_sideLow or high side. Low amounts to scaling by -1.

◆ X()

static ACCEL_DECORATION Point Proto::Point::X ( )
inlinestatic

References Basis().

Referenced by Proto::Shift::X().

◆ Y()

static ACCEL_DECORATION Point Proto::Point::Y ( )
inlinestatic

References Basis().

Referenced by Proto::Shift::Y().

◆ Z()

static ACCEL_DECORATION Point Proto::Point::Z ( )
inlinestatic

◆ Directions()

static std::set<Point> Proto::Point::Directions ( )
inlinestatic

Referenced by Z().

◆ DirectionsOfCodim()

static std::set<Point> Proto::Point::DirectionsOfCodim ( int  a_codim)
inlinestatic

◆ operator[]() [1/2]

ACCEL_DECORATION const int& Proto::Point::operator[] ( unsigned int  a_index) const
inline

Get Component (Const)

Returns a const reference to the a_index component of *this

Parameters
a_indexIndex in [0,DIM)

Referenced by Z().

◆ operator[]() [2/2]

ACCEL_DECORATION int& Proto::Point::operator[] ( unsigned int  a_index)
inline

Get Component (Non-Const)

Returns a mutable reference to the a_index component of *this

Parameters
a_indexIndex in [0,DIM)

◆ operator=()

ACCEL_DECORATION Point& Proto::Point::operator= ( const Point a_rhs)
inline

Asignment Operator.

Performs copy assignment.

Parameters
a_rhsAnother Point

Referenced by Z().

◆ operator<()

ACCEL_DECORATION bool Proto::Point::operator< ( const Point a_rhs) const
inline

Less-Than Operator.

Used to define an ordering for placing Points in maps etc. Uses Lexical comparison. Note that Chombo lexLT is also lexical but uses the dimensions in the opposite way.

Parameters
a_rhsAnother Point

Referenced by Z().

◆ operator==()

ACCEL_DECORATION bool Proto::Point::operator== ( const Point a_pt) const
inline

Equality Operator.

Equality is checked componentwise.

Parameters
a_ptAnother Point

Referenced by Z().

◆ operator!=()

ACCEL_DECORATION bool Proto::Point::operator!= ( const Point a_pt) const
inline

Inequality Operator.

Equality is checked componentwise.

Parameters
a_ptAnother Point

Referenced by Z().

◆ operator+() [1/2]

ACCEL_DECORATION Point Proto::Point::operator+ ( const Point a_rhs) const
inline

Componentwise Point Addition Operator.

Creates the new Point by adding *this and a_rhs componentwise.

Parameters
a_rhsAnother Point

Referenced by Z().

◆ operator-() [1/2]

ACCEL_DECORATION Point Proto::Point::operator- ( const Point a_rhs) const
inline

Componentwise Point Subtraction Operator.

Creates the new Point by subtracting *this and a_rhs componentwise.

Parameters
a_rhsAnother Point

Referenced by Z().

◆ operator*() [1/2]

ACCEL_DECORATION Point Proto::Point::operator* ( const Point a_pt) const
inline

Componentwise Point Multiplication Operator.

Creates the new Point by multiplying *this and a_rhs componentwise.

Parameters
a_ptAnother Point

Referenced by Z().

◆ operator/() [1/2]

ACCEL_DECORATION Point Proto::Point::operator/ ( const Point a_pt) const
inline

Componentwise Point Division Operator.

Creates the new Point by dividing *this by a_rhs componentwise. Quotients are rounded down. Division of any component by 0 yields an error.

Parameters
a_ptAnother Point

Referenced by Z().

◆ operator%() [1/2]

ACCEL_DECORATION Point Proto::Point::operator% ( const Point a_pt) const
inline

Componentwise Point Modulus Operator.

Creates the new Point by taking the modulus of *this by a_rhs componentwise. Quotients are rounded down. Modulo by 0 yields an error.

Parameters
a_ptAnother Point

Referenced by Z().

◆ operator+() [2/2]

Point Proto::Point::operator+ ( int  a_value) const
inline

Scalar Addition Operator.

Creates a new Point by adding nref to each component of *this.

Parameters
a_valueAn Integer scalar

◆ operator-() [2/2]

Point Proto::Point::operator- ( int  a_value) const
inline

Scalar Subtraction Operator.

Creates a new Point by subtracting nref to each component of *this.

Parameters
a_valueAn Integer scalar

◆ operator*() [2/2]

Point Proto::Point::operator* ( int  a_value) const
inline

Scalar Multiplication Operator.

Creates a new Point by multiplying each component of *this by a_value.

Parameters
a_valueAn Integer scalar

◆ operator/() [2/2]

Point Proto::Point::operator/ ( int  a_value) const
inline

Scalar Division Operator.

Creates a new Point by dividing each component of *this by a_value. Quotients are rounded down. Division of any component by 0 yields an error.

Parameters
a_valueAn Integer scalar

◆ operator%() [2/2]

Point Proto::Point::operator% ( int  a_value) const
inline

Scalar Modulus Operator.

Creates a new Point by taking the modulus of each component of *this by a_value. Quotients are rounded down. Modulo of any component by 0 yields an error.

Parameters
a_valueAn Integer scalar

◆ operator+=() [1/2]

ACCEL_DECORATION void Proto::Point::operator+= ( const Point a_pt)
inline

In Place Componentwise Addition Operator.

Adds another Point componentwise to *this.

Parameters
a_ptAnother Point

Referenced by Z().

◆ operator-=() [1/2]

ACCEL_DECORATION void Proto::Point::operator-= ( const Point a_pt)
inline

In Place Componentwise Subtraction Operator.

Subtracts another Point componentwise from *this.

Parameters
a_ptAnother Point

Referenced by Z().

◆ operator*=() [1/2]

ACCEL_DECORATION void Proto::Point::operator*= ( const Point a_pt)
inline

In Place Componentwise Multiplication Operator.

Multiplies *this by another Point componentwise.

Parameters
a_ptAnother Point

Referenced by Z().

◆ operator/=() [1/2]

ACCEL_DECORATION void Proto::Point::operator/= ( const Point a_pt)
inline

In Place Componentwise Division Operator.

Divides *this by another Point componentwise. Quotients are rounded down. Division of any component by 0 yields an error.

Parameters
a_ptAnother Point

Referenced by Z().

◆ operator%=() [1/2]

ACCEL_DECORATION void Proto::Point::operator%= ( const Point a_pt)
inline

In Place Componentwise Modulus Operator.

Computes the modulus of *this by another Point componentwise. Quotients are rounded down. Module of any component by 0 yields an error.

Parameters
a_ptAnother Point

Referenced by Z().

◆ operator+=() [2/2]

void Proto::Point::operator+= ( int  a_n)
inline

In Place Scalar Addition Operator.

Adds an integer to every component of *this.

Parameters
a_nAn integer.

◆ operator-=() [2/2]

void Proto::Point::operator-= ( int  a_n)
inline

In Place Scalar Subtraction Operator.

Subtracts an integer from every component of *this.

Parameters
a_nAn integer.

◆ operator*=() [2/2]

void Proto::Point::operator*= ( int  a_n)
inline

In Place Scalar Multiplication Operator.

Multiplies every component of *this by an integer.

Parameters
a_nAn integer.

◆ operator/=() [2/2]

void Proto::Point::operator/= ( int  a_n)
inline

In Place Scalar Division Operator.

Divides every component of *this by an integer. Quotients are rounded down. Division by 0 yields an error.

Parameters
a_nAn integer.

◆ operator%=() [2/2]

void Proto::Point::operator%= ( int  a_n)
inline

In Place Scalar Modulus Operator.

Computes the modulus of every component of *this by an integer. Modulo of 0 results in an error.

Parameters
a_nAn integer.

◆ dot()

int Proto::Point::dot ( const Point a_rhs) const
inline

Compute Dot Product.

Referenced by Z().

◆ coarsen()

Point Proto::Point::coarsen ( unsigned int  a_refRatio) const
inline

Coarsen Operator.

Returns a new Point coarsened by a_refRatio. This function is identical to any of the division operators.

Parameters
a_refRatioA non-zero refinement ratio.

Referenced by Z().

◆ sum()

ACCEL_DECORATION int Proto::Point::sum ( ) const
inline

Sum Operator.

Computes the sum of the entries in *this

Referenced by Z().

◆ sumAbs()

int Proto::Point::sumAbs ( ) const
inline

Absolute Value Sum Operator.

Computes the sum of the absolute values of the entries in *this

Referenced by Z().

◆ min()

int Proto::Point::min ( ) const
inline

Referenced by Z().

◆ max()

int Proto::Point::max ( ) const
inline

Referenced by Z().

◆ abs()

Point Proto::Point::abs ( ) const
inline

Referenced by Proto::absMaxPoint(), and Z().

◆ isotropic()

bool Proto::Point::isotropic ( ) const
inline

Isotropic Query.

Checks if all elements of *this are equal.

Referenced by Z().

◆ codim()

int Proto::Point::codim ( ) const
inline

Query Codimension.

Returns the codimensionality of *this (e.g. the number of num-zero entries)

Referenced by Proto::MBBoundaryData< T, C, MEM >::adjFace(), Proto::MBBoundaryData< T, C, MEM >::localFace(), Proto::Register< T, C, MEM >::Register(), and Z().

◆ parallelUnit()

std::array<Point, DIM> Proto::Point::parallelUnit ( ) const
inline

Parallel Unit Vectors.

Returns an array of Point representing the basis vectors of the smallest vector space containing *this. If the ith element of *this is non-zero, the ith element of the output will be Basis(i). Otherwise, the ith element of the output will be Zeros().

Referenced by Z().

◆ perpUnit()

std::array<Point, DIM> Proto::Point::perpUnit ( ) const
inline

Perpendicular Unit Vectors.

Returns an array of Point representing the basis vectors of the largest vector space not containing *this. If the ith element of *this is zero, the ith element of the output will be Basis(i). Otherwise, the ith element of the output will be Zeros().

Referenced by Z().

◆ firstNonZeroIndex()

int Proto::Point::firstNonZeroIndex ( ) const
inline

Referenced by Z().

◆ lastNonZeroIndex()

int Proto::Point::lastNonZeroIndex ( ) const
inline

Referenced by Z().

◆ coords()

std::vector<int> Proto::Point::coords ( ) const
inline

Coordinates of non-zero entries.

Referenced by Z().

◆ perpCoords()

std::vector<int> Proto::Point::perpCoords ( ) const
inline

Coordinates of zero entries.

Referenced by Z().

◆ split()

std::vector<Point> Proto::Point::split ( ) const
inline

Scaled Unit Vectors.

Referenced by Z().

◆ subset()

std::vector<Point> Proto::Point::subset ( ) const
inline

Returns a vector of Points each of which are this dotted into a subset of unit vectors The zero vector is omitted

Referenced by Z().

◆ dir()

Point Proto::Point::dir ( ) const
inline

Convert Point to Direction.

A "direction" is defined as a Point with values limited to 1, 0, and -1.

Referenced by Z().

◆ linearSize()

size_t Proto::Point::linearSize ( ) const
inline

Linear Size.

Returns the size of *this in bytes

Referenced by Z().

◆ linearOut()

void Proto::Point::linearOut ( char *  a_buf) const
inline

Linear Out.

Writes from *this into a linear buffer of size this->linearSize().

Parameters
a_bufA buffer

Referenced by Z().

◆ linearIn()

void Proto::Point::linearIn ( const char *  a_buf)
inline

Linear In.

Reads to *this from a linear buffer of size this->linearSize().

Parameters
a_bufA buffer

Referenced by Z().

◆ print()

void Proto::Point::print ( ) const
inline

Print Function.

Output is formatted: (p1,p2,...)

Referenced by Z().

◆ str()

std::string Proto::Point::str ( ) const
inline

Referenced by Z().

◆ unpack() [1/2]

template<typename... vars>
ACCEL_DECORATION void Proto::Point::unpack ( int  D,
int  i,
vars...  args 
)
inline

Referenced by Point().

◆ unpack() [2/2]

template<>
ACCEL_DECORATION void Proto::Point::unpack ( int  D,
int  i 
)
inline

Member Data Documentation

◆ m_tuple

int Proto::Point::m_tuple[DIM]

Integer coordinates of the Point.

Referenced by unpack().


The documentation for this class was generated from the following file: