private Plot ( IFunction f, Double minx, Double maxx, Double precision ) : |
||
f | IFunction | |
minx | Double | |
maxx | Double | |
precision | Double | |
return |
Plot2DValue Plot(IFunction f, Double minx, Double maxx, Double precision)
{
var cp = new Plot2DValue();
var N = (Int32)((maxx - minx) / precision) + 1;
var M = new MatrixValue(N, 2);
var x = new ScalarValue(minx);
for (var i = 0; i < N; i++)
{
var row = i + 1;
var y = f.Perform(Context, x);
M[row, 1] = x.Clone();
if (y is ScalarValue)
{
M[row, 2] = (ScalarValue)y;
}
else if (y is MatrixValue)
{
var Y = (MatrixValue)y;
for (var j = 1; j <= Y.Length; j++)
{
M[row, j + 1] = Y[j];
}
}
x.Re += precision;
}
cp.AddPoints(M);
return cp;
}