SphericalHarmonic1.cpp
Go to the documentation of this file.
1 
11 #include "stdafx.h"
13 #include "SphericalHarmonic1.h"
14 #include "CircularEngine.h"
15 #include "SphericalCoefficients.h"
16 #include "NETGeographicLib.h"
17 
18 using namespace NETGeographicLib;
19 
20 const char BADALLOC[] = "Failed to allocate memory for a GeographicLib::SphericalHarmonic1";
21 
22 //*****************************************************************************
24 {
25  if ( m_pSphericalHarmonic1 != NULL )
26  {
27  delete m_pSphericalHarmonic1;
28  m_pSphericalHarmonic1 = NULL;
29  }
30 
31  if ( m_C != NULL )
32  {
33  for ( int i = 0; i < m_numCoeffVectors; i++ )
34  if ( m_C[i] != NULL )
35  delete m_C[i];
36  delete [] m_C;
37  m_C = NULL;
38  }
39 
40  if ( m_S != NULL )
41  {
42  for ( int i = 0; i < m_numCoeffVectors; i++ )
43  if ( m_S[i] != NULL )
44  delete m_S[i];
45  delete [] m_S;
46  m_S = NULL;
47  }
48 }
49 
50 //*****************************************************************************
53  int N,
55  array<double>^ S1,
56  int N1,
57  double a,
58  Normalization norm )
59 {
60  try
61  {
62  m_C = new std::vector<double>*[m_numCoeffVectors];
63  for ( int i = 0; i < m_numCoeffVectors; i++ ) m_C[i] = new std::vector<double>();
64  m_S = new std::vector<double>*[m_numCoeffVectors];
65  for ( int i = 0; i < m_numCoeffVectors; i++ ) m_S[i] = new std::vector<double>();
66  for each ( double x in C ) m_C[0]->push_back( x );
67  for each ( double x in S ) m_S[0]->push_back( x );
68  for each ( double x in C1 ) m_C[1]->push_back( x );
69  for each ( double x in S1 ) m_S[1]->push_back( x );
71  *m_C[0], *m_S[0], N, *m_C[1], *m_S[1], N1, a, (unsigned)norm );
72  }
73  catch ( std::bad_alloc )
74  {
75  throw gcnew GeographicErr( BADALLOC );
76  }
77  catch ( const std::exception& err )
78  {
79  throw gcnew GeographicErr( err.what() );
80  }
81  catch ( System::Exception^ sxpt )
82  {
83  throw gcnew GeographicErr( sxpt->Message );
84  }
85 }
86 
87 //*****************************************************************************
90  int N, int nmx, int mmx,
92  array<double>^ S1,
93  int N1, int nmx1, int mmx1,
94  double a,
95  Normalization norm )
96 {
97  try
98  {
99  m_C = new std::vector<double>*[m_numCoeffVectors];
100  for ( int i = 0; i < m_numCoeffVectors; i++ ) m_C[i] = new std::vector<double>();
101  m_S = new std::vector<double>*[m_numCoeffVectors];
102  for ( int i = 0; i < m_numCoeffVectors; i++ ) m_S[i] = new std::vector<double>();
103  for each ( double x in C ) m_C[0]->push_back( x );
104  for each ( double x in S ) m_S[0]->push_back( x );
105  for each ( double x in C1 ) m_C[1]->push_back( x );
106  for each ( double x in S1 ) m_S[1]->push_back( x );
108  *m_C[0], *m_S[0], N, nmx, mmx, *m_C[1], *m_S[1], N1, nmx1, mmx1, a,
109  (unsigned)norm );
110  }
111  catch ( std::bad_alloc )
112  {
113  throw gcnew GeographicErr( BADALLOC );
114  }
115  catch ( const std::exception& err )
116  {
117  throw gcnew GeographicErr( err.what() );
118  }
119  catch ( System::Exception^ sxpt )
120  {
121  throw gcnew GeographicErr( sxpt->Message );
122  }
123 }
124 
125 //*****************************************************************************
126 double SphericalHarmonic1::HarmonicSum(double tau, double x, double y, double z)
127 {
128  return m_pSphericalHarmonic1->operator()( tau, x, y, z );
129 }
130 
131 //*****************************************************************************
132 double SphericalHarmonic1::HarmonicSum(double tau, double x, double y, double z,
133  [System::Runtime::InteropServices::Out] double% gradx,
134  [System::Runtime::InteropServices::Out] double% grady,
135  [System::Runtime::InteropServices::Out] double% gradz)
136 {
137  double lgradx, lgrady, lgradz;
138  double out = m_pSphericalHarmonic1->operator()( tau, x, y, z, lgradx, lgrady, lgradz );
139  gradx = lgradx;
140  grady = lgrady;
141  gradz = lgradz;
142  return out;
143 }
144 
145 //*****************************************************************************
146 CircularEngine^ SphericalHarmonic1::Circle(double tau, double p, double z, bool gradp)
147 {
148  try
149  {
150  return gcnew CircularEngine( m_pSphericalHarmonic1->Circle( tau, p, z, gradp ) );
151  }
152  catch ( std::bad_alloc )
153  {
154  throw gcnew GeographicErr( "Failed to allocate memory for a CircularEngine in SphericalHarmonic1::Circle" );
155  }
156 }
157 
158 //*****************************************************************************
160 {
162 }
163 
164 //*****************************************************************************
166 {
168 }
Header for NETGeographicLib::NETGeographicLib objects.
Scalar * y
Exception class for NETGeographicLib.
double HarmonicSum(double tau, double x, double y, double z)
const SphericalEngine::coeff & Coefficients1() const
.NET wrapper for GeographicLib::SphericalHarmonic1.
#define N
Definition: gksort.c:12
.NET wrapper for GeographicLib::SphericalEngine::coeff.
SphericalHarmonic1(array< double >^C, array< double >^S, int N, array< double >^C1, array< double >^S1, int N1, double a, Normalization norm)
Header for NETGeographicLib::CircularEngine class.
Array33i a
CircularEngine Circle(real tau, real p, real z, bool gradp) const
Header for NETGeographicLib::SphericalCoefficients class.
Key S(std::uint64_t j)
Header for GeographicLib::SphericalHarmonic1 class.
CircularEngine Circle(double tau, double p, double z, bool gradp)
#define NULL
Definition: ccolamd.c:609
const SphericalEngine::coeff & Coefficients() const
const GeographicLib::SphericalHarmonic1 * m_pSphericalHarmonic1
Matrix< Scalar, Dynamic, Dynamic > C
Definition: bench_gemm.cpp:37
float * p
Spherical harmonic series with a correction to the coefficients.
const char BADALLOC[]
.NET wrapper for GeographicLib::CircularEngine.
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
Header for NETGeographicLib::SphericalHarmonic1 class.


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:44:49