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,
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,
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 }
BADALLOC
const char BADALLOC[]
Definition: SphericalHarmonic1.cpp:20
S1
static double S1[]
Definition: shichi.c:61
NETGeographicLib::SphericalHarmonic1::Normalization
Normalization
Definition: SphericalHarmonic1.h:56
SphericalCoefficients.h
Header for NETGeographicLib::SphericalCoefficients class.
GeographicLib::SphericalHarmonic1::Coefficients1
const SphericalEngine::coeff & Coefficients1() const
Definition: SphericalHarmonic1.hpp:275
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
GeographicLib::SphericalHarmonic1::Circle
CircularEngine Circle(real tau, real p, real z, bool gradp) const
Definition: SphericalHarmonic1.hpp:246
NETGeographicLib::SphericalHarmonic1::SphericalHarmonic1
SphericalHarmonic1(array< double >^ C, array< double >^ S, int N, array< double >^ C1, array< double >^ S1, int N1, double a, Normalization norm)
Definition: SphericalHarmonic1.cpp:51
CircularEngine.h
Header for NETGeographicLib::CircularEngine class.
NETGeographicLib::GeographicErr
Exception class for NETGeographicLib.
Definition: NETGeographicLib.h:132
NETGeographicLib::SphericalHarmonic1::Coefficients
SphericalCoefficients Coefficients()
Definition: SphericalHarmonic1.cpp:159
NETGeographicLib::SphericalHarmonic1::m_S
std::vector< double > ** m_S
Definition: SphericalHarmonic1.h:51
NETGeographicLib::SphericalHarmonic1::m_C
std::vector< double > ** m_C
Definition: SphericalHarmonic1.h:51
GeographicLib::SphericalHarmonic1::Coefficients
const SphericalEngine::coeff & Coefficients() const
Definition: SphericalHarmonic1.hpp:270
NETGeographicLib::SphericalCoefficients
.NET wrapper for GeographicLib::SphericalEngine::coeff.
Definition: SphericalCoefficients.h:34
SphericalHarmonic1.hpp
Header for GeographicLib::SphericalHarmonic1 class.
C1
Definition: test_operator_overloading.cpp:97
SphericalHarmonic1.h
Header for NETGeographicLib::SphericalHarmonic1 class.
stdafx.h
pybind_wrapper_test_script.z
z
Definition: pybind_wrapper_test_script.py:61
NETGeographicLib.h
Header for NETGeographicLib::NETGeographicLib objects.
out
std::ofstream out("Result.txt")
NETGeographicLib::CircularEngine
.NET wrapper for GeographicLib::CircularEngine.
Definition: CircularEngine.h:54
NETGeographicLib::SphericalHarmonic1::Circle
CircularEngine Circle(double tau, double p, double z, bool gradp)
Definition: SphericalHarmonic1.cpp:146
y
Scalar * y
Definition: level1_cplx_impl.h:124
a
ArrayXXi a
Definition: Array_initializer_list_23_cxx11.cpp:1
array< double >
NETGeographicLib::SphericalHarmonic1::m_pSphericalHarmonic1
const GeographicLib::SphericalHarmonic1 * m_pSphericalHarmonic1
Definition: SphericalHarmonic1.h:42
C
Matrix< Scalar, Dynamic, Dynamic > C
Definition: bench_gemm.cpp:50
NETGeographicLib::SphericalHarmonic1
.NET wrapper for GeographicLib::SphericalHarmonic1.
Definition: SphericalHarmonic1.h:38
NETGeographicLib::SphericalHarmonic1::m_numCoeffVectors
static const int m_numCoeffVectors
Definition: SphericalHarmonic1.h:47
p
float * p
Definition: Tutorial_Map_using.cpp:9
N
#define N
Definition: igam.h:9
NULL
#define NULL
Definition: ccolamd.c:609
NETGeographicLib::SphericalHarmonic1::HarmonicSum
double HarmonicSum(double tau, double x, double y, double z)
Definition: SphericalHarmonic1.cpp:126
GeographicLib::SphericalHarmonic1
Spherical harmonic series with a correction to the coefficients.
Definition: SphericalHarmonic1.hpp:32
NETGeographicLib
Definition: Accumulator.h:13
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9
NETGeographicLib::SphericalHarmonic1::Coefficients1
SphericalCoefficients Coefficients1()
Definition: SphericalHarmonic1.cpp:165
S
DiscreteKey S(1, 2)


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