GeographicLib: SphericalEngine.hpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10#if !defined(GEOGRAPHICLIB_SPHERICALENGINE_HPP)

11#define GEOGRAPHICLIB_SPHERICALENGINE_HPP 1

12

13#include

14#include

16

17#if defined(_MSC_VER)

18

19# pragma warning (push)

20# pragma warning (disable: 4251)

21#endif

22

24

25 class CircularEngine;

26

27

28

29

30

31

32

33

34

35

36

37

38

39

41 private:

43

45

46 static std::vector& sqrttable();

47

48

49 static real scale() {

50 using std::pow;

51 static const real

52

53 s = real(pow(real(std::numeric_limits::radix),

54 -3 * (std::numeric_limits::max_exponent < (1<<14) ?

55 std::numeric_limits::max_exponent : (1<<14))

56 / 5));

57 return s;

58 }

59

60 static real eps() {

61 using std::sqrt;

62 return std::numeric_limits::epsilon() *

63 sqrt(std::numeric_limits::epsilon());

64 }

65 SphericalEngine();

66 public:

67

68

69

71

72

73

74

75

76

77 FULL = 0,

78

79

80

81

82

83

84 SCHMIDT = 1,

85 };

86

87

88

89

90

91

92

93

94

95

96

97

98

100 private:

101 int _nNx, _nmx, _mmx;

102 std::vector::const_iterator _cCnm;

103 std::vector::const_iterator _sSnm;

104 public:

105

106

107

108 coeff() : _nNx(-1) , _nmx(-1) , _mmx(-1) {}

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124 coeff(const std::vector& C,

125 const std::vector& S,

126 int N, int nmx, int mmx)

127 : _nNx(N)

128 , _nmx(nmx)

129 , _mmx(mmx)

130 , _cCnm(C.begin())

131 , _sSnm(S.begin())

132 {

133 if (!((_nNx >= _nmx && _nmx >= _mmx && _mmx >= 0) ||

134

135 (_nmx == -1 && _mmx == -1)))

137 if (!(index(_nmx, _mmx) < int(C.size()) &&

138 index(_nmx, _mmx) < int(S.size()) + (_nNx + 1)))

139 throw GeographicErr("Arrays too small in coeff");

140 SphericalEngine::RootTable(_nmx);

141 }

142

143

144

145

146

147

148

149

150

151

152

153

154 coeff(const std::vector& C,

155 const std::vector& S,

156 int N)

157 : _nNx(N)

158 , _nmx(N)

159 , _mmx(N)

160 , _cCnm(C.begin())

161 , _sSnm(S.begin())

162 {

163 if (!(_nNx >= -1))

165 if (!(index(_nmx, _mmx) < int(C.size()) &&

166 index(_nmx, _mmx) < int(S.size()) + (_nNx + 1)))

167 throw GeographicErr("Arrays too small in coeff");

168 SphericalEngine::RootTable(_nmx);

169 }

170

171

172

173 int N() const { return _nNx; }

174

175

176

177 int nmx() const { return _nmx; }

178

179

180

181 int mmx() const { return _mmx; }

182

183

184

185

186

187

188

189 int index(int n, int m) const

190 { return m * _nNx - m * (m - 1) / 2 + n; }

191

192

193

194

195

196

198

199

200

201

202

203

204 Math::real Sv(int k) const { return *(_sSnm + (k - (_nNx + 1))); }

205

206

207

208

209

210

211

212

213

214

216 { return m > _mmx || n > _nmx ? 0 : *(_cCnm + k) * f; }

217

218

219

220

221

222

223

224

225

226

228 { return m > _mmx || n > _nmx ? 0 : *(_sSnm + (k - (_nNx + 1))) * f; }

229

230

231

232

233

234

235

236

237

238 static int Csize(int N, int M)

239 { return (M + 1) * (2 * N - M + 2) / 2; }

240

241

242

243

244

245

246

247

248

249 static int Ssize(int N, int M)

250 { return Csize(N, M) - (N + 1); }

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277 static void readcoeffs(std::istream& stream, int& N, int& M,

278 std::vector& C, std::vector& S,

279 bool truncate = false);

280 };

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311 template<bool gradp, normalization norm, int L>

312 static Math::real Value(const coeff c[], const real f[],

315

316

317

318

319

320

321

322

323

324

325

326

327

328

329

330

331

332

333

334

335

336

337

338

339 template<bool gradp, normalization norm, int L>

342

343

344

345

346

347

348

349

350

351

352

353

354

355

356

357

358

359

360

361 static void RootTable(int N);

362

363

364

365

366

367

368

369

370

371

373 std::vector temp(0);

374 sqrttable().swap(temp);

375 }

376 };

377

378}

379

380#if defined(_MSC_VER)

381# pragma warning (pop)

382#endif

383

384#endif

Header for GeographicLib::Constants class.

#define GEOGRAPHICLIB_EXPORT

GeographicLib::Math::real real

Spherical harmonic sums for a circle.

Exception handling for GeographicLib.

Package up coefficients for SphericalEngine.

Definition SphericalEngine.hpp:99

coeff(const std::vector< real > &C, const std::vector< real > &S, int N)

Definition SphericalEngine.hpp:154

coeff(const std::vector< real > &C, const std::vector< real > &S, int N, int nmx, int mmx)

Definition SphericalEngine.hpp:124

int N() const

Definition SphericalEngine.hpp:173

Math::real Sv(int k) const

Definition SphericalEngine.hpp:204

Math::real Sv(int k, int n, int m, real f) const

Definition SphericalEngine.hpp:227

static int Csize(int N, int M)

Definition SphericalEngine.hpp:238

static int Ssize(int N, int M)

Definition SphericalEngine.hpp:249

coeff()

Definition SphericalEngine.hpp:108

Math::real Cv(int k, int n, int m, real f) const

Definition SphericalEngine.hpp:215

int index(int n, int m) const

Definition SphericalEngine.hpp:189

int nmx() const

Definition SphericalEngine.hpp:177

int mmx() const

Definition SphericalEngine.hpp:181

Math::real Cv(int k) const

Definition SphericalEngine.hpp:197

The evaluation engine for SphericalHarmonic.

Definition SphericalEngine.hpp:40

normalization

Definition SphericalEngine.hpp:70

static void ClearRootTable()

Definition SphericalEngine.hpp:372

Namespace for GeographicLib.