From Jason Turner

[linalg.scaled.scaledaccessor]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpr762_l2a/{from.md → to.md} +88 -0
tmp/tmpr762_l2a/{from.md → to.md} RENAMED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Class template `scaled_accessor` <a id="linalg.scaled.scaledaccessor">[[linalg.scaled.scaledaccessor]]</a>
2
+
3
+ The class template `scaled_accessor` is an `mdspan` accessor policy
4
+ which upon access produces scaled elements. It is part of the
5
+ implementation of `scaled` [[linalg.scaled.scaled]].
6
+
7
+ ``` cpp
8
+ namespace std::linalg {
9
+ template<class ScalingFactor, class NestedAccessor>
10
+ class scaled_accessor {
11
+ public:
12
+ using element_type =
13
+ const decltype(declval<ScalingFactor>() * declval<NestedAccessor::element_type>());
14
+ using reference = remove_const_t<element_type>;
15
+ using data_handle_type = NestedAccessor::data_handle_type;
16
+ using offset_policy = scaled_accessor<ScalingFactor, NestedAccessor::offset_policy>;
17
+
18
+ constexpr scaled_accessor() = default;
19
+ template<class OtherNestedAccessor>
20
+ explicit(!is_convertible_v<OtherNestedAccessor, NestedAccessor>)
21
+ constexpr scaled_accessor(const scaled_accessor<ScalingFactor,
22
+ OtherNestedAccessor>& other);
23
+ constexpr scaled_accessor(const ScalingFactor& s, const NestedAccessor& a);
24
+
25
+ constexpr reference access(data_handle_type p, size_t i) const;
26
+ constexpr offset_policy::data_handle_type offset(data_handle_type p, size_t i) const;
27
+
28
+ constexpr const ScalingFactor& scaling_factor() const noexcept { return scaling-factor; }
29
+ constexpr const NestedAccessor& nested_accessor() const noexcept { return nested-accessor; }
30
+
31
+ private:
32
+ ScalingFactor scaling-factor{}; // exposition only
33
+ NestedAccessor nested-accessor{}; // exposition only
34
+ };
35
+ }
36
+ ```
37
+
38
+ *Mandates:*
39
+
40
+ - `element_type` is valid and denotes a type,
41
+ - `is_copy_constructible_v<reference>` is `true`,
42
+ - `is_reference_v<element_type>` is `false`,
43
+ - `ScalingFactor` models `semiregular`, and
44
+ - `NestedAccessor` meets the accessor policy requirements
45
+ [[mdspan.accessor.reqmts]].
46
+
47
+ ``` cpp
48
+ template<class OtherNestedAccessor>
49
+ explicit(!is_convertible_v<OtherNestedAccessor, NestedAccessor>)
50
+ constexpr scaled_accessor(const scaled_accessor<ScalingFactor, OtherNestedAccessor>& other);
51
+ ```
52
+
53
+ *Constraints:*
54
+ `is_constructible_v<NestedAccessor, const OtherNestedAccessor&>` is
55
+ `true`.
56
+
57
+ *Effects:*
58
+
59
+ - Direct-non-list-initializes *scaling-factor* with
60
+ `other.scaling_factor()`, and
61
+ - direct-non-list-initializes *nested-accessor* with
62
+ `other.nested_accessor()`.
63
+
64
+ ``` cpp
65
+ constexpr scaled_accessor(const ScalingFactor& s, const NestedAccessor& a);
66
+ ```
67
+
68
+ *Effects:*
69
+
70
+ - Direct-non-list-initializes *scaling-factor* with `s`, and
71
+ - direct-non-list-initializes *nested-accessor* with `a`.
72
+
73
+ ``` cpp
74
+ constexpr reference access(data_handle_type p, size_t i) const;
75
+ ```
76
+
77
+ *Returns:*
78
+
79
+ ``` cpp
80
+ scaling_factor() * NestedAccessor::element_type(nested-accessor.access(p, i))
81
+ ```
82
+
83
+ ``` cpp
84
+ constexpr offset_policy::data_handle_type offset(data_handle_type p, size_t i) const;
85
+ ```
86
+
87
+ *Returns:* *`nested-accessor`*`.offset(p, i)`
88
+