types.hpp
Go to the documentation of this file.
1 
4 #ifndef SOPHUS_TYPES_HPP
5 #define SOPHUS_TYPES_HPP
6 
7 #include <type_traits>
8 #include "common.hpp"
9 
10 namespace Sophus {
11 
12 template <class Scalar, int M, int Options = 0>
13 using Vector = Eigen::Matrix<Scalar, M, 1, Options>;
14 
15 template <class Scalar, int Options = 0>
19 
20 template <class Scalar, int Options = 0>
24 
25 template <class Scalar>
29 
30 template <class Scalar>
34 
35 template <class Scalar>
39 
40 template <class Scalar, int M, int N>
41 using Matrix = Eigen::Matrix<Scalar, M, N>;
42 
43 template <class Scalar>
47 
48 template <class Scalar>
52 
53 template <class Scalar>
57 
58 template <class Scalar>
62 
63 template <class Scalar>
67 
68 template <class Scalar, int N, int Options = 0>
69 using ParametrizedLine = Eigen::ParametrizedLine<Scalar, N, Options>;
70 
71 template <class Scalar, int Options = 0>
75 
76 template <class Scalar, int Options = 0>
80 
81 namespace details {
82 template <class Scalar>
83 class MaxMetric {
84  public:
85  static Scalar impl(Scalar s0, Scalar s1) {
86  using std::abs;
87  return abs(s0 - s1);
88  }
89 };
90 
91 template <class Scalar, int M, int N>
92 class MaxMetric<Matrix<Scalar, M, N>> {
93  public:
94  static Scalar impl(Matrix<Scalar, M, N> const& p0,
95  Matrix<Scalar, M, N> const& p1) {
96  return (p0 - p1).template lpNorm<Eigen::Infinity>();
97  }
98 };
99 
100 template <class Scalar>
101 class SetToZero {
102  public:
103  static void impl(Scalar& s) { s = Scalar(0); }
104 };
105 
106 template <class Scalar, int M, int N>
107 class SetToZero<Matrix<Scalar, M, N>> {
108  public:
109  static void impl(Matrix<Scalar, M, N>& v) { v.setZero(); }
110 };
111 
112 template <class T1, class Scalar>
114 
115 template <class Scalar>
116 class SetElementAt<Scalar, Scalar> {
117  public:
118  static void impl(Scalar& s, Scalar value, int at) {
119  SOPHUS_ENSURE(at == 0, "is %", at);
120  s = value;
121  }
122 };
123 
124 template <class Scalar, int N>
125 class SetElementAt<Vector<Scalar, N>, Scalar> {
126  public:
127  static void impl(Vector<Scalar, N>& v, Scalar value, int at) {
128  SOPHUS_ENSURE(at >= 0 && at < N, "is %", at);
129  v[at] = value;
130  }
131 };
132 
133 template <class Scalar>
134 class SquaredNorm {
135  public:
136  static Scalar impl(Scalar const& s) { return s * s; }
137 };
138 
139 template <class Scalar, int N>
140 class SquaredNorm<Matrix<Scalar, N, 1>> {
141  public:
142  static Scalar impl(Matrix<Scalar, N, 1> const& s) { return s.squaredNorm(); }
143 };
144 
145 template <class Scalar>
146 class Transpose {
147  public:
148  static Scalar impl(Scalar const& s) { return s; }
149 };
150 
151 template <class Scalar, int M, int N>
152 class Transpose<Matrix<Scalar, M, N>> {
153  public:
155  return s.transpose();
156  }
157 };
158 } // namespace details
159 
163 template <class T>
164 auto maxMetric(T const& p0, T const& p1)
165  -> decltype(details::MaxMetric<T>::impl(p0, p1)) {
166  return details::MaxMetric<T>::impl(p0, p1);
167 }
168 
171 template <class T>
172 void setToZero(T& p) {
173  return details::SetToZero<T>::impl(p);
174 }
175 
179 template <class T, class Scalar>
180 void setElementAt(T& p, Scalar value, int i) {
181  return details::SetElementAt<T, Scalar>::impl(p, value, i);
182 }
183 
186 template <class T>
187 auto squaredNorm(T const& p) -> decltype(details::SquaredNorm<T>::impl(p)) {
189 }
190 
194 template <class T>
195 auto transpose(T const& p) -> decltype(details::Transpose<T>::impl(T())) {
196  return details::Transpose<T>::impl(p);
197 }
198 
199 template <class Scalar>
201  static bool const value = std::is_floating_point<Scalar>::value;
202 };
203 
204 template <class Scalar, int M, int N>
205 struct IsFloatingPoint<Matrix<Scalar, M, N>> {
206  static bool const value = std::is_floating_point<Scalar>::value;
207 };
208 
209 template <class Scalar_>
210 struct GetScalar {
211  using Scalar = Scalar_;
212 };
213 
214 template <class Scalar_, int M, int N>
215 struct GetScalar<Matrix<Scalar_, M, N>> {
216  using Scalar = Scalar_;
217 };
218 
221 template <typename Vector, int NumDimensions,
222  typename = typename std::enable_if<
223  Vector::RowsAtCompileTime == NumDimensions &&
224  Vector::ColsAtCompileTime == 1>::type>
225 struct IsFixedSizeVector : std::true_type {};
226 
228 template <class T>
229 using Plane3 = Eigen::Hyperplane<T, 3>;
232 
234 template <class T>
235 using Line2 = Eigen::Hyperplane<T, 2>;
238 
239 } // namespace Sophus
240 
241 #endif // SOPHUS_TYPES_HPP
Sophus::Vector7f
Vector7< float > Vector7f
Definition: types.hpp:37
Sophus::details::SquaredNorm
Definition: types.hpp:134
Sophus::details::MaxMetric
Definition: types.hpp:83
Sophus::Matrix6f
Matrix6< float > Matrix6f
Definition: types.hpp:60
Sophus::Vector6d
Vector6< double > Vector6d
Definition: types.hpp:33
Sophus::Matrix4f
Matrix4< float > Matrix4f
Definition: types.hpp:55
Sophus::Vector7d
Vector7< double > Vector7d
Definition: types.hpp:38
Sophus::setElementAt
void setElementAt(T &p, Scalar value, int i)
Definition: types.hpp:180
Sophus::setToZero
void setToZero(T &p)
Definition: types.hpp:172
common.hpp
Sophus::IsFloatingPoint::value
static const bool value
Definition: types.hpp:201
Sophus::ParametrizedLine2f
ParametrizedLine2< float > ParametrizedLine2f
Definition: types.hpp:78
Sophus::details::SetToZero::impl
static void impl(Scalar &s)
Definition: types.hpp:103
Sophus::Vector3
Vector< Scalar, 3, Options > Vector3
Definition: types.hpp:21
Sophus::Matrix4d
Matrix4< double > Matrix4d
Definition: types.hpp:56
Sophus::details::MaxMetric::impl
static Scalar impl(Scalar s0, Scalar s1)
Definition: types.hpp:85
Sophus::details::SquaredNorm< Matrix< Scalar, N, 1 > >::impl
static Scalar impl(Matrix< Scalar, N, 1 > const &s)
Definition: types.hpp:142
Sophus::IsFloatingPoint
Definition: types.hpp:200
Sophus::Matrix2
Matrix< Scalar, 2, 2 > Matrix2
Definition: types.hpp:44
SOPHUS_ENSURE
#define SOPHUS_ENSURE(expr,...)
Definition: common.hpp:137
Sophus::GetScalar< Matrix< Scalar_, M, N > >::Scalar
Scalar_ Scalar
Definition: types.hpp:216
Sophus::Matrix2f
Matrix2< float > Matrix2f
Definition: types.hpp:45
Sophus::Vector2f
Vector2< float > Vector2f
Definition: types.hpp:17
Sophus::Vector2
Vector< Scalar, 2, Options > Vector2
Definition: types.hpp:16
Sophus::details::SquaredNorm::impl
static Scalar impl(Scalar const &s)
Definition: types.hpp:136
Sophus::Vector4d
Vector4< double > Vector4d
Definition: types.hpp:28
Sophus::Matrix2d
Matrix2< double > Matrix2d
Definition: types.hpp:46
Sophus::Matrix3d
Matrix3< double > Matrix3d
Definition: types.hpp:51
Sophus::ParametrizedLine3
ParametrizedLine< Scalar, 3, Options > ParametrizedLine3
Definition: types.hpp:72
Sophus::Matrix7
Matrix< Scalar, 7, 7 > Matrix7
Definition: types.hpp:64
Sophus::details::Transpose::impl
static Scalar impl(Scalar const &s)
Definition: types.hpp:148
Sophus::details::SetElementAt< Vector< Scalar, N >, Scalar >::impl
static void impl(Vector< Scalar, N > &v, Scalar value, int at)
Definition: types.hpp:127
Sophus::Line2f
Line2< float > Line2f
Definition: types.hpp:237
Sophus::maxMetric
auto maxMetric(T const &p0, T const &p1) -> decltype(details::MaxMetric< T >::impl(p0, p1))
Definition: types.hpp:164
Sophus::Vector3d
Vector3< double > Vector3d
Definition: types.hpp:23
Sophus::details::SetToZero< Matrix< Scalar, M, N > >::impl
static void impl(Matrix< Scalar, M, N > &v)
Definition: types.hpp:109
Sophus::details::SetToZero
Definition: types.hpp:101
Sophus::details::MaxMetric< Matrix< Scalar, M, N > >::impl
static Scalar impl(Matrix< Scalar, M, N > const &p0, Matrix< Scalar, M, N > const &p1)
Definition: types.hpp:94
Sophus::Matrix7f
Matrix7< float > Matrix7f
Definition: types.hpp:65
Sophus::ParametrizedLine3d
ParametrizedLine3< double > ParametrizedLine3d
Definition: types.hpp:74
Sophus::Matrix
Eigen::Matrix< Scalar, M, N > Matrix
Definition: types.hpp:41
Sophus
Definition: average.hpp:17
Sophus::Matrix7d
Matrix7< double > Matrix7d
Definition: types.hpp:66
Sophus::Vector2d
Vector2< double > Vector2d
Definition: types.hpp:18
Sophus::details::Transpose
Definition: types.hpp:146
Sophus::transpose
auto transpose(T const &p) -> decltype(details::Transpose< T >::impl(T()))
Definition: types.hpp:195
Sophus::Plane3d
Plane3< double > Plane3d
Definition: types.hpp:230
Sophus::Matrix6
Matrix< Scalar, 6, 6 > Matrix6
Definition: types.hpp:59
Sophus::Plane3
Eigen::Hyperplane< T, 3 > Plane3
Planes in 3d are hyperplanes.
Definition: types.hpp:229
Sophus::GetScalar
Definition: types.hpp:210
Sophus::Vector3f
Vector3< float > Vector3f
Definition: types.hpp:22
Sophus::Vector7
Vector< Scalar, 7 > Vector7
Definition: types.hpp:36
Sophus::details::SetElementAt
Definition: types.hpp:113
Sophus::Vector6
Vector< Scalar, 6 > Vector6
Definition: types.hpp:31
Sophus::Matrix6d
Matrix6< double > Matrix6d
Definition: types.hpp:61
Sophus::details::SetElementAt< Scalar, Scalar >::impl
static void impl(Scalar &s, Scalar value, int at)
Definition: types.hpp:118
Sophus::ParametrizedLine2d
ParametrizedLine2< double > ParametrizedLine2d
Definition: types.hpp:79
Sophus::Line2
Eigen::Hyperplane< T, 2 > Line2
Lines in 2d are hyperplanes.
Definition: types.hpp:235
Sophus::IsFixedSizeVector
Definition: types.hpp:225
Sophus::ParametrizedLine3f
ParametrizedLine3< float > ParametrizedLine3f
Definition: types.hpp:73
Sophus::Vector6f
Vector6< float > Vector6f
Definition: types.hpp:32
Sophus::squaredNorm
auto squaredNorm(T const &p) -> decltype(details::SquaredNorm< T >::impl(p))
Definition: types.hpp:187
Sophus::Matrix3
Matrix< Scalar, 3, 3 > Matrix3
Definition: types.hpp:49
Sophus::Matrix3f
Matrix3< float > Matrix3f
Definition: types.hpp:50
Sophus::Vector4
Vector< Scalar, 4 > Vector4
Definition: types.hpp:26
Sophus::Vector4f
Vector4< float > Vector4f
Definition: types.hpp:27
Sophus::Vector
Eigen::Matrix< Scalar, M, 1, Options > Vector
Definition: types.hpp:13
Sophus::ParametrizedLine
Eigen::ParametrizedLine< Scalar, N, Options > ParametrizedLine
Definition: types.hpp:69
Sophus::details::Transpose< Matrix< Scalar, M, N > >::impl
static Matrix< Scalar, M, N > impl(Matrix< Scalar, M, N > const &s)
Definition: types.hpp:154
Sophus::ParametrizedLine2
ParametrizedLine< Scalar, 2, Options > ParametrizedLine2
Definition: types.hpp:77
Sophus::GetScalar::Scalar
Scalar_ Scalar
Definition: types.hpp:211
Sophus::Line2d
Line2< double > Line2d
Definition: types.hpp:236
Sophus::Matrix4
Matrix< Scalar, 4, 4 > Matrix4
Definition: types.hpp:54
Sophus::Plane3f
Plane3< float > Plane3f
Definition: types.hpp:231


sophus
Author(s): Hauke Strasdat
autogenerated on Wed Mar 2 2022 01:01:48