Ultra Geile Studenten Benutzer Oberfläche (UGSBO)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.7 KiB

  1. package com.ugsbo.matrixcalc;
  2. import static org.junit.Assert.assertArrayEquals;
  3. import org.junit.Test;
  4. /**
  5. * Tests the funktionality to Transpose a Matix
  6. */
  7. public class MatrixTransposeTest {
  8. @Test
  9. public void TransformQuadraticMatrixAResultsInQuadraticMatrixC() {
  10. MatrixCalcMath math = new MatrixCalcMath();
  11. // A(2,2) => C(2,2)
  12. double[][] matrixA = { { 1.0, 2.0 }, { 3.0, 4.0 } };
  13. double[][] matrixC = { { 1.0, 3.0 }, { 2.0, 4.0 } };
  14. double[][] result = math.matrixTransponation(matrixA);
  15. assertArrayEquals("The first row is not correct", matrixC[0], result[0], 0.1);
  16. assertArrayEquals("The seound row is not correct", matrixC[1], result[1], 0.1);
  17. }
  18. @Test
  19. public void Transform2by3MatrixAResultsIn3by2MatrixC() {
  20. MatrixCalcMath math = new MatrixCalcMath();
  21. // A(2,3) => C(3,2)
  22. double[][] matrixA = { { 1.0, 2.0, 3.0 }, { 4.0, 5.0, 6.0 } };
  23. double[][] matrixC = { { 1.0, 4.0 }, { 2.0, 5.0 }, { 3.0, 6.0 } };
  24. double[][] result = math.matrixTransponation(matrixA);
  25. assertArrayEquals("The first row is not correct", matrixC[0], result[0], 0.1);
  26. assertArrayEquals("The seound row is not correct", matrixC[1], result[1], 0.1);
  27. }
  28. @Test
  29. public void Transform1by3MatrixAResultsIn3by1MatrixC() {
  30. MatrixCalcMath math = new MatrixCalcMath();
  31. // A(1,3) => C(1,3)
  32. double[][] matrixA = { { 1.0, 2.0, 3.0 } };
  33. double[][] matrixC = { { 1.0 }, { 2.0 }, { 3.0 } };
  34. double[][] result = math.matrixTransponation(matrixA);
  35. assertArrayEquals("The first row is not correct", matrixC[0], result[0], 0.1);
  36. assertArrayEquals("The seound row is not correct", matrixC[1], result[1], 0.1);
  37. }
  38. }