NETGeographicLib  1.40
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Pages
SphericalCoefficients.h
Go to the documentation of this file.
1 #pragma once
2 /**
3  * \file NETGeographicLib/SphericalCoefficients.h
4  * \brief Header for NETGeographicLib::SphericalCoefficients class
5  *
6  * NETGeographicLib is copyright (c) Scott Heiman (2013)
7  * GeographicLib is Copyright (c) Charles Karney (2010-2012)
8  * <charles@karney.com> and licensed under the MIT/X11 License.
9  * For more information, see
10  * http://geographiclib.sourceforge.net/
11  **********************************************************************/
12 
13 namespace NETGeographicLib
14 {
15  /*!
16  \brief .NET wrapper for GeographicLib::SphericalEngine::coeff.
17 
18  This class allows .NET applications to access GeographicLib::SphericalEngine::coeff.
19 
20  The SphericalHarmonic classes provide accessor functions that allow
21  you to examine the coefficients. These accessor functions export a
22  GeographicLib::SphericalEngine::coeff object. The GeographicLib::SphericalEngine
23  class is not implemented in NETGeographicLib. SphericalCoefficients is provided as
24  a substitute for GeographicLib::SphericalEngine::coeff allowing you to examine the
25  coefficients in .NET applications.
26 
27  Use SphericalHarmonic::Coefficients, SphericalHarmonic1::Coefficient*,
28  or SphericalHarmonic2::Coefficient* to obtain an instance of this
29  class.
30 
31  <B>INTERFACE DIFFERENCES:</B><BR>
32  This class does not implement readcoeffs.
33  */
34  public ref class SphericalCoefficients
35  {
36  private:
37  // The cosine coefficients.
38  array<double>^ m_C; // size = Csize(m_nmx,m_mmx)
39  // The sine coefficients
40  array<double>^ m_S; // size = Ssize(m_nmx,m_mmx)
41  // The dimension of the coefficients
42  int m_N;
43  int m_nmx;
44  int m_mmx;
45  public:
46  /*!
47  \brief Constructor.
48  \param[in] c A reference to a GeographicLib::SphericalEngine::coeff object.
49  This constructor is for internal use only. Developers should
50  not create an instance of SphericalCoefficients. Use
51  SphericalHarmonic::Coefficients, SphericalHarmonic1::Coefficient*,
52  or SphericalHarmonic2::Coefficient* to obtain an instance of this
53  class.
54  */
56 
57  /**
58  * @return \e N the degree giving storage layout for \e C and \e S.
59  **********************************************************************/
60  property int N { int get() { return m_N; } }
61  /**
62  * @return \e nmx the maximum degree to be used.
63  **********************************************************************/
64  property int nmx { int get() { return m_nmx; } }
65  /**
66  * @return \e mmx the maximum order to be used.
67  **********************************************************************/
68  property int mmx { int get() { return m_mmx; } }
69  /**
70  * The one-dimensional index into \e C and \e S.
71  *
72  * @param[in] n the degree.
73  * @param[in] m the order.
74  * @return the one-dimensional index.
75  **********************************************************************/
76  int index(int n, int m)
77  { return m * m_N - m * (m - 1) / 2 + n; }
78  /**
79  * An element of \e C.
80  *
81  * @param[in] k the one-dimensional index.
82  * @return the value of the \e C coefficient.
83  **********************************************************************/
84  double Cv(int k) { return m_C[k]; }
85  /**
86  * An element of \e S.
87  *
88  * @param[in] k the one-dimensional index.
89  * @return the value of the \e S coefficient.
90  **********************************************************************/
91  double Sv(int k) { return m_S[k - (m_N + 1)]; }
92  /**
93  * An element of \e C with checking.
94  *
95  * @param[in] k the one-dimensional index.
96  * @param[in] n the requested degree.
97  * @param[in] m the requested order.
98  * @param[in] f a multiplier.
99  * @return the value of the \e C coefficient multiplied by \e f in \e n
100  * and \e m are in range else 0.
101  **********************************************************************/
102  double Cv(int k, int n, int m, double f)
103  { return m > m_mmx || n > m_nmx ? 0 : m_C[k] * f; }
104  /**
105  * An element of \e S with checking.
106  *
107  * @param[in] k the one-dimensional index.
108  * @param[in] n the requested degree.
109  * @param[in] m the requested order.
110  * @param[in] f a multiplier.
111  * @return the value of the \e S coefficient multiplied by \e f in \e n
112  * and \e m are in range else 0.
113  **********************************************************************/
114  double Sv(int k, int n, int m, double f)
115  { return m > m_mmx || n > m_nmx ? 0 : m_S[k - (m_N + 1)] * f; }
116 
117  /**
118  * The size of the coefficient vector for the cosine terms.
119  *
120  * @param[in] N the maximum degree.
121  * @param[in] M the maximum order.
122  * @return the size of the vector of cosine terms as stored in column
123  * major order.
124  **********************************************************************/
125  static int Csize(int N, int M)
126  { return (M + 1) * (2 * N - M + 2) / 2; }
127 
128  /**
129  * The size of the coefficient vector for the sine terms.
130  *
131  * @param[in] N the maximum degree.
132  * @param[in] M the maximum order.
133  * @return the size of the vector of cosine terms as stored in column
134  * major order.
135  **********************************************************************/
136  static int Ssize(int N, int M)
137  { return Csize(N, M) - (N + 1); }
138 
139  };
140 } // namespace NETGeographicLib
double Sv(int k, int n, int m, double f)
double Cv(int k, int n, int m, double f)
SphericalCoefficients(const GeographicLib::SphericalEngine::coeff &c)
Constructor.
.NET wrapper for GeographicLib::SphericalEngine::coeff.