1717namespace GeographicLib {
1818
1919 /* *
20- * \brief Circular Harmonic series
20+ * \brief Spherical Harmonic sums for a circle.
2121 *
22- * Sum a circular harmonic series.
22+ * The class is a companion to SphericalEngine. If the results of a
23+ * spherical harmonic sum are needed for several points on a circle of
24+ * constant latitude \e lat and height \e h, then SphericalEngine::Circle can
25+ * compute the inner sum, which is independent of longitude \e lon, and
26+ * produce a CircularEngine object. CircularEngine::operator()(real) can
27+ * then be used to perform the outer sum for particular vales of \e lon.
28+ * This can lead to substantial improvements in computational speed for high
29+ * degree sum (approximately by a factor of \e N / 2 where \e N is the
30+ * maximum degree).
31+ *
32+ * The constructor for this class is private. Use SphericalHarmonic::Circle,
33+ * SphericalHarmonic1::Circle, and SphericalHarmonic2::Circle to create
34+ * instances of this class.
2335 **********************************************************************/
2436
2537 class GEOGRAPHIC_EXPORT CircularEngine {
@@ -36,7 +48,7 @@ namespace GeographicLib {
3648 std::vector<real> _wc, _ws, _wrc, _wrs, _wtc, _wts;
3749 real _q, _uq, _uq2;
3850
39- Math::real Value (bool gradp, real coslam , real sinlam ,
51+ Math::real Value (bool gradp, real cl , real sl ,
4052 real& gradx, real& grady, real& gradz) const ;
4153
4254 static inline void cossin (real x, real& cosx, real& sinx) {
@@ -46,8 +58,28 @@ namespace GeographicLib {
4658 sinx = x == -180 ? 0 : sin (xi);
4759 }
4860
49- public:
50-
61+ friend class SphericalEngine ;
62+ /* *
63+ * Constructor for CircularEngine with
64+ *
65+ * @param[in] M the maximum order of the spherical harmonic sum.
66+ * @param[in] gradp whether to include the coefficients of the series for
67+ * the gradient of the sum.
68+ * @param[in] norm the normalization of the Legrendre functions (either
69+ * full or schmidt).
70+ * @param[in] scale a scaling that is given to the coefficients to avoid
71+ * overflow.
72+ * @param[in] a the reference radius for the sum.
73+ * @param[in] r the (spherical) radius of points.
74+ * @param[in] u the sine of the (spherical) colatiude.
75+ * @param[in] t the cosine of the (spherical) colatiude.
76+ *
77+ * Thus the CircularEngine evaluates the harmonic sum (and its gradient)
78+ * for points on the circle of radius \e u \e r which lies a distance \e t \e
79+ * r above the equatorial plane. The constructor allocates memory for the
80+ * arrays used to store the coefficients and stores zero in them. These
81+ * coefficients are set with calls to CircularEngine::SetCoeff.
82+ **********************************************************************/
5183 CircularEngine (int M, bool gradp, SphericalEngine::normalization norm,
5284 real scale, real a, real r, real u, real t)
5385 : _M(M)
@@ -69,8 +101,36 @@ namespace GeographicLib {
69101 _uq = _u * _q;
70102 _uq2 = Math::sq (_uq);
71103 }
104+
105+ /* *
106+ * Store coefficients for the sum for the order \e m term.
107+ *
108+ * @param[in] m the order of the term.
109+ * @param[in] wc the coefficient for the cos(\e m \e lam) term.
110+ * @param[in] ws the coefficient for the sin(\e m \e lam) term.
111+ *
112+ * \e m must lie in [0, \e M].
113+ **********************************************************************/
72114 void SetCoeff (int m, real wc, real ws)
73115 { _wc[m] = wc; _ws[m] = ws; }
116+
117+ /* *
118+ * Store coefficients for the sum and its gradient for the order \e m term.
119+ *
120+ * @param[in] m the order of the term
121+ * @param[in] wc the coefficient for the cos(\e m \e lam) term.
122+ * @param[in] ws the coefficient for the sin(\e m \e lam) term.
123+ * @param[in] wrc the coefficient for the radial derivative of the cosine
124+ * term.
125+ * @param[in] wrs the coefficient for the radial derivative of the sine
126+ * term.
127+ * @param[in] wtc the coefficient for the \e theta derivative of the cosine
128+ * term.
129+ * @param[in] wts the coefficient for the \e theta derivative of the sine
130+ * term.
131+ *
132+ * \e m must lie in [0, \e M]. Here \e theta is the spherical colatitude.
133+ **********************************************************************/
74134 void SetCoeff (int m, real wc, real ws,
75135 real wrc, real wrs, real wtc, real wts) {
76136 _wc[m] = wc; _ws[m] = ws;
@@ -79,24 +139,63 @@ namespace GeographicLib {
79139 _wtc[m] = wtc; _wts[m] = wts;
80140 }
81141 }
82- Math::real operator ()(real lam) const {
83- real coslam, sinlam;
84- cossin (lam, coslam, sinlam);
85- return (*this )(coslam, sinlam);
142+
143+ public:
144+ /* *
145+ * Evaluate the sum for a particular longitude.
146+ *
147+ * @param[in] lon the longitude (degrees).
148+ * @return[in] \e V the value of the sum.
149+ **********************************************************************/
150+ Math::real operator ()(real lon) const {
151+ real coslon, sinlon;
152+ cossin (lon, coslon, sinlon);
153+ return (*this )(coslon, sinlon);
86154 }
87- Math::real operator ()(real coslam, real sinlam) const {
155+
156+ /* *
157+ * Evaluate the sum for a particular longitude given in terms of its
158+ * cosine and sine.
159+ *
160+ * @param[in] coslon the cosine of the longitude.
161+ * @param[in] sinlon the sine of the longitude.
162+ * @return[in] \e V the value of the sum.
163+ **********************************************************************/
164+ Math::real operator ()(real coslon, real sinlon) const {
88165 real dummy;
89- return Value (false , coslam, sinlam , dummy, dummy, dummy);
166+ return Value (false , coslon, sinlon , dummy, dummy, dummy);
90167 }
91- Math::real operator ()(real lam,
168+
169+ /* *
170+ * Evaluate the sum and its gradient for a particular longitude.
171+ *
172+ * @param[in] lon the longitude (degrees).
173+ * @param[out] gradx \e x component of the gradient
174+ * @param[out] grady \e y component of the gradient
175+ * @param[out] gradz \e z component of the gradient
176+ * @return[in] \e V the value of the sum.
177+ **********************************************************************/
178+ Math::real operator ()(real lon,
92179 real& gradx, real& grady, real& gradz) const {
93- real coslam, sinlam ;
94- cossin (lam, coslam, sinlam );
95- return (*this )(coslam, sinlam , gradx, grady, gradz);
180+ real coslon, sinlon ;
181+ cossin (lon, coslon, sinlon );
182+ return (*this )(coslon, sinlon , gradx, grady, gradz);
96183 }
97- Math::real operator ()(real coslam, real sinlam,
184+
185+ /* *
186+ * Evaluate the sum and its gradient for a particular longitude given in
187+ * terms of its cosine and sine.
188+ *
189+ * @param[in] coslon the cosine of the longitude.
190+ * @param[in] sinlon the sine of the longitude.
191+ * @param[out] gradx \e x component of the gradient
192+ * @param[out] grady \e y component of the gradient
193+ * @param[out] gradz \e z component of the gradient
194+ * @return[in] \e V the value of the sum.
195+ **********************************************************************/
196+ Math::real operator ()(real coslon, real sinlon,
98197 real& gradx, real& grady, real& gradz) const {
99- return Value (true , coslam, sinlam , gradx, grady, gradz);
198+ return Value (true , coslon, sinlon , gradx, grady, gradz);
100199 }
101200 };
102201
0 commit comments