public void RunFloat(GaussType gausstype, int[,] matrix, int[] vector) { var floatMatrix = new MyMatrix <float>(_dimensions); for (int y = 0; y < _dimensions; y++) { floatMatrix.SetVectorB(y, 0); floatMatrix.SetVectorX(y, ((float)vector[y] / _maxValue)); for (int x = 0; x < _dimensions; x++) { floatMatrix.SetMatrixA(x, y, ((float)matrix[y, x] / _maxValue)); } } floatMatrix.Multiplication(); var sw = new Stopwatch(); switch (gausstype) { case GaussType.Basic: sw.Start(); floatMatrix.CalculateG(); sw.Stop(); _time[0] = sw.Elapsed.TotalMilliseconds; _diff[0] = floatMatrix.CalculateDiff(); break; case GaussType.Part: sw.Start(); floatMatrix.CalculateGP(); sw.Stop(); _time[1] = sw.Elapsed.TotalMilliseconds; _diff[1] = floatMatrix.CalculateDiff(); break; case GaussType.Full: sw.Start(); floatMatrix.CalculateGF(); sw.Stop(); _time[2] = sw.Elapsed.TotalMilliseconds; _diff[2] = floatMatrix.CalculateDiff(); break; } sw.Stop(); }
public void RunFraction(GaussType gausstype, int[,] matrix, int[] vector) { var fractionMatrix = new MyMatrix <Fraction>(_dimensions); for (int y = 0; y < _dimensions; y++) { fractionMatrix.SetVectorB(y, 0); fractionMatrix.SetVectorX(y, new Fraction(vector[y], _maxValue)); for (int x = 0; x < _dimensions; x++) { fractionMatrix.SetMatrixA(x, y, new Fraction(matrix[y, x], _maxValue)); } } fractionMatrix.Multiplication(); var sw = new Stopwatch(); switch (gausstype) { case GaussType.Basic: sw.Start(); fractionMatrix.CalculateG(); sw.Stop(); _time[6] = sw.Elapsed.TotalMilliseconds; _diff[6] = fractionMatrix.CalculateDiff(); break; case GaussType.Part: sw.Start(); fractionMatrix.CalculateGP(); sw.Stop(); _time[7] = sw.Elapsed.TotalMilliseconds; _diff[7] = fractionMatrix.CalculateDiff(); break; case GaussType.Full: sw.Start(); fractionMatrix.CalculateGF(); sw.Stop(); _time[8] = sw.Elapsed.TotalMilliseconds; _diff[8] = fractionMatrix.CalculateDiff(); break; } }
public void RunDouble(GaussType gausstype, int[,] matrix, int[] vector) { var doubleMatrix = new MyMatrix <double>(_dimensions); for (int y = 0; y < _dimensions; y++) { doubleMatrix.SetVectorB(y, 0); doubleMatrix.SetVectorX(y, ((double)vector[y] / _maxValue)); for (int x = 0; x < _dimensions; x++) { doubleMatrix.SetMatrixA(x, y, ((double)matrix[y, x] / _maxValue)); } } doubleMatrix.Multiplication(); var sw = new Stopwatch(); switch (gausstype) { case GaussType.Basic: sw.Start(); doubleMatrix.CalculateG(); sw.Stop(); _time[3] = sw.Elapsed.TotalMilliseconds; _diff[3] = doubleMatrix.CalculateDiff(); break; case GaussType.Part: sw.Start(); doubleMatrix.CalculateGP(); sw.Stop(); _time[4] = sw.Elapsed.TotalMilliseconds; _diff[4] = doubleMatrix.CalculateDiff(); break; case GaussType.Full: sw.Start(); doubleMatrix.CalculateGF(); sw.Stop(); _time[5] = sw.Elapsed.TotalMilliseconds; _diff[5] = doubleMatrix.CalculateDiff(); break; } }