OpenKalman
Public Member Functions | Protected Attributes | Friends | List of all members
OpenKalman::constant_adapter< Value, Shape > Struct Template Reference

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

#include <constant_adapter.hpp>

Inheritance diagram for OpenKalman::constant_adapter< Value, Shape >:
Inheritance graph
[legend]
Collaboration diagram for OpenKalman::constant_adapter< Value, Shape >:
Collaboration graph
[legend]

Public Member Functions

template<typename V , typename P , std::enable_if_t< values::value< V > and pattern_collection< P > and stdex::constructible_from< Value, V &&> and stdex::constructible_from< Pattern, P &&>, int > = 0>
constexpr constant_adapter (V &&v, P &&p)
 Construct from value and a pattern_collection.
 
template<typename V , typename S , std::enable_if_t< values::value< V > and stdex::constructible_from< Value, V &&> and stdex::constructible_from< Pattern, decltype(get_pattern_collection(std::declval< S &&>()))>, int > = 0>
constexpr constant_adapter (V &&v, S &&s)
 Construct from value and a reference to an indexible object.
 
template<typename V , typename S , std::enable_if_t< values::value< V > and stdex::constructible_from< Value, V &&> and coordinates::fixed_pattern_collection< Pattern >, int > = 0>
constexpr constant_adapter (V &&v)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
template<bool Enable, std::enable_if_t< Enable and values::fixed< Value > and coordinates::fixed_pattern_collection< Pattern >, int > = 0>
constexpr constant_adapter ()
 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_object< Arg > and(not stdex::same_as< std::decay_t< Arg >, constant_adapter >) and stdex::constructible_from< Value, constant_value< Arg >> and stdex::constructible_from< Pattern, decltype(get_pattern_collection(std::declval< Arg &&>()))>, int > = 0>
constexpr constant_adapter (Arg &&arg)
 Construct from another constant_object.
 
template<typename Arg , std::enable_if_t< constant_object< Arg > and(not stdex::same_as< std::decay_t< Arg >, constant_adapter >) and stdex::assignable_from< Value &, constant_value< Arg >> and stdex::assignable_from< Pattern &, decltype(get_pattern_collection(std::declval< Arg &&>()))>, int > = 0>
constexpr auto & operator= (const Arg &arg)
 Assign from a compatible constant_object.
 
template<typename Indices , std::enable_if_t< index_collection_for< Indices, Shape > 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 value () const
 Get the values::scalar associated with this object.
 

Protected Attributes

Value value_
 
Pattern pattern_
 

Friends

struct interface::object_traits< constant_adapter >
 
struct interface::library_interface< constant_adapter >
 

Detailed Description

template<typename Value, typename Shape>
struct OpenKalman::constant_adapter< Value, Shape >

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

The constant value can be any values::value. Examples:

using T = Eigen::Matrix<double, 3, 2>; // A 3-by-2 matrix of scalar-type double in the Eigen library.
constant_adapter<double, T> c1 {3.0}; // Construct a 3-by-2 double constant within the library of T with value 3.0 (known at runtime).
constant_adapter<int, T> c2 {3}; // Construct a 3-by-2 int constant within the library of T with value 3 (known at runtime).
constant_adapter<value::fixed_value<int, 1>, T> c3; // Construct a 3-by-2 int constant within the library of T with value 1 (known at compile time).
constant_adapter<value::fixed_value<double, 1, T> c4; // Construct a 3-by-2 double constant within the library of T with value 1.0 (known at compile time).
constant_adapter<std::integral_constant<int, 1>, T> c5; // Construct a 3-by-2 int constant within the library of T with value 1 (known at compile time).
constant_adapter<value::fixed_value<std::complex<double>, T> c6 {std::complex<double>{4, 5}}; // Construct a 3-by-2 complex constant within the library of T and value 4.0 + 5.0i (known at runtime).
constant_adapter<value::fixed_value<std::complex<double, 4, 5>, T> c7; // Construct a 3-by-2 A complex constant within the library of T and value 4.0 + 5.0i (known at compile time).
Template Parameters
ValueA values::value.
ShapeAn indexible object reflecting the size and shape of the adapter object.

Constructor & Destructor Documentation

◆ constant_adapter() [1/2]

template<typename Value, typename Shape>
template<typename V , typename S , std::enable_if_t< values::value< V > and stdex::constructible_from< Value, V &&> and coordinates::fixed_pattern_collection< Pattern >, int > = 0>
constexpr OpenKalman::constant_adapter< Value, Shape >::constant_adapter ( V &&  v)
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, if the pattern_collection associated with Shape is known at compile time.

◆ constant_adapter() [2/2]

template<typename Value, typename Shape>
template<bool Enable, std::enable_if_t< Enable and values::fixed< Value > and coordinates::fixed_pattern_collection< Pattern >, int > = 0>
constexpr OpenKalman::constant_adapter< Value, Shape >::constant_adapter ( )
inlineexplicit

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

Default constructor, assuming the constant and the shape are known at compile time.

Member Function Documentation

◆ operator[]()

template<typename Value, typename Shape>
template<typename Indices , std::enable_if_t< index_collection_for< Indices, Shape > and(not empty_object< PatternMatrix >), int > = 0>
constexpr auto OpenKalman::constant_adapter< Value, Shape >::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: