tmp/tmp8f8xclsp/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### Function template `transposed` <a id="linalg.transp.transposed">[[linalg.transp.transposed]]</a>
|
| 2 |
+
|
| 3 |
+
The `transposed` function takes a rank-2 `mdspan` representing a matrix,
|
| 4 |
+
and returns a new `mdspan` representing the input matrix’s transpose.
|
| 5 |
+
The input matrix’s data are not modified, and the returned `mdspan`
|
| 6 |
+
accesses the input matrix’s data in place.
|
| 7 |
+
|
| 8 |
+
``` cpp
|
| 9 |
+
template<class ElementType, class Extents, class Layout, class Accessor>
|
| 10 |
+
constexpr auto transposed(mdspan<ElementType, Extents, Layout, Accessor> a);
|
| 11 |
+
```
|
| 12 |
+
|
| 13 |
+
*Mandates:* `Extents::rank() == 2` is `true`.
|
| 14 |
+
|
| 15 |
+
Let `ReturnExtents` be *`transpose-extents-t`*`<Extents>`. Let `R` be
|
| 16 |
+
`mdspan<ElementType, ReturnExtents, ReturnLayout, Accessor>`, where
|
| 17 |
+
`ReturnLayout` is:
|
| 18 |
+
|
| 19 |
+
- `layout_right` if `Layout` is `layout_left`;
|
| 20 |
+
- otherwise, `layout_left` if `Layout` is `layout_right`;
|
| 21 |
+
- otherwise, `layout_right_padded<PaddingValue>` if `Layout` is
|
| 22 |
+
`layout_left_padded<PaddingValue>` for some `size_t` value
|
| 23 |
+
`PaddingValue`;
|
| 24 |
+
- otherwise, `layout_left_padded<PaddingValue>` if `Layout` is
|
| 25 |
+
`layout_right_padded<PaddingValue>` for some `size_t` value
|
| 26 |
+
`PaddingValue`;
|
| 27 |
+
- otherwise, `layout_stride` if `Layout` is `layout_stride`;
|
| 28 |
+
- otherwise,
|
| 29 |
+
`layout_blas_packed<OppositeTriangle, OppositeStorageOrder>`, if
|
| 30 |
+
`Layout` is `layout_blas_packed<Triangle, StorageOrder>` for some
|
| 31 |
+
`Triangle` and `StorageOrder`, where
|
| 32 |
+
- `OppositeTriangle` is
|
| 33 |
+
``` cpp
|
| 34 |
+
conditional_t<is_same_v<Triangle, upper_triangle_t>,
|
| 35 |
+
lower_triangle_t, upper_triangle_t>
|
| 36 |
+
```
|
| 37 |
+
|
| 38 |
+
and
|
| 39 |
+
- `OppositeStorageOrder` is
|
| 40 |
+
``` cpp
|
| 41 |
+
conditional_t<is_same_v<StorageOrder, column_major_t>, row_major_t, column_major_t>
|
| 42 |
+
```
|
| 43 |
+
- otherwise, `NestedLayout` if `Layout` is
|
| 44 |
+
`layout_transpose<NestedLayout>` for some `NestedLayout`;
|
| 45 |
+
- otherwise, `layout_transpose<Layout>`.
|
| 46 |
+
|
| 47 |
+
*Returns:* With `ReturnMapping` being the type
|
| 48 |
+
`typename ReturnLayout::template mapping<ReturnExtents>`:
|
| 49 |
+
|
| 50 |
+
- if `Layout` is `layout_left`, `layout_right`, or a specialization of
|
| 51 |
+
`layout_blas_packed`,
|
| 52 |
+
``` cpp
|
| 53 |
+
R(a.data_handle(), ReturnMapping(transpose-extents(a.mapping().extents())),
|
| 54 |
+
a.accessor())
|
| 55 |
+
```
|
| 56 |
+
- otherwise,
|
| 57 |
+
``` cpp
|
| 58 |
+
R(a.data_handle(), ReturnMapping(transpose-extents(a.mapping().extents()),
|
| 59 |
+
a.mapping().stride(1)), a.accessor())
|
| 60 |
+
```
|
| 61 |
+
|
| 62 |
+
if `Layout` is `layout_left_padded<PaddingValue>` for some `size_t`
|
| 63 |
+
value `PaddingValue`;
|
| 64 |
+
- otherwise,
|
| 65 |
+
``` cpp
|
| 66 |
+
R(a.data_handle(), ReturnMapping(transpose-extents(a.mapping().extents()),
|
| 67 |
+
a.mapping().stride(0)), a.accessor())
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
+
if `Layout` is `layout_right_padded<PaddingValue>` for some `size_t`
|
| 71 |
+
value `PaddingValue`;
|
| 72 |
+
- otherwise, if `Layout` is `layout_stride`,
|
| 73 |
+
``` cpp
|
| 74 |
+
R(a.data_handle(), ReturnMapping(transpose-extents(a.mapping().extents()),
|
| 75 |
+
array{a.mapping().stride(1), a.mapping().stride(0)}), a.accessor())
|
| 76 |
+
```
|
| 77 |
+
- otherwise, if `Layout` is a specialization of `layout_transpose`,
|
| 78 |
+
``` cpp
|
| 79 |
+
R(a.data_handle(), a.mapping().nested_mapping(), a.accessor())
|
| 80 |
+
```
|
| 81 |
+
- otherwise,
|
| 82 |
+
``` cpp
|
| 83 |
+
R(a.data_handle(), ReturnMapping(a.mapping()), a.accessor())
|
| 84 |
+
```
|
| 85 |
+
|
| 86 |
+
[*Example 1*:
|
| 87 |
+
|
| 88 |
+
``` cpp
|
| 89 |
+
void test_transposed(mdspan<double, extents<size_t, 3, 4>> a) {
|
| 90 |
+
const auto num_rows = a.extent(0);
|
| 91 |
+
const auto num_cols = a.extent(1);
|
| 92 |
+
|
| 93 |
+
auto a_t = transposed(a);
|
| 94 |
+
assert(num_rows == a_t.extent(1));
|
| 95 |
+
assert(num_cols == a_t.extent(0));
|
| 96 |
+
assert(a.stride(0) == a_t.stride(1));
|
| 97 |
+
assert(a.stride(1) == a_t.stride(0));
|
| 98 |
+
|
| 99 |
+
for (size_t row = 0; row < num_rows; ++row) {
|
| 100 |
+
for (size_t col = 0; col < num_rows; ++col) {
|
| 101 |
+
assert(a[row, col] == a_t[col, row]);
|
| 102 |
+
}
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
auto a_t_t = transposed(a_t);
|
| 106 |
+
assert(num_rows == a_t_t.extent(0));
|
| 107 |
+
assert(num_cols == a_t_t.extent(1));
|
| 108 |
+
assert(a.stride(0) == a_t_t.stride(0));
|
| 109 |
+
assert(a.stride(1) == a_t_t.stride(1));
|
| 110 |
+
|
| 111 |
+
for (size_t row = 0; row < num_rows; ++row) {
|
| 112 |
+
for (size_t col = 0; col < num_rows; ++col) {
|
| 113 |
+
assert(a[row, col] == a_t_t[row, col]);
|
| 114 |
+
}
|
| 115 |
+
}
|
| 116 |
+
}
|
| 117 |
+
```
|
| 118 |
+
|
| 119 |
+
— *end example*]
|
| 120 |
+
|