![]() |
NuPIC Core
Core algorithms for NuPIC(the Numenta Platform for Intelligent Computing), implemented in C++
|
Represents the dimensions of a Region. More...
#include <Dimensions.hpp>
Constructors | |
Dimensions () | |
Create a new Dimensions object. More... | |
Dimensions (std::vector< size_t > v) | |
Create a new Dimensions object from a std::vector<size_t> . More... | |
Dimensions (size_t x) | |
Create a new 1-dimension Dimensions object. More... | |
Dimensions (size_t x, size_t y) | |
Create a new 2-dimension Dimensions. More... | |
Dimensions (size_t x, size_t y, size_t z) | |
Create a new 3-dimension Dimensions. More... | |
Properties | |
size_t | getCount () const |
Get the count of cells in the grid, which is the product of the sizes of the dimensions. More... | |
size_t | getDimensionCount () const |
Get the number of dimensions. More... | |
size_t | getDimension (size_t index) const |
Get the size of a dimension. More... | |
Boolean properties | |
There are two "special" values for dimensions:
| |
bool | isUnspecified () const |
Tells whether the Dimensions object is "unspecified". More... | |
bool | isDontcare () const |
Tells whether the Dimensions object is "don't care". More... | |
bool | isSpecified () const |
Tells whether the Dimensions object is "specified". More... | |
bool | isOnes () const |
Tells whether the sizes of all dimensions are 1. More... | |
bool | isValid () const |
Tells whether Dimensions is "valid". More... | |
Coordinate<->index mapping | |
Coordinate<->index mapping is in lower-major order, i.e. for Region with dimensions [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). More... | |
Coordinate | getCoordinate (const size_t index) const |
Convert a linear index (in lower-major order) to a Coordinate. More... | |
Misc | |
std::string | toString (bool humanReadable=true) const |
Convert the Dimensions object to string representation. More... | |
void | promote (size_t newDimensionality) |
Promote the Dimensions object to a new dimensionality. More... | |
bool | operator== (const Dimensions &dims2) const |
The equivalence operator. More... | |
bool | operator!= (const Dimensions &dims2) const |
The in-equivalence operator, the opposite of operator==(). More... | |
Additional Inherited Members | |
![]() | |
T | elements |
STL member. | |
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.
Definition at line 73 of file Dimensions.hpp.
nupic::Dimensions::Dimensions | ( | ) |
Create a new Dimensions object.
nupic::Dimensions::Dimensions | ( | std::vector< size_t > | v | ) |
Create a new Dimensions object from a std::vector<size_t>
.
v | A std::vector of size_t , the value with the index of n is the size of the n th dimension |
nupic::Dimensions::Dimensions | ( | size_t | x | ) |
Create a new 1-dimension Dimensions object.
x | The size of the 1st dimension |
nupic::Dimensions::Dimensions | ( | size_t | x, |
size_t | y | ||
) |
Create a new 2-dimension Dimensions.
x | The size of the 1st dimension |
y | The size of the 2nd dimension |
nupic::Dimensions::Dimensions | ( | size_t | x, |
size_t | y, | ||
size_t | z | ||
) |
Create a new 3-dimension Dimensions.
x | The size of the 1st dimension |
y | The size of the 2nd dimension |
z | The size of the 3rd dimension |
Coordinate nupic::Dimensions::getCoordinate | ( | const size_t | index | ) | const |
Convert a linear index (in lower-major order) to a Coordinate.
index | The linear index to be converted |
size_t nupic::Dimensions::getCount | ( | ) | const |
Get the count of cells in the grid, which is the product of the sizes of the dimensions.
size_t nupic::Dimensions::getDimension | ( | size_t | index | ) | const |
Get the size of a dimension.
index | The index of the dimension |
size_t nupic::Dimensions::getDimensionCount | ( | ) | const |
Get the number of dimensions.
size_t nupic::Dimensions::getIndex | ( | const Coordinate & | coordinate | ) | const |
Convert a Coordinate to a linear index (in lower-major order).
coordinate | The coordinate to be converted |
bool nupic::Dimensions::isDontcare | ( | ) | const |
Tells whether the Dimensions object is "don't care".
bool nupic::Dimensions::isOnes | ( | ) | const |
Tells whether the sizes of all dimensions are 1.
bool nupic::Dimensions::isSpecified | ( | ) | const |
Tells whether the Dimensions object is "specified".
A "specified" Dimensions object satisfies all following conditions:
bool nupic::Dimensions::isUnspecified | ( | ) | const |
Tells whether the Dimensions object is "unspecified".
bool nupic::Dimensions::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")
bool nupic::Dimensions::operator!= | ( | const Dimensions & | dims2 | ) | const |
The in-equivalence operator, the opposite of operator==().
dims2 | The Dimensions object being compared |
bool nupic::Dimensions::operator== | ( | const Dimensions & | dims2 | ) | const |
The equivalence operator.
Two Dimensions objects will be considered equivalent, if any of the following satisfies:
true
for both of them. Some linking scenarios require us to treat [1] equivalent to [1 1] etc.dims2 | The Dimensions object being compared |
void nupic::Dimensions::promote | ( | size_t | newDimensionality | ) |
Promote the Dimensions object to a new dimensionality.
newDimensionality | The new dimensionality to promote to, it can be greater than, smaller than or equal to current dimensionality |
std::string nupic::Dimensions::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
humanReadable | The default is true , make the string human-readable, set to false for serialization |