template<class Index0, class Index1>
constexpr index_type operator() (Index0 ind0, Index1 ind1) const noexcept;
概要
2次元インデクス値ind0, ind1に対応する要素位置を求める。
テンプレートパラメータ制約
is_convertible_v<Index0, index_type> == trueis_convertible_v<Index1, index_type> == trueis_nothrow_convertible_v<index_type, Index0> == trueis_nothrow_convertible_v<index_type, Index1> == true
事前条件
iをextents_type::index-cast(ind0)、jをextents_type::index-cast(ind1)としたとき、2次元インデクス値i, jは多次元配列サイズextents_における有効なインデクスであること。
戻り値
Nをextetns_.extent(0)としたとき
i > jならば(*this)(j, i)、そうでなければ- 下記いずれの条件を満たすならば
i + j * (j + 1)/2、そうでなければ j + N * i - i * (i + 1)/2
例外
投げない
例
#include <cassert>
#include <mdspan>
#include <linalg>
namespace linalg = std::linalg;
int main()
{
using Ext3x3 = std::extents<size_t, 3, 3>;
linalg::layout_blas_packed<linalg::lower_triangle_t, linalg::column_major_t>::mapping<Ext3x3> map;
// 0 1 2
// 1 3 4
// 2 4 5
assert(map(0, 0) == 0);
assert(map(0, 1) == 1);
assert(map(2, 1) == 4);
}
出力
バージョン
言語
- C++26
処理系
- Clang: ??
- GCC: ??
- ICC: ??
- Visual C++: ??