Mantid
Loading...
Searching...
No Matches
Types.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
9// boost::multiprecision is not used here because the
10// with of the number is one WORD bigger, than actual
11// number size, see here
12// https://www.boost.org/doc/libs/1_61_0/libs/multiprecision/doc/html/boost_multiprecision/tut/ints/cpp_int.html
13#include "WideInt.h"
14#include <Eigen/Dense>
15#include <ostream>
16
17namespace morton_index {
18using std::operator"" _cppui128;
19using std::operator"" _cppui256;
23} // namespace morton_index
24
25namespace morton_index {
26
27template <size_t ND, typename IntT> using IntArray = Eigen::Array<IntT, static_cast<int>(ND), 1>;
28
29template <size_t ND> using MDCoordinate = Eigen::Array<float, static_cast<int>(ND), 1>;
30
31template <size_t ND> using MDSpaceBounds = Eigen::Array<float, static_cast<int>(ND), 2>;
32template <size_t ND> using MDSpaceDimensions = Eigen::Array<float, static_cast<int>(ND), 1>;
33template <size_t ND> using MDSpaceSteps = Eigen::Array<float, static_cast<int>(ND), 1>;
34
35template <typename CoordT, size_t ND> using AffineND = Eigen::Transform<CoordT, static_cast<int>(ND), Eigen::Affine>;
36
37template <size_t ND> using BinIndices = Eigen::Matrix<size_t, 1, static_cast<int>(ND)>;
38
44
51template <size_t SZ> struct MortonIndex {
52 using type = uint256_t;
53};
54
55template <> struct MortonIndex<1> {
56 using type = uint8_t;
57};
58
59template <> struct MortonIndex<2> {
60 using type = uint16_t;
61};
62
63template <> struct MortonIndex<4> {
64 using type = uint32_t;
65};
66
67template <> struct MortonIndex<8> {
68 using type = uint64_t;
69};
70
71template <> struct MortonIndex<12> {
72 using type = Morton96;
73};
74
75template <> struct MortonIndex<16> {
76 using type = uint128_t;
77};
78
84template <typename FP> struct UnderlyingInt {};
85
86template <> struct UnderlyingInt<float> {
87 using type = uint32_t;
88};
89
90template <> struct UnderlyingInt<double> {
91 using type = uint64_t;
92};
93
101template <size_t ND, typename FP> struct IndexTypes {
102 using MortonType = typename MortonIndex<ND * sizeof(FP)>::type;
104};
105
106} // namespace morton_index
Eigen::Array< float, static_cast< int >(ND), 1 > MDSpaceDimensions
Definition Types.h:32
Eigen::Matrix< size_t, 1, static_cast< int >(ND)> BinIndices
Definition Types.h:37
uint96_t Morton96
This class implements the structure of size 96bit, that can be used as Morton index.
Definition Types.h:43
std::wide_uint< 96 > uint96_t
Definition Types.h:20
Eigen::Array< float, static_cast< int >(ND), 1 > MDCoordinate
Definition Types.h:29
Eigen::Transform< CoordT, static_cast< int >(ND), Eigen::Affine > AffineND
Definition Types.h:35
std::uint256_t uint256_t
Definition Types.h:22
std::uint128_t uint128_t
Definition Types.h:21
Eigen::Array< IntT, static_cast< int >(ND), 1 > IntArray
Definition Types.h:27
Eigen::Array< float, static_cast< int >(ND), 1 > MDSpaceSteps
Definition Types.h:33
Eigen::Array< float, static_cast< int >(ND), 2 > MDSpaceBounds
Definition Types.h:31
wide_integer< Bits, unsigned > wide_uint
Definition WideInt.h:268
This structure determines Morton index type and underlying unsigned integer type for the floating poi...
Definition Types.h:101
typename UnderlyingInt< FP >::type IntType
Definition Types.h:103
typename MortonIndex< ND *sizeof(FP)>::type MortonType
Definition Types.h:102
This structure binds the size of accesible memory to store the Morton index to the Morton index type.
Definition Types.h:51
This structure binds floating point types to the unsigned integer types of the same width.
Definition Types.h:84