public void MatrixMultication_Smoke_Test() { var N = 2; int[,] A = new int[N, N], B = new int[N, N]; A[0, 0] = 1; A[0, 1] = 2; A[1, 0] = 1; A[1, 1] = 4; B[0, 0] = 2; B[0, 1] = 0; B[1, 0] = 1; B[1, 1] = 2; var result = MatrixMultiplication.Multiply(A, B); Assert.AreEqual(4, result[0, 0]); Assert.AreEqual(4, result[0, 1]); Assert.AreEqual(6, result[1, 0]); Assert.AreEqual(8, result[1, 1]); }
public async Task <List <MatrixMultiplication> > RunTask(InputParametrs input) { Data data = new Data(input.m, input.n, input.l); Stopwatch stopwatch = new Stopwatch(); for (int i = 0; i < 5; i++) { stopwatch.Start(); MatrixMultiplication matrixMultiplication = new MatrixMultiplication(data); matrixMultiplication.Multiply(); matrices.Add(matrixMultiplication); stopwatch.Stop(); matrixMultiplication.elapsedMs = stopwatch.ElapsedMilliseconds; Console.WriteLine(stopwatch.ElapsedMilliseconds); stopwatch.Reset(); data.m += input.mStep; data = new Data(data.m, data.n, data.l); } Console.WriteLine("-----------------------------"); for (int i = 0; i <= 5; i++) { stopwatch.Start(); MatrixMultiplication matrixMultiplication = new MatrixMultiplication(data); matrixMultiplication.Multiply(); matrices.Add(matrixMultiplication); stopwatch.Stop(); matrixMultiplication.elapsedMs = stopwatch.ElapsedMilliseconds; Console.WriteLine(stopwatch.ElapsedMilliseconds); stopwatch.Reset(); data.l += input.lStep; data = new Data(data.m, data.n, data.l); } //For matlab linear canvas Debug.Write("time = ["); foreach (var m in matrices) { Debug.Write(" " + m.elapsedMs); } Debug.Write(" ];"); Debug.WriteLine(" "); Debug.Write("m = [" + input.m); for (int i = 0; i < matrices.Count - 1; i++) { if (i < 5) { Debug.Write(" " + (input.m += input.mStep)); } else { Debug.Write(" " + (input.m)); } } Debug.Write(" ];"); Debug.WriteLine(" "); Debug.Write("n = ["); for (int i = 0; i < matrices.Count; i++) { Debug.Write(" " + input.n); } Debug.Write(" ];"); Debug.WriteLine(" "); return(matrices); }