Utilities#
Miscellaneous functions are listed here.
Parser#
-
configuration bbfft::parse_fft_descriptor(std::string_view desc)#
Parses an FFT descriptor.
See user manual for a description of the input format
- Parameters:
desc – descriptor
- Returns:
configuration
-
device_info bbfft::parse_device_info(std::string_view desc)#
Parses a device info descriptor.
See user manual for a description of the input format
- Parameters:
desc – descriptor
- Returns:
device info
Tensor indexer#
-
template<typename IdxT, unsigned int D, layout L = layout::row_major>
class tensor_indexer# Utility class to compute addresses for multi-dimensional data.
- Template Parameters:
IdxT – Index type
D – Tensor dimension
L – Storage layout
Public Functions
-
inline tensor_indexer()#
Construct empty indexer.
-
inline tensor_indexer(multi_idx_t shape)#
Construct indexer for
tensor.Strides are computed automatically assuming packed data as following:
Row-major layout:
Column-major layout:
- Parameters:
shape – The numbers
-
inline tensor_indexer(multi_idx_t shape, multi_idx_t stride)#
Construct indexer for
tensor with manual strides.- Parameters:
shape – The numbers
stride – Custom strides
-
template<typename ...Indices, typename = std::enable_if_t<sizeof...(Indices) == D, int>>
inline IdxT operator()(Indices... is) const# Compute linear index for entry
.Indices are computed as following:
are the entries of the stride array.- Template Parameters:
Indices – Index types of arguments
- Parameters:
...is – Indices
- Returns:
Linear index
-
inline IdxT operator()(multi_idx_t const &idx) const#
Compute linear index.
- Parameters:
idx – Multi-index
- Returns:
Linear index
-
inline auto shape() const -> std::conditional_t<L == layout::row_major, multi_idx_t, multi_idx_t const&>#
Tensor shape.
- Returns:
Numbers
-
inline auto shape(unsigned int d) const#
Tensor shape.
- Parameters:
d – mode
- Returns:
Number
-
inline auto stride() const -> std::conditional_t<L == layout::row_major, multi_idx_t, multi_idx_t const&>#
Strides.
- Returns:
Stride array
-
inline auto stride(unsigned int d) const#
Stride for d-th mode.
- Parameters:
d – mode
- Returns:
Stride
-
inline IdxT size() const#
Compute number of elements in tensor.
- Returns:
Size (multiply with element type to get number of bytes)
-
inline constexpr auto dim() const#
Dimension.
- Returns:
Dimension
-
template<unsigned int Dfrom = 0, unsigned int Dto = D - 1>
inline bool may_fuse() const# Checks whether indices may be fused.
“Fusing” means that one may treat 2 or more neighbouring indices as a single super-index. Modes may only be fused it they are packed in memory.
- Template Parameters:
Dfrom – First fused mode
Dto – Last fused mode
- Returns:
True if modes may be fused
-
template<unsigned int Dfrom = 0, unsigned int Dto = D - 1>
inline auto fused() const# Returns a tensor indexer with fused modes.
See also
- Template Parameters:
Dfrom – First fused mode
Dto – Last fused mode
- Returns:
Fused tensor indexer
-
template<std::size_t E>
inline bool may_reshape_mode(int mode, std::array<IdxT, E> const &mode_shape) const# Checks whether a mode may be reshaped.
“Reshaping a mode” means that one views a 1-D mode as a E-D tensor. E.g. for the tensor X_{i,j,k} of size N1 x N2 x N3 a reshape of mode 1 (= index j) with mode shape M1 x M2 means that we view the data of tensor X as the tensor X’_{i,j1,j2,k} of size N1 x M1 x M2 x N3.
- Template Parameters:
E – reshape dimension
- Parameters:
mode – The mode number to reshape; counting starts from 0
mode_shape – The E-D shape of the mode
- Returns:
True if the mode may be reshaped
-
template<std::size_t E>
inline auto reshaped_mode(int mode, std::array<IdxT, E> mode_shape) const# Returns a tensor indexer with reshaped mode.
See also
- Template Parameters:
E – reshape dimension
- Parameters:
mode – The mode number to reshape; counting starts from 0
mode_shape – The E-D shape of the mode
- Returns:
Reshaped tensor indexer
Storage layout#
Functions#
-
template<std::size_t Dout, typename IdxT, std::size_t Din>
constexpr auto bbfft::fit_array(std::array<IdxT, Din> const &in, IdxT fill_value = IdxT(0))# Truncate or extend std::array.
- Template Parameters:
Dout – Length of output array
IdxT – Array value type
Din – Length of input array
- Parameters:
in – Input array
fill_value – Fill value if extension is needed
- Returns:
Truncated or extended array