SphericalHarmonic2.cpp
Go to the documentation of this file.
1 
11 #include "stdafx.h"
13 #include "SphericalHarmonic2.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::SphericalHarmonic2";
21 
22 //*****************************************************************************
24 {
25  if ( m_pSphericalHarmonic2 != NULL )
26  {
27  delete m_pSphericalHarmonic2;
28  m_pSphericalHarmonic2 = 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,
56  int N1,
59  int N2,
60  double a,
61  Normalization norm )
62 {
63  try
64  {
65  m_C = new std::vector<double>*[m_numCoeffVectors];
66  for ( int i = 0; i < m_numCoeffVectors; i++ ) m_C[i] = new std::vector<double>();
67  m_S = new std::vector<double>*[m_numCoeffVectors];
68  for ( int i = 0; i < m_numCoeffVectors; i++ ) m_S[i] = new std::vector<double>();
69  for each ( double x in C ) m_C[0]->push_back( x );
70  for each ( double x in S ) m_S[0]->push_back( x );
71  for each ( double x in C1 ) m_C[1]->push_back( x );
72  for each ( double x in S1 ) m_S[1]->push_back( x );
73  for each ( double x in C2 ) m_C[2]->push_back( x );
74  for each ( double x in S2 ) m_S[2]->push_back( x );
76  *m_C[1], *m_S[1], N1, *m_C[2], *m_S[2], N2, a, (unsigned)norm);
77  }
78  catch ( std::bad_alloc )
79  {
80  throw gcnew GeographicErr( BADALLOC );
81  }
82  catch ( const std::exception& err )
83  {
84  throw gcnew GeographicErr( err.what() );
85  }
86  catch ( System::Exception^ sxpt )
87  {
88  throw gcnew GeographicErr( sxpt->Message );
89  }
90 }
91 
92 //*****************************************************************************
95  int N, int nmx, int mmx,
98  int N1, int nmx1, int mmx1,
100  array<double>^ S2,
101  int N2, int nmx2, int mmx2,
102  double a,
103  Normalization norm )
104 {
105  try
106  {
107  m_C = new std::vector<double>*[m_numCoeffVectors];
108  for ( int i = 0; i < m_numCoeffVectors; i++ ) m_C[i] = new std::vector<double>();
109  m_S = new std::vector<double>*[m_numCoeffVectors];
110  for ( int i = 0; i < m_numCoeffVectors; i++ ) m_S[i] = new std::vector<double>();
111  for each ( double x in C ) m_C[0]->push_back( x );
112  for each ( double x in S ) m_S[0]->push_back( x );
113  for each ( double x in C1 ) m_C[1]->push_back( x );
114  for each ( double x in S1 ) m_S[1]->push_back( x );
115  for each ( double x in C2 ) m_C[2]->push_back( x );
116  for each ( double x in S2 ) m_S[2]->push_back( x );
118  nmx, mmx, *m_C[1], *m_S[1], N1, nmx1, mmx1, *m_C[2], *m_S[2], N2, nmx2, mmx2, a,
119  (unsigned)norm );
120  }
121  catch ( std::bad_alloc )
122  {
123  throw gcnew GeographicErr( BADALLOC );
124  }
125  catch ( const std::exception& err )
126  {
127  throw gcnew GeographicErr( err.what() );
128  }
129  catch ( System::Exception^ sxpt )
130  {
131  throw gcnew GeographicErr( sxpt->Message );
132  }
133 }
134 
135 //*****************************************************************************
136 double SphericalHarmonic2::HarmonicSum(double tau1, double tau2, double x, double y, double z)
137 {
138  return m_pSphericalHarmonic2->operator()( tau1, tau2, x, y, z );
139 }
140 
141 //*****************************************************************************
142 double SphericalHarmonic2::HarmonicSum(double tau1, double tau2, double x, double y, double z,
143  [System::Runtime::InteropServices::Out] double% gradx,
144  [System::Runtime::InteropServices::Out] double% grady,
145  [System::Runtime::InteropServices::Out] double% gradz)
146 {
147  double lgradx, lgrady, lgradz;
148  double out = m_pSphericalHarmonic2->operator()( tau1, tau2, x, y, z,
149  lgradx, lgrady, lgradz );
150  gradx = lgradx;
151  grady = lgrady;
152  gradz = lgradz;
153  return out;
154 }
155 
156 //*****************************************************************************
157 CircularEngine^ SphericalHarmonic2::Circle(double tau1, double tau2, double p,
158  double z, bool gradp)
159 {
160  try
161  {
162  return gcnew CircularEngine( m_pSphericalHarmonic2->Circle( tau1, tau2, p, z, gradp ) );
163  }
164  catch ( std::bad_alloc )
165  {
166  throw gcnew GeographicErr( "Memory allocation error in SphericalHarmonic2::Circle" );
167  }
168 }
169 
170 //*****************************************************************************
172 {
174 }
175 
176 //*****************************************************************************
178 {
180 }
181 
182 //*****************************************************************************
184 {
186 }
NETGeographicLib::SphericalHarmonic2::HarmonicSum
double HarmonicSum(double tau1, double tau2, double x, double y, double z)
Definition: SphericalHarmonic2.cpp:136
NETGeographicLib::SphericalHarmonic2::Coefficients
SphericalCoefficients Coefficients()
Definition: SphericalHarmonic2.cpp:171
S1
static double S1[]
Definition: shichi.c:61
BADALLOC
const char BADALLOC[]
Definition: SphericalHarmonic2.cpp:20
NETGeographicLib::SphericalHarmonic2::Coefficients2
SphericalCoefficients Coefficients2()
Definition: SphericalHarmonic2.cpp:183
SphericalHarmonic2.hpp
Header for GeographicLib::SphericalHarmonic2 class.
NETGeographicLib::SphericalHarmonic2::m_S
std::vector< double > ** m_S
Definition: SphericalHarmonic2.h:52
SphericalCoefficients.h
Header for NETGeographicLib::SphericalCoefficients class.
NETGeographicLib::SphericalHarmonic2::Circle
CircularEngine Circle(double tau1, double tau2, double p, double z, bool gradp)
Definition: SphericalHarmonic2.cpp:157
x
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
Definition: gnuplot_common_settings.hh:12
CircularEngine.h
Header for NETGeographicLib::CircularEngine class.
C2
Definition: test_operator_overloading.cpp:98
NETGeographicLib::GeographicErr
Exception class for NETGeographicLib.
Definition: NETGeographicLib.h:132
GeographicLib::SphericalHarmonic2::Coefficients
const SphericalEngine::coeff & Coefficients() const
Definition: SphericalHarmonic2.hpp:302
NETGeographicLib::SphericalCoefficients
.NET wrapper for GeographicLib::SphericalEngine::coeff.
Definition: SphericalCoefficients.h:34
SphericalHarmonic2.h
Header for NETGeographicLib::SphericalHarmonic2 class.
S2
Symmetric< 2 > S2
Definition: testGroup.cpp:80
C1
Definition: test_operator_overloading.cpp:97
NETGeographicLib::SphericalHarmonic2::SphericalHarmonic2
SphericalHarmonic2(array< double >^ C, array< double >^ S, int N, array< double >^ C1, array< double >^ S1, int N1, array< double >^ C2, array< double >^ S2, int N2, double a, Normalization norm)
Definition: SphericalHarmonic2.cpp:51
GeographicLib::SphericalHarmonic2::Coefficients1
const SphericalEngine::coeff & Coefficients1() const
Definition: SphericalHarmonic2.hpp:307
NETGeographicLib::SphericalHarmonic2
.NET wrapper for GeographicLib::SphericalHarmonic2.
Definition: SphericalHarmonic2.h:40
NETGeographicLib::SphericalHarmonic2::m_numCoeffVectors
static const int m_numCoeffVectors
Definition: SphericalHarmonic2.h:48
NETGeographicLib::SphericalHarmonic2::m_pSphericalHarmonic2
const GeographicLib::SphericalHarmonic2 * m_pSphericalHarmonic2
Definition: SphericalHarmonic2.h:44
stdafx.h
pybind_wrapper_test_script.z
z
Definition: pybind_wrapper_test_script.py:61
NETGeographicLib::SphericalHarmonic2::m_C
std::vector< double > ** m_C
Definition: SphericalHarmonic2.h:52
NETGeographicLib.h
Header for NETGeographicLib::NETGeographicLib objects.
out
std::ofstream out("Result.txt")
NETGeographicLib::CircularEngine
.NET wrapper for GeographicLib::CircularEngine.
Definition: CircularEngine.h:54
y
Scalar * y
Definition: level1_cplx_impl.h:124
a
ArrayXXi a
Definition: Array_initializer_list_23_cxx11.cpp:1
array< double >
C
Matrix< Scalar, Dynamic, Dynamic > C
Definition: bench_gemm.cpp:50
GeographicLib::SphericalHarmonic2
Spherical harmonic series with two corrections to the coefficients.
Definition: SphericalHarmonic2.hpp:35
GeographicLib::SphericalHarmonic2::Coefficients2
const SphericalEngine::coeff & Coefficients2() const
Definition: SphericalHarmonic2.hpp:312
GeographicLib::SphericalHarmonic2::Circle
CircularEngine Circle(real tau1, real tau2, real p, real z, bool gradp) const
Definition: SphericalHarmonic2.hpp:277
p
float * p
Definition: Tutorial_Map_using.cpp:9
NETGeographicLib::SphericalHarmonic2::Coefficients1
SphericalCoefficients Coefficients1()
Definition: SphericalHarmonic2.cpp:177
N
#define N
Definition: igam.h:9
NULL
#define NULL
Definition: ccolamd.c:609
NETGeographicLib::SphericalHarmonic2::Normalization
Normalization
Definition: SphericalHarmonic2.h:57
NETGeographicLib
Definition: Accumulator.h:13
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9
S
DiscreteKey S(1, 2)


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:04:59