@Override
 public void compute() {
   if (!factorList.isDefined() || !Kernel.isInteger(number.getDouble())) {
     result.setUndefined();
     return;
   }
   long res = 1;
   for (int i = 0; i < factorList.size(); i++) {
     GeoList pair = (GeoList) factorList.get(i);
     double exp = ((NumberValue) pair.get(1)).getDouble();
     if (sum) {
       double prime = ((NumberValue) pair.get(0)).getDouble();
       App.debug(prime);
       res = res * Math.round((Math.pow(prime, exp + 1) - 1) / (prime - 1.0));
     } else {
       res = res * Math.round(exp + 1);
     }
   }
   result.setValue(res);
 }
Exemple #2
0
  @Override
  public final void compute() {

    size = inputList.size();
    if (!inputList.isDefined() || !function.toGeoElement().isDefined()) {
      r2.setUndefined();
      return;
    }

    GeoFunction funGeo = function.getGeoFunction();

    // Calculate errorsum and ssy:
    double sumyy = 0.0d;
    double sumy = 0.0d;
    double syy = 0.0d;
    double errorsum = 0.0d;
    GeoElement geo = null;
    GeoPoint point = null;
    double x, y, v;

    for (int i = 0; i < size; i++) {
      geo = inputList.get(i);
      if (geo.isGeoPoint()) {
        point = (GeoPoint) geo;
        x = point.getX();
        y = point.getY();
        v = funGeo.evaluate(x);
        errorsum += (v - y) * (v - y);
        sumy += y;
        sumyy += y * y;
      } else {
        r2.setUndefined();
        return;
      } // if calculation is possible
    } // for all points

    syy = sumyy - sumy * sumy / size;

    // calculate RSquare
    r2.setValue(1 - errorsum / syy);
  } // compute()