/[ascend]/trunk/base/generic/solver/relman.c
ViewVC logotype

Diff of /trunk/base/generic/solver/relman.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 908 by johnpye, Thu Oct 26 10:18:53 2006 UTC revision 909 by johnpye, Thu Oct 26 12:44:41 2006 UTC
# Line 494  int relman_diff2(struct rel_relation *re Line 494  int relman_diff2(struct rel_relation *re
494    gradient = (real64 *)rel_tmpalloc(len*sizeof(real64));    gradient = (real64 *)rel_tmpalloc(len*sizeof(real64));
495    assert(gradient !=NULL);    assert(gradient !=NULL);
496    *count = 0;    *count = 0;
497    if( safe ) {    if(safe){
498      status =(int32)RelationCalcGradientSafe(rel_instance(rel),gradient);      status =(int32)RelationCalcGradientSafe(rel_instance(rel),gradient);
499      safe_error_to_stderr( (enum safe_err *)&status );      safe_error_to_stderr( (enum safe_err *)&status );
500      /* always map when using safe functions */      /* always map when using safe functions */
501      for (c=0; c < len; c++) {      for (c=0; c < len; c++) {
502        if (var_apply_filter(vlist[c],filter)) {        if (var_apply_filter(vlist[c],filter)) {
503          variables[*count] = var_sindex(vlist[c]);          variables[*count] = var_sindex(vlist[c]);
504      derivatives[*count] = gradient[c];          derivatives[*count] = gradient[c];
505      (*count)++;          CONSOLE_DEBUG("Var %d = %f",var_sindex(vlist[c]),gradient[c]);
506            (*count)++;
507        }        }
508      }      }
509    }      return status;
510    else {    }else{
511      if((status=RelationCalcGradient(rel_instance(rel),gradient)) == 0) {      if((status=RelationCalcGradient(rel_instance(rel),gradient)) == 0) {
512        /* successful */        /* successful */
513        for (c=0; c < len; c++) {        for (c=0; c < len; c++) {
514          if (var_apply_filter(vlist[c],filter)) {          if (var_apply_filter(vlist[c],filter)) {
515        variables[*count] = var_sindex(vlist[c]);            variables[*count] = var_sindex(vlist[c]);
516        derivatives[*count] = gradient[c];            derivatives[*count] = gradient[c];
517        (*count)++;            (*count)++;
518          }          }
519        }        }
520      }      }
521        return !status;
522    }    }
   
   /* flip the status flag */  
   return !status;  
523  }  }
524    
525  int relman_diff_grad(struct rel_relation *rel, var_filter_t *filter,  int relman_diff_grad(struct rel_relation *rel, var_filter_t *filter,
# Line 586  int32 relman_diff_harwell(struct rel_rel Line 585  int32 relman_diff_harwell(struct rel_rel
585    int32 errcnt;    int32 errcnt;
586    enum safe_err status;    enum safe_err status;
587    
588    if (rlist == NULL || vfilter == NULL || rfilter == NULL || avec == NULL ||    if(rlist == NULL || vfilter == NULL || rfilter == NULL || avec == NULL
589        rlen < 0 || mORs >3 || mORs < 0 || bias <0 || bias > 1) {        || rlen < 0 || mORs >3 || mORs < 0 || bias <0 || bias > 1
590      ){
591      return 1;      return 1;
592    }    }
593    resid = &residual;    resid = &residual;
594    errcnt = k = 0;    errcnt = k = 0;
595    
596    if ( ivec == NULL || jvec == NULL ) {    if(ivec==NULL || jvec==NULL){
597      /*_skip stuffing ivec,jvec */      /*_skip stuffing ivec,jvec */
598      for (r=0; r < rlen; r++) {      for (r=0; r < rlen; r++) {
599        rel = rlist[r];        rel = rlist[r];
# Line 616  int32 relman_diff_harwell(struct rel_rel Line 616  int32 relman_diff_harwell(struct rel_rel
616          }          }
617        }        }
618      }      }
619    } else {    }else{
620      for (r=0; r < rlen; r++) {      for (r=0; r < rlen; r++) {
621        rel = rlist[r];        rel = rlist[r];
622        len = rel_n_incidences(rel);        len = rel_n_incidences(rel);

Legend:
Removed from v.908  
changed lines
  Added in v.909

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22