From Jason Turner

[linalg.conj.conjugated]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp3jr5qi82/{from.md → to.md} +57 -0
tmp/tmp3jr5qi82/{from.md → to.md} RENAMED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Function template `conjugated` <a id="linalg.conj.conjugated">[[linalg.conj.conjugated]]</a>
2
+
3
+ ``` cpp
4
+ template<class ElementType, class Extents, class Layout, class Accessor>
5
+ constexpr auto conjugated(mdspan<ElementType, Extents, Layout, Accessor> a);
6
+ ```
7
+
8
+ Let `A` be
9
+
10
+ - `remove_cvref_t<decltype(a.accessor().nested_accessor())>` if
11
+ `Accessor` is a specialization of `conjugated_accessor`;
12
+ - otherwise, `Accessor` if `remove_cvref_t<ElementType>` is an
13
+ arithmetic type;
14
+ - otherwise, `conjugated_accessor<Accessor>` if the expression `conj(E)`
15
+ is valid for any subexpression `E` whose type is
16
+ `remove_cvref_t<ElementType>` with overload resolution performed in a
17
+ context that includes the declaration
18
+ `template<class U> U conj(const U&) = delete;`;
19
+ - otherwise, `Accessor`.
20
+
21
+ *Returns:* Let `MD` be
22
+ `mdspan<typename A::element_type, Extents, Layout, A>`.
23
+
24
+ - `MD(a.data_handle(), a.mapping(), a.accessor().nested_accessor())` if
25
+ `Accessor` is a specialization of `conjugated_accessor`;
26
+ - otherwise, `a`, if `is_same_v<A, Accessor>` is `true`;
27
+ - otherwise,
28
+ `MD(a.data_handle(), a.mapping(), conjugated_accessor(a.accessor()))`.
29
+
30
+ [*Example 1*:
31
+
32
+ ``` cpp
33
+ void test_conjugated_complex(mdspan<complex<double>, extents<int, 10>> a) {
34
+ auto a_conj = conjugated(a);
35
+ for (int i = 0; i < a.extent(0); ++i) {
36
+ assert(a_conj[i] == conj(a[i]);
37
+ }
38
+ auto a_conj_conj = conjugated(a_conj);
39
+ for (int i = 0; i < a.extent(0); ++i) {
40
+ assert(a_conj_conj[i] == a[i]);
41
+ }
42
+ }
43
+
44
+ void test_conjugated_real(mdspan<double, extents<int, 10>> a) {
45
+ auto a_conj = conjugated(a);
46
+ for (int i = 0; i < a.extent(0); ++i) {
47
+ assert(a_conj[i] == a[i]);
48
+ }
49
+ auto a_conj_conj = conjugated(a_conj);
50
+ for (int i = 0; i < a.extent(0); ++i) {
51
+ assert(a_conj_conj[i] == a[i]);
52
+ }
53
+ }
54
+ ```
55
+
56
+ — *end example*]
57
+