コード例 #1
0
        static void TestPoprawnosci()
        {
            //Test mnożenia macierzy
            MyType[][] arrA = new MyType[3][];
            arrA[0] = new MyType[] { new MyType(1, 1), new MyType(-3, 1), new MyType(4, 1) };
            arrA[1] = new MyType[] { new MyType(16, 1), new MyType(6, 1), new MyType(7, 1) };
            arrA[2] = new MyType[] { new MyType(-5, 1), new MyType(10, 1), new MyType(4, 1) };
            MyMatrix <MyType> A = new MyMatrix <MyType>(arrA);

            MyType[][] arrX = new MyType[3][];
            arrX[0] = new MyType[] { new MyType(5, 1) };
            arrX[1] = new MyType[] { new MyType(2, 1) };
            arrX[2] = new MyType[] { new MyType(6, 1) };
            MyMatrix <MyType> X = new MyMatrix <MyType>(arrX);

            MyMatrix <MyType> B = A * X;

            Console.WriteLine("Wynik A * X");
            B.ShowVector();

            MyMatrix <MyType> AB = A.Connect(B);

            AB.PerformGaussianElimination(Choice.NONE);
            AB.PerformBackwardsOperation();

            Console.WriteLine("\nWynik A|B");
            AB.ShowVector();
        }
コード例 #2
0
        public static void Run(MyMatrix <T> A, MyMatrix <T> X, Choice choice)
        {
            MyMatrix <T> B  = A * X;
            MyMatrix <T> AB = A.Connect(B);

            // Przeprowadzenie Gaussa
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            AB.PerformGaussianElimination(choice);
            stopWatch.Stop();

            AB.PerformBackwardsOperation();

            // Wyciąganie wektorów

            T[][] results = new T[2][];
            results[0] = X.ExtractLastColumn();
            results[1] = AB.ExtractLastColumn();

            T[] errors = new T[results[0].Length];
            for (int index = 0; index < results[0].Length; index++)
            {
                dynamic temp = results[0][index];
                temp          = temp - results[1][index];
                errors[index] = MyMath.ABS(temp);
            }

            WriteStatistics(choice, A.Data.Length, errors, stopWatch);
        }