Ejemplo n.º 1
0
        static void Test_SLAE_home()
        {
            string file = "LW_2_3_3_Ab_v02.txt"; int Variant = 2;

            SW.WriteLine($"\r\n HOME WORK  \r\n {file} Variant = {Variant}");

            Matrix.Read(file, out Matrix A, out Vector b, out int n);
            SW.Write(Matrix.Print(A, b, true, 2, 3, "Matrix Ab"));

            Matrix V = Matrix.Inversion_1(A, out double err);

            SW.Write("\r\n Inversion_1 : ");
            SW.Write(Matrix.Print(V, true, 2, 7, "Matrix V"));
            SW.WriteLine($"\r\n Determinant|A| = {A.Det,12:F2}" +
                         $"     Error  = {err,10:E1}");

            Vector X = Vector.Multiply(V, b); //Розв'язування СЛАР

            SW.Write("\r\n Solving SLAE with Inversion_1 Matrix :");
            SW.Write(Vector.Print(X, PT.Vertical, true, 2, 10, "Vector X"));

            double error = MAC_Algebra.Error_of_SLAE(A, X, b);

            SW.WriteLine($"\r\n Error_of_SLAE = {error,10:E1}");
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            StreamWriter SW = new StreamWriter("Results_CT_2_2.txt");
            string       file = "CT_2_2_Ab_v00.txt"; int Variant = 0;

            SW.WriteLine($"\r\n {file} Variant = {Variant}");

            Matrix.Read(file, out Matrix A, out Vector b, out int n);
            SW.Write(Matrix.Print(A, b, true, 2, 3, "Matrix Ab"));

            Vector X = MAC_Algebra.Method_Simple_Iteration(A, b, 1.0E-5, out int K);

            SW.Write("\r\n Solving SLAE with Method_Simple_Iteration :");
            SW.Write(Vector.Print(X, PT.Vertical, true, 3, 10, "Vector X"));

            double error = MAC_Algebra.Error_of_SLAE(A, X, b);

            SW.WriteLine($"\r\n Error = {error,10:E1} iterations = {K}");

            X = MAC_Algebra.Method_Simple_Iteration(A, b, 1.0E-10, out K);

            SW.Write(Vector.Print(X, PT.Vertical, true, 3, 10, "Vector X"));

            error = MAC_Algebra.Error_of_SLAE(A, X, b);
            SW.WriteLine($"\r\n Error = {error,10:E1} iterations = {K}");

            // HOMEWORK
            file = "CT_2_2_Ab_3_v02.txt"; Variant = 2;
            SW.WriteLine($"\r\n HOME WORK \r\n {file} Variant = {Variant}");

            Matrix.Read(file, out A, out b, out n);
            SW.Write(Matrix.Print(A, b, true, 2, 3, "Matrix Ab"));

            X = MAC_Algebra.Method_Simple_Iteration(A, b, 1.0E-5, out K);

            SW.Write("\r\n Solving SLAE with Method_Simple_Iteration :");
            SW.Write(Vector.Print(X, PT.Vertical, true, 3, 10, "Vector X"));

            error = MAC_Algebra.Error_of_SLAE(A, X, b);
            SW.WriteLine($"\r\n Error = {error,10:E1} iterations = {K}");

            X = MAC_Algebra.Method_Simple_Iteration(A, b, 1.0E-10, out K);

            SW.Write(Vector.Print(X, PT.Vertical, true, 3, 10, "Vector X"));

            error = MAC_Algebra.Error_of_SLAE(A, X, b);
            SW.WriteLine($"\r\n Error = {error,10:E1} iterations = {K}");
            SW.Close();
        }
Ejemplo n.º 3
0
        static void Test_MJG()
        {
            Matrix.Read("test_LW_2_1_A.txt", out Matrix A, out int n);
            SW.Write(Matrix.Print(A, true, 3, 2, "Matrix A"));

            Vector.Read("test_LW_2_1_b.txt", out Vector b, out n);
            SW.Write(Vector.Print(b, PT.Vertical, true, 3, 2, "Vector b"));

            Vector X = MAC_Algebra.Method_Jordana_Gaussa(A, b);

            SW.Write(Vector.Print(X, PT.Vertical, true, 3, 2, "Vector X"));
            SW.WriteLine($"\r\n Determinant|A| = {A.Det,7:F1}");

            SW.Write(Matrix.Print(A, true, 3, 2, "Matrix A"));
            SW.Write(Vector.Print(b, PT.Horizontal, true, 3, 2, "Vector b"));
            SW.Close();
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            StreamWriter SW = new StreamWriter("Results_CT_2_3.txt");

            string file = "CT_2_3_Ab_v00.txt"; int Variant = 0;

            SW.WriteLine($"\r\n {file} Variant = {Variant}");

            Matrix.Read(file, out Matrix A, out Vector b, out int n);
            SW.Write(Matrix.Print(A, b, true, 2, 1, "Matrix Ab"));

            Vector X = MAC_Algebra.Method_Kramera(A, b, out Vector Dk);

            SW.Write(Vector.Print(Dk, PT.Vertical, true, 2, 2, "Vector Dk"));

            SW.Write("\r\n Solving SLAE with Method Kramera :");
            SW.Write(Vector.Print(X, PT.Horizontal, true, 2, 2, "Vector X"));


            double error = MAC_Algebra.Error_of_SLAE(A, X, b);

            SW.WriteLine($"\r\n Determinant|A| = {A.Det,12:F2}" +
                         $"     Error = {error,10:E1}");

            //HOMEWORK
            file = "CT_2_3_3_Ab_v02.txt"; Variant = 2;
            SW.WriteLine($"\r\n HOME WORK \r\n {file} Variant = {Variant}");

            Matrix.Read(file, out A, out b, out n);
            SW.Write(Matrix.Print(A, b, true, 2, 1, "Matrix Ab"));

            X = MAC_Algebra.Method_Kramera(A, b, out Dk);
            SW.Write(Vector.Print(Dk, PT.Vertical, true, 2, 2, "Vector Dk"));

            SW.Write("\r\n Solving SLAE with Method Kramera :");
            SW.Write(Vector.Print(X, PT.Horizontal, true, 2, 2, "Vector X"));


            error = MAC_Algebra.Error_of_SLAE(A, X, b);
            SW.WriteLine($"\r\n Determinant|A| = {A.Det,12:F2}" +
                         $"     Error = {error,10:E1}");


            SW.Close();
        }
Ejemplo n.º 5
0
        static void Home_LW_2_1()
        {
            Matrix.Read("LW_2_1_Ab_v02.txt", out Matrix A, out Vector b, out int n);
            SW.WriteLine($"LW_2_1_Ab_v02.txt  Variant - 2 Ochinskiy Nikita");

            SW.Write(Matrix.Print(A, b, true, 3, 2, "Matrix Ab"));

            Vector X = MAC_Algebra.Method_Jordana_Gaussa(A, b);

            SW.Write("\r\n Solving SLAE with Method Jordana-Gaussa :");
            SW.Write(Vector.Print(X, PT.Vertical, true, 3, 2, "Vector X"));
            SW.WriteLine($"\r\n Determinant|A| = {A.Det,7:F1}");

            double error = MAC_Algebra.Error_of_SLAE(A, X, b);

            SW.WriteLine($"\r\n error = {error,10:E1}");
            SW.Close();
        }
Ejemplo n.º 6
0
        static void Test_LW_2_1()
        {
            Matrix.Read("LW_2_1_A_v00.txt", out Matrix A, out int n);
            SW.Write(Matrix.Print(A, true, 3, 2, "Matrix A"));

            Vector.Read("LW_2_1_b_v00.txt", out Vector b, out n);
            SW.Write(Vector.Print(b, PT.Horizontal, true, 3, 2, "Vector b"));

            Vector X = MAC_Algebra.Method_Jordana_Gaussa(A, b);

            SW.Write("\r\n Solving SLAE with Method Jordana-Gaussa :");
            SW.Write(Vector.Print(X, PT.Vertical, true, 3, 2, "Vector X"));
            SW.WriteLine($"\r\n Determinant|A| = {A.Det,7:F1}");

            double error = MAC_Algebra.Error_of_SLAE(A, X, b);

            SW.WriteLine($"\r\n error = {error,10:E1}");
            SW.Close();
        }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            StreamWriter SW = new StreamWriter("Results_CT_2_1.txt");

            SW.WriteLine($"CT_2_1_Ab_3_v12.txt   Variant - 12 Ochinskiy Nikita");

            Matrix.Read("CT_2_1_Ab_3_v12.txt", out Matrix A, out Vector b, out int n);
            SW.Write(Matrix.Print(A, b, true, 3, 2, "Matrix Ab"));

            Vector X = MAC_Algebra.Method_Gaussa(A, b);

            SW.Write("\r\n Solving SLAE with Method Gaussa :");
            SW.Write(Vector.Print(X, PT.Horizontal, true, 3, 2, "Vector X"));
            SW.WriteLine($"\r\n Determinant|A| = {A.Det,7:F1}");

            double error = MAC_Algebra.Error_of_SLAE(A, X, b);

            SW.WriteLine($"\r\n error = {error,10:E1}");
            SW.Close();
        }
Ejemplo n.º 8
0
        static void Main(string[] args)
        {
            StreamWriter SW = new StreamWriter("Results_LW_2_2.txt");

            string file = "LW_2_2_Ab_v00.txt"; int Variant = 0;

            SW.WriteLine($"\r\n {file} Variant = {Variant}");

            Matrix.Read(file, out Matrix A, out Vector b, out int n);
            SW.Write(Matrix.Print(A, b, true, 3, 3, "Matrix Ab"));

            Vector X = MAC_Algebra.Method_Zeidela(A, b, 1.0E-8, out int K);

            SW.Write("\r\n Solving SLAE with Method_Zeidela :");
            SW.Write(Vector.Print(X, PT.Horizontal, true, 3, 7, "Vector X"));

            double error = MAC_Algebra.Error_of_SLAE(A, X, b);

            SW.WriteLine($"\r\n Error = {error,10:E1} iterations = {K}");

            //HOMEWORK
            string file_h = "LW_2_2_Ab_3_v02.txt"; int Variant_h = 2;

            SW.WriteLine($"\r\n HOME_WORK Ochinskiy \r\n {file_h} Variant = {Variant_h}");

            Matrix.Read(file_h, out Matrix A_h, out Vector b_h, out int n_h);
            SW.Write(Matrix.Print(A_h, b_h, true, 3, 3, "Matrix Ab"));

            Vector X_h = MAC_Algebra.Method_Zeidela(A_h, b_h, 1.0E-8, out int K_h);

            SW.Write("\r\n Solving SLAE with Method_Zeidela :");
            SW.Write(Vector.Print(X_h, PT.Horizontal, true, 3, 7, "Vector X"));

            double error_h = MAC_Algebra.Error_of_SLAE(A_h, X_h, b_h);

            SW.WriteLine($"\r\n Error = {error_h,10:E1} iterations = {K_h}");

            SW.Close();
        }