From Jason Turner

[linalg.algs.blas1.asum]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpisawm1et/{from.md → to.md} +61 -0
tmp/tmpisawm1et/{from.md → to.md} RENAMED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Sum of absolute values of vector elements <a id="linalg.algs.blas1.asum">[[linalg.algs.blas1.asum]]</a>
2
+
3
+ ``` cpp
4
+ template<in-vector InVec, class Scalar>
5
+ Scalar vector_abs_sum(InVec v, Scalar init);
6
+ template<class ExecutionPolicy, in-vector InVec, class Scalar>
7
+ Scalar vector_abs_sum(ExecutionPolicy&& exec, InVec v, Scalar init);
8
+ ```
9
+
10
+ [*Note 1*: These functions correspond to the BLAS functions `SASUM`,
11
+ `DASUM`, `SCASUM`, and `DZASUM`. — *end note*]
12
+
13
+ *Mandates:*
14
+
15
+ ``` cpp
16
+ decltype(init + abs-if-needed(real-if-needed(declval<typename InVec::value_type>())) +
17
+ abs-if-needed(imag-if-needed(declval<typename InVec::value_type>())))
18
+ ```
19
+
20
+ is convertible to `Scalar`.
21
+
22
+ *Returns:* Let `N` be `v.extent(0)`.
23
+
24
+ - `init` if `N` is zero;
25
+ - otherwise, if `InVec::value_type` is an arithmetic type,
26
+ ``` cpp
27
+ GENERALIZED_SUM(plus<>(), init, abs-if-needed(v[0]), …, abs-if-needed(v[N-1]))
28
+ ```
29
+ - otherwise,
30
+ ``` cpp
31
+ GENERALIZED_SUM(plus<>(), init,
32
+ abs-if-needed(real-if-needed(v[0])) + abs-if-needed(imag-if-needed(v[0])),
33
+ …,
34
+ abs-if-needed(real-if-needed(v[N-1])) + abs-if-needed(imag-if-needed(v[N-1])))
35
+ ```
36
+
37
+ *Remarks:* If `InVec::value_type` and `Scalar` are all floating-point
38
+ types or specializations of `complex`, and if `Scalar` has higher
39
+ precision than `InVec::value_type`, then intermediate terms in the sum
40
+ use `Scalar`’s precision or greater.
41
+
42
+ ``` cpp
43
+ template<in-vector InVec>
44
+ auto vector_abs_sum(InVec v);
45
+ template<class ExecutionPolicy, in-vector InVec>
46
+ auto vector_abs_sum(ExecutionPolicy&& exec, InVec v);
47
+ ```
48
+
49
+ *Effects:* Let `T` be `typename InVec::value_type`. Then,
50
+
51
+ - the one-parameter overload is equivalent to:
52
+ ``` cpp
53
+ return vector_abs_sum(v, T{});
54
+ ```
55
+
56
+ and
57
+ - the two-parameter overload is equivalent to:
58
+ ``` cpp
59
+ return vector_abs_sum(std::forward<ExecutionPolicy>(exec), v, T{});
60
+ ```
61
+