From Jason Turner

[linalg.scaled.intro]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpo6np09f9/{from.md → to.md} +24 -0
tmp/tmpo6np09f9/{from.md → to.md} RENAMED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Introduction <a id="linalg.scaled.intro">[[linalg.scaled.intro]]</a>
2
+
3
+ The `scaled` function takes a value `alpha` and an `mdspan` `x`, and
4
+ returns a new read-only `mdspan` that represents the elementwise product
5
+ of `alpha` with each element of `x`.
6
+
7
+ [*Example 1*:
8
+
9
+ ``` cpp
10
+ using Vec = mdspan<double, dextents<size_t, 1>>;
11
+
12
+ // z = alpha * x + y
13
+ void z_equals_alpha_times_x_plus_y(double alpha, Vec x, Vec y, Vec z) {
14
+ add(scaled(alpha, x), y, z);
15
+ }
16
+
17
+ // z = alpha * x + beta * y
18
+ void z_equals_alpha_times_x_plus_beta_times_y(double alpha, Vec x, double beta, Vec y, Vec z) {
19
+ add(scaled(alpha, x), scaled(beta, y), z);
20
+ }
21
+ ```
22
+
23
+ — *end example*]
24
+