//Testing simple operations on matrices :) private static void TestGauss() { Fraction[,] numbersA = { { new Fraction(1, 1), new Fraction(1, 1), new Fraction(1, 1) }, { new Fraction(2, 1), new Fraction(-3, 1), new Fraction(4, 1) }, { new Fraction(3, 1), new Fraction(4, 1), new Fraction(5, 1) } }; Fraction[,] numbersX = { { new Fraction(1, 1) }, { new Fraction(3, 1) }, { new Fraction(5, 1) } }; const int testSize = 3; GaussMath <Fraction> testMatrixA = new GaussMath <Fraction>(testSize); testMatrixA.Fill(numbersA); Console.WriteLine(testMatrixA); const int testColumnCount = 1; GaussMath <Fraction> testVectorX = new GaussMath <Fraction>(testSize, testColumnCount); testVectorX.Fill(numbersX); Console.WriteLine(testVectorX); GaussMath <Fraction> testVectorB = testMatrixA * testVectorX; Console.WriteLine("Multiplied matrix:\n" + testVectorB); GaussMath <Fraction> testMatrixAB = GaussMath <Fraction> .Concatenate(testMatrixA, testVectorB); Console.WriteLine(testMatrixAB); testMatrixAB.EliminateGaussian(Choice.Full); testMatrixAB.BackwardsOperation(); Console.WriteLine("\nEliminated matrix:\n" + testMatrixAB); testMatrixAB.ShowVector(); }
public void Execute(Choice choice, GaussMath <T> AB, GaussMath <T> X) { GaussMath <T> Matrix = AB; Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); Matrix.EliminateGaussian(choice); Matrix.BackwardsOperation(); stopwatch.Stop(); File.WriteAllText( $@"C:\Programy\Algorytmy Numeryczne\Gauss\Matrices\Results\{typeof(T)}_{choice}_{Matrix.RowCount}x{Matrix.RowCount}.txt", "\n" + stopwatch.Elapsed + "\n" + X.Difference(Matrix) ); Console.WriteLine($"Finished executing test [{typeof(T)} | {choice}] " + $"Time: {stopwatch.Elapsed}\n" + $"Diff: \n{X.Difference(Matrix)}"); }