mirror of
https://bitbucket.org/Mattrixwv/matrix.git
synced 2025-12-06 15:03:58 -05:00
Added transpose
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
//Matrix/src/test/java/com/mattrixwv/matrix/TestIntegerMatrix.java
|
//Matrix/src/test/java/com/mattrixwv/matrix/TestIntegerMatrix.java
|
||||||
//Mattrixwv
|
//Mattrixwv
|
||||||
// Created: 02-01-22
|
// Created: 02-01-22
|
||||||
//Modified: 02-02-22
|
//Modified: 02-03-22
|
||||||
package com.mattrixwv.matrix;
|
package com.mattrixwv.matrix;
|
||||||
|
|
||||||
|
|
||||||
@@ -1008,4 +1008,55 @@ public class TestIntegerMatrix{
|
|||||||
});
|
});
|
||||||
assertEquals("IntegerMatrix 10x10 failed dot product IntegerMatrix", correctMatrix, matrix.hadamardProduct(transformMatrix));
|
assertEquals("IntegerMatrix 10x10 failed dot product IntegerMatrix", correctMatrix, matrix.hadamardProduct(transformMatrix));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTranspose(){
|
||||||
|
//1x1
|
||||||
|
IntegerMatrix matrix = new IntegerMatrix(grid1);
|
||||||
|
IntegerMatrix correctMatrix = new IntegerMatrix(new int[][]{{1}});
|
||||||
|
assertEquals("IntegerMatrix 1x1 failed transpose", correctMatrix, matrix.transpose());
|
||||||
|
|
||||||
|
//2x2
|
||||||
|
matrix = new IntegerMatrix(grid2);
|
||||||
|
correctMatrix = new IntegerMatrix(new int[][]{
|
||||||
|
{1, 1},
|
||||||
|
{2, 2}
|
||||||
|
});
|
||||||
|
assertEquals("IntegerMatrix 2x2 failed transpose", correctMatrix, matrix.transpose());
|
||||||
|
|
||||||
|
//3x3
|
||||||
|
matrix = new IntegerMatrix(grid3);
|
||||||
|
correctMatrix = new IntegerMatrix(new int[][]{
|
||||||
|
{1, 1, 1},
|
||||||
|
{2, 2, 2},
|
||||||
|
{3, 3, 3}
|
||||||
|
});
|
||||||
|
assertEquals("IntegerMatrix 3x3 failed transpose", correctMatrix, matrix.transpose());
|
||||||
|
|
||||||
|
//4x4
|
||||||
|
matrix = new IntegerMatrix(grid4);
|
||||||
|
correctMatrix = new IntegerMatrix(new int[][]{
|
||||||
|
{1, 1, 1, 1},
|
||||||
|
{2, 2, 2, 2},
|
||||||
|
{3, 3, 3, 3},
|
||||||
|
{4, 4, 4, 4}
|
||||||
|
});
|
||||||
|
assertEquals("IntegerMatrix 4x4 failed transpose", correctMatrix, matrix.transpose());
|
||||||
|
|
||||||
|
//10x10
|
||||||
|
matrix = new IntegerMatrix(grid10);
|
||||||
|
correctMatrix = new IntegerMatrix(new int[][]{
|
||||||
|
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
|
||||||
|
{2, 2, 2, 2, 2, 2, 2, 2, 2, 2},
|
||||||
|
{3, 3, 3, 3, 3, 3, 3, 3, 3, 3},
|
||||||
|
{4, 4, 4, 4, 4, 4, 4, 4, 4, 4},
|
||||||
|
{5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
|
||||||
|
{6, 6, 6, 6, 6, 6, 6, 6, 6, 6},
|
||||||
|
{7, 7, 7, 7, 7, 7, 7, 7, 7, 7},
|
||||||
|
{8, 8, 8, 8, 8, 8, 8, 8, 8, 8},
|
||||||
|
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9},
|
||||||
|
{10, 10, 10, 10, 10, 10, 10, 10, 10, 10},
|
||||||
|
});
|
||||||
|
assertEquals("IntegerMatrix 10x10 failed transpose", correctMatrix, matrix.transpose());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user