Types

Dimensions

class Dimensions : public std::vector<size_t>

Represents the dimensions of a Region.

A Dimensions object is an n-dimensional grid, consists of many cells, and each dimension has a size, i.e. how many cells can there be along this dimension.

A node within a Region is represented by a cell of a n-dimensional grid, identified by a Coordinate.

It’s implemented by a vector of size_t plus a few methods for convenience and for wrapping.

Constructors

Dimensions()

Create a new Dimensions object.

Note
Default dimensions are unspecified, see isUnspecified()

Dimensions(std::vector<size_t> v)

Create a new Dimensions object from a std::vector<size_t>.

Parameters
  • v: A std::vector of size_t, the value with the index of n is the size of the n th dimension

Dimensions(size_t x)

Create a new 1-dimension Dimensions object.

Parameters
  • x: The size of the 1st dimension

Dimensions(size_t x, size_t y)

Create a new 2-dimension Dimensions.

Parameters
  • x: The size of the 1st dimension
  • y: The size of the 2nd dimension

Dimensions(size_t x, size_t y, size_t z)

Create a new 3-dimension Dimensions.

Parameters
  • x: The size of the 1st dimension
  • y: The size of the 2nd dimension
  • z: The size of the 3rd dimension

Properties

size_t getCount() const

Get the count of cells in the grid, which is the product of the sizes of the dimensions.

Return
The count of cells in the grid.

size_t getDimensionCount() const

Get the number of dimensions.

Return
number of dimensions

size_t getDimension(size_t index) const

Get the size of a dimension.

Return
The size of the dimension with the index of index
Note
Do not confuse index with “linear index” as in getIndex()
Parameters
  • index: The index of the dimension

Boolean properties

There are two “special” values for dimensions:

bool isUnspecified() const

Tells whether the Dimensions object is “unspecified”.

Return
Whether the Dimensions object is “unspecified”
See
isSpecified()

bool isDontcare() const

Tells whether the Dimensions object is “don’t care”.

Return
Whether the Dimensions object is “don’t care”

bool isSpecified() const

Tells whether the Dimensions object is “specified”.

A “specified” Dimensions object satisfies all following conditions:

  • “valid”
  • NOT “unspecified”
  • NOT “don’t care”

Return
Whether the Dimensions object is “specified”
Note
It’s not the opposite of isUnspecified()!

bool isOnes() const

Tells whether the sizes of all dimensions are 1.

Return
Whether the sizes of all dimensions are 1, e.g. [1], [1 1], [1 1 1], etc.

bool isValid() const

Tells whether Dimensions is “valid”.

A Dimensions object is valid if it specifies actual dimensions, i.e. all dimensions have a size greater than 0, or is a special value (“unspecified”/”don’t care”).

A Dimensions

object is invalid if any dimensions are 0 (except for “don’t

care”)

Return
Whether Dimensions is “valid”

Coordinate<->index mapping

Coordinate<->index mapping is in lower-major order, i.e.

for Region with dimensions [2,3]:

[0,0] -> index 0
[1,0] -> index 1
[0,1] -> index 2
[1,1] -> index 3
[0,2] -> index 4
[1,2] -> index 5

size_t getIndex(const Coordinate &coordinate) const

Convert a Coordinate to a linear index (in lower-major order).

Return
The linear index corresponding to coordinate
Parameters
  • coordinate: The coordinate to be converted

Coordinate getCoordinate(const size_t index) const

Convert a linear index (in lower-major order) to a Coordinate.

Return
The Coordinate corresponding to index
Parameters
  • index: The linear index to be converted

Misc

std::string toString(bool humanReadable = true) const

Convert the Dimensions object to string representation.

In most cases, we want a human-readable string, but for serialization we want only the actual dimension values

Return
The string representation of the Dimensions object
Parameters
  • humanReadable: The default is true, make the string human-readable, set to false for serialization

void promote(size_t newDimensionality)

Promote the Dimensions object to a new dimensionality.

Note
The sizes of all dimensions must be 1( i.e. isOnes() returns true), or an exception will be thrown.
Parameters
  • newDimensionality: The new dimensionality to promote to, it can be greater than, smaller than or equal to current dimensionality

bool operator==(const Dimensions &dims2) const

The equivalence operator.

Two Dimensions objects will be considered equivalent, if any of the following satisfies:

  • They have the same number of dimensions and the same size for every dimension.
  • Both of them have the size of 1 for everything dimensions, despite of how many dimensions they have, i.e. isOnes() returns true for both of them. Some linking scenarios require us to treat [1] equivalent to [1 1] etc.

Return
Whether this Dimensions object is equivalent to dims2.
Parameters

bool operator!=(const Dimensions &dims2) const

The in-equivalence operator, the opposite of operator==().

Return
Whether this Dimensions object is not equivalent to dims2.
Parameters

Types

BasicType

class BasicType

Fraction

class Fraction

Serializable

template <class ProtoT>
class Serializable

Base Serializable class that any serializable class should inherit from.