Closed sadqiang closed 5 years ago
There is a separate compilation function to compile to a function operating on complex values. Currently this only supports double precision complex numbers Complex
, not single precision Complex32
, but it would certainly be possible to extend the library to support also single precision in the future. This is what works for me:
using System;
using Complex = System.Numerics.Complex;
using Expr = MathNet.Symbolics.SymbolicExpression;
namespace MathNetSymbolicsCompile
{
class Program
{
static void Main(string[] args)
{
var z = Expr.Variable("z");
Func<Complex, Complex> f = (z * z + z - 6 * (z * z + z - 1).Cos()).CompileComplex("z");
Complex c = 2 + 3 * Complex.ImaginaryOne;
Console.WriteLine(f(c));
}
}
}
Double precision is much much better. Thank you for replying. An excellent answer!
I want to create a fractal generator that works on complex values.
Is there any workaround to handle this?