public void MatrixAddMatrixMulVectorTest(int testCount) { // --------------------------------------------------------- // fraction // --------------------------------------------------------- _time = new TimeSpan(); var frResult = new Fraction[0]; for (var i = 0; i < testCount; i++) { var frA = new MyMatrix <Fraction>(SfrA); var frB = new MyMatrix <Fraction>(SfrB); var frC = new MyMatrix <Fraction>(SfrC); var frX = SfrX; _stopwatch.Reset(); _stopwatch.Start(); frResult = (frA + frB + frC) * frX; _stopwatch.Stop(); _time += _stopwatch.Elapsed; } _handler.WriteToFileWithTimespan( IO.PrefixFraction + IO.ResultAbcx, MyMatrixFormatter.GetFormattedVector(frResult), CurrentMatrixSize, _time.TotalMilliseconds / testCount); // --------------------------------------------------------- // float // --------------------------------------------------------- _time = new TimeSpan(); var fResult = new float[0]; for (var i = 0; i < testCount; i++) { var fA = new MyMatrix <float>(SfA); var fB = new MyMatrix <float>(SfB); var fC = new MyMatrix <float>(SfC); var fX = SfX; _stopwatch.Reset(); _stopwatch.Start(); fResult = (fA + fB + fC) * fX; _stopwatch.Stop(); _time += _stopwatch.Elapsed; } _handler.WriteToFileWithTimespan( IO.PrefixFloat + IO.ResultAbcx, MyMatrixFormatter.GetFormattedVector(fResult), CurrentMatrixSize, _time.TotalMilliseconds / testCount); // --------------------------------------------------------- // double // --------------------------------------------------------- _time = new TimeSpan(); var dResult = new double[0]; for (var i = 0; i < testCount; i++) { var dA = new MyMatrix <double>(SdA); var dB = new MyMatrix <double>(SdB); var dC = new MyMatrix <double>(SdC); var dX = SdX; _stopwatch.Reset(); _stopwatch.Start(); dResult = (dA + dB + dC) * dX; _stopwatch.Stop(); _time += _stopwatch.Elapsed; } _handler.WriteToFileWithTimespan( IO.PrefixDouble + IO.ResultAbcx, MyMatrixFormatter.GetFormattedVector(dResult), CurrentMatrixSize, _time.TotalMilliseconds / testCount); }
public void WriteVectorToFile <T>(T[] vector, string fileName) where T : new() { var formattedMatrix = MyMatrixFormatter.GetFormattedVector(vector); WriteToFile(fileName, formattedMatrix, vector.Length); }
public void MatrixGaussianReductionFullPivotTest(int testCount) { // --------------------------------------------------------- // fraction // --------------------------------------------------------- _time = new TimeSpan(); var frX = SfrX; for (var i = 0; i < testCount; i++) { var frA = new MyMatrix <Fraction>(SfrA); frX = SfrX; _stopwatch.Reset(); _stopwatch.Start(); frA.GaussianReductionFullPivot(frX); _stopwatch.Stop(); _time += _stopwatch.Elapsed; } _handler.WriteToFileWithTimespan( IO.PrefixFraction + IO.ResultFullPivot, MyMatrixFormatter.GetFormattedVector(frX), CurrentMatrixSize, _time.TotalMilliseconds / testCount); // --------------------------------------------------------- // float // --------------------------------------------------------- _time = new TimeSpan(); var fX = SfX; for (var i = 0; i < testCount; i++) { var fA = new MyMatrix <float>(SfA); fX = SfX; _stopwatch.Reset(); _stopwatch.Start(); fA.GaussianReductionFullPivot(fX); _stopwatch.Stop(); _time += _stopwatch.Elapsed; } _handler.WriteToFileWithTimespan( IO.PrefixFloat + IO.ResultFullPivot, MyMatrixFormatter.GetFormattedVector(fX), CurrentMatrixSize, _time.TotalMilliseconds / testCount); // --------------------------------------------------------- // double // --------------------------------------------------------- _time = new TimeSpan(); var dX = SdX; for (var i = 0; i < testCount; i++) { var dA = new MyMatrix <double>(SdA); dX = SdX; _stopwatch.Reset(); _stopwatch.Start(); dA.GaussianReductionFullPivot(dX); _stopwatch.Stop(); _time += _stopwatch.Elapsed; } _handler.WriteToFileWithTimespan( IO.PrefixDouble + IO.ResultFullPivot, MyMatrixFormatter.GetFormattedVector(dX), CurrentMatrixSize, _time.TotalMilliseconds / testCount); }