tmp/tmpmqvu9k9c/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
### General <a id="linalg.general">[[linalg.general]]</a>
|
| 2 |
+
|
| 3 |
+
For the effects of all functions in [[linalg]], when the effects are
|
| 4 |
+
described as “computes R = E” or “compute R = E” (for some R and
|
| 5 |
+
mathematical expression E), the following apply:
|
| 6 |
+
|
| 7 |
+
- E has the conventional mathematical meaning as written.
|
| 8 |
+
- The pattern $x^T$ should be read as “the transpose of x.”
|
| 9 |
+
- The pattern $x^H$ should be read as “the conjugate transpose of x.”
|
| 10 |
+
- When R is the same name as a function parameter whose type is a
|
| 11 |
+
template parameter with `Out` in its name, the intent is that the
|
| 12 |
+
result of the computation is written to the elements of the function
|
| 13 |
+
parameter `R`.
|
| 14 |
+
|
| 15 |
+
Some of the functions and types in [[linalg]] distinguish between the
|
| 16 |
+
“rows” and the “columns” of a matrix. For a matrix `A` and a
|
| 17 |
+
multidimensional index `i, j` in `A.extents()`,
|
| 18 |
+
|
| 19 |
+
- *row* `i` of `A` is the set of elements `A[i, k1]` for all `k1` such
|
| 20 |
+
that `i, k1` is in `A.extents()`; and
|
| 21 |
+
- *column* `j` of `A` is the set of elements `A[k0, j]` for all `k0`
|
| 22 |
+
such that `k0, j` is in `A.extents()`.
|
| 23 |
+
|
| 24 |
+
Some of the functions in [[linalg]] distinguish between the “upper
|
| 25 |
+
triangle,” “lower triangle,” and “diagonal” of a matrix.
|
| 26 |
+
|
| 27 |
+
- The *diagonal* is the set of all elements of `A` accessed by `A[i,i]`
|
| 28 |
+
for 0 ≤ `i` \< min(`A.extent(0)`, `A.extent(1)`).
|
| 29 |
+
- The *upper triangle* of a matrix `A` is the set of all elements of `A`
|
| 30 |
+
accessed by `A[i,j]` with `i` ≤ `j`. It includes the diagonal.
|
| 31 |
+
- The *lower triangle* of `A` is the set of all elements of `A` accessed
|
| 32 |
+
by `A[i,j]` with `i` ≥ `j`. It includes the diagonal.
|
| 33 |
+
|
| 34 |
+
For any function `F` that takes a parameter named `t`, `t` applies to
|
| 35 |
+
accesses done through the parameter preceding `t` in the parameter list
|
| 36 |
+
of `F`. Let `m` be such an access-modified function parameter. `F` will
|
| 37 |
+
only access the triangle of `m` specified by `t`. For accesses `m[i, j]`
|
| 38 |
+
outside the triangle specified by `t`, `F` will use the value
|
| 39 |
+
|
| 40 |
+
- `conj-if-needed(m[j, i])` if the name of `F` starts with `hermitian`,
|
| 41 |
+
- `m[j, i]` if the name of `F` starts with `symmetric`, or
|
| 42 |
+
- the additive identity if the name of `F` starts with `triangular`.
|
| 43 |
+
|
| 44 |
+
[*Example 1*:
|
| 45 |
+
|
| 46 |
+
Small vector product accessing only specified triangle. It would not be
|
| 47 |
+
a precondition violation for the non-accessed matrix element to be
|
| 48 |
+
non-zero.
|
| 49 |
+
|
| 50 |
+
``` cpp
|
| 51 |
+
template<class Triangle>
|
| 52 |
+
void triangular_matrix_vector_2x2_product(
|
| 53 |
+
mdspan<const float, extents<int, 2, 2>> m,
|
| 54 |
+
Triangle t,
|
| 55 |
+
mdspan<const float, extents<int, 2>> x,
|
| 56 |
+
mdspan<float, extents<int, 2>> y) {
|
| 57 |
+
|
| 58 |
+
static_assert(is_same_v<Triangle, lower_triangle_t> ||
|
| 59 |
+
is_same_v<Triangle, upper_triangle_t>);
|
| 60 |
+
|
| 61 |
+
if constexpr (is_same_v<Triangle, lower_triangle_t>) {
|
| 62 |
+
y[0] = m[0,0] * x[0]; // + 0 * x[1]
|
| 63 |
+
y[1] = m[1,0] * x[0] + m[1,1] * x[1];
|
| 64 |
+
} else { // upper_triangle_t
|
| 65 |
+
y[0] = m[0,0] * x[0] + m[0,1] * x[1];
|
| 66 |
+
y[1] = /* 0 * x[0] + */ m[1,1] * x[1];
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
```
|
| 70 |
+
|
| 71 |
+
— *end example*]
|
| 72 |
+
|
| 73 |
+
For any function `F` that takes a parameter named `d`, `d` applies to
|
| 74 |
+
accesses done through the previous-of-the-previous parameter of `d` in
|
| 75 |
+
the parameter list of `F`. Let `m` be such an access-modified function
|
| 76 |
+
parameter. If `d` specifies that an implicit unit diagonal is to be
|
| 77 |
+
assumed, then
|
| 78 |
+
|
| 79 |
+
- `F` will not access the diagonal of `m`; and
|
| 80 |
+
- the algorithm will interpret `m` as if it has a unit diagonal, that
|
| 81 |
+
is, a diagonal each of whose elements behaves as a two-sided
|
| 82 |
+
multiplicative identity (even if `m`’s value type does not have a
|
| 83 |
+
two-sided multiplicative identity).
|
| 84 |
+
|
| 85 |
+
Otherwise, if `d` specifies that an explicit diagonal is to be assumed,
|
| 86 |
+
then `F` will access the diagonal of `m`.
|
| 87 |
+
|
| 88 |
+
Within all the functions in [[linalg]], any calls to `abs`, `conj`,
|
| 89 |
+
`imag`, and `real` are unqualified.
|
| 90 |
+
|
| 91 |
+
Two `mdspan` objects `x` and `y` *alias* each other, if they have the
|
| 92 |
+
same extents `e`, and for every pack of integers `i` which is a
|
| 93 |
+
multidimensional index in `e`, `x[i...]` and `y[i...]` refer to the same
|
| 94 |
+
element.
|
| 95 |
+
|
| 96 |
+
[*Note 1*: This means that `x` and `y` view the same elements in the
|
| 97 |
+
same order. — *end note*]
|
| 98 |
+
|
| 99 |
+
Two `mdspan` objects `x` and `y` *overlap* each other, if for some pack
|
| 100 |
+
of integers `i` that is a multidimensional index in `x.extents()`, there
|
| 101 |
+
exists a pack of integers `j` that is a multidimensional index in
|
| 102 |
+
`y.extents()`, such that `x[i...]` and `y[j...]` refer to the same
|
| 103 |
+
element.
|
| 104 |
+
|
| 105 |
+
[*Note 2*: Aliasing is a special case of overlapping. If `x` and `y` do
|
| 106 |
+
not overlap, then they also do not alias each other. — *end note*]
|
| 107 |
+
|