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

View File

@@ -0,0 +1,62 @@
[linalg.conj.conjugated]
# 29 Numerics library [[numerics]](./#numerics)
## 29.9 Basic linear algebra algorithms [[linalg]](linalg#conj.conjugated)
### 29.9.9 Conjugated in-place transformation [[linalg.conj]](linalg.conj#conjugated)
#### 29.9.9.3 Function template conjugated [linalg.conj.conjugated]
[🔗](#itemdecl:1)
` template<class ElementType, class Extents, class Layout, class Accessor>
constexpr auto [conjugated](#lib:conjugated "29.9.9.3Function template conjugated[linalg.conj.conjugated]")(mdspan<ElementType, Extents, Layout, Accessor> a);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L12875)
Let A be
- [(1.1)](#1.1)
remove_cvref_t<decltype(a.accessor().nested_accessor())> if Accessor is a specialization of conjugated_accessor;
- [(1.2)](#1.2)
otherwise,Accessor if remove_cvref_t<ElementType> is an arithmetic type;
- [(1.3)](#1.3)
otherwise,conjugated_accessor<Accessor> if the expression conj(E) is valid for any subexpression E whose type is remove_cvref_t<ElementType> with overload resolution performed in a context that includes the declarationtemplate<class U> U conj(const U&) = delete;;
- [(1.4)](#1.4)
otherwise,Accessor[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L12896)
*Returns*: Let MD be mdspan<typename A::element_type, Extents, Layout, A>[.](#2.sentence-1)
- [(2.1)](#2.1)
MD(a.data_handle(), a.mapping(), a.accessor().nested_accessor()) if Accessor is a
specialization of conjugated_accessor;
- [(2.2)](#2.2)
otherwise,a, if is_same_v<A, Accessor> is true;
- [(2.3)](#2.3)
otherwise,MD(a.data_handle(), a.mapping(), conjugated_accessor(a.accessor())).
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L12912)
[*Example [1](#example-1)*: void test_conjugated_complex(mdspan<complex<double>, extents<int, 10>> a) {auto a_conj = conjugated(a); for (int i = 0; i < a.extent(0); ++i) { assert(a_conj[i] == conj(a[i]); }auto a_conj_conj = conjugated(a_conj); for (int i = 0; i < a.extent(0); ++i) { assert(a_conj_conj[i] == a[i]); }}void test_conjugated_real(mdspan<double, extents<int, 10>> a) {auto a_conj = conjugated(a); for (int i = 0; i < a.extent(0); ++i) { assert(a_conj[i] == a[i]); }auto a_conj_conj = conjugated(a_conj); for (int i = 0; i < a.extent(0); ++i) { assert(a_conj_conj[i] == a[i]); }} — *end example*]

View File

@@ -0,0 +1,95 @@
[linalg.conj.conjugatedaccessor]
# 29 Numerics library [[numerics]](./#numerics)
## 29.9 Basic linear algebra algorithms [[linalg]](linalg#conj.conjugatedaccessor)
### 29.9.9 Conjugated in-place transformation [[linalg.conj]](linalg.conj#conjugatedaccessor)
#### 29.9.9.2 Class template conjugated_accessor [linalg.conj.conjugatedaccessor]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L12765)
The class template conjugated_accessor is an mdspan accessor policy
which upon access produces conjugate elements[.](#1.sentence-1)
It is part of the implementation ofconjugated ([[linalg.conj.conjugated]](linalg.conj.conjugated "29.9.9.3Function template conjugated"))[.](#1.sentence-2)
namespace std::linalg {template<class NestedAccessor>class [conjugated_accessor](#lib:conjugated_accessor "29.9.9.2Class template conjugated_­accessor[linalg.conj.conjugatedaccessor]") {public:using element_type = add_const_t<decltype(*conj-if-needed*(declval<NestedAccessor::element_type>()))>; using reference = remove_const_t<element_type>; using data_handle_type = typename NestedAccessor::data_handle_type; using offset_policy = conjugated_accessor<NestedAccessor::offset_policy>; constexpr conjugated_accessor() = default; template<class OtherNestedAccessor>explicit(!is_convertible_v<OtherNestedAccessor, NestedAccessor>>)constexpr conjugated_accessor(const conjugated_accessor<OtherNestedAccessor>& other); constexpr reference access(data_handle_type p, size_t i) const; constexpr typename offset_policy::data_handle_type
offset(data_handle_type p, size_t i) const; constexpr const NestedAccessor& nested_accessor() const noexcept { return *nested-accessor_*; }private: NestedAccessor *nested-accessor_*{}; // *exposition only*};}
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L12801)
*Mandates*:
- [(2.1)](#2.1)
element_type is valid and denotes a type,
- [(2.2)](#2.2)
is_copy_constructible_v<reference> is true,
- [(2.3)](#2.3)
is_reference_v<element_type> is false, and
- [(2.4)](#2.4)
NestedAccessor meets the accessor policy requirements ([[mdspan.accessor.reqmts]](mdspan.accessor.reqmts "23.7.3.5.2Requirements"))[.](#2.sentence-1)
[🔗](#lib:conjugated_accessor,constructor)
`constexpr conjugated_accessor(const NestedAccessor& acc);
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L12820)
*Effects*: Direct-non-list-initializes*nested-accessor_* with acc[.](#3.sentence-1)
[🔗](#lib:conjugated_accessor,constructor_)
`template<class OtherNestedAccessor>
explicit(!is_convertible_v<OtherNestedAccessor, NestedAccessor>>)
constexpr conjugated_accessor(const conjugated_accessor<OtherNestedAccessor>& other);
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L12834)
*Constraints*: is_constructible_v<NestedAccessor, const OtherNestedAccessor&> is true[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L12839)
*Effects*: Direct-non-list-initializes *nested-accessor_* with other.nested_accessor()[.](#5.sentence-1)
[🔗](#lib:conjugated_accessor,access)
`constexpr reference access(data_handle_type p, size_t i) const;
`
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L12851)
*Returns*: *conj-if-needed*(NestedAccessor::element_type(*nested-accessor_*.access(p, i)))
[🔗](#lib:conjugated_accessor,offset)
`constexpr typename offset_policy::data_handle_type offset(data_handle_type p, size_t i) const;
`
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L12862)
*Returns*: *nested-accessor_*.offset(p, i)

View File

@@ -0,0 +1,18 @@
[linalg.conj.intro]
# 29 Numerics library [[numerics]](./#numerics)
## 29.9 Basic linear algebra algorithms [[linalg]](linalg#conj.intro)
### 29.9.9 Conjugated in-place transformation [[linalg.conj]](linalg.conj#intro)
#### 29.9.9.1 Introduction [linalg.conj.intro]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L12756)
The conjugated function takes an mdspan x,
and returns a new read-only mdspan y with the same domain as x,
whose elements are the complex conjugates
of the corresponding elements of x[.](#1.sentence-1)