SphericalEngine.hpp
Go to the documentation of this file.
1 
10 #if !defined(GEOGRAPHICLIB_SPHERICALENGINE_HPP)
11 #define GEOGRAPHICLIB_SPHERICALENGINE_HPP 1
12 
13 #include <vector>
14 #include <istream>
16 
17 #if defined(_MSC_VER)
18 // Squelch warnings about dll vs vector
19 # pragma warning (push)
20 # pragma warning (disable: 4251)
21 #endif
22 
23 namespace GeographicLib {
24 
25  class CircularEngine;
26 
41  private:
42  typedef Math::real real;
43  // CircularEngine needs access to sqrttable, scale
44  friend class CircularEngine;
45  // Return the table of the square roots of integers
46  static std::vector<real>& sqrttable();
47  // An internal scaling of the coefficients to avoid overflow in
48  // intermediate calculations.
49  static real scale() {
50  using std::pow;
51  static const real
52  // Need extra real because, since C++11, pow(float, int) returns double
53  s = real(pow(real(std::numeric_limits<real>::radix),
54  -3 * (std::numeric_limits<real>::max_exponent < (1<<14) ?
55  std::numeric_limits<real>::max_exponent : (1<<14))
56  / 5));
57  return s;
58  }
59  // Move latitudes near the pole off the axis by this amount.
60  static real eps() {
61  using std::sqrt;
64  }
65  SphericalEngine(); // Disable constructor
66  public:
77  FULL = 0,
84  SCHMIDT = 1,
85  };
86 
100  private:
101  int _Nx, _nmx, _mmx;
102  std::vector<real>::const_iterator _Cnm;
103  std::vector<real>::const_iterator _Snm;
104  public:
108  coeff() : _Nx(-1) , _nmx(-1) , _mmx(-1) {}
124  coeff(const std::vector<real>& C,
125  const std::vector<real>& S,
126  int N, int nmx, int mmx)
127  : _Nx(N)
128  , _nmx(nmx)
129  , _mmx(mmx)
130  , _Cnm(C.begin())
131  , _Snm(S.begin())
132  {
133  if (!(_Nx >= _nmx && _nmx >= _mmx && _mmx >= -1))
134  throw GeographicErr("Bad indices for coeff");
135  if (!(index(_nmx, _mmx) < int(C.size()) &&
136  index(_nmx, _mmx) < int(S.size()) + (_Nx + 1)))
137  throw GeographicErr("Arrays too small in coeff");
139  }
152  coeff(const std::vector<real>& C,
153  const std::vector<real>& S,
154  int N)
155  : _Nx(N)
156  , _nmx(N)
157  , _mmx(N)
158  , _Cnm(C.begin())
159  , _Snm(S.begin())
160  {
161  if (!(_Nx >= -1))
162  throw GeographicErr("Bad indices for coeff");
163  if (!(index(_nmx, _mmx) < int(C.size()) &&
164  index(_nmx, _mmx) < int(S.size()) + (_Nx + 1)))
165  throw GeographicErr("Arrays too small in coeff");
167  }
171  int N() const { return _Nx; }
175  int nmx() const { return _nmx; }
179  int mmx() const { return _mmx; }
187  int index(int n, int m) const
188  { return m * _Nx - m * (m - 1) / 2 + n; }
195  Math::real Cv(int k) const { return *(_Cnm + k); }
202  Math::real Sv(int k) const { return *(_Snm + (k - (_Nx + 1))); }
213  Math::real Cv(int k, int n, int m, real f) const
214  { return m > _mmx || n > _nmx ? 0 : *(_Cnm + k) * f; }
225  Math::real Sv(int k, int n, int m, real f) const
226  { return m > _mmx || n > _nmx ? 0 : *(_Snm + (k - (_Nx + 1))) * f; }
227 
236  static int Csize(int N, int M)
237  { return (M + 1) * (2 * N - M + 2) / 2; }
238 
247  static int Ssize(int N, int M)
248  { return Csize(N, M) - (N + 1); }
249 
271  static void readcoeffs(std::istream& stream, int& N, int& M,
272  std::vector<real>& C, std::vector<real>& S);
273  };
274 
304  template<bool gradp, normalization norm, int L>
305  static Math::real Value(const coeff c[], const real f[],
306  real x, real y, real z, real a,
307  real& gradx, real& grady, real& gradz);
308 
332  template<bool gradp, normalization norm, int L>
333  static CircularEngine Circle(const coeff c[], const real f[],
334  real p, real z, real a);
354  static void RootTable(int N);
355 
365  static void ClearRootTable() {
366  std::vector<real> temp(0);
367  sqrttable().swap(temp);
368  }
369  };
370 
371 } // namespace GeographicLib
372 
373 #if defined(_MSC_VER)
374 # pragma warning (pop)
375 #endif
376 
377 #endif // GEOGRAPHICLIB_SPHERICALENGINE_HPP
GeographicLib::SphericalEngine::coeff::Cv
Math::real Cv(int k) const
Definition: SphericalEngine.hpp:195
GeographicLib::SphericalEngine::real
Math::real real
Definition: SphericalEngine.hpp:42
s
RealScalar s
Definition: level1_cplx_impl.h:126
GeographicLib
Namespace for GeographicLib.
Definition: JacobiConformal.hpp:15
GeographicLib::SphericalEngine::ClearRootTable
static void ClearRootTable()
Definition: SphericalEngine.hpp:365
gtsam.examples.SFMExample_bal.stream
stream
Definition: SFMExample_bal.py:24
c
Scalar Scalar * c
Definition: benchVecAdd.cpp:17
GeographicLib::SphericalEngine::coeff::coeff
coeff(const std::vector< real > &C, const std::vector< real > &S, int N)
Definition: SphericalEngine.hpp:152
x
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
Definition: gnuplot_common_settings.hh:12
GeographicLib::SphericalEngine::coeff::Cv
Math::real Cv(int k, int n, int m, real f) const
Definition: SphericalEngine.hpp:213
GeographicLib::SphericalEngine::coeff::_Cnm
std::vector< real >::const_iterator _Cnm
Definition: SphericalEngine.hpp:102
GeographicLib::SphericalEngine::normalization
normalization
Definition: SphericalEngine.hpp:70
real
float real
Definition: datatypes.h:10
GeographicLib::SphericalEngine::scale
static real scale()
Definition: SphericalEngine.hpp:49
GEOGRAPHICLIB_EXPORT
#define GEOGRAPHICLIB_EXPORT
Definition: Constants.hpp:91
GeographicLib::SphericalEngine::coeff::Ssize
static int Ssize(int N, int M)
Definition: SphericalEngine.hpp:247
GeographicLib::GeographicErr
Exception handling for GeographicLib.
Definition: Constants.hpp:389
GeographicLib::SphericalEngine
The evaluation engine for SphericalHarmonic.
Definition: SphericalEngine.hpp:40
GeographicLib::SphericalEngine::coeff::_Snm
std::vector< real >::const_iterator _Snm
Definition: SphericalEngine.hpp:103
n
int n
Definition: BiCGSTAB_simple.cpp:1
epsilon
static double epsilon
Definition: testRot3.cpp:37
GeographicLib::SphericalEngine::coeff::mmx
int mmx() const
Definition: SphericalEngine.hpp:179
GeographicLib::Math::real
double real
Definition: Math.hpp:129
GeographicLib::SphericalEngine::RootTable
static void RootTable(int N)
Definition: SphericalEngine.cpp:376
GeographicLib::SphericalEngine::coeff
Package up coefficients for SphericalEngine.
Definition: SphericalEngine.hpp:99
GeographicLib::SphericalEngine::coeff::Sv
Math::real Sv(int k, int n, int m, real f) const
Definition: SphericalEngine.hpp:225
GeographicLib::SphericalEngine::coeff::N
int N() const
Definition: SphericalEngine.hpp:171
GeographicLib::CircularEngine
Spherical harmonic sums for a circle.
Definition: CircularEngine.hpp:52
GeographicLib::SphericalEngine::coeff::index
int index(int n, int m) const
Definition: SphericalEngine.hpp:187
GeographicLib::SphericalEngine::coeff::coeff
coeff()
Definition: SphericalEngine.hpp:108
pybind_wrapper_test_script.z
z
Definition: pybind_wrapper_test_script.py:61
m
Matrix3f m
Definition: AngleAxis_mimic_euler.cpp:1
ceres::pow
Jet< T, N > pow(const Jet< T, N > &f, double g)
Definition: jet.h:570
Constants.hpp
Header for GeographicLib::Constants class.
y
Scalar * y
Definition: level1_cplx_impl.h:124
GeographicLib::SphericalEngine::coeff::coeff
coeff(const std::vector< real > &C, const std::vector< real > &S, int N, int nmx, int mmx)
Definition: SphericalEngine.hpp:124
tree::f
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Definition: testExpression.cpp:218
GeographicLib::SphericalEngine::coeff::Sv
Math::real Sv(int k) const
Definition: SphericalEngine.hpp:202
a
ArrayXXi a
Definition: Array_initializer_list_23_cxx11.cpp:1
GeographicLib::SphericalEngine::coeff::nmx
int nmx() const
Definition: SphericalEngine.hpp:175
C
Matrix< Scalar, Dynamic, Dynamic > C
Definition: bench_gemm.cpp:50
p
float * p
Definition: Tutorial_Map_using.cpp:9
GeographicLib::SphericalEngine::eps
static real eps()
Definition: SphericalEngine.hpp:60
GeographicLib::SphericalEngine::coeff::_Nx
int _Nx
Definition: SphericalEngine.hpp:101
N
#define N
Definition: igam.h:9
GeographicLib::SphericalEngine::coeff::Csize
static int Csize(int N, int M)
Definition: SphericalEngine.hpp:236
real
Definition: main.h:100
ceres::sqrt
Jet< T, N > sqrt(const Jet< T, N > &f)
Definition: jet.h:418
S
DiscreteKey S(1, 2)
M
Matrix< RealScalar, Dynamic, Dynamic > M
Definition: bench_gemm.cpp:51


gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:14:02