@Override
  public final void compute() {
    if (!f.toGeoElement().isDefined()) {
      g.toGeoElement().setUndefined();
      return;
    }

    applyCasCommand(StringTemplate.prefixedDefault);
  }
  // for AlgoElement
  @Override
  protected void setInputOutput() {
    input = new GeoElement[1];
    input[0] = f.toGeoElement();

    setOutputLength(1);
    setOutput(0, g.toGeoElement());
    setDependencies(); // done by AlgoElement
  }
 /**
  * Creates CAS algo, doesn't set any input, output or label
  *
  * @param cons construction
  * @param f input function
  */
 protected AlgoCasBase(Construction cons, CasEvaluableFunction f, Commands cmd) {
   super(cons);
   this.f = f;
   this.cmd = cmd;
   cons.addCASAlgo(this);
   g = (CasEvaluableFunction) f.toGeoElement().copyInternal(cons);
 }
  /**
   * Creates CAS algo and sets input, output and label. Do not use if compute() or setInputOutput()
   * are overriden.
   *
   * @param cons construction
   * @param label label for output
   * @param f input function
   */
  protected AlgoCasBase(Construction cons, String label, CasEvaluableFunction f, Commands cmd) {
    this(cons, f, cmd);

    setInputOutput(); // for AlgoElement
    compute();
    g.toGeoElement().setLabel(label);
  }
 /** @return resulting function */
 public GeoElement getResult() {
   return g.toGeoElement();
 }
 /**
  * Clears the cache (needed in Web when the CAS loads)
  *
  * @param label not used
  */
 public final void clearCasEvalMap(String label) {
   f.clearCasEvalMap(label);
 }