evaluate method
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) {
// Compensate for inaccuracies in machine-pi.
//
// If argEval divides cleanly from pi (when shifted back to Sin from Cos), return 0.
if (((argEval - math.pi / 2) / math.pi).abs() % 1 == 0) {
return 0.0;
}
return math.cos(argEval);
}
if (type == EvaluationType.VECTOR) {
//TODO apply function to all vector elements
}
if (type == EvaluationType.INTERVAL) {
// TODO evaluate endpoints and critical points (n * pi)
// or just return [-1, 1] if half a period is in the given interval
}
throw UnimplementedError('Can not evaluate $name on $type yet.');
}