Macro with an array type parameter
Posted: Fri Jul 20, 2012 1:35 pm
Good afternoon bright minds,
I had some issues while trying to replicate some C code on Flowcode. The problem is the input parameters on the macro. It allows you to create an array type parameter, but when you are trying to call it, you get an "incompatible argument" pop-up note error, or if you are tying to put a non array argument you get a message "Can not convert to type 'float[6]' "(in the case if it was a float type array parameter) , so no matter what you type in, it is not possible to call the macro. For example, I was trying to recreate such a C code on the flowcode:
the result was:
Which has to be used in the recreated macro on the flowcode but as the following C code:
The other issue I had is when I tried to recreate a C code like this, with a 2 dimentional array:
How is it possible to recreate such a parameter like const couble terms[][TERM_COUNT] ? This is suppose to acquire the value from the LUT, such as following example:
Best regards,
Mantas
I had some issues while trying to replicate some C code on Flowcode. The problem is the input parameters on the macro. It allows you to create an array type parameter, but when you are trying to call it, you get an "incompatible argument" pop-up note error, or if you are tying to put a non array argument you get a message "Can not convert to type 'float[6]' "(in the case if it was a float type array parameter) , so no matter what you type in, it is not possible to call the macro. For example, I was trying to recreate such a C code on the flowcode:
Code: Select all
double earth_values(double term_sum[], int count, double jme)
{
int i;
double sum=0;
for (i = 0; i < count; i++)
sum += term_sum[i]*pow(jme, i);
sum /= 1.0e8;
return sum;
}
Code: Select all
double earth_radius_vector(double jme)
{
double sum[R_COUNT];
int i;
for (i = 0; i < R_COUNT; i++)
sum[i] = earth_periodic_term_summation(R_TERMS[i], r_subcount[i], jme);
return earth_values(sum, R_COUNT, jme);
}
Code: Select all
double earth_periodic_term_summation(const double terms[][TERM_COUNT], int count, double jme)
{
int i;
double sum=0;
for (i = 0; i < count; i++)
sum += terms[i][TERM_A]*cos(terms[i][TERM_B]+terms[i][TERM_C]*jme);
return sum;
}
Code: Select all
const double R_TERMS[R_COUNT][R_MAX_SUBCOUNT][TERM_COUNT]=
{
{
{100013989.0,0,0},
{1670700.0,3.0984635,6283.07585},
{13956.0,3.05525,12566.1517},
{3084.0,5.1985,77713.7715},
{1628.0,1.1739,5753.3849},
{1576.0,2.8469,7860.4194},
{925.0,5.453,11506.77},
{542.0,4.564,3930.21},
{472.0,3.661,5884.927},
{346.0,0.964,5507.553},
{329.0,5.9,5223.694},
{307.0,0.299,5573.143},
{243.0,4.273,11790.629},
{212.0,5.847,1577.344},
{186.0,5.022,10977.079},
{175.0,3.012,18849.228},
{110.0,5.055,5486.778},
{98,0.89,6069.78},
{86,5.69,15720.84},
{86,1.27,161000.69},
{65,0.27,17260.15},
{63,0.92,529.69},
{57,2.01,83996.85},
{56,5.24,71430.7},
{49,3.25,2544.31},
{47,2.58,775.52},
{45,5.54,9437.76},
{43,6.01,6275.96},
{39,5.36,4694},
{38,2.39,8827.39},
{37,0.83,19651.05},
{37,4.9,12139.55},
{36,1.67,12036.46},
{35,1.84,2942.46},
{33,0.24,7084.9},
{32,0.18,5088.63},
{32,1.78,398.15},
{28,1.21,6286.6},
{28,1.9,6279.55},
{26,4.59,10447.39}
},
{
{103019.0,1.10749,6283.07585},
{1721.0,1.0644,12566.1517},
{702.0,3.142,0},
{32,1.02,18849.23},
{31,2.84,5507.55},
{25,1.32,5223.69},
{18,1.42,1577.34},
{10,5.91,10977.08},
{9,1.42,6275.96},
{9,0.27,5486.78}
},
{
{4359.0,5.7846,6283.0758},
{124.0,5.579,12566.152},
{12,3.14,0},
{9,3.63,77713.77},
{6,1.87,5573.14},
{3,5.47,18849.23}
},
{
{145.0,4.273,6283.076},
{7,3.92,12566.15}
},
{
{4,2.56,6283.08}
}
};
Mantas