Eigen/src/Geometry/Scaling.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #ifndef EIGEN_SCALING_H
11 #define EIGEN_SCALING_H
12 
13 namespace Eigen {
14 
33 namespace internal
34 {
35  // This helper helps nvcc+MSVC to properly parse this file.
36  // See bug 1412.
37  template <typename Scalar, int Dim, int Mode>
39  {
40  enum
41  {
42  NewMode = int(Mode) == int(Isometry) ? Affine : Mode
43  };
45  };
46 }
47 
48 template<typename _Scalar>
49 class UniformScaling
50 {
51 public:
53  typedef _Scalar Scalar;
54 
55 protected:
56 
57  Scalar m_factor;
58 
59 public:
60 
64  explicit inline UniformScaling(const Scalar& s) : m_factor(s) {}
65 
66  inline const Scalar& factor() const { return m_factor; }
67  inline Scalar& factor() { return m_factor; }
68 
71  { return UniformScaling(m_factor * other.factor()); }
72 
74  template<int Dim>
76 
78  template<int Dim, int Mode, int Options>
79  inline typename
82  {
84  res.prescale(factor());
85  return res;
86  }
87 
89  // TODO returns an expression
90  template<typename Derived>
92  { return other * m_factor; }
93 
94  template<typename Derived,int Dim>
96  { return r.toRotationMatrix() * m_factor; }
97 
99  inline UniformScaling inverse() const
100  { return UniformScaling(Scalar(1)/m_factor); }
101 
107  template<typename NewScalarType>
109  { return UniformScaling<NewScalarType>(NewScalarType(m_factor)); }
110 
112  template<typename OtherScalarType>
114  { m_factor = Scalar(other.factor()); }
115 
121  { return internal::isApprox(m_factor, other.factor(), prec); }
122 
123 };
124 
127 
131 // NOTE this operator is defined in MatrixBase and not as a friend function
132 // of UniformScaling to fix an internal crash of Intel's ICC
133 template<typename Derived,typename Scalar>
135 operator*(const MatrixBase<Derived>& matrix, const UniformScaling<Scalar>& s)
136 { return matrix.derived() * s.factor(); }
137 
143 template<typename RealScalar>
144 inline UniformScaling<std::complex<RealScalar> > Scaling(const std::complex<RealScalar>& s)
146 
148 template<typename Scalar>
149 inline DiagonalMatrix<Scalar,2> Scaling(const Scalar& sx, const Scalar& sy)
150 { return DiagonalMatrix<Scalar,2>(sx, sy); }
152 template<typename Scalar>
153 inline DiagonalMatrix<Scalar,3> Scaling(const Scalar& sx, const Scalar& sy, const Scalar& sz)
154 { return DiagonalMatrix<Scalar,3>(sx, sy, sz); }
155 
159 template<typename Derived>
161 { return coeffs.asDiagonal(); }
162 
172 
173 template<typename Scalar>
174 template<int Dim>
177 {
179  res.matrix().setZero();
180  res.linear().diagonal().fill(factor());
181  res.translation() = factor() * t.vector();
182  res(Dim,Dim) = Scalar(1);
183  return res;
184 }
185 
186 } // end namespace Eigen
187 
188 #endif // EIGEN_SCALING_H
SCALAR Scalar
Definition: bench_gemm.cpp:46
#define EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(EXPR, SCALAR, OPNAME)
Definition: Macros.h:1347
DiagonalMatrix< float, 3 > AlignedScaling3f
DiagonalMatrix< float, 2 > AlignedScaling2f
Represents a diagonal matrix with its storage.
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
DiagonalMatrix< double, 3 > AlignedScaling3d
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Definition: NumTraits.h:232
const Scalar & factor() const
UniformScaling< NewScalarType > cast() const
UniformScaling< float > Scaling(float s)
Represents a translation transformation.
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
UniformScaling(const UniformScaling< OtherScalarType > &other)
EIGEN_DEVICE_FUNC const MatrixType & matrix() const
Definition: Transform.h:389
UniformScaling operator*(const UniformScaling &other) const
EIGEN_DEVICE_FUNC ConstTranslationPart translation() const
Definition: Transform.h:404
EIGEN_DEVICE_FUNC const VectorType & vector() const
Definition: Translation.h:87
EIGEN_DEVICE_FUNC ConstLinearPart linear() const
Definition: Transform.h:394
EIGEN_DEVICE_FUNC Transform & prescale(const MatrixBase< OtherDerived > &other)
Matrix< Scalar, Dim, Dim > operator*(const RotationBase< Derived, Dim > &r) const
Represents a generic uniform scaling transformation.
Common base class for compact rotation representations.
RealScalar s
DiagonalMatrix< double, 2 > AlignedScaling2d
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorUInt128< uint64_t, uint64_t > operator*(const TensorUInt128< HL, LL > &lhs, const TensorUInt128< HR, LR > &rhs)
bool isApprox(const UniformScaling &other, const typename NumTraits< Scalar >::Real &prec=NumTraits< Scalar >::dummy_precision()) const
EIGEN_DEVICE_FUNC RotationMatrixType toRotationMatrix() const
Definition: RotationBase.h:45
EIGEN_DEVICE_FUNC const DiagonalWrapper< const Derived > asDiagonal() const
UniformScaling inverse() const
Expression of a diagonal matrix.
Map< Matrix< T, Dynamic, Dynamic, ColMajor >, 0, OuterStride<> > matrix(T *data, int rows, int cols, int stride)
The matrix class, also used for vectors and row-vectors.
EIGEN_DEVICE_FUNC bool isApprox(const Scalar &x, const Scalar &y, const typename NumTraits< Scalar >::Real &precision=NumTraits< Scalar >::dummy_precision())
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
Represents an homogeneous transformation in a N dimensional space.
Point2 t(10, 10)
void product(const MatrixType &m)
Definition: product.h:20


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:35:35