static long TestNTimes(MatrixMultiplier multiplier, Matrix a, Matrix b, int repeats) { long ticks = 0; for (int i = 0; i < repeats; i++) { multiplier.Multiply(a, b); ticks += multiplier.Ticks; } return(ticks / repeats); }
static void TestSimpleMethod() { Matrix first = new Matrix(2, 2); Matrix second = new Matrix(2, 2); Matrix correctResult = new Matrix(2, 2); correctResult[0, 0] = 1; correctResult[0, 1] = 0; correctResult[1, 0] = 9; correctResult[1, 1] = 4; first[0, 0] = 0; first[0, 1] = 1; first[1, 0] = 2; first[1, 1] = 3; second[0, 0] = 3; second[0, 1] = 2; second[1, 0] = 1; second[1, 1] = 0; Console.WriteLine("First matrix: "); Console.WriteLine(first.ToString()); Console.WriteLine("\nSecond matrix: "); Console.WriteLine(second.ToString()); MatrixMultiplier multiplier = MatrixMultiplier.GetMatrixMultiplier(MultiplicationMethod.Simple); if (multiplier != null) { Matrix result = multiplier.Multiply(first, second); Console.WriteLine("Result: "); Console.WriteLine(result); Console.WriteLine(correctResult.Equals(result) ? "CORRECT" : "WRONG RESULT!"); } Console.WriteLine(); }