Is the type for basic 2D plotting.
상속: XYPlotValue
예제 #1
0
        public Plot2DValue Function(MatrixValue m, MatrixValue n)
        {
            var plot = new Plot2DValue();

            plot.AddPoints(m, n);
            return(plot);
        }
예제 #2
0
        Plot2DValue Plot(IFunction f, double minx, double maxx, double precision)
        {
            var cp = new Plot2DValue();
            var N  = (int)((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);
        }
예제 #3
0
        /// <summary>
        /// Converts a set of bytes to a new instance.
        /// </summary>
        /// <param name="content">The binary representation.</param>
        /// <returns>The new instance.</returns>
        public override Value Deserialize(byte[] content)
        {
            var p2 = new Plot2DValue();

            using (var ds = Deserializer.Create(content))
            {
                p2.Deserialize(ds);
                p2.IsLogX = ds.GetBoolean();
                p2.IsLogY = ds.GetBoolean();
                var length = ds.GetInt();

                for (var i = 0; i < length; i++)
                {
                    var points = new Points <PointPair>();
                    points.Deserialize(ds);
                    var count = ds.GetInt();

                    for (int j = 0; j < count; j++)
                    {
                        var x = ds.GetDouble();
                        var y = ds.GetDouble();

                        points.Add(new PointPair
                        {
                            X = x,
                            Y = y
                        });
                    }

                    p2.AddSeries(points);
                }
            }

            return(p2);
        }
예제 #4
0
        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;
        }
예제 #5
0
        public Plot2DValue Function(MatrixValue m)
        {
            var plot = new Plot2DValue();

            plot.AddPoints(m);
            plot.IsLogX = true;
            return(plot);
        }
예제 #6
0
        public Plot2DValue Function(MatrixValue m, MatrixValue n, ArgumentsValue l)
        {
            var plot = new Plot2DValue();
            var values = new MatrixValue[l.Length];

            for (var i = 0; i != l.Length; i++)
            {
                if (l.Values[i] is MatrixValue)
                {
                    values[i] = (MatrixValue)l.Values[i];
                }
                else
                {
                    throw new YAMPOperationInvalidException("plot", l.Values[i]);
                }
            }

            plot.AddPoints(m, n, values);
            return plot;
        }
예제 #7
0
        public Plot2DValue Function(MatrixValue m, MatrixValue n, ArgumentsValue l)
        {
            var plot   = new Plot2DValue();
            var values = new MatrixValue[l.Length];

            for (var i = 0; i != l.Length; i++)
            {
                if (l.Values[i] is MatrixValue)
                {
                    values[i] = (MatrixValue)l.Values[i];
                }
                else
                {
                    throw new YAMPOperationInvalidException("plot", l.Values[i]);
                }
            }

            plot.AddPoints(m, n, values);
            return(plot);
        }
예제 #8
0
 public Plot2DValue Function(MatrixValue m, MatrixValue n)
 {
     var plot = new Plot2DValue();
     plot.AddPoints(m, n);
     return plot;
 }
예제 #9
0
        /// <summary>
        /// Converts a set of bytes to a new instance.
        /// </summary>
        /// <param name="content">The binary representation.</param>
        /// <returns>The new instance.</returns>
        public override Value Deserialize(byte[] content)
        {
            var p2 = new Plot2DValue();

            using (var ds = Deserializer.Create(content))
            {
                p2.Deserialize(ds);
                p2.IsLogX = ds.GetBoolean();
                p2.IsLogY = ds.GetBoolean();
                var length = ds.GetInt();

                for (var i = 0; i < length; i++)
                {
                    var points = new Points<PointPair>();
                    points.Deserialize(ds);
                    var count = ds.GetInt();

                    for (int j = 0; j < count; j++)
                    {
                        var x = ds.GetDouble();
                        var y = ds.GetDouble();

                        points.Add(new PointPair
                        {
                            X = x,
                            Y = y
                        });
                    }

                    p2.AddSeries(points);
                }
            }

            return p2;
        }