evaluate method

  1. @override
dynamic evaluate(
  1. EvaluationType type,
  2. ContextModel context
)
override

Evaluates this expression according to given type and context.

Implementation

@override
dynamic evaluate(EvaluationType type, ContextModel context) {
  final dynamic argEval = arg.evaluate(type, context);

  if (type == EvaluationType.REAL) {
    return math.sqrt(argEval);
  }

  if (type == EvaluationType.VECTOR) {
    //TODO apply function to all vector elements
  }

  if (type == EvaluationType.INTERVAL) {
    // Piecewiese sqrting.
    return Interval(math.sqrt(argEval.min), math.sqrt(argEval.max));
  }

  throw UnimplementedError('Can not evaluate $name on $type yet.');
}