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 
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
gtsam.examples.DogLegOptimizerExample.int
int
Definition: DogLegOptimizerExample.py:111
Eigen
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
Eigen::DiagonalMatrix
Represents a diagonal matrix with its storage.
Definition: DiagonalMatrix.h:140
Eigen::AlignedScaling2f
DiagonalMatrix< float, 2 > AlignedScaling2f
Definition: Eigen/src/Geometry/Scaling.h:164
Eigen::UniformScaling::UniformScaling
UniformScaling()
Definition: Eigen/src/Geometry/Scaling.h:62
Eigen::Transform
Represents an homogeneous transformation in a N dimensional space.
Definition: ForwardDeclarations.h:294
s
RealScalar s
Definition: level1_cplx_impl.h:126
Eigen::Affine
@ Affine
Definition: Constants.h:460
Eigen::MatrixBase::asDiagonal
const EIGEN_DEVICE_FUNC DiagonalWrapper< const Derived > asDiagonal() const
Definition: DiagonalMatrix.h:325
Eigen::UniformScaling::cast
UniformScaling< NewScalarType > cast() const
Definition: Eigen/src/Geometry/Scaling.h:108
Eigen::Scaling
UniformScaling< float > Scaling(float s)
Definition: Eigen/src/Geometry/Scaling.h:139
Eigen::UniformScaling::UniformScaling
UniformScaling(const Scalar &s)
Definition: Eigen/src/Geometry/Scaling.h:64
Eigen::UniformScaling::Scalar
_Scalar Scalar
Definition: Eigen/src/Geometry/Scaling.h:53
Eigen::internal::isApprox
EIGEN_DEVICE_FUNC bool isApprox(const Scalar &x, const Scalar &y, const typename NumTraits< Scalar >::Real &precision=NumTraits< Scalar >::dummy_precision())
Definition: Eigen/src/Core/MathFunctions.h:1947
res
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
Definition: PartialRedux_count.cpp:3
Eigen::AlignedScaling3d
DiagonalMatrix< double, 3 > AlignedScaling3d
Definition: Eigen/src/Geometry/Scaling.h:170
Eigen::internal::uniformscaling_times_affine_returntype
Definition: Eigen/src/Geometry/Scaling.h:38
Eigen::internal::plain_matrix_type
Definition: XprHelper.h:295
Eigen::UniformScaling::factor
Scalar & factor()
Definition: Eigen/src/Geometry/Scaling.h:67
Eigen::UniformScaling::m_factor
Scalar m_factor
Definition: Eigen/src/Geometry/Scaling.h:57
Eigen::UniformScaling::inverse
UniformScaling inverse() const
Definition: Eigen/src/Geometry/Scaling.h:99
Eigen::AlignedScaling3f
DiagonalMatrix< float, 3 > AlignedScaling3f
Definition: Eigen/src/Geometry/Scaling.h:168
Eigen::RotationBase::toRotationMatrix
EIGEN_DEVICE_FUNC RotationMatrixType toRotationMatrix() const
Definition: RotationBase.h:45
Eigen::Isometry
@ Isometry
Definition: Constants.h:457
Eigen::RotationBase
Common base class for compact rotation representations.
Definition: ForwardDeclarations.h:286
Eigen::UniformScaling::UniformScaling
UniformScaling(const UniformScaling< OtherScalarType > &other)
Definition: Eigen/src/Geometry/Scaling.h:113
Eigen::UniformScaling::factor
const Scalar & factor() const
Definition: Eigen/src/Geometry/Scaling.h:66
Eigen::UniformScaling::operator*
Matrix< Scalar, Dim, Dim > operator*(const RotationBase< Derived, Dim > &r) const
Definition: Eigen/src/Geometry/Scaling.h:95
Eigen::UniformScaling::operator*
UniformScaling operator*(const UniformScaling &other) const
Definition: Eigen/src/Geometry/Scaling.h:70
EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE
#define EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(EXPR, SCALAR, OPNAME)
Definition: Macros.h:1347
Eigen::internal::uniformscaling_times_affine_returntype::type
Transform< Scalar, Dim, NewMode > type
Definition: Eigen/src/Geometry/Scaling.h:44
Eigen::DiagonalWrapper
Expression of a diagonal matrix.
Definition: DiagonalMatrix.h:293
matrix
Map< Matrix< T, Dynamic, Dynamic, ColMajor >, 0, OuterStride<> > matrix(T *data, int rows, int cols, int stride)
Definition: gtsam/3rdparty/Eigen/blas/common.h:110
Eigen::UniformScaling::isApprox
bool isApprox(const UniformScaling &other, const typename NumTraits< Scalar >::Real &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: Eigen/src/Geometry/Scaling.h:120
Eigen::UniformScaling
Represents a generic uniform scaling transformation.
Definition: ForwardDeclarations.h:297
product
void product(const MatrixType &m)
Definition: product.h:20
Eigen::AlignedScaling2d
DiagonalMatrix< double, 2 > AlignedScaling2d
Definition: Eigen/src/Geometry/Scaling.h:166
Eigen::Translation
Represents a translation transformation.
Definition: ForwardDeclarations.h:291
Eigen::Matrix
The matrix class, also used for vectors and row-vectors.
Definition: 3rdparty/Eigen/Eigen/src/Core/Matrix.h:178
internal
Definition: BandTriangularSolver.h:13
Eigen::MatrixBase
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
Eigen::internal::uniformscaling_times_affine_returntype::NewMode
@ NewMode
Definition: Eigen/src/Geometry/Scaling.h:42
align_3::t
Point2 t(10, 10)
Eigen::NumTraits
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:232
pybind_wrapper_test_script.other
other
Definition: pybind_wrapper_test_script.py:42
Scalar
SCALAR Scalar
Definition: bench_gemm.cpp:46


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:04:01