[linalg.layout.packed.obs]

# 29 Numerics library [[numerics]](./#numerics)

## 29.9 Basic linear algebra algorithms [[linalg]](linalg#layout.packed.obs)

### 29.9.6 Layouts for packed matrix types [[linalg.layout.packed]](linalg.layout.packed#obs)

#### 29.9.6.3 Observers [linalg.layout.packed.obs]

[ð](#lib:layout_blas_packed::mapping,required_span_size)

`constexpr index_type required_span_size() const noexcept;
`

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L12198)

*Returns*: *extents_*.extent(0) * (*extents_*.extent(0) + 1)/2[.](#1.sentence-1)

[*Note [1](#note-1)*:

For example, a 5 x 5 packed matrix
only stores 15 matrix elements[.](#1.sentence-2)

â *end note*]

[ð](#lib:layout_blas_packed::mapping,operator())

`template<class Index0, class Index1>
  constexpr index_type operator() (Index0 ind0, Index1 ind1) const noexcept;
`

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L12214)

*Constraints*: 

- [(2.1)](#2.1)

is_convertible_v<Index0, index_type> is true,

- [(2.2)](#2.2)

is_convertible_v<Index1, index_type> is true,

- [(2.3)](#2.3)

is_nothrow_constructible_v<index_type, Index0> is true, and

- [(2.4)](#2.4)

is_nothrow_constructible_v<index_type, Index1> is true[.](#2.sentence-1)

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L12227)

Let i be extents_type​::​*index-cast*(ind0), and
let j be extents_type​::​*index-cast*(ind1)[.](#3.sentence-1)

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L12231)

*Preconditions*: i, j is a multidimensional index in *extents_* ([[mdspan.overview]](mdspan.overview "23.7.3.1 Overview"))[.](#4.sentence-1)

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L12236)

*Returns*: Let N be *extents_*.extent(0)[.](#5.sentence-1)

Then

- [(5.1)](#5.1)

(*this)(j, i) if i > j is true; otherwise

- [(5.2)](#5.2)

i + j * (j + 1)/2 ifis_same_v<StorageOrder, column_major_t> && is_same_v<Triangle, upper_triangle_t> is true oris_same_v<StorageOrder, row_major_t> && is_same_v<Triangle, lower_triangle_t> is true; otherwise

- [(5.3)](#5.3)

j + N * i - i * (i + 1)/2[.](#5.sentence-2)

[ð](#lib:layout_blas_packed::mapping,stride)

`constexpr index_type stride(rank_type r) const noexcept;
`

[6](#6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L12264)

*Preconditions*: 

- [(6.1)](#6.1)

is_strided() is true, and

- [(6.2)](#6.2)

r < extents_type​::​rank() is true[.](#6.sentence-1)

[7](#7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L12273)

*Returns*: 1[.](#7.sentence-1)

[ð](#lib:layout_blas_packed::mapping,operator==)

`template<class OtherExtents>
  friend constexpr bool operator==(const mapping& x, const mapping<OtherExtents>& y) noexcept;
`

[8](#8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L12285)

*Effects*: Equivalent to: return x.extents() == y.extents();
