OpenKalman
IdentityTransform.hpp
Go to the documentation of this file.
1 /* This file is part of OpenKalman, a header-only C++ library for
2  * Kalman filters and other recursive filters.
3  *
4  * Copyright (c) 2019-2021 Christopher Lee Ogden <ogden@gatech.edu>
5  *
6  * This Source Code Form is subject to the terms of the Mozilla Public
7  * License, v. 2.0. If a copy of the MPL was not distributed with this
8  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
9  */
10 
16 #ifndef OPENKALMAN_IDENTITYTRANSFORM_HPP
17 #define OPENKALMAN_IDENTITYTRANSFORM_HPP
18 
19 namespace OpenKalman
20 {
21  namespace oin = OpenKalman::internal;
22 
26  struct IdentityTransform : oin::TransformBase<IdentityTransform>
27  {
28 
29  private:
30 
32 
33  public:
34 
35  using Base::operator();
36 
37 
44 #ifdef __cpp_concepts
45  template<distribution InputDist, distribution ... NoiseDists> requires
46  (coordinates::compares_with<typename DistributionTraits<InputDist>::StaticDescriptor,
47  typename DistributionTraits<NoiseDists>::StaticDescriptor> and ...)
48 #else
49  template<typename InputDist, typename ... NoiseDists,
50  std::enable_if_t<(distribution<InputDist> and ... and distribution<NoiseDists>) and
51  (coordinates::compares_with<typename DistributionTraits<InputDist>::StaticDescriptor,
52  typename DistributionTraits<NoiseDists>::StaticDescriptor> and ...), int> = 0>
53 #endif
54  auto operator()(const InputDist& x, const NoiseDists& ... ns) const
55  {
56  return make_self_contained((x + ... + ns));
57  }
58 
59 
61 
62 
69 #ifdef __cpp_concepts
70  template<distribution InputDist, distribution ... NoiseDists> requires
71  (coordinates::compares_with<typename DistributionTraits<InputDist>::StaticDescriptor,
72  typename DistributionTraits<NoiseDists>::StaticDescriptor> and ...)
73 #else
74  template<typename InputDist, typename ... NoiseDists,
75  std::enable_if_t<(distribution<InputDist> and ... and distribution<NoiseDists>) and
76  (coordinates::compares_with<typename DistributionTraits<InputDist>::StaticDescriptor,
77  typename DistributionTraits<NoiseDists>::StaticDescriptor> and ...), int> = 0>
78 #endif
79  auto transform_with_cross_covariance(const InputDist& x, const NoiseDists& ... ns) const
80  {
81  auto cross = Matrix {covariance_of(x)};
82  return std::tuple {make_self_contained((x + ... + ns)), std::move(cross)};
83  }
84 
85  };
86 
87 }
88 
89 #endif //OPENKALMAN_IDENTITYTRANSFORM_HPP
An identity transform from one statistical distribution to another.
Definition: IdentityTransform.hpp:26
Definition: TransformBase.hpp:30
auto transform_with_cross_covariance(const InputDist &x, const NoiseDists &... ns) const
Perform identity transform, also returning the cross-covariance.
Definition: IdentityTransform.hpp:79
The root namespace for OpenKalman.
Definition: basics.hpp:34
constexpr bool distribution
T is a statistical distribution of any kind that is defined in OpenKalman.
Definition: object-types.hpp:193
auto operator()(const InputDist &x, const NoiseDists &... ns) const
Apply the identity transform on an input distribution.
Definition: IdentityTransform.hpp:54
Definition: basics.hpp:48
A matrix with typed rows and columns.
Definition: forward-class-declarations.hpp:448
auto transform_with_cross_covariance(const InputDist &x, const T &t, const Ts &...ts) const
Perform one or more consecutive transforms, also returning the cross-covariance.
Definition: TransformBase.hpp:80