|
Grangeat-based 2D/3D image registration
|
A simple vector class derived from std::array<T, N>, providing overrides for all useful operators.
More...
#include <Vec.h>
Public Types | |
| using | ElementType = T |
| using | Base = std::array< T, N > |
Public Member Functions | |
| __host__ __device__ | Vec () |
| Default construct all elements. | |
| __host__ __device__ | Vec (Base array) |
| Construct from a std::array (this is the base class of Vec) | |
| __host__ __device__ | Vec (std::initializer_list< T > l) |
| Construct from a series of values. | |
| __host__ __device__ constexpr at::IntArrayRef | ToIntArrayRef () const |
Convert to an at::IntArrayRef (this is the type of at::Tensor::sizes()) | |
| __host__ at::Tensor | ToTensor (at::TensorOptions options={}, bool nonOwning=false) const |
Convert to an at::Tensor | |
| __host__ __device__ constexpr Vec | Flipped () const |
| Construct a Vec with the same elements, but in the reverse order. | |
| __host__ __device__ constexpr T | Sum () const |
| Compute the sum of all elements. | |
| __host__ __device__ constexpr T | Min () const |
| Find the smallest element. | |
| __host__ __device__ constexpr T | Max () const |
| Find the largest element. | |
| __host__ __device__ constexpr std::pair< T, T > | MinMax () const |
| Find the smallest and largest elements. | |
| __host__ __device__ constexpr Vec< T, 3 > | DeHomogenise () const |
| Compute the 3-vector for this homogeneous vector, = (x, y, z) / w. | |
| template<typename newT > | |
| __host__ __device__ constexpr Vec< newT, N > | StaticCast () const |
| Construct a Vec with the elements form this one cast to a new type. | |
| __host__ __device__ constexpr T | Length () const |
| Compute the L^2 norm. | |
| __host__ __device__ constexpr bool | BooleanAll () const |
| Compute the combination of all elements using the AND operator. | |
| __host__ __device__ constexpr bool | BooleanAny () const |
| Compute the combination of all elements using the OR operator. | |
| template<typename newT > | |
| __host__ __device__ constexpr Vec< newT, N > | Apply (const std::function< newT(T)> &f) const |
Map all elements with a common std::function mapping function. | |
| template<typename newT > | |
| __host__ __device__ constexpr Vec< newT, N > | Apply (const std::function< newT(const T &)> &f) const |
Map all elements with a common std::function mapping function. | |
| template<typename newT > | |
| __host__ __device__ constexpr Vec< newT, N > | Apply (newT(*f)(T)) const |
| Map all elements with a common C-style mapping function. | |
| template<typename newT > | |
| __host__ __device__ constexpr Vec< newT, N > | Apply (newT(*f)(const T &)) const |
| Map all elements with a common C-style mapping function. | |
| __host__ __device__ Vec & | operator+= (const Vec &other) |
| Element-wise addition of another Vec. | |
| template<typename scalar_t > | |
| __host__ __device__ Vec & | operator+= (const scalar_t &scalar) |
| Element-wise addition of a scalar. | |
| __host__ __device__ Vec & | operator-= (const Vec &other) |
| Element-wise subtraction of another Vec. | |
| template<typename scalar_t > | |
| __host__ __device__ Vec & | operator-= (const scalar_t &scalar) |
| Element-wise subtraction of a scalar. | |
| __host__ __device__ Vec & | operator*= (const Vec &other) |
| Element-wise multiplication by another Vec. | |
| template<typename scalar_t > | |
| __host__ __device__ Vec & | operator*= (const scalar_t &scalar) |
| Element-wise multiplication by a scalar. | |
| __host__ __device__ Vec & | operator/= (const Vec &other) |
| Element-wise division by another Vec. | |
| template<typename scalar_t > | |
| __host__ __device__ Vec & | operator/= (const scalar_t &scalar) |
| Element-wise division by a scalar. | |
| __host__ __device__ constexpr const T & | X () const |
| Get a constant reference to the first element. | |
| __host__ __device__ constexpr T & | X () |
| Get the first element. | |
| __host__ __device__ constexpr const T & | Y () const |
| Get a constant reference to the second element. | |
| __host__ __device__ constexpr T & | Y () |
| Get the second element. | |
| __host__ __device__ constexpr const T & | Z () const |
| Get a constant reference to the third element. | |
| __host__ __device__ constexpr T & | Z () |
| Get the third element. | |
| __host__ __device__ constexpr const T & | W () const |
| Get a constant reference to the fourth element. | |
| __host__ __device__ constexpr T & | W () |
| Get the fourth element. | |
| __host__ __device__ constexpr Vec< T, 2 > | XY () const |
| Construct a Vec from the first two elements. | |
| __host__ __device__ constexpr Vec< T, 3 > | XYZ () const |
| Construct a Vec from the first three elements. | |
Static Public Member Functions | |
| __host__ static __device__ constexpr Vec | Full (const T &value) |
| Construct a Vec, copying the given value into every element. | |
| __host__ static __device__ constexpr Vec | Range (const T &start=T{0}, const T &step=T{1}) |
Construct a Vec where the ith element is start + i * step | |
| __host__ static __device__ constexpr Vec | FromIntArrayRef (const at::IntArrayRef &v) |
Construct a Vec from an at::IntArrayRef (this is the type of at::Tensor::sizes()) | |
| static __host__ Vec | FromTensor (const at::Tensor &t) |
| Construct a Vec from a 1D PyTorch tensor. | |
| static __host__ constexpr Vec | Identity () |
| Construct an identity matrix. | |
| static __host__ Vec | FromTensor2D (const at::Tensor &t) |
| Construct a matrix from a 2D PyTorch tensor. | |
Static Public Attributes | |
| static constexpr std::size_t | dimensionality = N |
A simple vector class derived from std::array<T, N>, providing overrides for all useful operators.
| T | The type of the vector's elements |
| N | The size/dimensionality of the vector; must be greater than 0 |
Vec<Vec<T, C>, R>; see reg23::MatMul
|
inline |
Default construct all elements.
|
inline |
Construct from a std::array (this is the base class of Vec)
|
inline |
Construct from a series of values.
|
inlineconstexpr |
Map all elements with a common std::function mapping function.
| newT | The element type of the returned vector |
| f | A function with which to map each element of this vector |
|
inlineconstexpr |
Map all elements with a common std::function mapping function.
| newT | The element type of the returned vector |
| f | A function with which to map each element of this vector |
|
inlineconstexpr |
Map all elements with a common C-style mapping function.
| newT | The element type of the returned vector |
| f | A function with which to map each element of this vector |
|
inlineconstexpr |
Map all elements with a common C-style mapping function.
| newT | The element type of the returned vector |
| f | A function with which to map each element of this vector |
|
inlineconstexpr |
Compute the combination of all elements using the AND operator.
trueFor boolean vectors only
|
inlineconstexpr |
Compute the combination of all elements using the OR operator.
trueFor boolean vectors only
|
inlineconstexpr |
Compute the 3-vector for this homogeneous vector, = (x, y, z) / w.
For floating-point 4-vectors only.
|
inlineconstexpr |
Construct a Vec with the same elements, but in the reverse order.
|
inlinestaticconstexpr |
Construct a Vec from an at::IntArrayRef (this is the type of at::Tensor::sizes())
Construct a matrix from a 2D PyTorch tensor.
| t | a tensor of size (N, T::dimensionality). The contained type must be consistent with the vector's type, i.e. for a Vec<Vec<float32_t, C>, R>, t must contain values of type torch.float32. |
Only valid for Vec of contained type T that is a specialisation of Vec, e.g. Vec<Vec<float, C>, R>
|
inlinestaticconstexpr |
Construct a Vec, copying the given value into every element.
|
inlineconstexpr |
Compute the L^2 norm.
|
inlineconstexpr |
Find the largest element.
|
inlineconstexpr |
Find the smallest element.
|
inlineconstexpr |
Find the smallest and largest elements.
|
inline |
Element-wise multiplication by a scalar.
|
inline |
Element-wise multiplication by another Vec.
|
inline |
Element-wise addition of a scalar.
|
inline |
Element-wise addition of another Vec.
|
inline |
Element-wise subtraction of a scalar.
|
inline |
Element-wise subtraction of another Vec.
|
inline |
Element-wise division by a scalar.
|
inline |
Element-wise division by another Vec.
|
inlinestaticconstexpr |
Construct a Vec where the ith element is start + i * step
|
inlineconstexpr |
Construct a Vec with the elements form this one cast to a new type.
newT
|
inlineconstexpr |
Compute the sum of all elements.
|
inlineconstexpr |
Convert to an at::IntArrayRef (this is the type of at::Tensor::sizes())
|
inline |
Convert to an at::Tensor
|
inlineconstexpr |
Get the fourth element.
|
inlineconstexpr |
Get a constant reference to the fourth element.
|
inlineconstexpr |
Get the first element.
|
inlineconstexpr |
Get a constant reference to the first element.
|
inlineconstexpr |
Construct a Vec from the first two elements.
|
inlineconstexpr |
Construct a Vec from the first three elements.
|
inlineconstexpr |
Get the second element.
|
inlineconstexpr |
Get a constant reference to the second element.
|
inlineconstexpr |
Get the third element.
|
inlineconstexpr |
Get a constant reference to the third element.
|
staticconstexpr |