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
Matrix3f m
Matrix< RealScalar, Dynamic, Dynamic > M
Definition: bench_gemm.cpp:51
#define GEOGRAPHICLIB_EXPORT
Definition: Constants.hpp:91
The evaluation engine for SphericalHarmonic.
float real
Definition: datatypes.h:10
Scalar * y
Math::real Cv(int k, int n, int m, real f) const
int n
Scalar Scalar * c
Definition: benchVecAdd.cpp:17
coeff(const std::vector< real > &C, const std::vector< real > &S, int N)
std::vector< real >::const_iterator _Cnm
#define N
Definition: gksort.c:12
DiscreteKey S(1, 2)
std::vector< real >::const_iterator _Snm
static double epsilon
Definition: testRot3.cpp:37
Math::real Sv(int k, int n, int m, real f) const
Package up coefficients for SphericalEngine.
coeff(const std::vector< real > &C, const std::vector< real > &S, int N, int nmx, int mmx)
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Namespace for GeographicLib.
RealScalar s
Matrix< Scalar, Dynamic, Dynamic > C
Definition: bench_gemm.cpp:50
Spherical harmonic sums for a circle.
Exception handling for GeographicLib.
Definition: Constants.hpp:389
Header for GeographicLib::Constants class.
float * p
Jet< T, N > sqrt(const Jet< T, N > &f)
Definition: jet.h:418
Jet< T, N > pow(const Jet< T, N > &f, double g)
Definition: jet.h:570
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


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