Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
arene::base::linalg Namespace Reference

Typedef Documentation

◆ math_accessor_t

template<class T>
using arene::base::linalg::math_accessor_t = typename math_traits<T>::accessor_type

The mdspan-equivalent accessor type of T if T is a linalg object, or a substitution error if not.

Template Parameters
TThe type to inspect

◆ math_element_t

template<class T>
using arene::base::linalg::math_element_t = typename math_traits<T>::element_type

The mdspan-equivalent element type of T if T is a linalg object, or a substitution error if not.

Template Parameters
TThe type to inspect

◆ math_extents_t

template<class T>
using arene::base::linalg::math_extents_t = typename math_traits<T>::extents_type

The mdspan-equivalent extents type of T if T is a linalg object, or a substitution error if not.

Template Parameters
TThe type to inspect

◆ math_index_t

template<class T>
using arene::base::linalg::math_index_t = typename math_traits<T>::index_type

The mdspan-equivalent index type of T if T is a linalg object, or a substitution error if not.

Template Parameters
TThe type to inspect

◆ math_layout_t

template<class T>
using arene::base::linalg::math_layout_t = typename math_traits<T>::layout_type

The mdspan-equivalent layout type of T if T is a linalg object, or a substitution error if not.

Template Parameters
TThe type to inspect

◆ math_rank_t

template<class T>
using arene::base::linalg::math_rank_t = typename math_traits<T>::rank_type

The mdspan-equivalent rank type of T if T is a linalg object, or a substitution error if not.

Template Parameters
TThe type to inspect

◆ math_reference_t

template<class T>
using arene::base::linalg::math_reference_t = typename math_traits<T>::reference

The mdspan-equivalent reference type of T if T is a linalg object, or a substitution error if not.

Template Parameters
TThe type to inspect

◆ math_size_t

template<class T>
using arene::base::linalg::math_size_t = typename math_traits<T>::size_type

The mdspan-equivalent size type of T if T is a linalg object, or a substitution error if not.

Template Parameters
TThe type to inspect

◆ math_value_t

template<class T>
using arene::base::linalg::math_value_t = typename math_traits<T>::value_type

The mdspan-equivalent value type of T if T is a linalg object, or a substitution error if not.

Template Parameters
TThe type to inspect

Function Documentation

◆ ARENE_CPP14_INLINE_VARIABLE() [1/23]

arene::base::linalg::ARENE_CPP14_INLINE_VARIABLE ( constant_detail::constant_fn ,
constant  )

Construct a constant-valued expression for a linear algebra operation.

◆ ARENE_CPP14_INLINE_VARIABLE() [2/23]

arene::base::linalg::ARENE_CPP14_INLINE_VARIABLE ( copy_elements_detail::copy_elements_fn ,
copy_elements  )

Copy corresponding elements from one multidimensional view to another.

◆ ARENE_CPP14_INLINE_VARIABLE() [3/23]

arene::base::linalg::ARENE_CPP14_INLINE_VARIABLE ( detail::dot_fn ,
dot  )

Compute the dot product of two vectors.

◆ ARENE_CPP14_INLINE_VARIABLE() [4/23]

arene::base::linalg::ARENE_CPP14_INLINE_VARIABLE ( detail::matrix_one_norm_fn ,
matrix_one_norm  )

Compute the maximum absolute column sum of a matrix.

◆ ARENE_CPP14_INLINE_VARIABLE() [5/23]

arene::base::linalg::ARENE_CPP14_INLINE_VARIABLE ( detail::matrix_rank_1_update_fn ,
matrix_rank_1_update  )

Compute a rank-1 matrix update of two vectors.

◆ ARENE_CPP14_INLINE_VARIABLE() [6/23]

arene::base::linalg::ARENE_CPP14_INLINE_VARIABLE ( detail::vector_abs_sum_fn ,
vector_abs_sum  )

Compute the sum of the absolute values of a vector's elements.

◆ ARENE_CPP14_INLINE_VARIABLE() [7/23]

arene::base::linalg::ARENE_CPP14_INLINE_VARIABLE ( detail::vector_idx_abs_max_fn ,
vector_idx_abs_max  )

Find the index of a vector element with greatest absolute value.

◆ ARENE_CPP14_INLINE_VARIABLE() [8/23]

arene::base::linalg::ARENE_CPP14_INLINE_VARIABLE ( elementwise_binary_transform_detail::elementwise_binary_transform_fn ,
elementwise_binary_transform  )

Apply a binary operation to corresponding elements of two multidimensional views.

◆ ARENE_CPP14_INLINE_VARIABLE() [9/23]

arene::base::linalg::ARENE_CPP14_INLINE_VARIABLE ( elementwise_unary_transform_detail::elementwise_unary_transform_fn ,
elementwise_unary_transform  )

Apply a unary operation to each element of a multidimensional view.

◆ ARENE_CPP14_INLINE_VARIABLE() [10/23]

arene::base::linalg::ARENE_CPP14_INLINE_VARIABLE ( equal_elements_detail::equal_elements_fn ,
equal_elements  )

Compare the corresponding elements of two multidimensional views for equality.

◆ ARENE_CPP14_INLINE_VARIABLE() [11/23]

arene::base::linalg::ARENE_CPP14_INLINE_VARIABLE ( explicit_diagonal_t ,
explicit_diagonal  )

Tag indicating that a triangular matrix stores its diagonal explicitly.

◆ ARENE_CPP14_INLINE_VARIABLE() [12/23]

arene::base::linalg::ARENE_CPP14_INLINE_VARIABLE ( implicit_unit_diagonal_t ,
implicit_unit_diagonal  )

Tag indicating that a triangular matrix has an implicit unit diagonal.

◆ ARENE_CPP14_INLINE_VARIABLE() [13/23]

arene::base::linalg::ARENE_CPP14_INLINE_VARIABLE ( lower_triangle_t ,
lower_triangle  )

Tag indicating that a triangular matrix stores its lower triangle.

◆ ARENE_CPP14_INLINE_VARIABLE() [14/23]

arene::base::linalg::ARENE_CPP14_INLINE_VARIABLE ( matrix_observers_detail::extent_accessor_fn< 0U > ,
row_count  )

Function object returning the number of rows of a matrix.

Given an in-matrix A, row_count(A) returns A.extent(0).

Note
Requires is_in_matrix_v<Mat> to be true.

◆ ARENE_CPP14_INLINE_VARIABLE() [15/23]

arene::base::linalg::ARENE_CPP14_INLINE_VARIABLE ( matrix_observers_detail::extent_accessor_fn< 1U > ,
column_count  )

Function object returning the number of columns of a matrix.

Given an in-matrix A, column_count(A) returns A.extent(1).

Note
Requires is_in_matrix_v<Mat> to be true.

◆ ARENE_CPP14_INLINE_VARIABLE() [16/23]

arene::base::linalg::ARENE_CPP14_INLINE_VARIABLE ( matrix_observers_detail::is_square_fn ,
is_square  )

Function object returning whether or not a matrix has as many rows as it has columns.

Given an in-matrix A, is_square(A) returns row_count(A) == column_count(A), except that it returns false without inspecting A when the static extents of A's type cannot be equal.

Note
Requires is_in_matrix_v<Mat> to be true.

◆ ARENE_CPP14_INLINE_VARIABLE() [17/23]

arene::base::linalg::ARENE_CPP14_INLINE_VARIABLE ( matrix_vector_product_detail::matrix_vector_product_impl ,
matrix_vector_product  )

Function object implementing a matrix-vector product with optional offset.

◆ ARENE_CPP14_INLINE_VARIABLE() [18/23]

arene::base::linalg::ARENE_CPP14_INLINE_VARIABLE ( row_column_view_detail::matrix_axis_view_fn< 0U > ,
row_view  )

Return a range over the rows of a matrix.

Given a matrix, row_view returns a range whose elements are the rows of that matrix, in order. The range has one element per row, totaling matrix.extent(0) elements, and its i-th element is a rank-1 view of the i-th row, holding the matrix.extent(1) elements of that row. The result is a range, so it may be used in a range-based for loop and with functions that operate on ranges.

The rows are views rather than copies, so each one refers to the elements of matrix. Where the element type is non-const, writing through a row writes through to the matrix.

auto const A = ...; // a 3-by-4 matrix
for (auto const row : arene::base::linalg::row_view(A)) {
// the loop runs 3 times, once per row of A
// row is a rank-1 view of the 4 elements of that row, so row(0) is its first element
}

The argument must be an in-matrix, that is a rank-2 mdspan whose value type is a scalar (see arene::base::linalg::is_in_matrix_v). The i -th row is exactly submdspan(matrix, i, full_extent) , so the layout of matrix must support slicing.

Can also be called with a second index parameter i to get a view of the i-th row:

auto const A = ...; // a 3-by-4 matrix
auto const row = arene::base::linalg::row_view(A, std::integral_constant<int, 1>);
// row is a rank-1 view of the 4 elements of row 1, so row(0) is A(1, 0)
A helper class to represent a compile-time constant with the specified type and value....
Definition integral_constant.hpp:23
See also
arene::base::linalg::column_view
arene::base::axis_view

◆ ARENE_CPP14_INLINE_VARIABLE() [19/23]

arene::base::linalg::ARENE_CPP14_INLINE_VARIABLE ( row_column_view_detail::matrix_axis_view_fn< 1U > ,
column_view  )

Return a range over the columns of a matrix.

Given a matrix, column_view returns a range whose elements are the columns of that matrix, in order. The range has one element per column, totaling matrix.extent(1) elements, and its i-th element is a rank-1 view of the i-th column, holding the matrix.extent(0) elements of that column. The result is a range, so it may be used in a range-based for loop and with functions that operate on ranges.

The columns are views rather than copies, so each one refers to the elements of matrix itself. Where the element type is non-const, writing through a column writes through to the matrix.

auto const A = ...; // a 3-by-4 matrix
for (auto const column : arene::base::linalg::column_view(A)) {
// the loop runs 4 times, once per column of A
// column is a rank-1 view of the 3 elements of that column, so column(0) is its first element
}

The argument must be an in-matrix, that is a rank-2 mdspan whose value type is a scalar (see arene::base::linalg::is_in_matrix_v). The i -th column is exactly submdspan(matrix, full_extent, i) , so the layout of matrix must support slicing.

Can also be called with a second index parameter i to get a view of the i-th column:

auto const A = ...; // a 3-by-4 matrix
auto const col = arene::base::linalg::column_view(A, std::integral_constant<int, 1>);
// col is a rank-1 view of the 3 elements of column 1, so col(0) is A(0, 1)
See also
arene::base::linalg::row_view
arene::base::axis_view

◆ ARENE_CPP14_INLINE_VARIABLE() [20/23]

arene::base::linalg::ARENE_CPP14_INLINE_VARIABLE ( swap_elements_detail::swap_elements_fn ,
swap_elements  )

Swap corresponding elements of two multidimensional views.

◆ ARENE_CPP14_INLINE_VARIABLE() [21/23]

arene::base::linalg::ARENE_CPP14_INLINE_VARIABLE ( swap_rows_detail::swap_rows_fn ,
swap_rows  )

Swap two rows of a matrix.

◆ ARENE_CPP14_INLINE_VARIABLE() [22/23]

arene::base::linalg::ARENE_CPP14_INLINE_VARIABLE ( transposed_detail::transposed_fn ,
transposed  )

Return a transposed view of a rank-2 mdspan that aliases the input data in place.

Selects an overload of transposed_detail::transposed_fn::operator() by the input layout: a layout_left input yields a layout_right view (and vice versa), a layout_stride input yields a layout_stride view with its two strides swapped, a layout_transpose input is unwrapped to its nested layout, and any other layout is wrapped in layout_transpose.

Note
Mandates: the input mdspan has rank 2; the input's data are neither copied nor modified.

◆ ARENE_CPP14_INLINE_VARIABLE() [23/23]

arene::base::linalg::ARENE_CPP14_INLINE_VARIABLE ( upper_triangle_t ,
upper_triangle  )

Tag indicating that a triangular matrix stores its upper triangle.

◆ ARENE_CPP14_INLINE_VARIABLE_INIT() [1/2]

arene::base::linalg::ARENE_CPP14_INLINE_VARIABLE_INIT ( add ,
arene::base::bind_back(elementwise_binary_transform, std::plus<>{})  )

Add two mdspans elementwise, writing the result into a third.

Template Parameters
LhsInSpanThe type of the first input span
RhsInSpanThe type of the second input span
OutSpanThe type of the output span Pass the first and second input spans as lhs_span and rhs_span, and the output span as out_span.
Precondition
All of LhsInSpan , RhsInSpan , and OutSpan must be instantiations of mdspan with the same rank
if lhs_in_span and out_span overlap, they must alias
if rhs_in_span and out_span overlap, they must alias
std::plus must be invocable with elements of the input spans, and the result must be assignable to the elements of the output span
All of lhs_span , rhs_span , and out_span must have equal extents

◆ ARENE_CPP14_INLINE_VARIABLE_INIT() [2/2]

arene::base::linalg::ARENE_CPP14_INLINE_VARIABLE_INIT ( subtract ,
arene::base::bind_back(elementwise_binary_transform, std::minus<>{})  )

subract two mdspans elementwise, writing the result into a third

Template Parameters
LhsInSpanThe type of the first input span
RhsInSpanThe type of the second input span
OutSpanThe type of the output span Pass the first and second input spans as lhs_span and rhs_span, and the output span as out_span.
Precondition
All of LhsInSpan , RhsInSpan , and OutSpan must be instantiations of mdspan with the same rank
if lhs_in_span and out_span overlap, they must alias
if rhs_in_span and out_span overlap, they must alias
std::minus must be invocable with elements of the input spans, and the result must be assignable to the elements of the output span
All of lhs_span , rhs_span , and out_span must have equal extents

◆ scaled()

template<class ScalingFactor, class ElementType, class Extents, class Layout, class Accessor>
auto arene::base::linalg::scaled ( ScalingFactor scaling_factor,
mdspan< ElementType, Extents, Layout, Accessor > original ) -> scaled_detail::scaled_mdspan<mdspan<ElementType, Extents, Layout, Accessor>, ScalingFactor>
constexprnoexcept

Return a version of the given mdspan instance that has an accessor which scales by scaling_factor.

Template Parameters
ScalingFactorType of the scaling factor to be used; normally deduced from scaling_factor
ElementTypeType of the elements of the original mdspan; normally deduced from original
ExtentsType of the extents of the original mdspan; normally deduced from original
LayoutType of the layout of the original mdspan; normally deduced from original
AccessorType of the accessor of the original mdspan; normally deduced from original
Parameters
scaling_factorSpecific amount by which to scale the elements of original
originalThe original mdspan instance into whose elements this function will create a scaled view
Returns
An mdspan instance with the same extents and layout as original but whose elements appear scaled

Variable Documentation

◆ identity_matrix

template<typename ElementType>
identity_matrix_detail::identity_matrix_impl<ElementType> arene::base::linalg::identity_matrix {}
externconstexpr

Return an mdspan representing an identity matrix with the same shape as the passed-in extents.

Template Parameters
ElementTypeThe element type to use for the returned matrix; must be a linalg scalar

◆ is_diagonal_storage_tag_v

template<typename T>
bool arene::base::linalg::is_diagonal_storage_tag_v
externconstexpr
Initial value:
{
}
Tag indicating that a triangular matrix stores its diagonal explicitly.
Definition diagonal_tags.hpp:35
Tag indicating that a triangular matrix has an implicit unit diagonal.
Definition diagonal_tags.hpp:24
Trait to detect if the two template parameters are the same or not. The value member is true if the t...
Definition is_same.hpp:35

Determines whether a type, ignoring cv-qualification, is a diagonal storage tag.

Template Parameters
TThe type to inspect.

◆ is_in_matrix_v

template<typename T>
bool arene::base::linalg::is_in_matrix_v {linalg_traits_detail::is_in_matrix_v<std::remove_cv_t<T>>}
externconstexpr

Determine if the given type is an in-matrix, usable as an input matrix for linalg algorithms.

Template Parameters
TThe type to check

◆ is_in_object_v

template<typename T>
bool arene::base::linalg::is_in_object_v {linalg_traits_detail::is_in_object_v<std::remove_cv_t<T>>}
externconstexpr

Determine if the given type is an in-object, e.g. an in-vector or in-matrix.

Template Parameters
TThe type to check

◆ is_in_vector_v

template<typename T>
bool arene::base::linalg::is_in_vector_v {linalg_traits_detail::is_in_vector_v<std::remove_cv_t<T>>}
externconstexpr

Determine if the given type is an in-vector, usable as an input vector for linalg algorithms.

Template Parameters
TThe type to check

◆ is_inout_matrix_v

template<typename T>
bool arene::base::linalg::is_inout_matrix_v {is_out_matrix_v<T>}
externconstexpr

Determine if the given type is an inout-matrix, usable as both input and output matrix for linalg algorithms.

Template Parameters
TThe type to check

◆ is_inout_object_v

template<typename T>
bool arene::base::linalg::is_inout_object_v {is_out_object_v<T>}
externconstexpr

Determine if the given type is an inout-object, e.g. an inout-vector or inout-matrix.

Template Parameters
TThe type to check

◆ is_inout_vector_v

template<typename T>
bool arene::base::linalg::is_inout_vector_v {is_out_vector_v<T>}
externconstexpr

Determine if the given type is an inout-vector, usable as both input and output vector for linalg algorithms.

Template Parameters
TThe type to check

◆ is_out_matrix_v

template<typename T>
bool arene::base::linalg::is_out_matrix_v {linalg_traits_detail::is_out_matrix_v<std::remove_cv_t<T>>}
externconstexpr

Determine if the given type is an out-matrix, usable as an output matrix for linalg algorithms.

Template Parameters
TThe type to check

◆ is_out_object_v

template<typename T>
bool arene::base::linalg::is_out_object_v {linalg_traits_detail::is_out_object_v<std::remove_cv_t<T>>}
externconstexpr

Determine if the given type is an out-object, e.g. an out-vector or out-matrix.

Template Parameters
TThe type to check

◆ is_out_vector_v

template<typename T>
bool arene::base::linalg::is_out_vector_v {linalg_traits_detail::is_out_vector_v<std::remove_cv_t<T>>}
externconstexpr

Determine if the given type is an out-vector, usable as an output vector for linalg algorithms.

Template Parameters
TThe type to check

◆ is_scalar_v

template<typename T>
bool arene::base::linalg::is_scalar_v
externconstexpr
Initial value:
{
}
static constexpr value_type value
Definition integral_constant.hpp:34
constexpr bool is_mdspan_v
Type trait to determine if the given type is an mdspan of some kind.
constexpr bool is_copyable_v
Backport for the C++20 copyable concept.

Determine if the given type is a scalar for the purposes of linalg algorithms.

Template Parameters
TThe type to check
Note
To be a scalar for this purpose, the type must be semiregular (having all special member functions) and not be an mdspan. The value_types of vectors and matrices used in linalg must be scalars in this sense.
C++26 also requires !std::is_execution_policy_v<T> but there are no execution policies in C++14.

◆ is_triangular_tag_v

template<typename T>
bool arene::base::linalg::is_triangular_tag_v
externconstexpr
Initial value:
{
}
Tag indicating that a triangular matrix stores its lower triangle.
Definition triangular_tags.hpp:33
Tag indicating that a triangular matrix stores its upper triangle.
Definition triangular_tags.hpp:23

Determines whether a type, ignoring cv-qualification, is a triangular matrix storage tag.

Template Parameters
TThe type to inspect.

◆ static_column_count_v

template<typename Mat>
std::size_t arene::base::linalg::static_column_count_v {matrix_observers_detail::static_extent<Mat, 1U>::value}
externconstexpr

The compile-time number of columns of a matrix.

Template Parameters
MatMatrix type; must satisfy is_in_matrix_v
Note
Ill-formed when Mat is not an in-matrix.

Equals math_extents_t<Mat>::static_extent(1), which is dynamic_extent if the column extent is not known statically.

◆ static_row_count_v

template<typename Mat>
std::size_t arene::base::linalg::static_row_count_v {matrix_observers_detail::static_extent<Mat, 0U>::value}
externconstexpr

The compile-time number of rows of a matrix.

Template Parameters
MatMatrix type; must satisfy is_in_matrix_v
Note
Ill-formed when Mat is not an in-matrix.

Equals math_extents_t<Mat>::static_extent(0), which is dynamic_extent if the row extent is not known statically.