Intel xvec
Experimental C++ simd class library
Loading...
Searching...
No Matches
simd
1//===----------------------------------------------------------------------===//
2//
3// Copyright (C) 2021 Intel Corporation
4//
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9// xvec header files refer to the following instruction sets:
10// - Intel(R) Advanced Vector Extensions (Intel(R) AVX)
11// - Intel(R) Advanced Vector Extensions 10 (Intel(R) AVX10)
12// - Intel(R) Advanced Vector Extensions 2 (Intel(R) AVX2)
13// - Intel(R) Advanced Vector Extensions 512 (Intel(R) AVX-512)
14// - Intel(R) Streaming SIMD Extensions (Intel(R) SSE).
15
16#pragma once
17
18#include <algorithm>
19#include <array>
20#include <cassert>
21#include <cstddef>
22#include <concepts>
23#include <bit>
24#include <complex>
25#include <functional> // std::plus, std::negate, etc.
26
27#include <numeric>
28#include <ostream> // std::ostream
29#include <ranges>
30#include <span>
31#include <tuple>
32#include <type_traits>
33
34#include <xvec/detail/config.hpp>
35#include <xvec/detail/compat.hpp>
36
37#include <xvec/detail/target_config.hpp>
38
39#include <xvec/detail/core.hpp>
40
41#include <xvec/detail/std_limits.hpp>
42#include <xvec/detail/std_rebind.hpp>
43
44#include <xvec/generic/generic_impl.hpp>
45#include <xvec/detail/iterator.hpp>
46
47// Vendor specific variants.
48#if defined(__SSE__) and !defined(_XVEC_FORCE_SCALAR)
49#include <xvec/x86/intrin.hpp>
50#include <xvec/x86/x86_impl.hpp>
51#endif
52
53// Operators go after target specific extensions, so they get picked up.
54#include <xvec/detail/operators.hpp>
55
56#include <xvec/detail/mask.hpp>
57
58#ifdef _XVEC_DEFINE_OUTPUT_OPERATORS
59#include <iostream>
60#endif
61
62namespace _XVEC_NAMESPACE::simd
63{
64
65// :TODO: Pay more attention to constexpr. Many of the functions can be made to work with constexpr,
66// but they don't enable that at the moment.
67
74
83
90
97
104
111
118
125
132
142
147
152
157
161template <typename _Tp, typename _Abi> class basic_vec {
162public:
163
165
166 using value_type = _Tp;
168 using abi_type = _Abi;
170 using const_iterator = simd_iterator<const basic_vec>;
171
173 using real_type =
174 std::conditional_t<vec_complex<basic_vec>,
175 rebind_t<detail::complex_element_type<_Tp>, basic_vec>, struct invalid>;
176
177 using builtin_type = typename traits::builtin_type;
178
181
184 using mask_type = basic_mask<sizeof(_Tp), _Abi>;
185
187 static constexpr auto size = size_constant<simd_size_v<_Tp, _Abi>>{};
188
189private:
190
194 builtin_type data;
195
196public:
197
200
201 constexpr basic_vec() requires (!vec_complex<basic_vec>) = default;
202 constexpr basic_vec() requires (vec_complex<basic_vec>) : data() {}
203
204 constexpr basic_vec(const basic_vec&) = default;
205 constexpr basic_vec(basic_vec&&) noexcept = default;
206 constexpr basic_vec& operator=(const basic_vec&) = default;
207 constexpr basic_vec& operator=(basic_vec&&) noexcept = default;
208
210
213
218 constexpr basic_vec(const builtin_type& v) noexcept : data(v) {}
219
227 explicit constexpr basic_vec(register_type r) noexcept
228 requires (!std::is_convertible_v<register_type, const builtin_type&>)
229 : data(traits::from_register(r)) {}
230
231
234
241 template<typename _InputSpan, typename... _Flags>
242 requires (!vec_type<_InputSpan> &&
243 detail::span_extent_v<_InputSpan> == size &&
245 constexpr basic_vec(const _InputSpan& in_span, flags<_Flags...> f = {})
246 : basic_vec([=](){
247 if (std::is_constant_evaluated())
248 return basic_vec([=](auto i) { return static_cast<value_type>(in_span[i]); });
249 else
250 return detail::load<basic_vec>(target, std::span(in_span), detail::add_unchecked_flag(f));
251 }()) {}
252
257 template<typename _InputSpan, typename... _Flags>
258 requires (!vec_type<_InputSpan> &&
259 detail::span_extent_v<_InputSpan> == size &&
260 detail::explicitly_convertible_to<detail::span_element_type<_InputSpan>, _Tp>)
261 constexpr basic_vec(const _InputSpan& in_span, const mask_type& m, flags<_Flags...> f = {})
262 : basic_vec([=](){
263 if (std::is_constant_evaluated())
264 return select(m, basic_vec(in_span, f), basic_vec());
265 else
266 return detail::load_masked<basic_vec>(target, std::span(in_span), m, detail::add_unchecked_flag(f));
267 }()) {}
268
271 template<detail::broadcast_constructible<_Tp> _Up = _Tp>
272 constexpr basic_vec(_Up&& v) noexcept : basic_vec([v](auto) { return _Tp(v); }) {}
273
279 constexpr basic_vec(const real_type& r, const real_type& i = {}) noexcept
280 requires (vec_complex<basic_vec>) : data(zip(r, i).to_builtin()) {}
281
289 template<vec_type _Vp>
290 requires (!(vec_complex<basic_vec> ^ vec_complex<_Vp>) &&
291 (_Vp::size() == size()) &&
292 detail::explicitly_convertible_to<typename _Vp::value_type, _Tp> &&
293 detail::needs_explicit_conversion<typename _Vp::value_type, _Tp>)
294 explicit constexpr basic_vec(const _Vp& v) noexcept :
296
299 template<vec_type _Vp>
301 (_Vp::size() == size()) &&
304 /*no_explicit*/ constexpr basic_vec(const _Vp& v) noexcept :
306
310 constexpr explicit basic_vec(detail::generator_invocable<value_type, size> auto&& fn) : basic_vec(detail::generate<basic_vec>(fn)) {}
311
313
316
318 constexpr iterator begin() noexcept { return {*this, 0}; }
319
321 constexpr const_iterator begin() const noexcept { return {*this, 0}; }
322
324 constexpr const_iterator cbegin() const noexcept { return {*this, 0}; }
325
327 constexpr std::default_sentinel_t end() const noexcept { return {}; }
328
330 constexpr std::default_sentinel_t cend() const noexcept { return {}; }
331
333
336
339 explicit constexpr operator typename traits::register_type() const { return traits::to_register(data); }
340
344 constexpr typename traits::register_type to_register() const { return traits::to_register(data); }
345
347 constexpr builtin_type to_builtin() const { return data; }
348
350 static constexpr basic_vec from_builtin(const builtin_type& v) noexcept { return basic_vec(v); }
351
353
356
359 constexpr value_type operator[](simd_size_type pos) const { return detail::subscript(target, *this, pos); }
360
364 constexpr auto operator[](const vec_integral auto& indexes) const { return permute(*this, indexes); }
365
367
371 friend constexpr basic_vec simd_select_impl(const mask_type& m, const basic_vec& if_true, const basic_vec& if_false) noexcept
372 { return detail::select_if_else(target, m, if_true, if_false); }
373
376
378 constexpr mask_type operator!() const noexcept
379 requires requires (value_type a) { {!a} -> std::same_as<bool>; }
381
383 constexpr basic_vec operator~() const noexcept
384 requires detail::supported_unary_op<value_type, std::bit_not<>>
385 { return detail::do_operator<std::bit_not<>>(*this); }
386
388 constexpr basic_vec operator-() const noexcept
389 requires detail::supported_unary_op<value_type, std::negate<>>
390 { return detail::do_operator<std::negate<>>(*this); }
391
393 constexpr basic_vec operator+() const noexcept { return *this; }
394
396 constexpr basic_vec& operator++() noexcept requires requires (basic_vec v) { v + basic_vec(_Tp(1)); }
397 { *this = *this + basic_vec(_Tp(1)); return *this; }
398
400 constexpr basic_vec operator++(int) noexcept requires requires (basic_vec v) { v + basic_vec(_Tp(1)); }
401 { const auto original = *this; *this = *this + basic_vec(_Tp(1)); return original; }
402
404 constexpr basic_vec& operator--() noexcept requires requires (basic_vec v) { v - basic_vec(_Tp(1)); }
405 { *this = *this - basic_vec(_Tp(1)); return *this; }
406
408 constexpr basic_vec operator--(int) noexcept requires requires (basic_vec v) { v - basic_vec(_Tp(1)); }
409 { const auto original = *this; *this = *this - basic_vec(_Tp(1)); return original; }
410
412
415
417 friend constexpr basic_vec operator+(const basic_vec& lhs, const basic_vec& rhs) noexcept requires detail::supported_binary_op<value_type, std::plus<>>
418 { return detail::do_operator<std::plus<>>(lhs, rhs); }
419
421 friend constexpr basic_vec operator-(const basic_vec& lhs, const basic_vec& rhs) noexcept requires detail::supported_binary_op<value_type, std::minus<>>
422 { return detail::do_operator<std::minus<>>(lhs, rhs); }
423
425 friend constexpr basic_vec operator*(const basic_vec& lhs, const basic_vec& rhs) noexcept requires detail::supported_binary_op<value_type, std::multiplies<>>
426 { return detail::do_operator<std::multiplies<>>(lhs, rhs); }
427
429 friend constexpr basic_vec operator/(const basic_vec& lhs, const basic_vec& rhs) noexcept requires detail::supported_binary_op<value_type, std::divides<>>
430 { return detail::do_operator<std::divides<>>(lhs, rhs); }
431
433 friend constexpr basic_vec operator%(const basic_vec& lhs, const basic_vec& rhs) noexcept requires detail::supported_binary_op<value_type, std::modulus<>>
434 { return detail::do_operator<std::modulus<>>(lhs, rhs); }
435
437 friend constexpr basic_vec operator&(const basic_vec& lhs, const basic_vec& rhs) noexcept requires detail::supported_binary_op<value_type, std::bit_and<>>
438 { return detail::do_operator<std::bit_and<>>(lhs, rhs); }
439
441 friend constexpr basic_vec operator|(const basic_vec& lhs, const basic_vec& rhs) noexcept requires detail::supported_binary_op<value_type, std::bit_or<>>
442 { return detail::do_operator<std::bit_or<>>(lhs, rhs); }
443
445 friend constexpr basic_vec operator^(const basic_vec& lhs, const basic_vec& rhs) noexcept requires detail::supported_binary_op<value_type, std::bit_xor<>>
446 { return detail::do_operator<std::bit_xor<>>(lhs, rhs); }
447
449
452
454 friend constexpr basic_vec operator*(const basic_vec& lhs, const detail::complex_element_type<_Tp>& rhs) noexcept
455 requires (vec_complex<basic_vec>)
456 {
458 return std::bit_cast<basic_vec>(t);
459 }
460
462 friend constexpr basic_vec operator*(const detail::complex_element_type<_Tp>& lhs, const basic_vec& rhs) noexcept
463 requires (vec_complex<basic_vec>)
464 { return rhs * lhs; }
465
467 friend constexpr basic_vec& operator*=(basic_vec& lhs, const detail::complex_element_type<_Tp>& rhs) noexcept requires (vec_complex<basic_vec>)
468 { lhs = lhs * rhs; return lhs; }
469
471
474
476 friend constexpr mask_type operator==(const basic_vec& lhs, const basic_vec& rhs) noexcept
478 { return detail::do_operator<std::equal_to<>>(lhs, rhs); }
479
481 friend constexpr mask_type operator!=(const basic_vec& lhs, const basic_vec& rhs) noexcept
483 { return detail::do_operator<std::not_equal_to<>>(lhs, rhs); }
484
486 friend constexpr mask_type operator< (const basic_vec& lhs, const basic_vec& rhs) noexcept
488 { return detail::do_operator<std::less<>>(lhs, rhs); }
489
491 friend constexpr mask_type operator<=(const basic_vec& lhs, const basic_vec& rhs) noexcept
493 { return detail::do_operator<std::less_equal<>>(lhs, rhs); }
494
496 friend constexpr mask_type operator> (const basic_vec& lhs, const basic_vec& rhs) noexcept
498 { return detail::do_operator<std::greater<>>(lhs, rhs); }
499
501 friend constexpr mask_type operator>=(const basic_vec& lhs, const basic_vec& rhs) noexcept
503 { return detail::do_operator<std::greater_equal<>>(lhs, rhs); }
504
506
509
511 friend constexpr basic_vec& operator+=(basic_vec& lhs, const basic_vec& rhs) noexcept
513 { lhs = lhs + rhs; return lhs; }
514
516 friend constexpr basic_vec& operator-=(basic_vec& lhs, const basic_vec& rhs) noexcept
518 { lhs = lhs - rhs; return lhs; }
519
521 friend constexpr basic_vec& operator*=(basic_vec& lhs, const basic_vec& rhs) noexcept
523 { lhs = lhs * rhs; return lhs; }
524
526 friend constexpr basic_vec& operator/=(basic_vec& lhs, const basic_vec& rhs) noexcept
528 { lhs = lhs / rhs; return lhs; }
529
531 friend constexpr basic_vec& operator%=(basic_vec& lhs, const basic_vec& rhs) noexcept
533 { lhs = lhs % rhs; return lhs; }
534
536 friend constexpr basic_vec& operator&=(basic_vec& lhs, const basic_vec& rhs) noexcept
538 { lhs = lhs & rhs; return lhs; }
539
541 friend constexpr basic_vec& operator|=(basic_vec& lhs, const basic_vec& rhs) noexcept
543 { lhs = lhs | rhs; return lhs; }
544
546 friend constexpr basic_vec& operator^=(basic_vec& lhs, const basic_vec& rhs) noexcept
548 { lhs = lhs ^ rhs; return lhs; }
549
551
554
556 friend constexpr basic_vec operator<<(const basic_vec& lhs, const basic_vec& rhs) noexcept requires detail::supported_binary_op<value_type, detail::bit_lshift<>>
557 { return detail::do_operator<detail::bit_lshift<>>(lhs, rhs); }
558
560 friend constexpr basic_vec operator>>(const basic_vec& lhs, const basic_vec& rhs) noexcept requires detail::supported_binary_op<value_type, detail::bit_rshift<>>
561 { return detail::do_operator<detail::bit_rshift<>>(lhs, rhs); }
562
564 friend constexpr basic_vec operator<<(const basic_vec& lhs, simd_size_type rhs) noexcept requires detail::supported_binary_op<value_type, detail::bit_lshift<>>
565 { return lhs << basic_vec(value_type(rhs)); }
566
568 friend constexpr basic_vec operator>>(const basic_vec& lhs, simd_size_type rhs) noexcept requires detail::supported_binary_op<value_type, detail::bit_rshift<>>
569 { return lhs >> basic_vec(value_type(rhs)); }
570
571
574
576 friend constexpr basic_vec& operator<<=(basic_vec& lhs, const basic_vec& shift) noexcept
578 { lhs = lhs << shift; return lhs; }
579
581 friend constexpr basic_vec& operator>>=(basic_vec& lhs, const basic_vec& shift) noexcept
583 { lhs = lhs >> shift; return lhs; }
584
586 friend constexpr basic_vec& operator<<=(basic_vec& lhs, simd_size_type shift) noexcept
588 { lhs = lhs << shift; return lhs; }
589
591 friend constexpr basic_vec& operator>>=(basic_vec& lhs, simd_size_type shift) noexcept
593 { lhs = lhs >> shift; return lhs; }
594
596
599
602 constexpr real_type real() const noexcept requires (vec_complex<basic_vec>) {
603 const auto e = simd_bit_cast<typename _Tp::value_type>(*this);
604 return permute<size>(e, [](simd_size_type idx) { return idx * 2; });
605 };
606
609 constexpr real_type imag() const noexcept requires (vec_complex<basic_vec>) {
610 const auto e = simd_bit_cast<typename _Tp::value_type>(*this);
611 return permute<size>(e, [](simd_size_type idx) { return idx * 2 + 1; });
612 };
613
616 constexpr void real(const real_type& new_reals) noexcept requires detail::complex_number<_Tp>
617 { *this = basic_vec(new_reals, imag()); }
618
621 constexpr void imag(const real_type& new_imags) noexcept requires detail::complex_number<_Tp>
622 { *this = basic_vec(real(), new_imags); }
623
625
626#ifdef _XVEC_DEFINE_OUTPUT_OPERATORS
630 friend std::ostream &operator<<(std::ostream& stream, basic_vec value) {
631 // Note that the values are printed in reverse order to match dvec.
632 for (simd_size_type i = 0; i < basic_vec::size; ++i) {
633 const int ri = (basic_vec::size - 1) - i;
634 if (i > 0)
635 stream << ' ';
636 stream << '[' << ri << "]:" << value[ri];
637 }
638 return stream;
639 }
640#endif // _XVEC_DEFINE_OUTPUT_OPERATORS
641};
642
647template <typename _Span, class... Ts>
648requires (detail::span_extent_v<std::remove_cvref_t<_Span>>
649 <= detail::max_fixed_size<detail::span_element_type<std::remove_cvref_t<_Span>>>)
650basic_vec(_Span&&, Ts...)
652
653} // namespace _XVEC_NAMESPACE::simd
654
655#include <xvec/detail/named_permute.hpp>
656#include <xvec/detail/loadstore.hpp>
657#include <xvec/detail/invoke.hpp>
658#include <xvec/detail/permute.hpp>
659#include <xvec/detail/split_concat.hpp>
660#include <xvec/detail/std_algorithm.hpp>
661#include <xvec/detail/std_bit.hpp>
662#include <xvec/detail/std_math.hpp>
663#include <xvec/detail/std_complex.hpp>
664#include <xvec/detail/reduce.hpp>
665#include <xvec/detail/std_numeric.hpp>
666#include <xvec/detail/std_utility.hpp>
A mask containing boolean elements.
Definition mask.hpp:121
Vector of elements sharing an element type and ABI.
Definition simd:161
detail::vec_traits< target_tag, _Tp, _Abi::num_elements > traits
Definition simd:164
typename traits::register_type register_type
Definition simd:180
simd_iterator< basic_vec > iterator
Definition simd:169
std::conditional_t< vec_complex< basic_vec >, rebind_t< detail::complex_element_type< _Tp >, basic_vec >, struct invalid > real_type
Definition simd:173
constexpr basic_vec(const _Vp &v) noexcept
Convert a vector implicitly when its element conversion permits it.
Definition simd:304
xvec implementation of the exposition-only SIMD iterator.
Definition iterator.hpp:32
Detect whether a given type is std::complex.
Definition utilities.hpp:53
Definition core.hpp:62
Definition core.hpp:70
Definition core.hpp:65
Definition core.hpp:61
constexpr auto select(const _M &m, const _T &if_true, const _U &if_false) noexcept -> decltype(simd_select_impl(m, if_true, if_false))
Select between corresponding elements according to a mask.
Definition std_algorithm.hpp:88
friend constexpr basic_vec operator&(const basic_vec &lhs, const basic_vec &rhs) noexcept
Compute the bitwise AND of corresponding elements.
Definition simd:437
friend constexpr basic_vec operator/(const basic_vec &lhs, const basic_vec &rhs) noexcept
Divide corresponding elements.
Definition simd:429
friend constexpr basic_vec operator>>(const basic_vec &lhs, simd_size_type rhs) noexcept
Shift every element right by a shared amount.
Definition simd:568
friend constexpr basic_vec operator*(const basic_vec &lhs, const basic_vec &rhs) noexcept
Multiply corresponding elements.
Definition simd:425
friend constexpr basic_vec operator|(const basic_vec &lhs, const basic_vec &rhs) noexcept
Compute the bitwise OR of corresponding elements.
Definition simd:441
friend constexpr basic_vec operator+(const basic_vec &lhs, const basic_vec &rhs) noexcept
Add corresponding elements.
Definition simd:417
friend constexpr basic_vec operator<<(const basic_vec &lhs, const basic_vec &rhs) noexcept
Shift elements left by corresponding element-wise amounts.
Definition simd:556
friend constexpr basic_vec operator-(const basic_vec &lhs, const basic_vec &rhs) noexcept
Subtract corresponding elements.
Definition simd:421
friend constexpr basic_vec operator>>(const basic_vec &lhs, const basic_vec &rhs) noexcept
Shift elements right by corresponding element-wise amounts.
Definition simd:560
friend constexpr basic_vec operator%(const basic_vec &lhs, const basic_vec &rhs) noexcept
Compute the remainder for corresponding elements.
Definition simd:433
friend constexpr basic_vec operator<<(const basic_vec &lhs, simd_size_type rhs) noexcept
Shift every element left by a shared amount.
Definition simd:564
friend constexpr basic_vec operator^(const basic_vec &lhs, const basic_vec &rhs) noexcept
Compute the bitwise XOR of corresponding elements.
Definition simd:445
friend constexpr basic_vec & operator*=(basic_vec &lhs, const basic_vec &rhs) noexcept
Multiply corresponding elements and assign the result.
Definition simd:521
friend constexpr basic_vec & operator>>=(basic_vec &lhs, const basic_vec &shift) noexcept
Shift elements right by element-wise amounts and assign the result.
Definition simd:581
friend constexpr basic_vec & operator-=(basic_vec &lhs, const basic_vec &rhs) noexcept
Subtract corresponding elements and assign the result.
Definition simd:516
friend constexpr basic_vec & operator/=(basic_vec &lhs, const basic_vec &rhs) noexcept
Divide corresponding elements and assign the result.
Definition simd:526
friend constexpr basic_vec & operator>>=(basic_vec &lhs, simd_size_type shift) noexcept
Shift every element right by a shared amount and assign the result.
Definition simd:591
friend constexpr basic_vec & operator<<=(basic_vec &lhs, const basic_vec &shift) noexcept
Shift elements left by element-wise amounts and assign the result.
Definition simd:576
friend constexpr basic_vec & operator^=(basic_vec &lhs, const basic_vec &rhs) noexcept
Compute the element-wise bitwise XOR and assign the result.
Definition simd:546
friend constexpr basic_vec & operator%=(basic_vec &lhs, const basic_vec &rhs) noexcept
Compute element-wise remainders and assign the result.
Definition simd:531
friend constexpr basic_vec & operator<<=(basic_vec &lhs, simd_size_type shift) noexcept
Shift every element left by a shared amount and assign the result.
Definition simd:586
friend constexpr basic_vec & operator&=(basic_vec &lhs, const basic_vec &rhs) noexcept
Compute the element-wise bitwise AND and assign the result.
Definition simd:536
friend constexpr basic_vec & operator|=(basic_vec &lhs, const basic_vec &rhs) noexcept
Compute the element-wise bitwise OR and assign the result.
Definition simd:541
friend constexpr basic_vec & operator+=(basic_vec &lhs, const basic_vec &rhs) noexcept
Add corresponding elements and assign the result.
Definition simd:511
friend constexpr mask_type operator==(const basic_vec &lhs, const basic_vec &rhs) noexcept
Compare corresponding elements for equality.
Definition simd:476
friend constexpr mask_type operator<=(const basic_vec &lhs, const basic_vec &rhs) noexcept
Compare corresponding elements using less-than-or-equal.
Definition simd:491
friend constexpr mask_type operator!=(const basic_vec &lhs, const basic_vec &rhs) noexcept
Compare corresponding elements for inequality.
Definition simd:481
friend constexpr mask_type operator>=(const basic_vec &lhs, const basic_vec &rhs) noexcept
Compare corresponding elements using greater-than-or-equal.
Definition simd:501
constexpr real_type real() const noexcept
Return the real components of the complex elements.
Definition simd:602
constexpr void imag(const real_type &new_imags) noexcept
Replace the imaginary component of each complex element.
Definition simd:621
constexpr real_type imag() const noexcept
Return the imaginary components of the complex elements.
Definition simd:609
constexpr void real(const real_type &new_reals) noexcept
Replace the real component of each complex element.
Definition simd:616
friend constexpr basic_vec simd_select_impl(const mask_type &m, const basic_vec &if_true, const basic_vec &if_false) noexcept
Implementation of element-wise vector selection.
Definition simd:371
constexpr basic_vec(detail::generator_invocable< value_type, size > auto &&fn)
Construct a vector by generating each element from its index.
Definition simd:310
constexpr basic_vec(_Up &&v) noexcept
Create a basic_vec value in which every element is set to the single value provided.
Definition simd:272
constexpr basic_vec(const _Vp &v) noexcept
Explicitly convert a vector with the same number of elements. Both element types must be complex or n...
Definition simd:294
constexpr 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....
Definition simd:245
constexpr 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 t...
Definition simd:279
constexpr basic_vec(const _InputSpan &in_span, const mask_type &m, flags< _Flags... > f={})
Construct a vector from selected elements of a span-like object.
Definition simd:261
constexpr std::default_sentinel_t cend() const noexcept
Return the end sentinel.
Definition simd:330
constexpr const_iterator begin() const noexcept
Return a const iterator to the first element.
Definition simd:321
constexpr const_iterator cbegin() const noexcept
Return a const iterator to the first element.
Definition simd:324
constexpr iterator begin() noexcept
Return an iterator to the first element.
Definition simd:318
constexpr std::default_sentinel_t end() const noexcept
Return the end sentinel.
Definition simd:327
constexpr auto permute(const _Vp &v, detail::index_generator_function auto &&fn)
Permute the elements in a vec value using a generator function to compute the indexing.
Definition permute.hpp:94
constexpr auto operator[](const vec_integral auto &indexes) const
Select vector elements using an integral index vector.
Definition simd:364
constexpr value_type operator[](simd_size_type pos) const
Access the element at the specified position.
Definition simd:359
constexpr basic_vec & operator--() noexcept
Decrement each element and return the updated vector.
Definition simd:404
constexpr mask_type operator!() const noexcept
Apply logical not to each vector element to produce a mask.
Definition simd:378
constexpr basic_vec operator--(int) noexcept
Decrement each element and return the original vector.
Definition simd:408
constexpr basic_vec operator+() const noexcept
Return a copy of the vector.
Definition simd:393
constexpr basic_vec operator++(int) noexcept
Increment each element and return the original vector.
Definition simd:400
constexpr basic_vec operator-() const noexcept
Negate each vector element.
Definition simd:388
constexpr basic_vec & operator++() noexcept
Increment each element and return the updated vector.
Definition simd:396
constexpr basic_vec operator~() const noexcept
Apply bitwise not to each vector element.
Definition simd:383
constexpr auto zip(const _Sps &...simds)
Definition named_permute.hpp:283
static constexpr basic_vec from_builtin(const builtin_type &v) noexcept
Construct a vector from its builtin representation.
Definition simd:350
constexpr builtin_type to_builtin() const
Return the builtin value.
Definition simd:347
constexpr traits::register_type to_register() const
Definition simd:344
constexpr basic_vec(register_type r) noexcept
Definition simd:227
friend constexpr basic_vec operator*(const basic_vec &lhs, const detail::complex_element_type< _Tp > &rhs) noexcept
Multiply each complex element by a real scalar.
Definition simd:454
friend constexpr basic_vec & operator*=(basic_vec &lhs, const detail::complex_element_type< _Tp > &rhs) noexcept
Multiply each complex element by a real scalar and assign the result.
Definition simd:467
constexpr auto simd_bit_cast(const _From &v) noexcept
A simd-generic version of simd_bit_cast which directly invokes std::bit_cast.
Definition core.hpp:585
friend constexpr basic_vec operator*(const detail::complex_element_type< _Tp > &lhs, const basic_vec &rhs) noexcept
Multiply a real scalar by each complex element.
Definition simd:462
Detect a scoped enum. This will be provided in C++23 onwards.
Definition compat.hpp:27
constexpr auto do_operator(const _Vp &first, const _Vps &... rest) noexcept
Definition operators.hpp:136
constexpr _To convert_operator(const _From &v) noexcept
Conversion operator for basic_vec. All gate-keeping has been done, just do the convert.
Definition operators.hpp:163
Definition core.hpp:451
decltype(detail::get_register_type< builtin_type >()) register_type
Definition core.hpp:474
static constexpr register_type to_register(builtin_type v)
Definition core.hpp:488
Definition core.hpp:393
An implementation ABI type which is used to specify a simd::vec with a fixed number of elements.
Definition core.hpp:34