OpenKalman
Public Member Functions | Protected Attributes | Friends | List of all members
OpenKalman::ConstantAdapter< PatternMatrix, Scalar, constant > Struct Template Reference

A tensor or other matrix in which all elements are a constant scalar value. More...

#include <forward-class-declarations.hpp>

Inheritance diagram for OpenKalman::ConstantAdapter< PatternMatrix, Scalar, constant >:
Inheritance graph
[legend]
Collaboration diagram for OpenKalman::ConstantAdapter< PatternMatrix, Scalar, constant >:
Collaboration graph
[legend]

Public Member Functions

template<typename C , typename Descriptors , std::enable_if_t< values::scalar< C > and pattern_collection< Descriptors > and std::is_constructible_v< MyConstant, C &&> and compatible_with_vector_space_descriptor_collection< PatternMatrix, Descriptors >, int > = 0>
constexpr ConstantAdapter (C &&c, Descriptors &&descriptors)
 Construct from values::scalar and a pattern_collection.
 
template<typename Descriptors , std::enable_if_t< pattern_collection< Descriptors > and values::fixed< MyConstant > and compatible_with_vector_space_descriptor_collection< PatternMatrix, Descriptors >, int > = 0>
constexpr ConstantAdapter (Descriptors &&descriptors)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
template<typename C , typename Arg , std::enable_if_t< values::scalar< C > and vector_space_descriptors_may_match_with< Arg, PatternMatrix > and std::is_constructible_v< MyConstant, C &&>, int > = 0>
constexpr ConstantAdapter (C &&c, const Arg &arg)
 Construct based on a values::scalar and the shape of an indexible reference object. More...
 
template<typename Arg , std::enable_if_t< vector_space_descriptors_may_match_with< Arg, PatternMatrix > and(not std::is_base_of_v< ConstantAdapter, Arg >) and values::fixed< MyConstant >, int > = 0>
constexpr ConstantAdapter (const Arg &arg)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
template<typename Arg , std::enable_if_t< constant_matrix< Arg > and(not std::is_base_of_v< ConstantAdapter, Arg >) and vector_space_descriptors_may_match_with< Arg, PatternMatrix > and std::is_constructible_v< MyConstant, constant_coefficient< Arg >>, int > = 0>
constexpr ConstantAdapter (const Arg &arg)
 Construct from another constant object.
 
template<typename C , typename... Ds, std::enable_if_t< values::scalar< C > and(coordinates::pattern< Ds > and ...) and std::is_constructible_v< MyConstant, C &&> and compatible_with_vector_space_descriptor_collection< PatternMatrix, std::tuple< Ds... >>, int > = 0>
constexpr ConstantAdapter (C &&c, Ds &&...ds)
 Construct using a full set of coordinates::pattern objects. More...
 
template<typename... Ds, std::enable_if_t<(coordinates::pattern< Ds > and ...) and values::fixed< MyConstant > and compatible_with_vector_space_descriptor_collection< PatternMatrix, std::tuple< Ds... >>, int > = 0>
constexpr ConstantAdapter (Ds &&...ds)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
template<typename C , typename... Ds, std::enable_if_t< values::scalar< C > and(dynamic_pattern< Ds > and ...) and pattern_tuple< DescriptorCollection > and(dynamic_index_count_v< PatternMatrix > !=dynamic_size) and(sizeof...(Ds)==dynamic_index_count_v< PatternMatrix >) and std::is_constructible_v< MyConstant, C &&>, int > = 0>
constexpr ConstantAdapter (C &&c, Ds &&...ds)
 Construct using only applicable dynamic_pattern. More...
 
template<typename... Ds, std::enable_if_t< values::scalar< C > and(dynamic_pattern< Ds > and ...) and pattern_tuple< DescriptorCollection > and(dynamic_index_count_v< PatternMatrix > !=dynamic_size) and(sizeof...(Ds)==dynamic_index_count_v< PatternMatrix >) and values::fixed< MyConstant >, int > = 0>
constexpr ConstantAdapter (Ds &&...ds)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
template<typename Arg , std::enable_if_t< constant_matrix< Arg > and(not std::is_base_of_v< ConstantAdapter, Arg >) and vector_space_descriptors_may_match_with< Arg, PatternMatrix > and std::is_assignable_v< MyConstant, constant_coefficient< Arg >>, int > = 0>
constexpr auto & operator= (const Arg &arg)
 Assign from a compatible constant_matrix.
 
template<typename Arg , std::enable_if_t< indexible< Arg >, int > = 0>
constexpr bool operator== (const Arg &arg) const
 Comparison operator.
 
template<typename Arg , std::enable_if_t< indexible< Arg >, int > = 0>
constexpr bool operator!= (const Arg &arg) const
 
template<typename Indices , std::enable_if_t< index_range_for< Indices, PatternMatrix > and(not empty_object< PatternMatrix >), int > = 0>
constexpr auto operator[] (const Indices &indices) const
 Access a component at a set of indices. More...
 
constexpr auto get_scalar_constant () const
 Get the values::scalar associated with this object.
 

Protected Attributes

MyConstant my_constant
 
DescriptorCollection descriptor_collection
 

Friends

struct interface::indexible_object_traits< ConstantAdapter >
 
struct interface::library_interface< ConstantAdapter >
 
template<typename Arg , std::enable_if_t< indexible< Arg > and not constant_adapter< Arg >, int > = 0>
constexpr bool operator== (const Arg &arg, const ConstantAdapter &c)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename Arg , std::enable_if_t< indexible< Arg > and not std::is_same_v< Arg, ConstantAdapter >, int > = 0>
constexpr bool operator!= (const Arg &arg, const ConstantAdapter &c)
 
auto operator- (const ConstantAdapter &arg)
 
template<typename S , std::enable_if_t< values::scalar< S >, int > = 0>
auto operator* (const ConstantAdapter &arg, S s)
 
template<typename S , std::enable_if_t< values::scalar< S >, int > = 0>
auto operator* (S s, const ConstantAdapter &arg)
 
template<typename S , std::enable_if_t< values::scalar< S >, int > = 0>
auto operator/ (const ConstantAdapter &arg, S s)
 

Detailed Description

template<typename PatternMatrix, typename Scalar, auto... constant>
struct OpenKalman::ConstantAdapter< PatternMatrix, Scalar, constant >

A tensor or other matrix in which all elements are a constant scalar value.

The constant value can be static (known at compile time), or dynamic (known only at runtime). Examples:

using T = Eigen::Matrix<double, 3, 2>; // A 3-by-2 matrix of scalar-type double.
ConstantAdapter<T> c1 {3.0}; // Construct a 3-by-2 double constant of shape T with value 3.0 (known at runtime).
ConstantAdapter<T, int> c2 {3}; // Construct a 3-by-2 int constant of shape T with value 3 (known at runtime).
ConstantAdapter<T, int, 1> c3; // Construct a 3-by-2 int constant of shape T with value 1 (known at compile time).
ConstantAdapter<T, double, 1> c4; // Construct a 3-by-2 double constant of shape T with value 1.0 (known at compile time).
ConstantAdapter<T, std::integral_constant<int, 1>> c5; // Construct a 3-by-2 int constant of shape T with value 1 (known at compile time).
ConstantAdapter<T, std::complex<double>> c6 {std::complex<double>{4, 5}}; // Construct a 3-by-2 complex constant of shape T and value 4.0 + 5.0i (known at runtime).
ConstantAdapter<T, std::complex<double>, 4, 5> c7; // Construct a 3-by-2 A complex constant of shape T and value 4.0 + 5.0i (known at compile time).
Template Parameters
PatternMatrixAn indexible object reflecting the size and shape of the constant object
ScalarA values::number reflecting the type of the constant
constantOptional parameters for constructing Scalar at compile time.

Constructor & Destructor Documentation

◆ ConstantAdapter() [1/7]

template<typename PatternMatrix , typename Scalar , auto... constant>
template<typename Descriptors , std::enable_if_t< pattern_collection< Descriptors > and values::fixed< MyConstant > and compatible_with_vector_space_descriptor_collection< PatternMatrix, Descriptors >, int > = 0>
constexpr OpenKalman::ConstantAdapter< PatternMatrix, Scalar, constant >::ConstantAdapter ( Descriptors &&  descriptors)
inlineexplicit

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Same as above, where the constant is known at compile time.

◆ ConstantAdapter() [2/7]

template<typename PatternMatrix , typename Scalar , auto... constant>
template<typename C , typename Arg , std::enable_if_t< values::scalar< C > and vector_space_descriptors_may_match_with< Arg, PatternMatrix > and std::is_constructible_v< MyConstant, C &&>, int > = 0>
constexpr OpenKalman::ConstantAdapter< PatternMatrix, Scalar, constant >::ConstantAdapter ( C &&  c,
const Arg &  arg 
)
inline

Construct based on a values::scalar and the shape of an indexible reference object.

The following constructs a 2-by-3 ConstantAdapter with constant 5.

ConstantAdapter {std::integral_constant<int, 5>{}, eigen_matrix_t<double, 2, 3>{})
ConstantAdapter {std::integral_constant<int, 5>{}, eigen_matrix_t<double, 2, Eigen::Dynamic>(2, 3))
ConstantAdapter {5, eigen_matrix_t<double, 2, 3>{})
ConstantAdapter {5, eigen_matrix_t<double, Eigen::Dynamic, 3>(2, 3))

◆ ConstantAdapter() [3/7]

template<typename PatternMatrix , typename Scalar , auto... constant>
template<typename Arg , std::enable_if_t< vector_space_descriptors_may_match_with< Arg, PatternMatrix > and(not std::is_base_of_v< ConstantAdapter, Arg >) and values::fixed< MyConstant >, int > = 0>
constexpr OpenKalman::ConstantAdapter< PatternMatrix, Scalar, constant >::ConstantAdapter ( const Arg &  arg)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Same as above, where the constant is known at compile time.

◆ ConstantAdapter() [4/7]

template<typename PatternMatrix , typename Scalar , auto... constant>
template<typename C , typename... Ds, std::enable_if_t< values::scalar< C > and(coordinates::pattern< Ds > and ...) and std::is_constructible_v< MyConstant, C &&> and compatible_with_vector_space_descriptor_collection< PatternMatrix, std::tuple< Ds... >>, int > = 0>
constexpr OpenKalman::ConstantAdapter< PatternMatrix, Scalar, constant >::ConstantAdapter ( C &&  c,
Ds &&...  ds 
)
inlineexplicit

Construct using a full set of coordinates::pattern objects.

For example, the following construct a 2-by-3 constant matrix of value 5:

ConstantAdapter<eigen_matrix_t<double, 2, 3>, 5>(std::integral_constant<int, 5>{}, 2, 3)
ConstantAdapter<eigen_matrix_t<double, Eigen::Dynamic, 3>>(5., 2, 3)
ConstantAdapter<eigen_matrix_t<double, Eigen::Dynamic, Eigen::Dynamic>>(5., 2, 3)

◆ ConstantAdapter() [5/7]

template<typename PatternMatrix , typename Scalar , auto... constant>
template<typename... Ds, std::enable_if_t<(coordinates::pattern< Ds > and ...) and values::fixed< MyConstant > and compatible_with_vector_space_descriptor_collection< PatternMatrix, std::tuple< Ds... >>, int > = 0>
constexpr OpenKalman::ConstantAdapter< PatternMatrix, Scalar, constant >::ConstantAdapter ( Ds &&...  ds)
inlineexplicit

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Same as above, where the constant is known at compile time.

Template Parameters
DsA set of coordinates::pattern objects corresponding to PatternMatrix.

For example, the following construct a 2-by-3 constant matrix of value 5:

ConstantAdapter<eigen_matrix_t<double, 1, 1>, 5>()
ConstantAdapter<eigen_matrix_t<double, 2, 3>, 5>(2, std::integral_constant<int, 3>{})
ConstantAdapter<eigen_matrix_t<double, Eigen::Dynamic, 3>, 5>(2, 3)
ConstantAdapter<eigen_matrix_t<double, Eigen::Dynamic, Eigen::Dynamic>, 5>(2, 3)

◆ ConstantAdapter() [6/7]

template<typename PatternMatrix , typename Scalar , auto... constant>
template<typename C , typename... Ds, std::enable_if_t< values::scalar< C > and(dynamic_pattern< Ds > and ...) and pattern_tuple< DescriptorCollection > and(dynamic_index_count_v< PatternMatrix > !=dynamic_size) and(sizeof...(Ds)==dynamic_index_count_v< PatternMatrix >) and std::is_constructible_v< MyConstant, C &&>, int > = 0>
constexpr OpenKalman::ConstantAdapter< PatternMatrix, Scalar, constant >::ConstantAdapter ( C &&  c,
Ds &&...  ds 
)
inlineexplicit

Construct using only applicable dynamic_pattern.

Template Parameters
DsA set of dynamic_pattern corresponding to each of class template parameter Ds that is dynamic, in order of Ds. This list should omit any fixed_pattern.

If PatternMatrix has no dynamic dimensions, this is a default constructor. The constructor can take a number of arguments representing the number of dynamic dimensions. For example, the following construct a 2-by-3 constant matrix of value 5:

ConstantAdapter<eigen_matrix_t<double, 2, dynamic_size>, 5>(std::integral_constant<int, 5>{}, 3) // Fixed rows and dynamic columns.
ConstantAdapter<eigen_matrix_t<double, 2, 3>>(5) // Fixed rows and columns.
ConstantAdapter<eigen_matrix_t<double, dynamic_size, 3>>(5, 2) // Dynamic rows and fixed columns.
ConstantAdapter<eigen_matrix_t<double, 2, dynamic_size>, 5>(5, 3) // Fixed rows and dynamic columns.

◆ ConstantAdapter() [7/7]

template<typename PatternMatrix , typename Scalar , auto... constant>
template<typename... Ds, std::enable_if_t< values::scalar< C > and(dynamic_pattern< Ds > and ...) and pattern_tuple< DescriptorCollection > and(dynamic_index_count_v< PatternMatrix > !=dynamic_size) and(sizeof...(Ds)==dynamic_index_count_v< PatternMatrix >) and values::fixed< MyConstant >, int > = 0>
constexpr OpenKalman::ConstantAdapter< PatternMatrix, Scalar, constant >::ConstantAdapter ( Ds &&...  ds)
inlineexplicit

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Same as above, where the constant is known at compile time.

For example, the following construct a 2-by-3 constant matrix of value 5:

ConstantAdapter<eigen_matrix_t<double, dynamic_size, dynamic_size>, 5>(2, 3) // Dynamic rows and columns.
ConstantAdapter<eigen_matrix_t<double, 2, dynamic_size>, 5>(3) // Fixed rows and dynamic columns.
ConstantAdapter<eigen_matrix_t<double, dynamic_size, 3>, 5>(2) // Dynamic rows and fixed columns.
ConstantAdapter<eigen_matrix_t<double, 2, 3>, 5>() // Fixed rows and columns.

Member Function Documentation

◆ operator[]()

template<typename PatternMatrix , typename Scalar , auto... constant>
template<typename Indices , std::enable_if_t< index_range_for< Indices, PatternMatrix > and(not empty_object< PatternMatrix >), int > = 0>
constexpr auto OpenKalman::ConstantAdapter< PatternMatrix, Scalar, constant >::operator[] ( const Indices &  indices) const
inline

Access a component at a set of indices.

Returns
The element corresponding to the indices (always the constant).

The documentation for this struct was generated from the following file: