farm-ng-core
division_ring.h
Go to the documentation of this file.
1 // Copyright (c) 2011, Hauke Strasdat
2 // Copyright (c) 2012, Steven Lovegrove
3 // Copyright (c) 2021, farm-ng, inc.
4 //
5 // Use of this source code is governed by an MIT-style
6 // license that can be found in the LICENSE file or at
7 // https://opensource.org/licenses/MIT.
8 
9 #pragma once
10 #include "sophus/concepts/params.h"
11 #include "sophus/concepts/utils.h"
12 
13 namespace sophus {
14 namespace concepts {
15 
16 template <class TScalar, int kN>
17 class UnitVector;
18 
19 template <class TT>
21  ::sophus::concepts::ParamsImpl<TT> // or homogeneous point representation
22  && requires(
23  typename TT::Params params,
24  Eigen::Vector<CompatScalarEx<typename TT::Scalar>, TT::kNumParams>
25  compatible_params) {
26  // constructors and factories
27  { TT::one() } -> ::sophus::concepts::ConvertibleTo<typename TT::Params>;
28 
29  { TT::zero() } -> ::sophus::concepts::ConvertibleTo<typename TT::Params>;
30 
31  // operations
32 
33  {
34  TT::addition(params, params)
35  } -> ::sophus::concepts::ConvertibleTo<typename TT::Params>;
36 
37  {
38  TT::multiplication(params, params)
39  } -> ::sophus::concepts::ConvertibleTo<typename TT::Params>;
40 
41 #if __cplusplus >= 202002L
42  {
43  TT::template addition<CompatScalarEx<typename TT::Scalar>>(
44  params, compatible_params)
45  } -> ::sophus::concepts::ConvertibleTo<typename TT::template ParamsReturn<
47 
48  {
49  TT::template multiplication<CompatScalarEx<typename TT::Scalar>>(
50  params, compatible_params)
51  } -> ::sophus::concepts::ConvertibleTo<typename TT::template ParamsReturn<
53 #endif
54 
55  {
56  TT::conjugate(params)
57  } -> ::sophus::concepts::ConvertibleTo<typename TT::Params>;
58 
59  {
60  TT::inverse(params)
61  } -> ::sophus::concepts::ConvertibleTo<typename TT::Params>;
62 
63  // reduction
64  {
65  TT::norm(params)
66  } -> ::sophus::concepts::ConvertibleTo<typename TT::Scalar>;
67 
68  {
69  TT::squaredNorm(params)
70  } -> ::sophus::concepts::ConvertibleTo<typename TT::Scalar>;
71 };
72 
73 template <class TT>
74 concept DivisionRingConcept = DivisionRingImpl<typename TT::Impl> && requires(
75  TT r,
76  typename TT::Scalar real,
77  typename TT::Imag imag,
78  typename TT::Params params) {
79  // operations
80  { r.operator+(r) } -> ::sophus::concepts::ConvertibleTo<TT>;
81 
82  { r.operator*(r) } -> ::sophus::concepts::ConvertibleTo<TT>;
83 
84  { r.conjugate() } -> ::sophus::concepts::ConvertibleTo<TT>;
85 
86  { r.inverse() } -> ::sophus::concepts::ConvertibleTo<TT>;
87 
88  // reduction
89  { r.norm() } -> ::sophus::concepts::ConvertibleTo<typename TT::Scalar>;
90 
91  { r.squaredNorm() } -> ::sophus::concepts::ConvertibleTo<typename TT::Scalar>;
92 
93  { r.real() } -> ::sophus::concepts::ConvertibleTo<typename TT::Scalar>;
94 
95  { r.imag() } -> ::sophus::concepts::ConvertibleTo<typename TT::Imag>;
96 };
97 } // namespace concepts
98 } // namespace sophus
sophus::concepts::UnitVector
Definition: division_ring.h:17
sophus
Image MutImage, owning images types.
Definition: num_diff.h:20
utils.h
sophus::concepts::DivisionRingConcept
concept DivisionRingConcept
Definition: division_ring.h:74
sophus::zero
auto zero() -> TPoint
Definition: vector_space.h:34
sophus::concepts::DivisionRingImpl
concept DivisionRingImpl
Definition: division_ring.h:20
params.h
sophus::concepts::CompatScalarEx
Definition: params.h:63
sophus::concepts::ConvertibleTo
concept ConvertibleTo
Definition: utils.h:33
sophus::concepts::Params
concept Params
Definition: params.h:41