User:Karthik0112358/coefficient find

From ASCEND
Jump to navigation Jump to search
//This is just a function. I am not sure where to place it (either in a separate place or with in the previous skeletal code).
int coefficient_find(struct rel_relation *rel, const var_filter_t *filter,real64 *coefficients,int32 *variables,int32 *count){
   const struct var_variable **vlist=NULL;
   int32 len,c;
   real64 *coefficient;
   int status;
   assert(rel!=NULL && filter!=NULL);
   len = rel_n_incidences(rel);
   vlist = rel_incidence_list(rel);
   *count = 0;
   coefficient = (real64 *)rel_tmpalloc(len*sizeof(real64));
   assert(coefficient !=NULL);
   status =(int32)Coefficient_Calculator(rel_instance(rel),coefficient); 
   for (c=0; c < len; c++) {
      if (var_apply_filter(vlist[c],filter)) {
         variables[*count] = var_sindex(vlist[c]);
         coefficients[*count] = coefficient[c];
         (*count)++;
      }
   }
}