12.21.6. - Referring to independent variables
These next definitions show how to refer to the current value of the independent variable(s) to be used in the current evaluation of the fitting equation.
#define X (M_flag? Make_x[0]:dp->d_xx[0]) #define X1 (M_flag? Make_x[0]:dp->d_xx[0]) #define X2 (M_flag? Make_x[1]:dp->d_xx[1]) #define X3 (M_flag? Make_x[2]:dp->d_xx[2]) /* etc. */The integer variable
M_flag is nonzero when evaluation of the
fitting equation is being performed on behalf of the
make data
command,
md, or the
make residuals
command,
mr, and zero when the evaluation is being performed during fitting.
The
C-language ternary operator (?:) within parentheses evaluates
to the expression on the left of the colon if
M_flag is nonzero
and the expression on the right of the colon otherwise.
Notice that the definitions of
X and
X1 are the same.
The latter is for the case of multiple independent variables.
You
can of course change the defined names to make your fitting equation
more readable.
