tmp/tmp3564paqp/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### Overview <a id="linalg.layout.packed.overview">[[linalg.layout.packed.overview]]</a>
|
| 2 |
+
|
| 3 |
+
`layout_blas_packed` is an `mdspan` layout mapping policy that
|
| 4 |
+
represents a square matrix that stores only the entries in one triangle,
|
| 5 |
+
in a packed contiguous format. Its `Triangle` template parameter
|
| 6 |
+
determines whether an `mdspan` with this layout stores the upper or
|
| 7 |
+
lower triangle of the matrix. Its `StorageOrder` template parameter
|
| 8 |
+
determines whether the layout packs the matrix’s elements in
|
| 9 |
+
column-major or row-major order.
|
| 10 |
+
|
| 11 |
+
A `StorageOrder` of `column_major_t` indicates column-major ordering.
|
| 12 |
+
This packs matrix elements starting with the leftmost (least column
|
| 13 |
+
index) column, and proceeding column by column, from the top entry
|
| 14 |
+
(least row index).
|
| 15 |
+
|
| 16 |
+
A `StorageOrder` of `row_major_t` indicates row-major ordering. This
|
| 17 |
+
packs matrix elements starting with the topmost (least row index) row,
|
| 18 |
+
and proceeding row by row, from the leftmost (least column index) entry.
|
| 19 |
+
|
| 20 |
+
[*Note 1*: `layout_blas_packed` describes the data layout used by the
|
| 21 |
+
BLAS’ Symmetric Packed (SP), Hermitian Packed (HP), and Triangular
|
| 22 |
+
Packed (TP) matrix types. — *end note*]
|
| 23 |
+
|
| 24 |
+
``` cpp
|
| 25 |
+
namespace std::linalg {
|
| 26 |
+
template<class Triangle, class StorageOrder>
|
| 27 |
+
class layout_blas_packed {
|
| 28 |
+
public:
|
| 29 |
+
using triangle_type = Triangle;
|
| 30 |
+
using storage_order_type = StorageOrder;
|
| 31 |
+
|
| 32 |
+
template<class Extents>
|
| 33 |
+
struct mapping {
|
| 34 |
+
public:
|
| 35 |
+
using extents_type = Extents;
|
| 36 |
+
using index_type = extents_type::index_type;
|
| 37 |
+
using size_type = extents_type::size_type;
|
| 38 |
+
using rank_type = extents_type::rank_type;
|
| 39 |
+
using layout_type = layout_blas_packed;
|
| 40 |
+
|
| 41 |
+
// [linalg.layout.packed.cons], constructors
|
| 42 |
+
constexpr mapping() noexcept = default;
|
| 43 |
+
constexpr mapping(const mapping&) noexcept = default;
|
| 44 |
+
constexpr mapping(const extents_type&) noexcept;
|
| 45 |
+
template<class OtherExtents>
|
| 46 |
+
constexpr explicit(!is_convertible_v<OtherExtents, extents_type>)
|
| 47 |
+
mapping(const mapping<OtherExtents>& other) noexcept;
|
| 48 |
+
|
| 49 |
+
constexpr mapping& operator=(const mapping&) noexcept = default;
|
| 50 |
+
|
| 51 |
+
// [linalg.layout.packed.obs], observers
|
| 52 |
+
constexpr const extents_type& extents() const noexcept { return extents_; }
|
| 53 |
+
|
| 54 |
+
constexpr index_type required_span_size() const noexcept;
|
| 55 |
+
|
| 56 |
+
template<class Index0, class Index1>
|
| 57 |
+
constexpr index_type operator() (Index0 ind0, Index1 ind1) const noexcept;
|
| 58 |
+
|
| 59 |
+
static constexpr bool is_always_unique() noexcept {
|
| 60 |
+
return (extents_type::static_extent(0) != dynamic_extent &&
|
| 61 |
+
extents_type::static_extent(0) < 2) ||
|
| 62 |
+
(extents_type::static_extent(1) != dynamic_extent &&
|
| 63 |
+
extents_type::static_extent(1) < 2);
|
| 64 |
+
}
|
| 65 |
+
static constexpr bool is_always_exhaustive() noexcept { return true; }
|
| 66 |
+
static constexpr bool is_always_strided() noexcept
|
| 67 |
+
{ return is_always_unique(); }
|
| 68 |
+
|
| 69 |
+
constexpr bool is_unique() const noexcept {
|
| 70 |
+
return extents_.extent(0) < 2;
|
| 71 |
+
}
|
| 72 |
+
constexpr bool is_exhaustive() const noexcept { return true; }
|
| 73 |
+
constexpr bool is_strided() const noexcept {
|
| 74 |
+
return extents_.extent(0) < 2;
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
constexpr index_type stride(rank_type) const noexcept;
|
| 78 |
+
|
| 79 |
+
template<class OtherExtents>
|
| 80 |
+
friend constexpr bool operator==(const mapping&, const mapping<OtherExtents>&) noexcept;
|
| 81 |
+
|
| 82 |
+
private:
|
| 83 |
+
extents_type extents_{}; // exposition only
|
| 84 |
+
};
|
| 85 |
+
};
|
| 86 |
+
}
|
| 87 |
+
```
|
| 88 |
+
|
| 89 |
+
*Mandates:*
|
| 90 |
+
|
| 91 |
+
- `Triangle` is either `upper_triangle_t` or `lower_triangle_t`,
|
| 92 |
+
- `StorageOrder` is either `column_major_t` or `row_major_t`,
|
| 93 |
+
- `Extents` is a specialization of `std::extents`,
|
| 94 |
+
- `Extents::rank()` equals 2,
|
| 95 |
+
- one of
|
| 96 |
+
``` cpp
|
| 97 |
+
extents_type::static_extent(0) == dynamic_extent,
|
| 98 |
+
extents_type::static_extent(1) == dynamic_extent, or
|
| 99 |
+
extents_type::static_extent(0) == extents_type::static_extent(1)
|
| 100 |
+
```
|
| 101 |
+
|
| 102 |
+
is `true`, and
|
| 103 |
+
- if `Extents::rank_dynamic() == 0` is `true`, let Nₛ be equal to
|
| 104 |
+
`Extents::static_extent(0)`; then, Nₛ × (Nₛ + 1) is representable as a
|
| 105 |
+
value of type `index_type`.
|
| 106 |
+
|
| 107 |
+
`layout_blas_packed<T, SO>::mapping<E>` is a trivially copyable type
|
| 108 |
+
that models `regular` for each `T`, `SO`, and `E`.
|
| 109 |
+
|