I'm trying to warp adapted functions of the solar position algorithm(aka "spa") made by the United States Naval Observatory to my code in a class so I can easily just call on one method to compute the solar positions.
This code belows is from the source code by the USNO. I am trying to initialize the lists L_TERMS, B_TERMS and R_TERMS
#define L_COUNT 6
#define B_COUNT 2
#define R_COUNT 5
#define Y_COUNT 63
#define L_MAX_SUBCOUNT 64
#define B_MAX_SUBCOUNT 5
#define R_MAX_SUBCOUNT 40
enum {TERM_A, TERM_B, TERM_C, TERM_COUNT};
enum {TERM_X0, TERM_X1, TERM_X2, TERM_X3, TERM_X4, TERM_X_COUNT};
enum {TERM_PSI_A, TERM_PSI_B, TERM_EPS_C, TERM_EPS_D, TERM_PE_COUNT};
enum {JD_MINUS, JD_ZERO, JD_PLUS, JD_COUNT};
enum {SUN_TRANSIT, SUN_RISE, SUN_SET, SUN_COUNT};
#define TERM_Y_COUNT TERM_X_COUNT
const int l_subcount[L_COUNT] = {64,34,20,7,3,1};
const int b_subcount[B_COUNT] = {5,2};
const int r_subcount[R_COUNT] = {40,10,6,2,1};
const double L_TERMS[L_COUNT][L_MAX_SUBCOUNT][TERM_COUNT]=
{ ... }; // contains 3*(64+34+20+7+3+1) = 387 doubles
const double B_TERMS[B_COUNT][B_MAX_SUBCOUNT][TERM_COUNT]=
{ ... }; // contains 3*(5+2) = 21 doubles
const double R_TERMS[R_COUNT][R_MAX_SUBCOUNT][TERM_COUNT]=
{ ... }; // contains 3*(40+10+6+2+1) = 177 doubles
I'm having trouble however initializing the arrays with the constructor. I tried using an initialization list but it doesn't seem to work. If I initialize the arrays in the constructor, all is well but won't be on the scope of the other methods since I can't declare them in the header. I can't initialize them either like a const int array.
Is there a better way to initialize multidimensional const double array that I am not aware of?
Note: the source code written by the USNO was done in C but I'm trying to use it in C++. Should I just include their file and call on the computing function?
std::vector
. – tadmanvector
instead of an array of known size???? – Swordfishstd::array
instead. – NathanOliverstd::vector
is bad for this purpose.std::array
is better. – geza