ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
detray::algebra::storage::vector< N, scalar_t, array_t > Class Template Reference

Vector wrapper for AoS vs interleaved SoA data. More...

#include <detray/algebra/common/vector.hpp>

Inheritance diagram for detray::algebra::storage::vector< N, scalar_t, array_t >:
[legend]

Public Types

using array_type = array_t<scalar_t, simd_size()>
 Underlying data array type.
using scalar_type = scalar_t
 Value type is a simd vector in SoA and a scalar in AoS.

Public Member Functions

constexpr vector ()
 Default constructor sets all entries to zero.
template<typename other_t>
constexpr auto compare (const other_t &rhs) const noexcept
 Elementwise comparison.
constexpr const auto & get () const
 Return the underlying storage array.
template<typename other_t>
constexpr bool operator!= (const other_t &rhs) const noexcept
 Inequality operator.
constexpr decltype(auto) operator*= (scalar_type factor) noexcept
 Operator*=.
template<std::size_t M>
requires (vector<N, scalar_t, array_t>::simd_size() == vector<M, scalar_t, array_t>::simd_size())
constexpr const vector & operator= (const vector< M, scalar_t, array_t > &lhs)
 Assignment operator from a vector with the same underlying storage.
template<typename... Scalars>
requires (concepts::simd_scalar<scalar_t> && (sizeof...(Scalars) == N) && ((concepts::simd_scalar<Scalars> || std::convertible_to<Scalars, scalar_t>) && ...))
constexpr vector (Scalars &&...scals)
 Construct from element values vals .
template<typename... Values>
requires (!concepts::simd_scalar<scalar_t> && (sizeof...(Values) > 1) && ((concepts::value<Values> || std::convertible_to<Values, scalar_t>) && ...))
constexpr vector (Values &&...vals)
 In order to avoid uninitialized values, which deteriorate the performance in explicitly vectorized code, the underlying data array is filled with zeroes if too few arguments are given.
constexpr vector (array_type &&vals)
 Construct from existing array storage vals.
constexpr vector (const array_type &vals)
constexpr operator array_type & ()
 Conversion operator from wrapper to underlying data array.
constexpr operator const array_type & () const
 Convert the wrapper to its underlying const data array.
constexpr decltype(auto) operator[] (std::size_t i)
 Subscript operator[].
constexpr decltype(auto) operator[] (std::size_t i) const

Static Public Member Functions

static consteval std::size_t simd_size ()

Public Attributes

array_t< scalar_t, simd_size()> m_data
 Holds the data value for every vector element.

Detailed Description

template<std::size_t N, concepts::scalar scalar_t, template< typename, std::size_t > class array_t>
class detray::algebra::storage::vector< N, scalar_t, array_t >

Vector wrapper for AoS vs interleaved SoA data.

scalar_t can e.g. be a SIMD vector.

Constructor & Destructor Documentation

◆ vector() [1/4]

template<std::size_t N, concepts::scalar scalar_t, template< typename, std::size_t > class array_t>
template<typename... Scalars>
requires (concepts::simd_scalar<scalar_t> && (sizeof...(Scalars) == N) && ((concepts::simd_scalar<Scalars> || std::convertible_to<Scalars, scalar_t>) && ...))
detray::algebra::storage::vector< N, scalar_t, array_t >::vector ( Scalars &&... scals)
constexpr

Construct from element values vals .

Construct vector in SoA layout from simd scalars

Parameters
scalsElement values, one for each logical vector component.

◆ vector() [2/4]

template<std::size_t N, concepts::scalar scalar_t, template< typename, std::size_t > class array_t>
template<typename... Values>
requires (!concepts::simd_scalar<scalar_t> && (sizeof...(Values) > 1) && ((concepts::value<Values> || std::convertible_to<Values, scalar_t>) && ...))
detray::algebra::storage::vector< N, scalar_t, array_t >::vector ( Values &&... vals)
constexpr

In order to avoid uninitialized values, which deteriorate the performance in explicitly vectorized code, the underlying data array is filled with zeroes if too few arguments are given.

Parameters
valsElement values; any unused storage lanes are initialized to zero where supported by the storage size.

◆ vector() [3/4]

template<std::size_t N, concepts::scalar scalar_t, template< typename, std::size_t > class array_t>
detray::algebra::storage::vector< N, scalar_t, array_t >::vector ( array_type && vals)
constexpr

Construct from existing array storage vals.

Implicit in both directions on purpose: together with the conversion operators below this makes the wrapper a drop-in for the array it wraps.

Parameters
valsStorage array to move into the wrapper.

◆ vector() [4/4]

template<std::size_t N, concepts::scalar scalar_t, template< typename, std::size_t > class array_t>
detray::algebra::storage::vector< N, scalar_t, array_t >::vector ( const array_type & vals)
constexpr
Parameters
valsStorage array to copy into the wrapper.

Member Function Documentation

◆ compare()

template<std::size_t N, concepts::scalar scalar_t, template< typename, std::size_t > class array_t>
template<typename other_t>
auto detray::algebra::storage::vector< N, scalar_t, array_t >::compare ( const other_t & rhs) const
constexprnoexcept

Elementwise comparison.

Can result in a vector-of-masks for SoA vectors

Parameters
rhsValue whose elements are compared with this vector.
Returns
The per-element comparison results.

◆ get()

template<std::size_t N, concepts::scalar scalar_t, template< typename, std::size_t > class array_t>
const auto & detray::algebra::storage::vector< N, scalar_t, array_t >::get ( ) const
constexpr

Return the underlying storage array.

Returns
A const reference to the stored array.

◆ operator array_type &()

template<std::size_t N, concepts::scalar scalar_t, template< typename, std::size_t > class array_t>
detray::algebra::storage::vector< N, scalar_t, array_t >::operator array_type & ( )
constexpr

Conversion operator from wrapper to underlying data array.

Returns
A mutable reference to the stored array.

◆ operator const array_type &()

template<std::size_t N, concepts::scalar scalar_t, template< typename, std::size_t > class array_t>
detray::algebra::storage::vector< N, scalar_t, array_t >::operator const array_type & ( ) const
constexpr

Convert the wrapper to its underlying const data array.

Returns
A const reference to the stored array.

◆ operator!=()

template<std::size_t N, concepts::scalar scalar_t, template< typename, std::size_t > class array_t>
template<typename other_t>
bool detray::algebra::storage::vector< N, scalar_t, array_t >::operator!= ( const other_t & rhs) const
constexprnoexcept

Inequality operator.

Parameters
rhsValue to compare against.
Returns
Whether the values compare unequal.

◆ operator*=()

template<std::size_t N, concepts::scalar scalar_t, template< typename, std::size_t > class array_t>
decltype(auto) detray::algebra::storage::vector< N, scalar_t, array_t >::operator*= ( scalar_type factor)
constexprnoexcept

Operator*=.

Parameters
factorScalar multiplier.
Returns
Vector expression/return type according to the operation.

◆ operator=()

template<std::size_t N, concepts::scalar scalar_t, template< typename, std::size_t > class array_t>
template<std::size_t M>
requires (vector<N, scalar_t, array_t>::simd_size() == vector<M, scalar_t, array_t>::simd_size())
const vector & detray::algebra::storage::vector< N, scalar_t, array_t >::operator= ( const vector< M, scalar_t, array_t > & lhs)
constexpr

Assignment operator from a vector with the same underlying storage.

Parameters
lhswrap a copy of this data.
Returns
A const reference to this vector after assignment.

◆ operator[]() [1/2]

template<std::size_t N, concepts::scalar scalar_t, template< typename, std::size_t > class array_t>
decltype(auto) detray::algebra::storage::vector< N, scalar_t, array_t >::operator[] ( std::size_t i)
constexpr

Subscript operator[].

Parameters
iZero-based component index.
Returns
A reference to the selected component.

◆ operator[]() [2/2]

template<std::size_t N, concepts::scalar scalar_t, template< typename, std::size_t > class array_t>
decltype(auto) detray::algebra::storage::vector< N, scalar_t, array_t >::operator[] ( std::size_t i) const
constexpr
Parameters
iZero-based component index.
Returns
The selected component.

◆ simd_size()

template<std::size_t N, concepts::scalar scalar_t, template< typename, std::size_t > class array_t>
consteval std::size_t detray::algebra::storage::vector< N, scalar_t, array_t >::simd_size ( )
staticconsteval
Returns
the required size of the underlying array storage