GeographicLib::SphericalHarmonic1 Class Reference

Spherical harmonic series with a correction to the coefficients. More...

`#include <GeographicLib/SphericalHarmonic1.hpp>`

## Public Types

enum | normalization { FULL , SCHMIDT }

## Public Member Functions

| SphericalHarmonic1 (const std::vector< real > &C, const std::vector< real > &S, int N, const std::vector< real > &C1, const std::vector< real > &S1, int N1, real a, unsigned norm=FULL)
| SphericalHarmonic1 (const std::vector< real > &C, const std::vector< real > &S, int N, int nmx, int mmx, const std::vector< real > &C1, const std::vector< real > &S1, int N1, int nmx1, int mmx1, real a, unsigned norm=FULL)
| SphericalHarmonic1 ()
Math::real | operator() (real tau, real x, real y, real z) const
Math::real | operator() (real tau, real x, real y, real z, real &gradx, real &grady, real &gradz) const
CircularEngine | Circle (real tau, real p, real z, bool gradp) const
const SphericalEngine::coeff & | Coefficients () const
const SphericalEngine::coeff & | Coefficients1 () const

## Detailed Description

Spherical harmonic series with a correction to the coefficients.

This classes is similar to SphericalHarmonic, except that the coefficients Cnm are replaced by Cnm + tau C'nm (and similarly for Snm).

Example of use:

// Example of using the GeographicLib::SphericalHarmonic1 class
#include <iostream>
#include <exception>
#include <vector>
#include <GeographicLib/SphericalHarmonic1.hpp>
using namespace std;
using namespace GeographicLib;
int main() {
try {
int N = 3, N1 = 2; // The maxium degrees
double ca[] = {10, 9, 8, 7, 6, 5, 4, 3, 2, 1}; // cosine coefficients
vector<double> C(ca, ca + (N + 1) * (N + 2) / 2);
double sa[] = {6, 5, 4, 3, 2, 1}; // sine coefficients
vector<double> S(sa, sa + N * (N + 1) / 2);
double cb[] = {1, 2, 3, 4, 5, 6};
vector<double> C1(cb, cb + (N1 + 1) * (N1 + 2) / 2);
double sb[] = {3, 2, 1};
vector<double> S1(sb, sb + N1 * (N1 + 1) / 2);
double a = 1;
SphericalHarmonic1 h(C, S, N, C1, S1, N1, a);
double tau = 0.1, x = 2, y = 3, z = 1;
double v, vx, vy, vz;
v = h(tau, x, y, z, vx, vy, vz);
cout << v << " " << vx << " " << vy << " " << vz << "\n";
}
catch (const exception& e) {
cerr << "Caught exception: " << e.what() << "\n";
return 1;
}
}
main
int main(int argc, const char *const argv[])
Definition: CartConvert.cpp:29
SphericalHarmonic1.hpp
Header for GeographicLib::SphericalHarmonic1 class.
GeographicLib::SphericalHarmonic1::SphericalHarmonic1
SphericalHarmonic1()
Definition: SphericalHarmonic1.hpp:156
GeographicLib
Namespace for GeographicLib.
Definition: Accumulator.cpp:12
std
Definition: NearestNeighbor.hpp:812

Definition at line 32 of file SphericalHarmonic1.hpp.

## Member Enumeration Documentation

## normalization

enum GeographicLib::SphericalHarmonic1::normalization

Supported normalizations for associate Legendre polynomials.

Enumerator
FULL | Fully normalized associated Legendre polynomials. See SphericalHarmonic::FULL for documentation.
SCHMIDT | Schmidt semi-normalized associated Legendre polynomials. See SphericalHarmonic::SCHMIDT for documentation.

Definition at line 37 of file SphericalHarmonic1.hpp.

## Constructor & Destructor Documentation

## SphericalHarmonic1() [1/3]

GeographicLib::SphericalHarmonic1::SphericalHarmonic1 | ( | const std::vector< real > & | C,
|  | const std::vector< real > & | S,
|  | int | N,
|  | const std::vector< real > & | C1,
|  | const std::vector< real > & | S1,
|  | int | N1,
|  | real | a,
|  | unsigned | norm = `FULL`
| ) |  |

inline

Constructor with a full set of coefficients specified.

Parameters

  [in] | C | the coefficients Cnm.
  [in] | S | the coefficients Snm.
  [in] | N | the maximum degree and order of the sum
  [in] | C1 | the coefficients C'nm.
  [in] | S1 | the coefficients S'nm.
  [in] | N1 | the maximum degree and order of the correction coefficients C'nm and S'nm.
  [in] | a | the reference radius appearing in the definition of the sum.
  [in] | norm | the normalization for the associated Legendre polynomials, either SphericalHarmonic1::FULL (the default) or SphericalHarmonic1::SCHMIDT.

Exceptions

  GeographicErr | if N and N1 do not satisfy N ≥ N1 ≥ −1.
  GeographicErr | if any of the vectors of coefficients is not large enough.

See SphericalHarmonic for the way the coefficients should be stored.

The class stores pointers to the first elements of C, S, C', and S'. These arrays should not be altered or destroyed during the lifetime of a SphericalHarmonic object.

Definition at line 88 of file SphericalHarmonic1.hpp.

## SphericalHarmonic1() [2/3]

GeographicLib::SphericalHarmonic1::SphericalHarmonic1 | ( | const std::vector< real > & | C,
|  | const std::vector< real > & | S,
|  | int | N,
|  | int | nmx,
|  | int | mmx,
|  | const std::vector< real > & | C1,
|  | const std::vector< real > & | S1,
|  | int | N1,
|  | int | nmx1,
|  | int | mmx1,
|  | real | a,
|  | unsigned | norm = `FULL`
| ) |  |

inline

Constructor with a subset of coefficients specified.

Parameters

  [in] | C | the coefficients Cnm.
  [in] | S | the coefficients Snm.
  [in] | N | the degree used to determine the layout of C and S.
  [in] | nmx | the maximum degree used in the sum. The sum over n is from 0 thru nmx.
  [in] | mmx | the maximum order used in the sum. The sum over m is from 0 thru min(n, mmx).
  [in] | C1 | the coefficients C'nm.
  [in] | S1 | the coefficients S'nm.
  [in] | N1 | the degree used to determine the layout of C' and S'.
  [in] | nmx1 | the maximum degree used for C' and S'.
  [in] | mmx1 | the maximum order used for C' and S'.
  [in] | a | the reference radius appearing in the definition of the sum.
  [in] | norm | the normalization for the associated Legendre polynomials, either SphericalHarmonic1::FULL (the default) or SphericalHarmonic1::SCHMIDT.

Exceptions

  GeographicErr | if the parameters do not satisfy N ≥ nmx ≥ mmx ≥ −1; N1 ≥ nmx1 ≥ mmx1 ≥ −1; N ≥ N1; nmx ≥ nmx1; mmx ≥ mmx1.
  GeographicErr | if any of the vectors of coefficients is not large enough.

The class stores pointers to the first elements of C, S, C', and S'. These arrays should not be altered or destroyed during the lifetime of a SphericalHarmonic object.

Definition at line 134 of file SphericalHarmonic1.hpp.

## SphericalHarmonic1() [3/3]

GeographicLib::SphericalHarmonic1::SphericalHarmonic1 | ( |  | ) |

inline

A default constructor so that the object can be created when the constructor for another object is initialized. This default object can then be reset with the default copy assignment operator.

Definition at line 156 of file SphericalHarmonic1.hpp.

## Member Function Documentation

## operator()() [1/2]

Math::real GeographicLib::SphericalHarmonic1::operator() | ( | real | tau,
|  | real | x,
|  | real | y,
|  | real | z
| ) |  | const

inline

Compute a spherical harmonic sum with a correction term.

Parameters

  [in] | tau | multiplier for correction coefficients C' and S'.
  [in] | x | cartesian coordinate.
  [in] | y | cartesian coordinate.
  [in] | z | cartesian coordinate.

Returns
  V the spherical harmonic sum.

This routine requires constant memory and thus never throws an exception.

Definition at line 170 of file SphericalHarmonic1.hpp.

## operator()() [2/2]

Math::real GeographicLib::SphericalHarmonic1::operator() | ( | real | tau,
|  | real | x,
|  | real | y,
|  | real | z,
|  | real & | gradx,
|  | real & | grady,
|  | real & | gradz
| ) |  | const

inline

Compute a spherical harmonic sum with a correction term and its gradient.

Parameters

  [in] | tau | multiplier for correction coefficients C' and S'.
  [in] | x | cartesian coordinate.
  [in] | y | cartesian coordinate.
  [in] | z | cartesian coordinate.
  [out] | gradx | x component of the gradient
  [out] | grady | y component of the gradient
  [out] | gradz | z component of the gradient

Returns
  V the spherical harmonic sum.

This is the same as the previous function, except that the components of the gradients of the sum in the x, y, and z directions are computed. This routine requires constant memory and thus never throws an exception.

Definition at line 206 of file SphericalHarmonic1.hpp.

## Circle()

CircularEngine GeographicLib::SphericalHarmonic1::Circle | ( | real | tau,
|  | real | p,
|  | real | z,
|  | bool | gradp
| ) |  | const

inline

Create a CircularEngine to allow the efficient evaluation of several points on a circle of latitude at a fixed value of tau.

Parameters

  [in] | tau | the multiplier for the correction coefficients.
  [in] | p | the radius of the circle.
  [in] | z | the height of the circle above the equatorial plane.
  [in] | gradp | if true the returned object will be able to compute the gradient of the sum.

Exceptions

  std::bad_alloc | if the memory for the CircularEngine can't be allocated.

Returns
  the CircularEngine object.

SphericalHarmonic1::operator()() exchanges the order of the sums in the definition, i.e., ∑n = 0..N ∑m = 0..n becomes ∑m = 0..N ∑n = m..N. SphericalHarmonic1::Circle performs the inner sum over degree n (which entails about N2 operations). Calling CircularEngine::operator()() on the returned object performs the outer sum over the order m (about N operations).

See SphericalHarmonic::Circle for an example of its use.

Definition at line 248 of file SphericalHarmonic1.hpp.

Referenced by GeographicLib::GravityModel::Circle().

## Coefficients()

const SphericalEngine::coeff & GeographicLib::SphericalHarmonic1::Coefficients | ( |  | ) | const

inline

Returns
  the zeroth SphericalEngine::coeff object.

Definition at line 272 of file SphericalHarmonic1.hpp.

## Coefficients1()

const SphericalEngine::coeff & GeographicLib::SphericalHarmonic1::Coefficients1 | ( |  | ) | const

inline

Returns
  the first SphericalEngine::coeff object.

Definition at line 277 of file SphericalHarmonic1.hpp.

The documentation for this class was generated from the following file:

- SphericalHarmonic1.hpp