5#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_LINALG_IDENTITY_MATRIX_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_LINALG_IDENTITY_MATRIX_HPP_
15#include "arene/base/linalg/detail/mandates.hpp"
22#include "arene/base/stdlib_choice/cstddef.hpp"
23#include "arene/base/stdlib_choice/enable_if.hpp"
24#include "arene/base/stdlib_choice/forward.hpp"
38namespace identity_matrix_detail {
44template <
typename Extents>
45constexpr auto mandate_is_extents() noexcept ->
bool {
48 "The argument to linalg::identity_matrix should be an instance of arene::base::extents"
55template <
typename ElementType>
60template <
typename ElementType>
61class identity_matrix_impl {
67 template <
typename Extents>
68 using identity_mdspan = mdspan<ElementType const, Extents, layout_constant_diagonal<extents<std::size_t, 0U, 0U>>>;
83 identity_mdspan<remove_cvref_t<Extents>>
const result{
84 identity_elements<ElementType>.data(),
99template <
typename ElementType>
100extern constexpr identity_matrix_detail::identity_matrix_impl<ElementType>
identity_matrix{};
#define ARENE_PRECONDITION(condition)
Check that a precondition holds, and terminate the application if it does not.
Definition contract.hpp:150
constexpr identity_matrix_detail::identity_matrix_impl< ElementType > identity_matrix
Return an mdspan representing an identity matrix with the same shape as the passed-in extents.
constexpr bool is_scalar_v
Determine if the given type is a scalar for the purposes of linalg algorithms.
constexpr const & one_v
constexpr reference to the multiplicative identity value one<T>::value .
Definition arithmetic_identities.hpp:105
constexpr const & zero_v
constexpr reference to the additive identity value zero<T>::value .
Definition arithmetic_identities.hpp:58
Definition accumulate.hpp:37
constexpr bool is_extents_v
Helper variable to check if a provided type is an instantiation of extents.
typename constraints_impl::constraints< EnableIfs... >::type constraints
Helper used to express template constraints in a consistent way using std::enable_if_t.
Definition constraints.hpp:51
remove_cv_t< remove_reference_t< T > > remove_cvref_t
Backport of std::remove_cvref_t.
Definition remove_cvref.hpp:35
Definition accumulate.hpp:36
typename enable_if< Condition, Type >::type enable_if_t
Type alias to support constraining templates. Is an alias for the specified type if the Condition is ...
Definition enable_if.hpp:41
constexpr auto forward(remove_reference_t< T > &value) noexcept -> T &&
Cast a value to an rvalue if T is an rvalue or rvalue reference, otherwise forward an lvalue referenc...
Definition forward.hpp:24