Exemple #1
0
        public static void getSingle(IApplicationBuilder app)
        {
            app.Run(async context =>
            {
                try
                {
                    var input              = SingleXInput.getFromRequest(context);
                    var lagrange           = new LagrangeMethod();
                    var differentialValues = DiffirentialEquationSolver.lastValues;
                    double[] resx          = new double[differentialValues.Count];
                    double[] resy          = new double[differentialValues.Count];
                    for (int i = 0; i < differentialValues.Count; i++)
                    {
                        resx[i] = differentialValues[i].X;
                        resy[i] = differentialValues[i].Y;
                    }
                    var result = lagrange.getY(resx, resy, input.X);

                    await context.Response.WriteAsync(result.ToString());
                }
                catch (Exception ex)
                {
                    await context.Response.WriteAsync(ex.Message);
                }
            });
        }
Exemple #2
0
        private double[] CalculateYByInterpolation(double[] xData, double[] yData, int interpolatedSize, double[] newXData)
        {
            var newYData = new double[interpolatedSize];

            for (var i = 0; i < interpolatedSize; i++)
            {
                newYData[i] = _lagrange.getY(xData, yData, newXData[i], step);
            }

            return(newYData);
        }