Package org.eclipse.imp.pdb.facts

Examples of org.eclipse.imp.pdb.facts.ITuple


 
  private int numberOfStates(ISet st){
    st.size();
    int r = 0;
    for(IValue v : st){
      ITuple t = (ITuple) v;
      IInteger from = (IInteger) t.get(0);
      IInteger to = (IInteger) t.get(2);
      if(from.intValue() > r) r = from.intValue();
      if(to.intValue() > r) r = to.intValue();
    }
    return r + 1;
  }
View Full Code Here


  }
 
  private void printTransitions(PrintStream fos, ISet st){
    fos.println("des(0," + st.size() + "," + numberOfStates(st) + ")");
    for(IValue v : st){
      ITuple t = (ITuple) v;
      IInteger from = (IInteger) t.get(0);
      IString act = (IString) t.get(1);
      IInteger to = (IInteger) t.get(2);
      fos.print('(');
      fos.print(from.intValue());
      fos.print(',');
      fos.print("\"" + act.getValue() + "\"");
      fos.print(',');
View Full Code Here

    return loe.isLess();
  }
 
  @Override
  protected LessThanOrEqualResult lessThanOrEqualTuple(TupleResult that) {
    ITuple left = that.getValue();
    int leftArity = left.arity();
    ITuple right = getValue();
    int rightArity = right.arity();
   
    for (int i = 0; i < Math.min(leftArity, rightArity); i++) {
       IValue leftArg = left.get(i);
       IValue rightArg = right.get(i);
       LessThanOrEqualResult loe = makeResult(leftArg.getType(), leftArg, ctx).lessThanOrEqual(makeResult(rightArg.getType(), rightArg,ctx));
      
       if (loe.getLess()) {
         return loe;
       }
View Full Code Here

    this.tuple = tuple;
  }
 
  @Override
  public IValue up(IValue focus) {
    ITuple sub = (ITuple)focus;
    int i = 0;
    ITuple newTuple = tuple;
    for (IValue elt: sub) {
      newTuple = newTuple.set(fields[i], elt);
    }
    return new TupleCursor(newTuple, ctx);
  }
View Full Code Here

    this.tuple = tuple;
  }

  @Override
  public IValue up(IValue focus) {
    ITuple sub = (ITuple)focus;
    int i = 0;
    ITuple newTuple = tuple;
    for (IValue elt: sub) {
      newTuple = newTuple.set(fields[i], elt);
      i++;
    }
    return new TupleCursor(newTuple, ctx);
  }
View Full Code Here

    }
    if (reader.getLastChar() == '}') {
      reader.readSkippingWS();
      return w.done();
    }
    ITuple term = parseEntry(reader, expected);
    w.put(term.get(0), term.get(1));
    while (reader.getLastChar() == ',') {
      reader.readSkippingWS();
      term = parseEntry(reader, expected);
      w.put(term.get(0), term.get(1));
    }
    if (reader.getLastChar() != '}') {
      throw new FactParseError("expected '}' but got '"
          + (char) reader.getLastChar() + "'", reader.getPosition());
    }
View Full Code Here

    expected = new double[n];
    observed = new long[n];
 
    int i = 0;
    for(IValue v : dataValues){
      ITuple t = (ITuple) v;
      INumber exp = (INumber) t.get(0);
      INumber obs = (INumber) t.get(1);
      expected[i] = (long) exp.toReal().doubleValue();
      observed[i] = obs.toInteger().longValue();
     
      if(expected[i] < 0 || observed[i] < 0) throw RuntimeExceptionFactory.illegalArgument(dataValues, null, null, "Chi test requires positive values");
      i++;
View Full Code Here

    double g = 0;
    double N = 0;
   
    double xvalues[] = new double[dataValues.length()];
    for(int i = 0; i < dataValues.length(); i++){
      ITuple T = (ITuple) dataValues.get(i);
      xvalues[i] = ((INumber) T.get(0)).toReal().doubleValue();
    }
   
    // Create a natural ranking: largest first.
    double rank[] = new NaturalRanking().rank(xvalues);
   
    for(int i = 0; i < rank.length; i++){
      rank[i] = rank.length - rank[i] + 1; // invert the ranking: smallest come now first.
      //System.err.println("rank[" + i + "] = " + rank[i]);
    }
   
    for(int i = 0; i < dataValues.length(); i++){
      ITuple T = (ITuple) dataValues.get(i);
      double Y = ((INumber) T.get(1)).toReal().doubleValue();
      if(Y < 0)
        throw RuntimeExceptionFactory.illegalArgument(T, null, null, "Frequency should be positive");
     
      g += xvalues[i] * rank[i] * Y;
      N += Y;
View Full Code Here

      }
     
      Pattern escapingNeeded = Pattern.compile("[\\n\\r\"\\x" + Integer.toHexString(separator.charAt(0)) + "]");
     
      for(IValue v : (isListRel ? lrel : irel)){
        ITuple tup = (ITuple) v;
        boolean firstTime = true;
        for(IValue w : tup){
          if(firstTime)
            firstTime = false;
          else
View Full Code Here

    xvalues = new double[n];
    yvalues = new double[n];
    xyvalues = new double[n][n];
    int i = 0;
    for(IValue v : dataValues){
      ITuple t = (ITuple) v;
      INumber x = (INumber) t.get(0);
      INumber y = (INumber) t.get(1);
      xvalues[i] = xyvalues[i][0] = x.toReal().doubleValue();
      yvalues[i] = xyvalues[i][0] = y.toReal().doubleValue();
      i++;
    }
  }
View Full Code Here

TOP

Related Classes of org.eclipse.imp.pdb.facts.ITuple

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.