tmp/tmphqnv6j5r/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### Euclidean norm of a vector <a id="linalg.algs.blas1.nrm2">[[linalg.algs.blas1.nrm2]]</a>
|
| 2 |
+
|
| 3 |
+
``` cpp
|
| 4 |
+
template<in-vector InVec, class Scalar>
|
| 5 |
+
Scalar vector_two_norm(InVec v, Scalar init);
|
| 6 |
+
template<class ExecutionPolicy, in-vector InVec, class Scalar>
|
| 7 |
+
Scalar vector_two_norm(ExecutionPolicy&& exec, InVec v, Scalar init);
|
| 8 |
+
```
|
| 9 |
+
|
| 10 |
+
[*Note 1*: These functions correspond to the BLAS function
|
| 11 |
+
`xNRM2`. — *end note*]
|
| 12 |
+
|
| 13 |
+
*Mandates:* Let `a` be
|
| 14 |
+
*`abs-if-needed`*`(declval<typename InVec::value_type>())`. Then,
|
| 15 |
+
`decltype(init + a * a` is convertible to `Scalar`.
|
| 16 |
+
|
| 17 |
+
*Returns:* The square root of the sum of the square of `init` and the
|
| 18 |
+
squares of the absolute values of the elements of `v`.
|
| 19 |
+
|
| 20 |
+
[*Note 2*: For `init` equal to zero, this is the Euclidean norm (also
|
| 21 |
+
called 2-norm) of the vector `v`. — *end note*]
|
| 22 |
+
|
| 23 |
+
*Remarks:* If `InVec::value_type`, and `Scalar` are all floating-point
|
| 24 |
+
types or specializations of `complex`, and if `Scalar` has higher
|
| 25 |
+
precision than `InVec::value_type`, then intermediate terms in the sum
|
| 26 |
+
use `Scalar`’s precision or greater.
|
| 27 |
+
|
| 28 |
+
[*Note 3*: An implementation of this function for floating-point types
|
| 29 |
+
`T` can use the `scaled_sum_of_squares` result from
|
| 30 |
+
`vector_sum_of_squares(x, {.scaling_factor=1.0, .scaled_sum_of_squares=init})`. — *end note*]
|
| 31 |
+
|
| 32 |
+
``` cpp
|
| 33 |
+
template<in-vector InVec>
|
| 34 |
+
auto vector_two_norm(InVec v);
|
| 35 |
+
template<class ExecutionPolicy, in-vector InVec>
|
| 36 |
+
auto vector_two_norm(ExecutionPolicy&& exec, InVec v);
|
| 37 |
+
```
|
| 38 |
+
|
| 39 |
+
*Effects:* Let `a` be
|
| 40 |
+
*`abs-if-needed`*`(declval<typename InVec::value_type>())`. Let `T` be
|
| 41 |
+
`decltype(a * a)`. Then,
|
| 42 |
+
|
| 43 |
+
- the one-parameter overload is equivalent to:
|
| 44 |
+
``` cpp
|
| 45 |
+
return vector_two_norm(v, T{});
|
| 46 |
+
```
|
| 47 |
+
|
| 48 |
+
and
|
| 49 |
+
- the two-parameter overload is equivalent to:
|
| 50 |
+
``` cpp
|
| 51 |
+
return vector_two_norm(std::forward<ExecutionPolicy>(exec), v, T{});
|
| 52 |
+
```
|
| 53 |
+
|