public void GaussPartialPivotTimeTest(int numberOfAgents, int count) { MatrixGenerator mg = new MatrixGenerator(numberOfAgents); MyMatrix <double> macierz = new MyMatrix <double>(mg.size, mg.size); MyMatrix <double> macierzKopia = new MyMatrix <double>(mg.size, mg.size); double[] wektor = new double[mg.size]; double[] wektorKopia = new double[mg.size]; //przygotowanie macierzy i wektorów macierz = mg.GenerateMatrix(); macierzKopia = mg.GenerateMatrix(); wektor = GenerateVector(mg.size); wektorKopia = GenerateVector(mg.size); //liczenie czasu double[] czasy = new double[count]; double suma = 0.0; double srednia = 0.0; for (int i = 0; i < count; i++) { var watchDouble = Stopwatch.StartNew(); macierz.GaussPartialPivot(wektor); watchDouble.Stop(); var elapsedMsDouble = watchDouble.ElapsedMilliseconds; czasy[i] = elapsedMsDouble; for (var j = 0; j < macierz.Rows(); j++) { for (var k = 0; k < macierz.Columns(); k++) { macierz[j, k] = macierzKopia[j, k]; wektor[j] = wektorKopia[j]; } } suma += czasy[i]; } srednia = suma / count; StreamWriter writer = new StreamWriter("CzasGaussPartialPivot.csv", append: true); if (writer != null) { writer.WriteLine(srednia); } writer.Close(); Console.WriteLine("Średni czas GaussPartialPivot" + ": " + srednia + "ms"); }
public void GenerateMatrixTimeTest(int numberOfAgents, int count) { MatrixGenerator mg = new MatrixGenerator(numberOfAgents); MyMatrix <double> macierz = new MyMatrix <double>(mg.size, mg.size); double[] czasy = new double[count]; double suma = 0.0; double srednia = 0.0; for (var i = 0; i < count; i++) { var watchDouble = Stopwatch.StartNew(); macierz = mg.GenerateMatrix(); watchDouble.Stop(); var elapsedMsDouble = watchDouble.ElapsedMilliseconds; czasy[i] = elapsedMsDouble; suma += czasy[i]; } srednia = suma / count; StreamWriter writer = new StreamWriter("CzasGenerowaniaMacierzy.csv", append: true); if (writer != null) { writer.WriteLine(srednia); } writer.Close(); Console.WriteLine("Średni czas generowania macierzy" + ": " + srednia + "ms"); }
public void SeidelTimeTest(int numberOfAgents, int count, double accuracy) { MatrixGenerator mg = new MatrixGenerator(numberOfAgents); MyMatrix <double> macierz = new MyMatrix <double>(mg.size, mg.size); double[] wektor = new double[mg.size]; //przygotowanie macierzy i wektorów macierz = mg.GenerateMatrix(); wektor = GenerateVector(mg.size); //liczenie czasu double[] czasy = new double[count]; double suma = 0.0; double srednia = 0.0; for (int i = 0; i < count; i++) { var watchDouble = Stopwatch.StartNew(); macierz.SeidelAccuracy(wektor, accuracy); watchDouble.Stop(); var elapsedMsDouble = watchDouble.ElapsedMilliseconds; czasy[i] = elapsedMsDouble; suma += czasy[i]; wektor = GenerateVector(mg.size); } srednia = suma / count; string name = "CzasSeidel" + accuracy + ".csv"; StreamWriter writer = new StreamWriter(name, append: true); if (writer != null) { writer.WriteLine(srednia); } writer.Close(); Console.WriteLine("Średni czas Seidel " + accuracy + ": " + srednia + "ms"); }