Exemplo n.º 1
0
/* Creation of the numerical constraint (l rel r) */
void rp_ctr_num_create(rp_ctr_num * c,
                       rp_erep * l, int rel, rp_erep * r)
{
  rp_malloc(*c,rp_ctr_num,sizeof(rp_ctr_num_def));

  /* creation of the constraint functional expression */
  if ((rp_erep_type(*l)==RP_EREP_NODE_CST) &&
      (rp_interval_zero(rp_erep_val(*l))))
  {
    /* 0 rel r */
    rp_erep rc;
    rp_erep_copy(&rc,*r);
    rp_expression_create(&rp_ctr_num_func(*c),&rc);
    switch( rel )
    {
      case RP_RELATION_EQUAL:
        rp_ctr_num_relfunc(*c) = RP_RELATION_EQUAL;
        break;

      case RP_RELATION_SUPEQUAL:
        rp_ctr_num_relfunc(*c) = RP_RELATION_INFEQUAL;
        break;

      case RP_RELATION_INFEQUAL:
        rp_ctr_num_relfunc(*c) = RP_RELATION_SUPEQUAL;
        break;
    }
  }
  else if((rp_erep_type(*r)==RP_EREP_NODE_CST) &&
          (rp_interval_zero(rp_erep_val(*r))))
  {
    /* l rel 0 */
    rp_erep lc;
    rp_erep_copy(&lc,*l);
    rp_expression_create(&rp_ctr_num_func(*c),&lc);
    rp_ctr_num_relfunc(*c) = rel;
  }
  else
  {
    /* l rel r */
    rp_erep lc, rc, f;
    rp_erep_copy(&lc,*l);
    rp_erep_copy(&rc,*r);
    rp_erep_create_binary(&f,RP_SYMBOL_SUB,lc,rc);
    rp_erep_destroy(&lc);
    rp_erep_destroy(&rc);
    rp_expression_create(&rp_ctr_num_func(*c),&f);
    rp_ctr_num_relfunc(*c) = rel;
  }

  /* creation of constraint */
  rp_expression_create(&rp_ctr_num_left(*c),l);
  rp_expression_create(&rp_ctr_num_right(*c),r);
  rp_ctr_num_rel(*c) = rel;
}
Exemplo n.º 2
0
int rp_rule_function_call(rp_parser p, rp_function f, rp_erep * out)
{
  if (rp_parser_expect(p,RP_TOKEN_LBR,"("))
  {
    rp_erep_copy(out,rp_function_rep(f));
    return( rp_rule_function_call_iter(p,f,0,out) );
  }
  else
  {
    return( 0 );
  }
}
Exemplo n.º 3
0
// Copy
rp_operator_box_sup::rp_operator_box_sup(const rp_operator_box_sup& o):
  rp_operator(o),
  _x(o._x),
  _improve(o._improve),
  _eps(o._eps)
{
  rp_erep aux;
  rp_erep_copy(&aux,rp_expression_rep(o._f));
  rp_expression_create(&_f,&aux);
  if (rp_expression_derivable(_f))
  {
    rp_expression_deriv_symb(&_df,_f,_x);
  }
  else
  {
    _df = NULL;
  }
}