Planetary Orbital Evolution due to Tides
Orbital evolution of two objects experiencing tides
mass_feh_interp.cpp
1 #define BUILDING_LIBRARY
2 #include "mass_feh_interp.h"
3 
4 namespace StellarEvolution {
5 
6  double mass_feh_interp(
7  const alglib::real_1d_array &interp_masses,
8  const alglib::real_1d_array &interp_feh,
9  const alglib::real_1d_array &interp_values,
10  double stellar_mass,
11  double stellar_feh
12  )
13  {
14  assert(interp_masses.length() * interp_feh.length()
15  ==
16  interp_values.length());
17 
18  if(interp_values.length() == 1) {
19  return interp_values[0];
20  } else if(interp_masses.length() == 1) {
21  alglib::spline1dinterpolant spline;
22  alglib::spline1dbuildcubic(interp_feh,
23  interp_values,
24  spline);
25  return alglib::spline1dcalc(spline, stellar_feh);
26  } else if(interp_feh.length() == 1) {
27  alglib::spline1dinterpolant spline;
28  alglib::spline1dbuildcubic(interp_masses,
29  interp_values,
30  spline);
31  return alglib::spline1dcalc(spline, stellar_mass);
32  } else {
33  alglib::spline2dinterpolant spline;
34  alglib::spline2dbuildbicubicv(interp_masses,
35  interp_masses.length(),
36  interp_feh,
37  interp_feh.length(),
38  interp_values,
39  1,
40  spline);
41  return alglib::spline2dcalc(spline,
42  stellar_mass,
43  stellar_feh);
44  }
45  }
46 
47 }
Define a single function performing mass-[Fe/H] interpolations.