// Example of using the GeographicLib::SphericalHarmonic2 class#include <iostream>#include <exception>#include <vector>#include <GeographicLib/SphericalHarmonic2.hpp>usingnamespacestd;usingnamespaceGeographicLib;intmain(){try{intN=3,N1=2,N2=1;// The maxium degreesdoubleca[]={10,9,8,7,6,5,4,3,2,1};// cosine coefficientsvector<double>C(ca,ca+(N+1)*(N+2)/2);doublesa[]={6,5,4,3,2,1};// sine coefficientsvector<double>S(sa,sa+N*(N+1)/2);doublecb[]={1,2,3,4,5,6};vector<double>C1(cb,cb+(N1+1)*(N1+2)/2);doublesb[]={3,2,1};vector<double>S1(sb,sb+N1*(N1+1)/2);doublecc[]={2,1};vector<double>C2(cc,cc+(N2+1));vector<double>S2;doublea=1;SphericalHarmonic2h(C,S,N,N,N,C1,S1,N1,N1,N1,C2,S2,N2,N2,0,a);doubletau1=0.1,tau2=0.05,x=2,y=3,z=1;doublev,vx,vy,vz;v=h(tau1,tau2,x,y,z,vx,vy,vz);cout<<v<<" "<<vx<<" "<<vy<<" "<<vz<<"\n";}catch(constexception&e){cerr<<"Caught exception: "<<e.what()<<"\n";return1;}}