From Jason Turner

[linalg.scaled.scaled]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp9qs17krf/{from.md → to.md} +36 -0
tmp/tmp9qs17krf/{from.md → to.md} RENAMED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Function template `scaled` <a id="linalg.scaled.scaled">[[linalg.scaled.scaled]]</a>
2
+
3
+ The `scaled` function template takes a scaling factor `alpha` and an
4
+ `mdspan` `x`, and returns a new read-only `mdspan` with the same domain
5
+ as `x`, that represents the elementwise product of `alpha` with each
6
+ element of `x`.
7
+
8
+ ``` cpp
9
+ template<class ScalingFactor,
10
+ class ElementType, class Extents, class Layout, class Accessor>
11
+ constexpr auto scaled(ScalingFactor alpha, mdspan<ElementType, Extents, Layout, Accessor> x);
12
+ ```
13
+
14
+ Let `SA` be `scaled_accessor<ScalingFactor, Accessor>`.
15
+
16
+ *Returns:*
17
+
18
+ ``` cpp
19
+ mdspan<typename SA::element_type, Extents, Layout, SA>(x.data_handle(), x.mapping(),
20
+ SA(alpha, x.accessor()))
21
+ ```
22
+
23
+ [*Example 1*:
24
+
25
+ ``` cpp
26
+ void test_scaled(mdspan<double, extents<int, 10>> x)
27
+ {
28
+ auto x_scaled = scaled(5.0, x);
29
+ for (int i = 0; i < x.extent(0); ++i) {
30
+ assert(x_scaled[i] == 5.0 * x[i]);
31
+ }
32
+ }
33
+ ```
34
+
35
+ — *end example*]
36
+