public void Multiply() { double[,] expected = MakeResult(size, size, 750); FastMatrix one = MakeMatrix(size, size, 15); FastMatrix two = MakeMatrix(size, size, 10); FastMatrix actual = gpu.Multiply(one, two); VerifyResults(actual, expected); }
public static void FillMatrix(FastMatrix matrix, double value) { for (int i = 0, n = matrix.GetSize(0); i < n; i++) { for (int j = 0, m = matrix.GetSize(1); j < m; j++) { matrix[i, j] = value; } } }
protected void VerifyResults(FastMatrix matrix, double[,] expected) { Assert.Equal(matrix.GetSize(0), expected.GetLength(0)); Assert.Equal(matrix.GetSize(1), expected.GetLength(1)); for (int i = 0; i < matrix.GetSize(0); i++) { for (int j = 0; j < matrix.GetSize(1); j++) { Assert.Equal(expected[i, j], matrix[i, j]); } } }
public void Transpose() { double[,] expected = MakeResult(size, size, 10); FastMatrix one = MakeMatrix(size, size, 10); one[size - 1, 0] = 5; expected[0, size - 1] = 5; FastMatrix actual = gpu.Transpose(one); VerifyResults(actual, expected); }
static void Transpose() { GPUOperator op = new GPUOperator(); //5*3 matrix FastMatrix one = new FastMatrix(5, 3); Utilities.FillMatrix(one, 5); //10 will start at the bottom left and go to the top right one[0, one.GetSize(0) - 1] = 10; FastMatrix result = op.Transpose(one); }
static void Transpose() { //process is same for parallel SingleThreadedOperator <IntWrapper> op = new SingleThreadedOperator <IntWrapper>(); //5*3 matrix FastMatrix <IntWrapper> one = new FastMatrix <IntWrapper>(5, 3); Utilities.FillMatrix(one, 5); //10 will start at the bottom left and go to the top right one[0, one.Rows - 1] = 10; FastMatrix <IntWrapper> result = op.Transpose(one); Console.WriteLine(result); }