Beispiel #1
0
 void init(FunApr <double>[] funApr)
 {
     for (int j = 0; j < funApr.Length; j++)
     {
         funApr[j] = new FunApr <double>();
     }
 }
Beispiel #2
0
        public Fixer()
        {
            string       path = @"f:\Informatyka\trasaZjednymWzniesieniem.txt";
            StreamReader sr   = new StreamReader(path);

            funAprMain = new FunApr <double> [512];
            init(funAprMain);

            try
            {
                string ourStr;
                int    i = 0;
                while ((ourStr = sr.ReadLine()) != null) /*Dystans(m),Wysokość(m)*/
                {
                    string[] disHeight = ourStr.Split(' ');
                    funAprMain[i].Distance = Double.Parse(disHeight[0]);
                    funAprMain[i].Height   = Double.Parse(disHeight[1]);
                    i++;
                }
                sr.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Could not read the file");
            }

            matrix = new Matrix <double>(512 / amountOfSmaller + 1);
            FunApr <double>[] funAprSmaller = new FunApr <double> [512 / amountOfSmaller + 1];
            init(funAprSmaller);
            dividePoints(funAprSmaller);

            cubicSpline = new CubicSpline <double>(512 / amountOfSmaller + 1);
            matrix.gauss(funAprSmaller, cubicSpline.Spline, cubicSpline.Fun, cubicSpline.H);

            FunApr <double>[] funApr = new FunApr <double> [512];
            init(funApr); // tutaj bedziemy mieli nowe wyniki

            laGrangeMethod(funApr, funAprSmaller);
            string       path2 = @"f:\Informatyka\LagrangeCo128wezelTrasaZjednymWzniesieniem.txt";
            StreamWriter sw    = new StreamWriter(path2);

            for (int j = 0; j < funApr.Length; j++)
            {
                double wartosc = (Math.Abs(funAprMain[j].Height - funApr[j].Height)) / funAprMain[j].Height;
                sw.WriteLine(wartosc.ToString());
            }
            sw.Close();

            for (int j = 0; j < funApr.Length; j++)
            {
                Console.WriteLine("{0}     {1}", funApr[j].Distance, funApr[j].Height);
            }

            Console.Read();
        }