/* Parse and evaluate multiplication and division expressions */ struct val * eval4(void) { struct val *l, *r; enum token op; l = eval5(); while ((op = token) == MUL || op == DIV || op == MOD) { nexttoken(0); r = eval5(); if (!to_integer(l) || !to_integer(r)) { errx(2, "non-numeric argument"); } if (op == MUL) { l->u.i *= r->u.i; } else { if (r->u.i == 0) { errx(2, "division by zero"); } if (op == DIV) { l->u.i /= r->u.i; } else { l->u.i %= r->u.i; } } free_value(r); } return l; }
static VALUE *eval4(void) { VALUE *l, *r; int op; arith_t val; l = eval5(); while (1) { op = nextarg("*"); if (!op) { op = nextarg("/"); if (!op) { op = nextarg("%"); if (!op) return l; }} G.args++; r = eval5(); val = arithmetic_common(l, r, op); freev(l); freev(r); l = int_value(val); } }
static inline_macro int drizzle_polynomial(void* state, const double xd, const double yd, const integer_t n, const double* xin /*[n]*/, const double* yin /*[n]*/, /* Output parameters */ double* xout, double* yout, struct driz_error_t* error) { struct mapping_param_t* m = (struct mapping_param_t*)state; double xdoff, ydoff; integer_t i; bool_t new_reference; /* Check for the presence of "refpix" additional information in the coefficients. If it is, set a flag and offset again */ if (m->coeff_type > COEFF_OFFSET / 2) { new_reference = TRUE; m->coeff_type -= COEFF_OFFSET; xdoff = m->xcen - m->x_coeffs[m->num_coeffs - 1] + 1.0; ydoff = m->ycen - m->y_coeffs[m->num_coeffs - 1] + 1.0; m->num_coeffs--; } else { new_reference = FALSE; xdoff = 2.0; ydoff = 2.0; } if (m->coeff_type == 3) { for (i = 0; i < n; ++i) { xout[i] = eval3(xin[i] + xdoff, yin[i] + ydoff, m->x_coeffs) - xdoff; yout[i] = eval3(xin[i] + xdoff, yin[i] + ydoff, m->y_coeffs) - ydoff; } } else if (m->coeff_type == 4) { for (i = 0; i < n; ++i) { xout[i] = eval4(xin[i] + xdoff, yin[i] + ydoff, m->x_coeffs) - xdoff; yout[i] = eval4(xin[i] + xdoff, yin[i] + ydoff, m->y_coeffs) - ydoff; } } else if (m->coeff_type == 5) { for (i = 0; i < n; ++i) { xout[i] = eval5(xin[i] + xdoff, yin[i] + ydoff, m->x_coeffs) - xdoff; yout[i] = eval5(xin[i] + xdoff, yin[i] + ydoff, m->y_coeffs) - ydoff; } } else if (m->coeff_type >= 6 || m->coeff_type == 1 || m->coeff_type == 2) { for (i = 0; i < n; ++i) { if (evaln(xin[i] + xdoff, yin[i] + ydoff, m->x_coeffs, m->coeff_type, &xout[i], error) || evaln(xin[i] + xdoff, yin[i] + ydoff, m->y_coeffs, m->coeff_type, &yout[i], error)) return 1; xout[i] -= xdoff; yout[i] -= ydoff; } } else if (m->coeff_type == -3) { for (i = 0; i < n; ++i) { rad3(xin[i] + xdoff, yin[i] + ydoff, m->x_coeffs, &xout[i], &yout[i]); xout[i] -= xdoff; yout[i] -= ydoff; } } else { driz_error_format_message(error, "Invalid coefficient type %d", m->coeff_type); return 1; } if (new_reference) { m->coeff_type += COEFF_OFFSET; m->num_coeffs++; } return 0; }