using System;

namespace _08_Interpolacja
{
    public class Generator
    {
        Random rnd = new Random();

        public void Losuj_1(int n, out double[] x, out double[] y)
        {
            x = new double[n];
            y = new double[n];
            for (int i = 0; i < n; i++)
            {
                x[i] = rnd.NextDouble() * 10 - 5;
                y[i] = 0.12 * x[i] * x[i] - 0.3 * x[i] + 12
                    + (rnd.NextDouble() * 5 - 2.5);
            }
        }

        public double[][] PolyM(double a, double b,
                                int stopien, int licznosc)
        {
            double[] p = new double[stopien];
            for (int i = 0; i < stopien; i++)
                p[i] = (b - a) * rnd.NextDouble() + a;
            double[][] W = new double[2][];
            W[0] = new double[licznosc]; // x
            W[1] = new double[licznosc]; // y
            for (int i = 0; i < licznosc; i++)
            {
                W[0][i] = (b - a) * rnd.NextDouble() + a;
                W[1][i] = 1;
                for (int k = 0; k < stopien; k++)
                    W[1][i] *= (W[0][i] - p[k]);
            }
            return W;
        }

    }
}
