static VALUE *eval2(void) { VALUE *l, *r; int op; arith_t val; l = eval3(); while (1) { op = nextarg("<"); if (!op) { op = nextarg("<="); if (!op) { op = nextarg("="); if (!op) { op = nextarg("=="); if (!op) { op = nextarg("!="); if (!op) { op = nextarg(">="); if (!op) { op = nextarg(">"); if (!op) return l; }}}}}} G.args++; r = eval3(); toarith(l); toarith(r); val = cmp_common(l, r, op); freev(l); freev(r); l = int_value(val); } }
void DatasetTensor::createLogTensors() { qDebug() << "create log tensors..."; int blockSize = m_data.size(); m_logData.resize( blockSize ); std::vector<QVector3D> evec1( blockSize ); std::vector<float> eval1( blockSize ); std::vector<QVector3D> evec2( blockSize ); std::vector<float> eval2( blockSize ); std::vector<QVector3D> evec3( blockSize ); std::vector<float> eval3( blockSize ); FMath::evecs( m_data, evec1, eval1, evec2, eval2, evec3, eval3 ); //log(M) =Ulog(D)UT Matrix U(3,3); DiagonalMatrix D(3); Matrix logM(3,3); for ( unsigned int i = 0; i < m_logData.size(); ++i ) { U( 1, 1 ) = evec1[i].x(); U( 2, 1 ) = evec1[i].y(); U( 3, 1 ) = evec1[i].z(); U( 1, 2 ) = evec2[i].x(); U( 2, 2 ) = evec2[i].y(); U( 3, 2 ) = evec2[i].z(); U( 1, 3 ) = evec3[i].x(); U( 2, 3 ) = evec3[i].y(); U( 3, 3 ) = evec3[i].z(); D(1) = log( eval1[i] ); D(2) = log( eval2[i] ); D(3) = log( eval3[i] ); logM = U*D*U.t(); m_logData[i] = logM; } qDebug() << "create log tensors done!"; }
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; }
/* Parse and evaluate comparison expressions */ struct val * eval2(void) { struct val *l, *r; enum token op; int v = 0, li, ri; l = eval3(); while ((op = token) == EQ || op == NE || op == LT || op == GT || op == LE || op == GE) { nexttoken(0); r = eval3(); if (is_integer(l, &li) && is_integer(r, &ri)) { switch (op) { case GT: v = (li > ri); break; case GE: v = (li >= ri); break; case LT: v = (li < ri); break; case LE: v = (li <= ri); break; case EQ: v = (li == ri); break; case NE: v = (li != ri); break; default: break; } } else { to_string(l); to_string(r); switch (op) { case GT: v = (strcoll(l->u.s, r->u.s) > 0); break; case GE: v = (strcoll(l->u.s, r->u.s) >= 0); break; case LT: v = (strcoll(l->u.s, r->u.s) < 0); break; case LE: v = (strcoll(l->u.s, r->u.s) <= 0); break; case EQ: v = (strcoll(l->u.s, r->u.s) == 0); break; case NE: v = (strcoll(l->u.s, r->u.s) != 0); break; default: break; } } free_value(l); free_value(r); l = make_int(v); } return l; }