[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
/* Create an environment with 6 real variables */ ap_var_t name_of_dim[6] = { "x","y","z","u","w","v" }; ap_environment_t* env = ap_environment_alloc(NULL,0,name_of_dim,6); |
Then, we build an array of constraints. At level 1, an array of constraints is an abstract datatype, which requires careful manipulation w.r.t. memory management.
/* Create an array of constraints of size 2 */ ap_lincons1_array_t array = ap_lincons1_array_make(env,2); /* 1.a Creation of an inequality constraint */ ap_linexpr1_t expr = ap_linexpr1_make(env,AP_LINEXPR_SPARSE,1); ap_lincons1_t cons = ap_lincons1_make(AP_CONS_SUP,&expr,NULL); /* Now expr is memory-managed by cons */ /* 1.b Fill the constraint */ ap_lincons1_set_list(&cons, AP_COEFF_S_INT,"x", AP_CST_S_FRAC,1,2, AP_END); /* 1.c Put in the array */ ap_lincons1_array_set(&array,0,&cons); /* Now cons is memory-managed by array */ /* 2.a Creation of an inequality constraint */ expr = ap_linexpr1_make(env,AP_LINEXPR_SPARSE,2); cons = ap_lincons1_make(AP_CONS_SUPEQ,&expr,NULL); /* The old cons is not lost, because it is stored in the array. It would be an error to clear it (same for expr). */ /* 2.b Fill the constraint */ ap_lincons1_set_list(&cons, AP_COEFF_S_INT,1,"x", AP_COEFF_S_INT,1,"y", AP_COEFF_S_INT,1,"z", AP_END); /* 2.c Put in the array */ ap_lincons1_array_set(&array,1,&cons); |
Last we can build an abstract value.
/* Creation of an abstract value defined by the array of constraints */ ap_abstract1_t abs = ap_abstract1_of_lincons_array(man,env,&array); fprintf(stdout,"Abstract value:\n"); ap_abstract1_fprint(stdout,man,&abs); |
We now deallocate everything:
/* deallocation */ ap_lincons1_array_clear(&array); ap_abstract1_clear(&abs); ap_environment_free(env); ap_manager_free(man); |