Intel xvec
Experimental C++ simd class library
Loading...
Searching...
No Matches
C++26: Vector constructors

Construct vectors from values, ranges, generators, and other vectors. More...

Functions

template<std::size_t _Bytes, typename _Abi>
 xvec::simd::basic_vec (basic_mask< _Bytes, _Abi > k) -> basic_vec< typename basic_mask< _Bytes, _Abi >::traits::element_signed_container_type, _Abi >
 Deduce a vector type from a mask, equivalent to decltype(+k).
template<typename _InputSpan, typename... _Flags>
requires (!vec_type<_InputSpan> && detail::span_extent_v<_InputSpan> == size && detail::explicitly_convertible_to<detail::span_element_type<_InputSpan>, _Tp>)
constexpr xvec::simd::basic_vec< _Tp, _Abi >::basic_vec (const _InputSpan &in_span, flags< _Flags... > f={})
 Constructs a basic_vec by reading the contents of an object with the same number of elements (e.g., span, C-array, std::array).
template<typename _InputSpan, typename... _Flags>
requires (!vec_type<_InputSpan> && detail::span_extent_v<_InputSpan> == size && detail::explicitly_convertible_to<detail::span_element_type<_InputSpan>, _Tp>)
constexpr xvec::simd::basic_vec< _Tp, _Abi >::basic_vec (const _InputSpan &in_span, const mask_type &m, flags< _Flags... > f={})
 Construct a vector from selected elements of a span-like object.
template<detail::broadcast_constructible< _Tp > _Up = _Tp>
constexpr xvec::simd::basic_vec< _Tp, _Abi >::basic_vec (_Up &&v) noexcept
 Create a basic_vec value in which every element is set to the single value provided.
constexpr xvec::simd::basic_vec< _Tp, _Abi >::basic_vec (const real_type &r, const real_type &i={}) noexcept
 Construct a complex vector from real and imaginary component vectors. Each complex element combines the corresponding real and imaginary elements. If the imaginary vector is omitted, its elements are value initialized.
template<vec_type _Vp>
requires (!(vec_complex<basic_vec> ^ vec_complex<_Vp>) && (_Vp::size() == size()) && detail::explicitly_convertible_to<typename _Vp::value_type, _Tp> && detail::needs_explicit_conversion<typename _Vp::value_type, _Tp>)
constexpr xvec::simd::basic_vec< _Tp, _Abi >::basic_vec (const _Vp &v) noexcept
 Explicitly convert a vector with the same number of elements. Both element types must be complex or neither must be complex. Construction of a complex vector from real components is provided separately.
constexpr xvec::simd::basic_vec< _Tp, _Abi >::basic_vec (detail::generator_invocable< value_type, size > auto &&fn)
 Construct a vector by generating each element from its index.
template<typename _Span, class... Ts>
requires (detail::span_extent_v<std::remove_cvref_t<_Span>> <= detail::max_fixed_size<detail::span_element_type<std::remove_cvref_t<_Span>>>)
 xvec::simd::basic_vec (_Span &&, Ts...) -> basic_vec< detail::span_element_type< std::remove_cvref_t< _Span > >, simd_fixed_size_abi< detail::span_extent_v< std::remove_cvref_t< _Span > > > >

Detailed Description

Construct vectors from values, ranges, generators, and other vectors.

Includes complex-component construction and vector deduction guides.

See also
https://eel.is/c++draft/simd.ctor

Function Documentation

◆ basic_vec() [1/7]

template<typename _Span, class... Ts>
requires (detail::span_extent_v<std::remove_cvref_t<_Span>> <= detail::max_fixed_size<detail::span_element_type<std::remove_cvref_t<_Span>>>)
xvec::simd::basic_vec ( _Span && ,
Ts...  )->basic_vec< detail::span_element_type< std::remove_cvref_t< _Span > >, simd_fixed_size_abi< detail::span_extent_v< std::remove_cvref_t< _Span > > > >

Deduction guide from static extent. Anything span-like, with a compile-time size which is small enough to fit a vec, and with valid element types can be turned into a vec.

◆ basic_vec() [2/7]

template<typename _Tp, typename _Abi>
template<detail::broadcast_constructible< _Tp > _Up = _Tp>
xvec::simd::basic_vec< _Tp, _Abi >::basic_vec ( _Up && v)
inlineconstexprnoexcept

Create a basic_vec value in which every element is set to the single value provided.

Parameters
vThe value to broadcast to every element of the new vec value.

◆ basic_vec() [3/7]

template<typename _Tp, typename _Abi>
template<typename _InputSpan, typename... _Flags>
requires (!vec_type<_InputSpan> && detail::span_extent_v<_InputSpan> == size && detail::explicitly_convertible_to<detail::span_element_type<_InputSpan>, _Tp>)
xvec::simd::basic_vec< _Tp, _Abi >::basic_vec ( const _InputSpan & in_span,
const mask_type & m,
flags< _Flags... > f = {} )
inlineconstexpr

Construct a vector from selected elements of a span-like object.

Parameters
in_spanThe source span-like object.
mThe mask selecting elements to load. Unselected elements are value initialized.
fThe flags to apply to the copy.

◆ basic_vec() [4/7]

template<typename _Tp, typename _Abi>
template<typename _InputSpan, typename... _Flags>
requires (!vec_type<_InputSpan> && detail::span_extent_v<_InputSpan> == size && detail::explicitly_convertible_to<detail::span_element_type<_InputSpan>, _Tp>)
xvec::simd::basic_vec< _Tp, _Abi >::basic_vec ( const _InputSpan & in_span,
flags< _Flags... > f = {} )
inlineconstexpr

Constructs a basic_vec by reading the contents of an object with the same number of elements (e.g., span, C-array, std::array).

Template Parameters
_InputSpanThe span-like object to copy.
_FlagsFlags which control any conversions necessary.
Parameters
in_spanThe source span-like object.
fThe flags to apply to the copy.

◆ basic_vec() [5/7]

template<typename _Tp, typename _Abi>
template<vec_type _Vp>
requires (!(vec_complex<basic_vec> ^ vec_complex<_Vp>) && (_Vp::size() == size()) && detail::explicitly_convertible_to<typename _Vp::value_type, _Tp> && detail::needs_explicit_conversion<typename _Vp::value_type, _Tp>)
xvec::simd::basic_vec< _Tp, _Abi >::basic_vec ( const _Vp & v)
inlineexplicitconstexprnoexcept

Explicitly convert a vector with the same number of elements. Both element types must be complex or neither must be complex. Construction of a complex vector from real components is provided separately.

Two implementations are provided because conditional explicit was not supported correctly by Intel compiler versions before 2023.

Parameters
vThe value to copy and convert.

◆ basic_vec() [6/7]

template<typename _Tp, typename _Abi>
xvec::simd::basic_vec< _Tp, _Abi >::basic_vec ( const real_type & r,
const real_type & i = {} )
inlineconstexprnoexcept

Construct a complex vector from real and imaginary component vectors. Each complex element combines the corresponding real and imaginary elements. If the imaginary vector is omitted, its elements are value initialized.

Parameters
rThe vector of real components.
iThe vector of imaginary components.

◆ basic_vec() [7/7]

template<typename _Tp, typename _Abi>
xvec::simd::basic_vec< _Tp, _Abi >::basic_vec ( detail::generator_invocable< value_type, size > auto && fn)
inlineexplicitconstexpr

Construct a vector by generating each element from its index.

Parameters
fnA function accepting an element index and returning the value to store at that index.