// copied from AlgoInterationList.java
  // TODO should it be centralised?
  private void setListElement(int index, double value, double exp) {
    GeoList listElement;
    if (index < outputList.getCacheSize()) {
      // use existing list element
      listElement = (GeoList) outputList.getCached(index);
      listElement.clear();
    } else {
      // create a new list element
      listElement = new GeoList(cons);
      listElement.setParentAlgorithm(this);
      listElement.setConstructionDefaults();
      listElement.setUseVisualDefaults(false);
    }

    outputList.add(listElement);
    GeoNumeric prime = new GeoNumeric(cons);
    prime.setValue(value);
    GeoNumeric exponent = new GeoNumeric(cons);
    exponent.setValue(exp);
    listElement.add(prime);
    listElement.add(exponent);
  }
 @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 #3
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()
 /** @param x the new value */
 public static void setNumericValue(GeoNumeric geo, double x) {
   geo.setValue(x);
 }
 // set parameter of parabola
 @Override
 public final void compute() {
   if (c.type == GeoConicNDConstants.CONIC_PARABOLA) num.setValue(c.p);
   else num.setUndefined();
 }