16 #ifndef OPENKALMAN_LIBRARY_INTERFACE_HPP 17 #define OPENKALMAN_LIBRARY_INTERFACE_HPP 19 #include <type_traits> 33 template<
typename LibraryObject>
35 template<
typename LibraryObject,
typename>
39 #ifdef DOXYGEN_SHOULD_SKIP_THIS 48 template<
typename Derived>
49 using LibraryBase = std::monostate;
60 #ifdef __cpp_lib_ranges 61 template<indexible Arg, std::ranges::input_range Indices> requires values::index<std::ranges::range_value_t<Indices>>
62 static constexpr values::scalar decltype(
auto)
64 template<
typename Arg,
typename Indices>
65 static constexpr decltype(
auto)
78 #ifdef __cpp_lib_ranges 79 template<indexible Arg, std::ranges::input_range Indices> requires values::index<std::ranges::range_value_t<Indices>>
81 template<
typename Arg,
typename Indices>
99 template<
typename Arg>
100 static decltype(
auto)
110 #ifdef __cpp_concepts 111 template<writable To, indexible From>
113 template<
typename To,
typename From, std::enable_if_t<indexible<To> and indexible<From>,
int> = 0>
116 assign(M& a, From&& b) =
delete;
128 #ifdef __cpp_concepts 129 template<Layout layout, values::number Scalar> requires (layout !=
Layout::stride)
131 make_default(coordinates::euclidean_pattern_collection
auto&& descriptors) =
delete;
133 template<Layout layout,
typename Scalar,
typename Descriptors>
135 make_default(Descriptors&& descriptors) =
delete;
146 #ifdef __cpp_concepts 151 template<
Layout layout,
typename Arg,
typename...Scalars, std::enable_if_t<
165 #ifdef __cpp_concepts 167 make_constant(
const values::scalar
auto& c, coordinates::euclidean_pattern_collection
auto&& d) =
delete;
169 template<
typename C,
typename D>
170 static constexpr
auto 182 #ifdef __cpp_concepts 183 template<values::number Scalar>
185 make_identity_matrix(coordinates::euclidean_pattern_collection
auto&& d) =
delete;
187 template<
typename Scalar,
typename D>
188 static constexpr
auto 189 make_identity_matrix(D&& d) =
delete;
201 #ifdef __cpp_concepts 202 template<TriangleType t>
203 static constexpr
auto 206 template<TriangleType t,
typename Arg>
207 static constexpr
auto 220 #ifdef __cpp_concepts 221 template<HermitianAdapterType t>
222 static constexpr
auto 223 make_hermitian_adapter(
indexible auto&& arg) =
delete;
225 template<HermitianAdapterType t,
typename Arg>
226 static constexpr
auto 227 make_hermitian_adapter(Arg&& arg) =
delete;
237 #ifdef __cpp_concepts 238 template<indexible Arg>
241 template<
typename Arg>
242 static constexpr
auto 254 #ifdef __cpp_concepts 255 template<indexible Arg, coordinates::pattern V>
258 template<
typename Arg,
typename V>
259 static constexpr
auto 269 #ifdef __cpp_concepts 270 template<indexible Arg>
273 template<
typename Arg>
274 static constexpr
auto 276 wrap_angles(Arg&& arg) =
delete;
284 #ifdef __cpp_concepts 286 (index_count_v<Arg> ==
sizeof...(Begin)) and (index_count_v<Arg> ==
sizeof...(Size))
289 template<
typename Arg,
typename...Begin,
typename...Size>
290 static decltype(
auto)
292 get_slice(Arg&& arg,
const std::tuple<Begin...>& begin,
const std::tuple<Size...>&
size) =
delete;
304 #ifdef __cpp_concepts 306 (index_count_v<Block> ==
sizeof...(Begin)) and (index_count_v<Arg> ==
sizeof...(Begin))
308 template<
typename Arg,
typename Block,
typename...Begin>
311 set_slice(Arg& arg, Block&& block,
const Begin&...begin) =
delete;
323 #ifdef __cpp_concepts 324 template<TriangleType t>
326 set_triangle(writable
auto& a,
indexible auto&& b) =
delete;
328 template<TriangleType t,
typename A,
typename B, std::enable_if_t<writable<A> and indexible<B>,
int> = 0>
330 set_triangle(
A& a, B&& b) =
delete;
340 #ifdef __cpp_concepts 344 template<
typename Arg>
345 static constexpr
auto 359 #ifdef __cpp_concepts 361 diagonal_of(square_shaped<Applicability::permitted>
auto&& arg) =
delete;
363 template<
typename Arg>
364 static constexpr
auto 376 #ifdef __cpp_concepts 380 template<
typename Arg,
typename...Factors>
382 broadcast(Arg&& arg,
const Factors&...factors) =
delete;
400 #ifdef __cpp_concepts 401 template<coordinates::pattern...Ds,
typename Operation,
indexible...Args> requires
402 std::invocable<Operation&&, scalar_type_of_t<Args>...> or
403 std::invocable<Operation&&, scalar_type_of_t<Args>..., std::conditional_t<true, std::size_t, Ds>...>
406 template<
typename...Ds,
typename Operation,
typename...Args>
409 n_ary_operation(
const std::tuple<Ds...>& d_tup, Operation&& op, Args&&...args) =
delete;
422 #ifdef __cpp_concepts 423 template<std::size_t...indices,
typename BinaryFunction,
indexible Arg>
425 template<std::size_t...indices,
typename BinaryFunction,
typename Arg>
427 static constexpr
auto 428 reduce(BinaryFunction&& op, Arg&& arg) =
delete;
435 #ifdef __cpp_concepts 436 template<indexible Arg>
437 static constexpr vector_space_descriptors_may_match_with<Arg>
auto 439 template<
typename Arg>
440 static constexpr
auto 449 #ifdef __cpp_concepts 450 template<indexible Arg>
453 template<
typename Arg>
454 static constexpr
auto 464 #ifdef __cpp_concepts 465 template<indexible Arg>
468 template<
typename Arg>
469 static constexpr
auto 478 #ifdef __cpp_concepts 479 template<square_shaped<Applicability::permitted> Arg>
480 static constexpr std::convertible_to<scalar_type_of_t<Arg>>
auto 482 template<
typename Arg>
483 static constexpr
auto 494 #ifdef __cpp_concepts 495 template<indexible Arg, vector_space_descriptors_may_match_with<Arg>...Args>
496 static constexpr vector_space_descriptors_may_match_with<Arg>
auto 498 template<
typename Arg,
typename...Args>
499 static constexpr
auto 501 sum(Arg&& arg, Args&&...args) =
delete;
510 #ifdef __cpp_concepts 511 template<indexible Arg, values::scalar S> requires
512 requires(S s) { {
values::to_number(s)} -> std::convertible_to<scalar_type_of_t<Arg>>; }
513 static constexpr vector_space_descriptors_may_match_with<Arg>
auto 515 template<
typename Arg,
typename S>
516 static constexpr
auto 518 scalar_product(Arg&& arg, S&& s) =
delete;
527 #ifdef __cpp_concepts 528 template<indexible Arg, values::scalar S> requires
529 requires(S s) { {
values::to_number(s)} -> std::convertible_to<scalar_type_of_t<Arg>>; }
530 static constexpr vector_space_descriptors_may_match_with<Arg>
auto 532 template<
typename Arg,
typename S>
533 static constexpr
auto 535 scalar_quotient(Arg&& arg, S&& s) =
delete;
543 #ifdef __cpp_concepts 544 template<indexible A, vector_space_descriptors_may_match_with<A> B>
547 template<
typename A,
typename B>
548 static constexpr
auto 559 #ifdef __cpp_concepts 560 template<
bool on_the_right, writable A, vector_space_descriptors_may_match_with<A> B>
562 template<
bool on_the_right,
typename A,
typename B>
576 #ifdef __cpp_concepts 577 template<TriangleType triangle_type>
578 static constexpr triangular_matrix<triangle_type>
auto 581 template<TriangleType triangle_type,
typename Arg>
582 static constexpr
auto 600 #ifdef __cpp_concepts 601 template<HermitianAdapterType significant_triangle, indexible A, indexible U>
604 template<HermitianAdapterType significant_triangle,
typename A,
typename U>
605 static decltype(
auto)
626 #ifdef __cpp_concepts 627 template<TriangleType triangle, indexible A, indexible U> requires
629 static triangular_matrix<triangle> decltype(
auto)
631 template<TriangleType triangle,
typename A,
typename U>
632 static decltype(
auto)
651 #ifdef __cpp_concepts 652 template<
bool must_be_unique = false,
bool must_be_exact = false, indexible A, indexible B>
656 template<
bool must_be_unique = false,
bool must_be_exact = false,
typename A,
typename B>
658 solve(
A&& a, B&& b) =
delete;
668 #ifdef __cpp_concepts 669 static constexpr triangular_matrix<TriangleType::lower>
auto 672 template<
typename Arg>
673 static constexpr
auto 684 #ifdef __cpp_concepts 685 static constexpr triangular_matrix<TriangleType::upper>
auto 688 template<
typename Arg>
689 static constexpr
auto 693 #endif // DOXYGEN_SHOULD_SKIP_THIS 700 #endif //OPENKALMAN_LIBRARY_INTERFACE_HPP decltype(auto) constexpr from_euclidean(Arg &&arg, const V &v)
Project the Euclidean vector space associated with index 0 to coordinates::pattern v after applying d...
Definition: from_euclidean.hpp:35
constexpr auto n_ary_operation(const std::tuple< Ds... > &d_tup, Operation &&operation, Args &&...args)
Perform a component-wise n-ary operation, using broadcasting to match the size of a pattern matrix...
Definition: n_ary_operation.hpp:319
decltype(auto) constexpr contract(A &&a, B &&b)
Matrix multiplication of A * B.
Definition: contract.hpp:54
Definition: basics.hpp:41
decltype(auto) rank_update_hermitian(A &&a, U &&u, scalar_type_of_t< A > alpha=1)
Do a rank update on a hermitian matrix.
Definition: rank_update_hermitian.hpp:45
Row-major storage (C or C++ style): contiguous storage in which the right-most index has a stride of ...
constexpr bool constant_matrix
Specifies that all components of an object are the same constant value.
Definition: constant_matrix.hpp:31
constexpr bool diagonal_matrix
Specifies that a type is a diagonal matrix or tensor.
Definition: diagonal_matrix.hpp:32
Arg && set_component(Arg &&arg, const scalar_type_of_t< Arg > &s, const Indices &indices)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: set_component.hpp:51
decltype(auto) constexpr conjugate(Arg &&arg)
Take the conjugate of a matrix.
Definition: conjugate.hpp:33
decltype(auto) constexpr get_slice(Arg &&arg, const std::tuple< Offset... > &offsets, const std::tuple< Extent... > &extents)
Extract a slice from a matrix or tensor.
Definition: get_slice.hpp:101
typename scalar_type_of< T >::type scalar_type_of_t
helper template for scalar_type_of.
Definition: scalar_type_of.hpp:54
constexpr bool indexible
T is a generalized tensor type.
Definition: indexible.hpp:32
decltype(auto) to_native_matrix(Arg &&arg)
If it isn't already, convert Arg to a native object in the library associated with LibraryObject...
Definition: to_native_matrix.hpp:35
decltype(auto) constexpr QR_decomposition(A &&a)
Perform a QR decomposition of matrix A=Q[U,0], U is a upper-triangular matrix, and Q is orthogonal...
Definition: QR_decomposition.hpp:33
decltype(auto) constexpr to_diagonal(Arg &&arg)
Convert an indexible object into a diagonal matrix.
Definition: to_diagonal.hpp:32
An upper-right triangular matrix.
decltype(auto) constexpr reduce(BinaryFunction &&b, Arg &&arg)
Perform a partial reduction based on an associative binary function, across one or more indices...
Definition: reduce.hpp:143
decltype(auto) constexpr broadcast(Arg &&arg, const Factors &...factors)
Broadcast an object by replicating it by factors specified for each index.
Definition: broadcast.hpp:49
constexpr auto to_number(Arg arg)
Convert any values::value to a values::number.
Definition: to_number.hpp:34
decltype(auto) constexpr transpose(Arg &&arg)
Take the transpose of a matrix.
Definition: transpose.hpp:58
An interface to various routines from the linear algebra library associated with indexible object T...
Definition: library_interface.hpp:37
Column-major storage (Fortran, Matlab, or Eigen style): contiguous storage in which the left-most ext...
constexpr bool identity_matrix
Specifies that a type is an identity matrix.
Definition: identity_matrix.hpp:45
constexpr A && contract_in_place(A &&a, B &&b)
In-place matrix multiplication of A * B, storing the result in A.
Definition: contract_in_place.hpp:38
constexpr auto solve(A &&a, B &&b)
Solve the equation AX = B for X, which may or may not be a unique solution.
Definition: solve.hpp:87
constexpr auto determinant(Arg &&arg)
Take the determinant of a matrix.
Definition: determinant.hpp:44
decltype(auto) constexpr diagonal_of(Arg &&arg)
Extract a column vector (or column slice for rank>2 tensors) comprising the diagonal elements...
Definition: diagonal_of.hpp:33
A generalization of the above: a custom stride is specified for each index.
constexpr bool size
T is either an index representing a size, or void which represents that there is no size...
Definition: size.hpp:32
decltype(auto) constexpr to_euclidean(Arg &&arg)
Project the vector space associated with index 0 to a Euclidean space for applying directional statis...
Definition: to_euclidean.hpp:38
decltype(auto) constexpr adjoint(Arg &&arg)
Take the adjoint of a matrix.
Definition: adjoint.hpp:33
typename vector_space_descriptor_of< T, N >::type vector_space_descriptor_of_t
helper template for vector_space_descriptor_of.
Definition: vector_space_descriptor_of.hpp:56
Arg && fill_components(Arg &&arg, S...s)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: fill_components.hpp:44
Layout
The layout format of a multidimensional array.
Definition: global-definitions.hpp:47
decltype(auto) constexpr sum(Ts &&...ts)
Element-by-element sum of one or more objects.
Definition: sum.hpp:112
decltype(auto) constexpr LQ_decomposition(A &&a)
Perform an LQ decomposition of matrix A=[L,0]Q, L is a lower-triangular matrix, and Q is orthogonal...
Definition: LQ_decomposition.hpp:33
decltype(auto) rank_update_triangular(A &&a, U &&u, scalar_type_of_t< A > alpha=1)
Do a rank update on triangular matrix.
Definition: rank_update_triangular.hpp:48
constexpr bool index
T is an index value.
Definition: index.hpp:56
constexpr auto make_constant(C &&c, Descriptors &&descriptors)
Make a constant object based on a particular library object.
Definition: make_constant.hpp:37
constexpr To && assign(To &&a, From &&b)
Assign a writable object from an indexible object.
Definition: assign.hpp:51
decltype(auto) constexpr get_component(Arg &&arg, const Indices &indices)
Get a component of an object at a particular set of indices.
Definition: get_component.hpp:54
constexpr bool compatible_with_vector_space_descriptor_collection
indexible T is compatible with pattern_collection D.
Definition: compatible_with_vector_space_descriptor_collection.hpp:74
A lower-left triangular matrix.
A matrix with typed rows and columns.
Definition: forward-class-declarations.hpp:448
constexpr bool hermitian_matrix
Specifies that a type is a hermitian matrix (assuming it is square_shaped).
Definition: hermitian_matrix.hpp:50
decltype(auto) constexpr make_triangular_matrix(Arg &&arg)
Create a triangular_matrix from a general matrix.
Definition: make_triangular_matrix.hpp:35
decltype(auto) constexpr cholesky_factor(A &&a)
Take the Cholesky factor of a matrix.
Definition: cholesky_factor.hpp:38
constexpr Arg && set_slice(Arg &&arg, Block &&block, const Begin &...begin)
Assign an object to a particular slice of a matrix or tensor.
Definition: set_slice.hpp:56