Mantid
Loading...
Searching...
No Matches
Classes | Typedefs | Functions
morton_index Namespace Reference

Classes

struct  IndexTypes
 This structure determines Morton index type and underlying unsigned integer type for the floating point coordinate type and number of dimensions. More...
 
struct  Interleaver
 
struct  Interleaver< ND, IntT, Morton96 >
 
struct  MortonIndex
 This structure binds the size of accesible memory to store the Morton index to the Morton index type. More...
 
struct  MortonIndex< 1 >
 
struct  MortonIndex< 12 >
 
struct  MortonIndex< 16 >
 
struct  MortonIndex< 2 >
 
struct  MortonIndex< 4 >
 
struct  MortonIndex< 8 >
 
struct  UnderlyingInt
 This structure binds floating point types to the unsigned integer types of the same width. More...
 
struct  UnderlyingInt< double >
 
struct  UnderlyingInt< float >
 

Typedefs

template<typename CoordT , size_t ND>
using AffineND = Eigen::Transform< CoordT, static_cast< int >(ND), Eigen::Affine >
 
template<size_t ND>
using BinIndices = Eigen::Matrix< size_t, 1, static_cast< int >(ND)>
 
template<size_t ND, typename IntT >
using IntArray = Eigen::Array< IntT, static_cast< int >(ND), 1 >
 
template<size_t ND>
using MDCoordinate = Eigen::Array< float, static_cast< int >(ND), 1 >
 
template<size_t ND>
using MDSpaceBounds = Eigen::Array< float, static_cast< int >(ND), 2 >
 
template<size_t ND>
using MDSpaceDimensions = Eigen::Array< float, static_cast< int >(ND), 1 >
 
template<size_t ND>
using MDSpaceSteps = Eigen::Array< float, static_cast< int >(ND), 1 >
 
using Morton96 = uint96_t
 This class implements the structure of size 96bit, that can be used as Morton index. More...
 
using uint128_t = std::uint128_t
 
using uint256_t = std::uint256_t
 
using uint96_t = std::wide_uint< 96 >
 

Functions

template<size_t ND, typename IntT , typename MortonT >
MortonT calculateDefaultBound (IntT intBound)
 
template<int ND>
size_t CalculateRequiredCoordinateIntegerWidth (const MDSpaceBounds< ND > &bounds, const MDSpaceSteps< ND > &steps)
 Calculates the required width of the interleaved integer to accurately represent coordinates in a given space at a given resolution. More...
 
template<int ND>
bool CheckCoordinatesInMDSpace (const MDSpaceBounds< ND > &bounds, const MDCoordinate< ND > &coord)
 Checks that a coordinate is within the extents of an MD space. More...
 
template<size_t N, typename IntT , typename MortonT >
IntT compact (MortonT)
 Compacts (removes padding from) an integer with a given number of padding bits. More...
 
template<>
uint16_t compact< 1, uint16_t, uint32_t > (uint32_t x)
 
template<>
uint16_t compact< 1, uint16_t, uint64_t > (uint64_t x)
 
template<>
uint32_t compact< 1, uint32_t, uint128_t > (uint128_t x)
 
template<>
uint16_t compact< 2, uint16_t, uint64_t > (uint64_t x)
 
template<>
uint32_t compact< 2, uint32_t, uint128_t > (uint128_t x)
 
template<>
uint64_t compact< 2, uint64_t, uint256_t > (uint256_t x)
 
template<>
uint8_t compact< 2, uint8_t, uint32_t > (uint32_t x)
 
template<>
uint16_t compact< 3, uint16_t, uint64_t > (uint64_t x)
 
template<>
uint32_t compact< 3, uint32_t, uint128_t > (uint128_t x)
 
template<>
uint64_t compact< 3, uint64_t, uint256_t > (uint256_t x)
 
template<typename IntT >
float ConvertCoordinateFromIntegerRange (IntT value, float lower, float upper)
 Converts a single integer coordinate to a floating point. More...
 
template<int ND, typename IntT >
MDCoordinate< ND > ConvertCoordinatesFromIntegerRange (const MDSpaceBounds< ND > &bounds, const Eigen::Array< IntT, ND, 1 > &intCoord)
 Converts a point expressed as integer coordinates back to floating point, given bounds of the original coordinate space. More...
 
template<int ND, typename IntT >
Eigen::Array< IntT, ND, 1 > ConvertCoordinatesToIntegerRange (const MDSpaceBounds< ND > &bounds, const float *crd)
 Converts a point to integer range given a range of floating point coordinates. More...
 
template<typename IntT >
IntT ConvertCoordinateToIntegerRange (float value, float lower, float upper)
 Converts a single floating point coordinate to an integer range. More...
 
template<size_t nd, typename IntT , typename MortonT , typename coord_t = float>
MortonT coordinatesToIndex (coord_t *coord, const MDSpaceBounds< nd > &space)
 
template<size_t ND, typename IntT >
IntArray< ND, IntT > deinterleave (const Morton96 &z)
 
template<size_t ND, typename IntT , typename MortonT >
IntArray< ND, IntT > deinterleave (const MortonT z)
 Deinterleaves a Morton number into an integer coordinate. More...
 
template<int ND>
void ExpandBounds (MDSpaceBounds< ND > &bounds)
 Expands a coordinate space enough that floating point error cannot cause an overflow when mapping a value at the upper limit of the range to an integer range. More...
 
template<size_t nd, typename IntT , typename MortonT >
MDCoordinate< nd > indexToCoordinates (const MortonT &idx, const MDSpaceBounds< nd > &space)
 
template<size_t ND, typename IntT >
Morton96 interleave (const IntArray< 3, uint32_t > &coord)
 
template<size_t ND, typename IntT , typename MortonT >
MortonT interleave (const IntArray< ND, IntT > &coord)
 Interleaves an integer coordinate. More...
 
template<typename MortonT >
bool morton_contains (const MortonT lower, const MortonT upper, const MortonT value)
 Checks if a point defined by a Morton number is within the box bounds (as defined by an upper and lower Morton number). More...
 
template<size_t N, typename IntT , typename MortonT >
MortonT pad (IntT)
 Pad an integer with a given number of padding bits. More...
 
template<>
uint32_t pad< 1, uint16_t, uint32_t > (uint16_t v)
 
template<>
uint64_t pad< 1, uint16_t, uint64_t > (uint16_t v)
 
template<>
uint128_t pad< 1, uint32_t, uint128_t > (uint32_t v)
 
template<>
uint64_t pad< 2, uint16_t, uint64_t > (uint16_t v)
 
template<>
uint128_t pad< 2, uint32_t, uint128_t > (uint32_t v)
 
template<>
uint256_t pad< 2, uint64_t, uint256_t > (uint64_t v)
 
template<>
uint32_t pad< 2, uint8_t, uint32_t > (uint8_t v)
 
template<>
uint64_t pad< 3, uint16_t, uint64_t > (uint16_t v)
 
template<>
uint128_t pad< 3, uint32_t, uint128_t > (uint32_t v)
 
template<>
uint256_t pad< 3, uint64_t, uint256_t > (uint64_t v)
 

Typedef Documentation

◆ AffineND

template<typename CoordT , size_t ND>
using morton_index::AffineND = typedef Eigen::Transform<CoordT, static_cast<int>(ND), Eigen::Affine>

Definition at line 35 of file Types.h.

◆ BinIndices

template<size_t ND>
using morton_index::BinIndices = typedef Eigen::Matrix<size_t, 1, static_cast<int>(ND)>

Definition at line 37 of file Types.h.

◆ IntArray

template<size_t ND, typename IntT >
using morton_index::IntArray = typedef Eigen::Array<IntT, static_cast<int>(ND), 1>

Definition at line 27 of file Types.h.

◆ MDCoordinate

template<size_t ND>
using morton_index::MDCoordinate = typedef Eigen::Array<float, static_cast<int>(ND), 1>

Definition at line 29 of file Types.h.

◆ MDSpaceBounds

template<size_t ND>
using morton_index::MDSpaceBounds = typedef Eigen::Array<float, static_cast<int>(ND), 2>

Definition at line 31 of file Types.h.

◆ MDSpaceDimensions

template<size_t ND>
using morton_index::MDSpaceDimensions = typedef Eigen::Array<float, static_cast<int>(ND), 1>

Definition at line 32 of file Types.h.

◆ MDSpaceSteps

template<size_t ND>
using morton_index::MDSpaceSteps = typedef Eigen::Array<float, static_cast<int>(ND), 1>

Definition at line 33 of file Types.h.

◆ Morton96

This class implements the structure of size 96bit, that can be used as Morton index.

Definition at line 43 of file Types.h.

◆ uint128_t

Definition at line 21 of file Types.h.

◆ uint256_t

Definition at line 22 of file Types.h.

◆ uint96_t

Definition at line 20 of file Types.h.

Function Documentation

◆ calculateDefaultBound()

template<size_t ND, typename IntT , typename MortonT >
MortonT morton_index::calculateDefaultBound ( IntT  intBound)

◆ CalculateRequiredCoordinateIntegerWidth()

template<int ND>
size_t morton_index::CalculateRequiredCoordinateIntegerWidth ( const MDSpaceBounds< ND > &  bounds,
const MDSpaceSteps< ND > &  steps 
)

Calculates the required width of the interleaved integer to accurately represent coordinates in a given space at a given resolution.

Definition at line 41 of file CoordinateConversion.h.

◆ CheckCoordinatesInMDSpace()

template<int ND>
bool morton_index::CheckCoordinatesInMDSpace ( const MDSpaceBounds< ND > &  bounds,
const MDCoordinate< ND > &  coord 
)

Checks that a coordinate is within the extents of an MD space.

Definition at line 72 of file CoordinateConversion.h.

◆ compact()

template<size_t N, typename IntT , typename MortonT >
IntT morton_index::compact ( MortonT  )

Compacts (removes padding from) an integer with a given number of padding bits.

Template Parameters
NNumber of padding bits to remove
IntTInteger type
MortonTPadded integer type
Returns
Original integer

Definition at line 37 of file BitInterleaving.h.

Referenced by deinterleave().

◆ compact< 1, uint16_t, uint32_t >()

template<>
uint16_t morton_index::compact< 1, uint16_t, uint32_t > ( uint32_t  x)
inline

Definition at line 55 of file BitInterleaving.h.

◆ compact< 1, uint16_t, uint64_t >()

template<>
uint16_t morton_index::compact< 1, uint16_t, uint64_t > ( uint64_t  x)
inline

Definition at line 74 of file BitInterleaving.h.

◆ compact< 1, uint32_t, uint128_t >()

template<>
uint32_t morton_index::compact< 1, uint32_t, uint128_t > ( uint128_t  x)
inline

Definition at line 153 of file BitInterleaving.h.

◆ compact< 2, uint16_t, uint64_t >()

template<>
uint16_t morton_index::compact< 2, uint16_t, uint64_t > ( uint64_t  x)
inline

Definition at line 110 of file BitInterleaving.h.

◆ compact< 2, uint32_t, uint128_t >()

template<>
uint32_t morton_index::compact< 2, uint32_t, uint128_t > ( uint128_t  x)
inline

Definition at line 176 of file BitInterleaving.h.

◆ compact< 2, uint64_t, uint256_t >()

template<>
uint64_t morton_index::compact< 2, uint64_t, uint256_t > ( uint256_t  x)
inline

Definition at line 227 of file BitInterleaving.h.

◆ compact< 2, uint8_t, uint32_t >()

template<>
uint8_t morton_index::compact< 2, uint8_t, uint32_t > ( uint32_t  x)
inline

Definition at line 92 of file BitInterleaving.h.

◆ compact< 3, uint16_t, uint64_t >()

template<>
uint16_t morton_index::compact< 3, uint16_t, uint64_t > ( uint64_t  x)
inline

Definition at line 131 of file BitInterleaving.h.

◆ compact< 3, uint32_t, uint128_t >()

template<>
uint32_t morton_index::compact< 3, uint32_t, uint128_t > ( uint128_t  x)
inline

Definition at line 201 of file BitInterleaving.h.

◆ compact< 3, uint64_t, uint256_t >()

template<>
uint64_t morton_index::compact< 3, uint64_t, uint256_t > ( uint256_t  x)
inline

Definition at line 254 of file BitInterleaving.h.

◆ ConvertCoordinateFromIntegerRange()

template<typename IntT >
float morton_index::ConvertCoordinateFromIntegerRange ( IntT  value,
float  lower,
float  upper 
)

Converts a single integer coordinate to a floating point.

Definition at line 128 of file CoordinateConversion.h.

References lower, upper, and value.

◆ ConvertCoordinatesFromIntegerRange()

template<int ND, typename IntT >
MDCoordinate< ND > morton_index::ConvertCoordinatesFromIntegerRange ( const MDSpaceBounds< ND > &  bounds,
const Eigen::Array< IntT, ND, 1 > &  intCoord 
)

Converts a point expressed as integer coordinates back to floating point, given bounds of the original coordinate space.

Definition at line 109 of file CoordinateConversion.h.

◆ ConvertCoordinatesToIntegerRange()

template<int ND, typename IntT >
Eigen::Array< IntT, ND, 1 > morton_index::ConvertCoordinatesToIntegerRange ( const MDSpaceBounds< ND > &  bounds,
const float *  crd 
)

Converts a point to integer range given a range of floating point coordinates.

Definition at line 90 of file CoordinateConversion.h.

References n.

◆ ConvertCoordinateToIntegerRange()

template<typename IntT >
IntT morton_index::ConvertCoordinateToIntegerRange ( float  value,
float  lower,
float  upper 
)

Converts a single floating point coordinate to an integer range.

Definition at line 119 of file CoordinateConversion.h.

References lower, upper, and value.

◆ coordinatesToIndex()

template<size_t nd, typename IntT , typename MortonT , typename coord_t = float>
MortonT morton_index::coordinatesToIndex ( coord_t *  coord,
const MDSpaceBounds< nd > &  space 
)

◆ deinterleave() [1/2]

template<size_t ND, typename IntT >
IntArray< ND, IntT > morton_index::deinterleave ( const Morton96 z)

Definition at line 306 of file BitInterleaving.h.

◆ deinterleave() [2/2]

template<size_t ND, typename IntT , typename MortonT >
IntArray< ND, IntT > morton_index::deinterleave ( const MortonT  z)

Deinterleaves a Morton number into an integer coordinate.

Template Parameters
NDNumber of dimensions
IntTIntermediate integer type
MortonTMorton number type
Parameters
zMorton number
Returns
Integer coordinate

Definition at line 298 of file BitInterleaving.h.

References compact().

◆ ExpandBounds()

template<int ND>
void morton_index::ExpandBounds ( MDSpaceBounds< ND > &  bounds)

Expands a coordinate space enough that floating point error cannot cause an overflow when mapping a value at the upper limit of the range to an integer range.

Sets bounds to the next lowest (for lower axis bound) or highest (for upper axis bound) representable floating point value.

Definition at line 62 of file CoordinateConversion.h.

◆ indexToCoordinates()

template<size_t nd, typename IntT , typename MortonT >
MDCoordinate< nd > morton_index::indexToCoordinates ( const MortonT &  idx,
const MDSpaceBounds< nd > &  space 
)

Definition at line 134 of file CoordinateConversion.h.

◆ interleave() [1/2]

template<size_t ND, typename IntT >
Morton96 morton_index::interleave ( const IntArray< 3, uint32_t > &  coord)

Definition at line 285 of file BitInterleaving.h.

◆ interleave() [2/2]

template<size_t ND, typename IntT , typename MortonT >
MortonT morton_index::interleave ( const IntArray< ND, IntT > &  coord)

Interleaves an integer coordinate.

Template Parameters
NDNumber of dimensions
IntTIntermediate integer type
MortonTMorton number type
Parameters
coordCoordinate in intermediate integer space
Returns
Interleaved integer (Morton number)

Definition at line 277 of file BitInterleaving.h.

References pad().

◆ morton_contains()

template<typename MortonT >
bool morton_index::morton_contains ( const MortonT  lower,
const MortonT  upper,
const MortonT  value 
)

Checks if a point defined by a Morton number is within the box bounds (as defined by an upper and lower Morton number).

A box contains a Morton number if it is within the upper and lower bounds, inclusive of the box bounds themselves.

Parameters
lowerLower bound
upperUpper bound
valueMorton value to test

Definition at line 26 of file CoordinateConversion.h.

References lower, upper, and value.

◆ pad()

template<size_t N, typename IntT , typename MortonT >
MortonT morton_index::pad ( IntT  )

Pad an integer with a given number of padding bits.

Template Parameters
NNumber of padding bits to add
IntTInteger type
MortonTPadded integer type
Returns
Padded integer

Definition at line 24 of file BitInterleaving.h.

Referenced by interleave().

◆ pad< 1, uint16_t, uint32_t >()

template<>
uint32_t morton_index::pad< 1, uint16_t, uint32_t > ( uint16_t  v)
inline

Definition at line 45 of file BitInterleaving.h.

◆ pad< 1, uint16_t, uint64_t >()

template<>
uint64_t morton_index::pad< 1, uint16_t, uint64_t > ( uint16_t  v)
inline

Definition at line 64 of file BitInterleaving.h.

◆ pad< 1, uint32_t, uint128_t >()

template<>
uint128_t morton_index::pad< 1, uint32_t, uint128_t > ( uint32_t  v)
inline

Definition at line 142 of file BitInterleaving.h.

◆ pad< 2, uint16_t, uint64_t >()

template<>
uint64_t morton_index::pad< 2, uint16_t, uint64_t > ( uint16_t  v)
inline

Definition at line 100 of file BitInterleaving.h.

◆ pad< 2, uint32_t, uint128_t >()

template<>
uint128_t morton_index::pad< 2, uint32_t, uint128_t > ( uint32_t  v)
inline

Definition at line 164 of file BitInterleaving.h.

◆ pad< 2, uint64_t, uint256_t >()

template<>
uint256_t morton_index::pad< 2, uint64_t, uint256_t > ( uint64_t  v)
inline

Definition at line 214 of file BitInterleaving.h.

◆ pad< 2, uint8_t, uint32_t >()

template<>
uint32_t morton_index::pad< 2, uint8_t, uint32_t > ( uint8_t  v)
inline

Definition at line 83 of file BitInterleaving.h.

◆ pad< 3, uint16_t, uint64_t >()

template<>
uint64_t morton_index::pad< 3, uint16_t, uint64_t > ( uint16_t  v)
inline

Definition at line 119 of file BitInterleaving.h.

◆ pad< 3, uint32_t, uint128_t >()

template<>
uint128_t morton_index::pad< 3, uint32_t, uint128_t > ( uint32_t  v)
inline

Definition at line 187 of file BitInterleaving.h.

◆ pad< 3, uint64_t, uint256_t >()

template<>
uint256_t morton_index::pad< 3, uint64_t, uint256_t > ( uint64_t  v)
inline

Definition at line 239 of file BitInterleaving.h.