Example #1
0
bool
operator==(Val& v1, Val& v2)
{
  if(v1.edge() != v2.edge()) return false;
  shortIter si2 = v2.vec().begin();
  for(shortIter si = v1.vec().begin(); si != v1.vec().end() ; si++)
    {
      if((*si) != (*si2)) return false;
      si2++;
    }
  return true;
}
Example #2
0
Val*
Val::
newIth(int ith, Val* oval, bool& stop)
{
  int ithc = oval->vec(ith);
  if(ithc > 0) stop = true;
  short nxtI = ithc +1;;
  //cerr<< "Wnt " << nxtI << "th var on pos " << ith << " of " << *oval<< endl;
  if(oval->wrd() >= 0) return NULL; //???;
  double ovalprob = oval->prob();
  //if(oval->status == TERMINALVAL) return NULL;
  Val* nval = ithBst(ith,oval->bsts()).next(nxtI);
  if(!nval) return NULL;
  double ovalcompprob = ithBst(ith, oval->bsts()).nth(ithc)->prob();
  double nprob = nval->prob();
  //cerr << "Its prob is " << nprob << endl;
  if(nprob < 0) return NULL;
  Val* ans = new Val(oval);
  ans->vec(ith) = nxtI;
  double frac = nprob/ovalcompprob;
  ans->prob() *= frac;
  assert(nxtI <= ithBst(ith,ans->bsts()).num());
  //cerr << "ith is " << ith << " " << ans->vec().size() << " "
  //   << ans->vec()[ith] << " " << frac << endl;
  //cerr << "The var is " << *ans << endl;
  //assert(ans->check());
  return ans;
}