Exemple #1
0
Expr* expr_taper(Expr* dz, Expr* s0, Expr* s1, Expr* g) {
  auto zrad = expr_mul(expr_lit(0.5), dz);
  auto z0   = expr_neg(zrad);
  auto z1   = zrad;
  return new ExprXform(expr_mul(expr_x(), expr_div(dz,expr_add(expr_mul(s1,expr_sub(expr_z(),z0)), expr_mul(s0,expr_sub(z1,expr_z()))))),
                       expr_mul(expr_y(), expr_div(dz,expr_add(expr_mul(s1,expr_sub(expr_z(),z0)), expr_mul(s0,expr_sub(z1,expr_z()))))),
                       expr_z(),
                       g);
}
Exemple #2
0
Expr* expr_mag1(Expr* dxyz, Expr* g) {
  auto tg = new ExprXform(expr_div(expr_x(), dxyz), expr_div(expr_y(), dxyz), expr_div(expr_z(), dxyz), g);
  tg->xmin = expr_mul(dxyz, g->xmin);
  tg->xmax = expr_mul(dxyz, g->xmax);
  tg->ymin = expr_mul(dxyz, g->ymin);
  tg->ymax = expr_mul(dxyz, g->ymax);
  tg->zmin = expr_mul(dxyz, g->zmin);
  tg->zmax = expr_mul(dxyz, g->zmax);
  return tg;
}
Exemple #3
0
Expr* expr_mag(Expr* dx, Expr* dy, Expr* dz, Expr* g) {
  auto tg = new ExprXform(expr_div(expr_x(), dx), expr_div(expr_y(), dy), expr_div(expr_z(), dz), g);
  tg->xmin = expr_mul(dx, g->xmin);
  tg->xmax = expr_mul(dx, g->xmax);
  tg->ymin = expr_mul(dy, g->ymin);
  tg->ymax = expr_mul(dy, g->ymax);
  tg->zmin = expr_mul(dz, g->zmin);
  tg->zmax = expr_mul(dz, g->zmax);
  return tg;
}
Exemple #4
0
Expr* expr_shear_x_z(Expr* z0, Expr* z1, Expr* dx0, Expr* dx1, Expr* g) {
  return new ExprXform(expr_sub(expr_x(),
                                expr_sub(dx0, expr_div(expr_mul(expr_sub(dx1,dx0),expr_sub(expr_z(),z0)),
                                                       expr_sub(z1,z0)))),
                       expr_y(),
                       expr_z(),
                       g);
}
Exemple #5
0
static void test_arithmetic()
{
    double d0 = 0.0;
    double d1 = 0.0;

    Expr *e_isum = expr_sum(expr_int(2), expr_int(2));
    Expr *e_lsum = expr_sum(expr_long(2), expr_long(2));
    Expr *e_rsum = expr_sum(expr_real(2.2), expr_real(2.2));

    Expr *e_isub = expr_sub(expr_int(3), expr_int(7));
    Expr *e_lsub = expr_sub(expr_long(3), expr_long(7));
    Expr *e_rsub = expr_sub(expr_real(1.3), expr_real(0.3));

    Expr *e_idiv = expr_div(expr_int(8), expr_int(4));
    Expr *e_ldiv = expr_div(expr_long(8), expr_long(4));
    Expr *e_rdiv = expr_div(expr_real(3.0), expr_real(0.1));

    Expr *e_imul = expr_mul(expr_int(5), expr_int(5));
    Expr *e_lmul = expr_mul(expr_long(5), expr_long(5));
    Expr *e_rmul = expr_mul(expr_real(5.0), expr_real(0.5));

    if (4 != val_int(expr_new_val(e_isum, NULL, NULL)))
        fail();
    if (4LL != val_long(expr_new_val(e_lsum, NULL, NULL)))
        fail();

    d0 = val_real(expr_new_val(e_rsum, NULL, NULL));
    d1 = 4.4;
    if (d1 != d0)
        fail();

    if (-4 != val_int(expr_new_val(e_isub, NULL, NULL)))
        fail();
    if (-4LL != val_long(expr_new_val(e_lsub, NULL, NULL)))
        fail();

    d0 = val_real(expr_new_val(e_rsub, NULL, NULL));
    d1 = 1.0;
    if (d1 != d0)
        fail();

    if (2 != val_int(expr_new_val(e_idiv, NULL, NULL)))
        fail();
    if (2LL != val_long(expr_new_val(e_ldiv, NULL, NULL)))
        fail();

    d0 = val_real(expr_new_val(e_rdiv, NULL, NULL));
    d1 = 30;
    if (d1 != d0)
        fail();

    if (25 != val_int(expr_new_val(e_imul, NULL, NULL)))
        fail();
    if (25 != val_long(expr_new_val(e_lmul, NULL, NULL)))
        fail();

    d0 = val_real(expr_new_val(e_rmul, NULL, NULL));
    d1 = 2.5;
    if (d1 != d0)
        fail();

    expr_free(e_isum);
    expr_free(e_lsum);
    expr_free(e_rsum);

    expr_free(e_isub);
    expr_free(e_lsub);
    expr_free(e_rsub);

    expr_free(e_idiv);
    expr_free(e_ldiv);
    expr_free(e_rdiv);

    expr_free(e_imul);
    expr_free(e_lmul);
    expr_free(e_rmul);
}