Package org.eclipse.imp.pdb.facts

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


        Result<X> second,
        IValueFactory vf,
        TypeFactory tf,
        IEvaluatorContext ctx) {
   
    INumber iFrom = from.getValue();
    INumber iTo = to.getValue();
   
    // I still think it is ugly to do it here...
    if (!second.getType().isSubtypeOf(tf.numberType())) {
      throw new UnexpectedType(tf.numberType(), second.getType(), ctx.getCurrentAST());
    }
   
    INumber iSecond = (INumber) second.getValue();
    INumber diff = iSecond.subtract(iFrom);
   
    INumber zero = diff.subtract(diff); // zero in the type that we're dealing with.

    // Use declared types here
    Type resultType = second.getType().lub(from.getType().lub(to.getType()));
   
    IListWriter w = vf.listWriter();
View Full Code Here


    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[] makeT(IList dataValues){
    int n = dataValues.length();
    double [] data = new double[n];
 
    for(int i = 0; i < n; i++){
      INumber d = (INumber) dataValues.get(i);
      data[i] = d.toReal().doubleValue();
    }
   
    return data;
  }
View Full Code Here

    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

    if(dataValues.length() <= 2)
      throw RuntimeExceptionFactory.illegalArgument(dataValues, null, null, "SimpleRegression data should have more than 2 elements");
    SimpleRegression simple = new SimpleRegression();
    for(IValue v : dataValues){
      ITuple t = (ITuple) v;
      INumber x = (INumber) t.get(0);
      INumber y = (INumber) t.get(1);
      simple.addData(x.toReal().doubleValue(), y.toReal().doubleValue());
    }
    return simple;
  }
View Full Code Here

        Result<X> second,
        IValueFactory vf,
        TypeFactory tf,
        IEvaluatorContext ctx) {
   
    INumber iFrom = from.getValue();
    INumber iTo = to.getValue();
   
    // I still think it is ugly to do it here...
    if (!second.getType().isSubtypeOf(tf.numberType())) {
      throw new UnexpectedType(tf.numberType(), second.getType(), ctx.getCurrentAST());
    }
   
    INumber iSecond = (INumber) second.getValue();
    INumber diff = iSecond.subtract(iFrom);
   
    INumber zero = diff.subtract(diff); // zero in the type that we're dealing with.

    // Use declared types here
    Type resultType = second.getType().lub(from.getType().lub(to.getType()));
   
    IListWriter w = vf.listWriter();
View Full Code Here

TOP

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

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.