This commit is contained in:
2025-10-25 03:02:53 +03:00
commit 043225d523
3416 changed files with 681196 additions and 0 deletions

258
cppdraft/simd/ctor.md Normal file
View File

@@ -0,0 +1,258 @@
[simd.ctor]
# 29 Numerics library [[numerics]](./#numerics)
## 29.10 Data-parallel types [[simd]](simd#ctor)
### 29.10.7 Class template basic_vec [[simd.class]](simd.class#simd.ctor)
#### 29.10.7.2 basic_vec constructors [simd.ctor]
[🔗](#lib:basic_vec,constructor)
`template<class U> constexpr explicit(see below) basic_vec(U&& value) noexcept;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17699)
Let From denote the type remove_cvref_t<U>[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17702)
*Constraints*: value_type satisfies [constructible_from](concept.constructible#concept:constructible_from "18.4.11Concept constructible_­from[concept.constructible]")<U>[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17706)
*Effects*: Initializes each element to the value of the argument after conversion tovalue_type[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17711)
*Remarks*: The expression inside explicit evaluates to false if and only ifU satisfies [convertible_to](concept.convertible#concept:convertible_to "18.4.4Concept convertible_­to[concept.convertible]")<value_type>, and either
- [(4.1)](#4.1)
From is not an arithmetic type and does not satisfy [*constexpr-wrapper-like*](simd.expos#concept:constexpr-wrapper-like "29.10.2Exposition-only types, variables, and concepts[simd.expos]"),
- [(4.2)](#4.2)
From is an arithmetic type and the conversion from From to value_type is value-preserving ([[simd.general]](simd.general "29.10.1General")), or
- [(4.3)](#4.3)
From satisfies [*constexpr-wrapper-like*](simd.expos#concept:constexpr-wrapper-like "29.10.2Exposition-only types, variables, and concepts[simd.expos]"), remove_const_t<decltype(From::value)> is an arithmetic type, and From::value is representable by value_type[.](#4.sentence-1)
[🔗](#lib:basic_vec,constructor_)
`template<class U, class UAbi>
constexpr explicit(see below) basic_vec(const basic_vec<U, UAbi>& x) noexcept;
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17736)
*Constraints*: *simd-size-v*<U, UAbi> == size() is true[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17740)
*Effects*: Initializes the ith element with static_cast<T>(x[i]) for
all i in the range of [0, size())[.](#6.sentence-1)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17745)
*Remarks*: The expression inside explicit evaluates to true if either
- [(7.1)](#7.1)
the conversion from U to value_type is not value-preserving,
or
- [(7.2)](#7.2)
both U and value_type are integral types and the integer
conversion rank ([[conv.rank]](conv.rank "6.9.6Conversion ranks")) of U is greater than the integer
conversion rank of value_type, or
- [(7.3)](#7.3)
both U and value_type are floating-point types and the
floating-point conversion rank ([[conv.rank]](conv.rank "6.9.6Conversion ranks")) of U is greater than
the floating-point conversion rank of value_type[.](#7.sentence-1)
[🔗](#lib:basic_vec,constructor__)
`template<class G> constexpr explicit basic_vec(G&& gen);
`
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17769)
Let Fromi denote the typedecltype(gen(integral_constant<*simd-size-type*, i>()))[.](#8.sentence-1)
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17773)
*Constraints*: Fromi satisfies [convertible_to](concept.convertible#concept:convertible_to "18.4.4Concept convertible_­to[concept.convertible]")<value_type> for all i in
the range of [0, size())[.](#9.sentence-1)
In addition, for all i in the range of [0, size()), if Fromi is an arithmetic type, conversion from Fromi to value_type is value-preserving[.](#9.sentence-2)
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17781)
*Effects*: Initializes the ith element withstatic_cast<value_type>(gen(integral_constant<*simd-size-type*,
i>())) for all i in the range of [0, size())[.](#10.sentence-1)
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17787)
*Remarks*: gen is invoked exactly once for each i, in increasing order of i[.](#11.sentence-1)
[🔗](#lib:basic_vec,constructor___)
`template<class R, class... Flags>
constexpr basic_vec(R&& r, flags<Flags...> = {});
template<class R, class... Flags>
constexpr basic_vec(R&& r, const mask_type& mask, flags<Flags...> = {});
`
[12](#12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17801)
Let mask be mask_type(true) for the overload with nomask parameter[.](#12.sentence-1)
[13](#13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17805)
*Constraints*:
- [(13.1)](#13.1)
R models ranges::[contiguous_range](range.refinements#concept:contiguous_range "25.4.6Other range refinements[range.refinements]") and ranges::[sized_range](range.sized#concept:sized_range "25.4.4Sized ranges[range.sized]"),
- [(13.2)](#13.2)
ranges::size(r) is a constant expression, and
- [(13.3)](#13.3)
ranges::size(r) is equal to size()[.](#13.sentence-1)
[14](#14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17814)
*Mandates*:
- [(14.1)](#14.1)
ranges::range_value_t<R> is a vectorizable type, and
- [(14.2)](#14.2)
if the template parameter pack Flags does not contain *convert-flag*, then the conversion from ranges::range_value_t<R> to value_type is value-preserving[.](#14.sentence-1)
[15](#15)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17825)
*Preconditions*:
- [(15.1)](#15.1)
If the template parameter pack Flags contains *aligned-flag*, ranges::data(r) points to
storage aligned by alignment_v<basic_vec,
ranges::range_value_t<R>>[.](#15.1.sentence-1)
- [(15.2)](#15.2)
If the template parameter pack Flags contains *overaligned-flag*<N>, ranges::data(r) points to
storage aligned by N[.](#15.2.sentence-1)
[16](#16)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17839)
*Effects*: Initializes the ith element with mask[i] ?static_cast<T>(ranges::data(r)[i]) : T() for all i in the
range of [0, size())[.](#16.sentence-1)
[🔗](#itemdecl:5)
`template<class R, class... Ts>
basic_vec(R&& r, Ts...) -> see below;
`
[17](#17)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17852)
*Constraints*:
- [(17.1)](#17.1)
R models ranges::[contiguous_range](range.refinements#concept:contiguous_range "25.4.6Other range refinements[range.refinements]") and ranges::[sized_range](range.sized#concept:sized_range "25.4.4Sized ranges[range.sized]"), and
- [(17.2)](#17.2)
ranges::size(r) is a constant expression[.](#17.sentence-1)
[18](#18)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17860)
*Remarks*: The deduced type is equivalent to vec<ranges::range_value_t<R>,
ranges::size(r)>[.](#18.sentence-1)
[🔗](#lib:basic_vec,constructor____)
`template<[simd-floating-point](simd.expos#concept:simd-floating-point "29.10.2Exposition-only types, variables, and concepts[simd.expos]") V>
constexpr explicit(see below)
basic_vec(const V& reals, const V& imags = {}) noexcept;
`
[19](#19)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17874)
*Constraints*:
- [(19.1)](#19.1)
[*simd-complex*](simd.expos#concept:simd-complex "29.10.2Exposition-only types, variables, and concepts[simd.expos]")<basic_vec> is modeled, and
- [(19.2)](#19.2)
V::size() == size() is true[.](#19.sentence-1)
[20](#20)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17883)
*Effects*: Initializes the ith element with value_type(reals[i],
imags[i]) for all i in the range [0, size())[.](#20.sentence-1)
[21](#21)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L17888)
*Remarks*: The expression inside explicit evaluates to false if and only
if the floating-point conversion rank of T::value_type is greater than
or equal to the floating-point conversion rank of V::value_type[.](#21.sentence-1)