mirror of
https://bitbucket.org/Mattrixwv/matrix.git
synced 2025-12-06 15:03:58 -05:00
Fixed tests
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
//Matrix/src/test/java/com/mattrixwv/matrix/TestIntegerMatrix.java
|
||||
//Mattrixwv
|
||||
// Created: 02-01-22
|
||||
//Modified: 02-07-22
|
||||
//Modified: 02-08-22
|
||||
package com.mattrixwv.matrix;
|
||||
|
||||
|
||||
@@ -117,35 +117,35 @@ public class TestIntegerMatrix{
|
||||
public void testEquals(){
|
||||
//1x1
|
||||
IntegerMatrix matrix = new IntegerMatrix(grid1);
|
||||
assertTrue("IntegerMatrix 1x1 failed equals IntegerMatrix", matrix.equals(matrix));
|
||||
assertTrue("IntegerMatrix 1x1 failed equals IntegerMatrix.", matrix.equals(matrix));
|
||||
@SuppressWarnings("unlikely-arg-type")
|
||||
boolean gridEquals = matrix.equals(grid1);
|
||||
assertTrue("IntegerMatrix 1x1 failed equals int[][]", gridEquals);
|
||||
|
||||
//2x2
|
||||
matrix = new IntegerMatrix(grid2);
|
||||
assertTrue("IntegerMatrix 2x2 failed equals IntegerMatrix", matrix.equals(matrix));
|
||||
assertTrue("IntegerMatrix 2x2 failed equals IntegerMatrix.", matrix.equals(matrix));
|
||||
@SuppressWarnings("unlikely-arg-type")
|
||||
boolean gridEquals2 = matrix.equals(grid2);
|
||||
assertTrue("IntegerMatrix 2x2 failed equals int[][]", gridEquals2);
|
||||
|
||||
//3x3
|
||||
matrix = new IntegerMatrix(grid3);
|
||||
assertTrue("IntegerMatrix 3x3 failed equals IntegerMatrix", matrix.equals(matrix));
|
||||
assertTrue("IntegerMatrix 3x3 failed equals IntegerMatrix.", matrix.equals(matrix));
|
||||
@SuppressWarnings("unlikely-arg-type")
|
||||
boolean gridEquals3 = matrix.equals(grid3);
|
||||
assertTrue("IntegerMatrix 3x3 failed equals int[][]", gridEquals3);
|
||||
|
||||
//4x4
|
||||
matrix = new IntegerMatrix(grid4);
|
||||
assertTrue("IntegerMatrix 4x4 failed equals IntegerMatrix", matrix.equals(matrix));
|
||||
assertTrue("IntegerMatrix 4x4 failed equals IntegerMatrix.", matrix.equals(matrix));
|
||||
@SuppressWarnings("unlikely-arg-type")
|
||||
boolean gridEquals4 = matrix.equals(grid4);
|
||||
assertTrue("IntegerMatrix 4x4 failed equals int[][]", gridEquals4);
|
||||
|
||||
//10x10
|
||||
matrix = new IntegerMatrix(grid10);
|
||||
assertTrue("IntegerMatrix = 10x10 failed equals IntegerMatrix", matrix.equals(matrix));
|
||||
assertTrue("IntegerMatrix = 10x10 failed equals IntegerMatrix.", matrix.equals(matrix));
|
||||
@SuppressWarnings("unlikely-arg-type")
|
||||
boolean gridEquals10 = matrix.equals(grid10);
|
||||
assertTrue("IntegerMatrix 10x10 failed equals int[][]", gridEquals10);
|
||||
@@ -605,8 +605,8 @@ public class TestIntegerMatrix{
|
||||
IntegerMatrix matrix = new IntegerMatrix(grid1);
|
||||
IntegerMatrix transformMatrix = new IntegerMatrix(transformGrid1_1);
|
||||
IntegerMatrix correctMatrix = new IntegerMatrix(new int[][]{{2}});
|
||||
assertEquals("IntegerMatrix 1x1 failed add IntegerMatrix", correctMatrix, matrix.add(transformMatrix));
|
||||
assertEquals("IntegerMatrix 1x1 failed add scalar", correctMatrix, matrix.add(1));
|
||||
assertEquals("IntegerMatrix 1x1 failed add IntegerMatrix.", correctMatrix, matrix.add(transformMatrix));
|
||||
assertEquals("IntegerMatrix 1x1 failed add scalar.", correctMatrix, matrix.add(1));
|
||||
|
||||
//2x2
|
||||
matrix = new IntegerMatrix(grid2);
|
||||
@@ -615,12 +615,12 @@ public class TestIntegerMatrix{
|
||||
{2, 2},
|
||||
{2, 2}
|
||||
});
|
||||
assertEquals("IntegerMatrix 2x2 failed add IntegerMatrix", correctMatrix, matrix.add(transformMatrix));
|
||||
assertEquals("IntegerMatrix 2x2 failed add IntegerMatrix.", correctMatrix, matrix.add(transformMatrix));
|
||||
correctMatrix = new IntegerMatrix(new int[][]{
|
||||
{2, 3},
|
||||
{2, 3}
|
||||
});
|
||||
assertEquals("IntegerMatrix 2x2 failed add scalar", correctMatrix, matrix.add(1));
|
||||
assertEquals("IntegerMatrix 2x2 failed add scalar.", correctMatrix, matrix.add(1));
|
||||
|
||||
//3x3
|
||||
matrix = new IntegerMatrix(grid3);
|
||||
@@ -630,13 +630,13 @@ public class TestIntegerMatrix{
|
||||
{3, 3, 3},
|
||||
{3, 3, 3}
|
||||
});
|
||||
assertEquals("IntegerMatrix 3x3 failed add IntegerMatrix", correctMatrix, matrix.add(transformMatrix));
|
||||
assertEquals("IntegerMatrix 3x3 failed add IntegerMatrix.", correctMatrix, matrix.add(transformMatrix));
|
||||
correctMatrix = new IntegerMatrix(new int[][]{
|
||||
{2, 3, 4},
|
||||
{2, 3, 4},
|
||||
{2, 3, 4}
|
||||
});
|
||||
assertEquals("IntegerMatrix 3x3 failed add scalar", correctMatrix, matrix.add(1));
|
||||
assertEquals("IntegerMatrix 3x3 failed add scalar.", correctMatrix, matrix.add(1));
|
||||
|
||||
//4x4
|
||||
matrix = new IntegerMatrix(grid4);
|
||||
@@ -647,14 +647,14 @@ public class TestIntegerMatrix{
|
||||
{4, 4, 4, 4},
|
||||
{4, 4, 4, 4}
|
||||
});
|
||||
assertEquals("IntegerMatrix 4x4 failed add IntegerMatrix", correctMatrix, matrix.add(transformMatrix));
|
||||
assertEquals("IntegerMatrix 4x4 failed add IntegerMatrix.", correctMatrix, matrix.add(transformMatrix));
|
||||
correctMatrix = new IntegerMatrix(new int[][]{
|
||||
{2, 3, 4, 5},
|
||||
{2, 3, 4, 5},
|
||||
{2, 3, 4, 5},
|
||||
{2, 3, 4, 5}
|
||||
});
|
||||
assertEquals("IntegerMatrix 4x4 failed add scalar", correctMatrix, matrix.add(1));
|
||||
assertEquals("IntegerMatrix 4x4 failed add scalar.", correctMatrix, matrix.add(1));
|
||||
|
||||
//10x10
|
||||
matrix = new IntegerMatrix(grid10);
|
||||
@@ -671,7 +671,7 @@ public class TestIntegerMatrix{
|
||||
{10, 10, 10, 10, 10, 10, 10, 10, 10, 10},
|
||||
{10, 10, 10, 10, 10, 10, 10, 10, 10, 10}
|
||||
});
|
||||
assertEquals("IntegerMatrix 5x5 failed add IntegerMatrix", correctMatrix, matrix.add(transformMatrix));
|
||||
assertEquals("IntegerMatrix 5x5 failed add IntegerMatrix.", correctMatrix, matrix.add(transformMatrix));
|
||||
correctMatrix = new IntegerMatrix(new int[][]{
|
||||
{2, 3, 4, 5, 6, 7, 8, 9, 10, 11},
|
||||
{2, 3, 4, 5, 6, 7, 8, 9, 10, 11},
|
||||
@@ -684,84 +684,61 @@ public class TestIntegerMatrix{
|
||||
{2, 3, 4, 5, 6, 7, 8, 9, 10, 11},
|
||||
{2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
|
||||
});
|
||||
assertEquals("IntegerMatrix 10x10 failed add IntegerMatrix", correctMatrix, matrix.add(1));
|
||||
assertEquals("IntegerMatrix 10x10 failed add IntegerMatrix.", correctMatrix, matrix.add(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSubtraction(){
|
||||
//1x1
|
||||
IntegerMatrix matrix = new IntegerMatrix(grid1);
|
||||
IntegerMatrix transformMatrix = new IntegerMatrix(transformGrid1_1);
|
||||
IntegerMatrix transformMatrix = new IntegerMatrix(grid1);
|
||||
IntegerMatrix correctMatrix = new IntegerMatrix(new int[][]{
|
||||
{0}
|
||||
});
|
||||
assertEquals("IntegerMatrix 1x1 failed subtract IntegerMatrix", correctMatrix, matrix.subtract(transformMatrix));
|
||||
assertEquals("IntegerMatrix 1x1 failed subtract scalar", correctMatrix, matrix.subtract(1));
|
||||
assertEquals("IntegerMatrix 1x1 failed subtract IntegerMatrix.", correctMatrix, matrix.subtract(transformMatrix));
|
||||
assertEquals("IntegerMatrix 1x1 failed subtract scalar.", correctMatrix, matrix.subtract(1));
|
||||
|
||||
//2x2
|
||||
matrix = new IntegerMatrix(grid2);
|
||||
transformMatrix = new IntegerMatrix(grid2);
|
||||
correctMatrix = new IntegerMatrix(new int[][]{
|
||||
{0, 0},
|
||||
{0, 0}
|
||||
});
|
||||
assertEquals("IntegerMatrix 2x2 failed subtract IntegerMatrix", correctMatrix, matrix.subtract(transformMatrix));
|
||||
correctMatrix = new IntegerMatrix(2, 2, 0);
|
||||
assertEquals("IntegerMatrix 2x2 failed subtract IntegerMatrix.", correctMatrix, matrix.subtract(transformMatrix));
|
||||
correctMatrix = new IntegerMatrix(new int[][]{
|
||||
{0, 1},
|
||||
{0, 1}
|
||||
});
|
||||
assertEquals("IntegerMatrix 2x2 failed subtract scalar", correctMatrix, matrix.subtract(1));
|
||||
assertEquals("IntegerMatrix 2x2 failed subtract scalar.", correctMatrix, matrix.subtract(1));
|
||||
|
||||
//3x3
|
||||
matrix = new IntegerMatrix(grid3);
|
||||
transformMatrix = new IntegerMatrix(grid3);
|
||||
correctMatrix = new IntegerMatrix(new int[][]{
|
||||
{0, 0, 0},
|
||||
{0, 0, 0},
|
||||
{0, 0, 0}
|
||||
});
|
||||
assertEquals("IntegerMatrix 3x3 failed subtract IntegerMatrix", correctMatrix, matrix.subtract(transformMatrix));
|
||||
correctMatrix = new IntegerMatrix(3, 3, 0);
|
||||
assertEquals("IntegerMatrix 3x3 failed subtract IntegerMatrix.", correctMatrix, matrix.subtract(transformMatrix));
|
||||
correctMatrix = new IntegerMatrix(new int[][]{
|
||||
{0, 1, 2},
|
||||
{0, 1, 2},
|
||||
{0, 1, 2}
|
||||
});
|
||||
assertEquals("IntegerMatrix 3x3 failed subtract scalar", correctMatrix, matrix.subtract(1));
|
||||
assertEquals("IntegerMatrix 3x3 failed subtract scalar.", correctMatrix, matrix.subtract(1));
|
||||
|
||||
//4x4
|
||||
matrix = new IntegerMatrix(grid4);
|
||||
transformMatrix = new IntegerMatrix(grid4);
|
||||
correctMatrix = new IntegerMatrix(new int[][]{
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0}
|
||||
});
|
||||
assertEquals("IntegerMatrix 4x4 failed subtract IntegerMatrix", correctMatrix, matrix.subtract(transformMatrix));
|
||||
correctMatrix = new IntegerMatrix(4, 4, 0);
|
||||
assertEquals("IntegerMatrix 4x4 failed subtract IntegerMatrix.", correctMatrix, matrix.subtract(transformMatrix));
|
||||
correctMatrix = new IntegerMatrix(new int[][]{
|
||||
{0, 1, 2, 3},
|
||||
{0, 1, 2, 3},
|
||||
{0, 1, 2, 3},
|
||||
{0, 1, 2, 3}
|
||||
});
|
||||
assertEquals("IntegerMatrix 4x4 failed subtract scalar", correctMatrix, matrix.subtract(1));
|
||||
assertEquals("IntegerMatrix 4x4 failed subtract scalar.", correctMatrix, matrix.subtract(1));
|
||||
|
||||
//10x10
|
||||
matrix = new IntegerMatrix(grid10);
|
||||
transformMatrix = new IntegerMatrix(grid10);
|
||||
correctMatrix = new IntegerMatrix(new int[][]{
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
});
|
||||
assertEquals("IntegerMatrix 10x10 failed subtract IntegerMatrix", correctMatrix, matrix.subtract(transformMatrix));
|
||||
correctMatrix = new IntegerMatrix(10, 10, 0);
|
||||
assertEquals("IntegerMatrix 10x10 failed subtract IntegerMatrix.", correctMatrix, matrix.subtract(transformMatrix));
|
||||
correctMatrix = new IntegerMatrix(new int[][]{
|
||||
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
|
||||
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
|
||||
@@ -774,7 +751,7 @@ public class TestIntegerMatrix{
|
||||
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
|
||||
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
|
||||
});
|
||||
assertEquals("IntegerMatrix 10x10 failed subtract scalar", correctMatrix, matrix.subtract(1));
|
||||
assertEquals("IntegerMatrix 10x10 failed subtract scalar.", correctMatrix, matrix.subtract(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -783,8 +760,8 @@ public class TestIntegerMatrix{
|
||||
IntegerMatrix matrix = new IntegerMatrix(grid1);
|
||||
IntegerMatrix transformMatrix = new IntegerMatrix(transformGrid1_2);
|
||||
IntegerMatrix correctMatrix = new IntegerMatrix(transformGrid1_2);
|
||||
assertEquals("IntegerMatrix 1x1 failed multiplication IntegerMatrix", correctMatrix, matrix.multiply(transformMatrix));
|
||||
assertEquals("IntegerMatrix 1x1 failed multiplication scalar", correctMatrix, matrix.multiply(2));
|
||||
assertEquals("IntegerMatrix 1x1 failed multiplication IntegerMatrix.", correctMatrix, matrix.multiply(transformMatrix));
|
||||
assertEquals("IntegerMatrix 1x1 failed multiplication scalar.", correctMatrix, matrix.multiply(2));
|
||||
|
||||
//2x2
|
||||
matrix = new IntegerMatrix(grid2);
|
||||
@@ -793,7 +770,7 @@ public class TestIntegerMatrix{
|
||||
{6, 9},
|
||||
{6, 9}
|
||||
});
|
||||
assertEquals("IntegerMatrix 2x2 failed multiplication IntegerMatrix", correctMatrix, matrix.multiply(transformMatrix));
|
||||
assertEquals("IntegerMatrix 2x2 failed multiplication IntegerMatrix.", correctMatrix, matrix.multiply(transformMatrix));
|
||||
IntegerMatrix vector = new IntegerMatrix(new int[][]{
|
||||
{2},
|
||||
{3}
|
||||
@@ -802,12 +779,12 @@ public class TestIntegerMatrix{
|
||||
{8},
|
||||
{8}
|
||||
});
|
||||
assertEquals("IntegerMatrix 2x2 failed multiplication vector", correctMatrix, matrix.multiply(vector));
|
||||
assertEquals("IntegerMatrix 2x2 failed multiplication vector.", correctMatrix, matrix.multiply(vector));
|
||||
correctMatrix = new IntegerMatrix(new int[][]{
|
||||
{2, 4},
|
||||
{2, 4}
|
||||
});
|
||||
assertEquals("IntegerMatrix 2x2 failed multiplication scalar", correctMatrix, matrix.multiply(2));
|
||||
assertEquals("IntegerMatrix 2x2 failed multiplication scalar.", correctMatrix, matrix.multiply(2));
|
||||
|
||||
//3x3
|
||||
matrix = new IntegerMatrix(grid3);
|
||||
@@ -817,7 +794,7 @@ public class TestIntegerMatrix{
|
||||
{12, 18, 24},
|
||||
{12, 18, 24}
|
||||
});
|
||||
assertEquals("IntegerMatrix 3x3 failed multiplication IntegerMatrix", correctMatrix, matrix.multiply(transformMatrix));
|
||||
assertEquals("IntegerMatrix 3x3 failed multiplication IntegerMatrix.", correctMatrix, matrix.multiply(transformMatrix));
|
||||
vector = new IntegerMatrix(new int[][]{
|
||||
{2},
|
||||
{3},
|
||||
@@ -828,13 +805,13 @@ public class TestIntegerMatrix{
|
||||
{20},
|
||||
{20}
|
||||
});
|
||||
assertEquals("IntegerMatrix 3x3 failed multiplication vector", correctMatrix, matrix.multiply(vector));
|
||||
assertEquals("IntegerMatrix 3x3 failed multiplication vector.", correctMatrix, matrix.multiply(vector));
|
||||
correctMatrix = new IntegerMatrix(new int[][]{
|
||||
{2, 4, 6},
|
||||
{2, 4, 6},
|
||||
{2, 4, 6}
|
||||
});
|
||||
assertEquals("IntegerMatrix 3x3 failed multiplication scalar", correctMatrix, matrix.multiply(2));
|
||||
assertEquals("IntegerMatrix 3x3 failed multiplication scalar.", correctMatrix, matrix.multiply(2));
|
||||
|
||||
//4x4
|
||||
matrix = new IntegerMatrix(grid4);
|
||||
@@ -845,7 +822,7 @@ public class TestIntegerMatrix{
|
||||
{20, 30, 40, 50},
|
||||
{20, 30, 40, 50},
|
||||
});
|
||||
assertEquals("IntegerMatrix 4x4 failed multiplication IntegerMatrix", correctMatrix, matrix.multiply(transformMatrix));
|
||||
assertEquals("IntegerMatrix 4x4 failed multiplication IntegerMatrix.", correctMatrix, matrix.multiply(transformMatrix));
|
||||
vector = new IntegerMatrix(new int[][]{
|
||||
{2},
|
||||
{3},
|
||||
@@ -858,14 +835,14 @@ public class TestIntegerMatrix{
|
||||
{40},
|
||||
{40}
|
||||
});
|
||||
assertEquals("IntegerMatrix 4x4 failed multiplication vector", correctMatrix, matrix.multiply(vector));
|
||||
assertEquals("IntegerMatrix 4x4 failed multiplication vector.", correctMatrix, matrix.multiply(vector));
|
||||
correctMatrix = new IntegerMatrix(new int[][]{
|
||||
{2, 4, 6, 8},
|
||||
{2, 4, 6, 8},
|
||||
{2, 4, 6, 8},
|
||||
{2, 4, 6, 8}
|
||||
});
|
||||
assertEquals("IntegerMatrix 4x4 failed multiplication scalar", correctMatrix, matrix.multiply(2));
|
||||
assertEquals("IntegerMatrix 4x4 failed multiplication scalar.", correctMatrix, matrix.multiply(2));
|
||||
|
||||
//10x10
|
||||
matrix = new IntegerMatrix(grid10);
|
||||
@@ -882,7 +859,7 @@ public class TestIntegerMatrix{
|
||||
{110, 165, 220, 275, 330, 385, 440, 495, 550, 605},
|
||||
{110, 165, 220, 275, 330, 385, 440, 495, 550, 605}
|
||||
});
|
||||
assertEquals("IntegerMatrix 10x10 failed multiplication IntegerMatrix", correctMatrix, matrix.multiply(transformMatrix));
|
||||
assertEquals("IntegerMatrix 10x10 failed multiplication IntegerMatrix.", correctMatrix, matrix.multiply(transformMatrix));
|
||||
vector = new IntegerMatrix(new int[][]{
|
||||
{2},
|
||||
{3},
|
||||
@@ -907,7 +884,7 @@ public class TestIntegerMatrix{
|
||||
{440},
|
||||
{440}
|
||||
});
|
||||
assertEquals("IntegerMatrix 10x10 failed multiplication vector", correctMatrix, matrix.multiply(vector));
|
||||
assertEquals("IntegerMatrix 10x10 failed multiplication vector.", correctMatrix, matrix.multiply(vector));
|
||||
correctMatrix = new IntegerMatrix(new int[][]{
|
||||
{2, 4, 6, 8, 10, 12, 14, 16, 18, 20},
|
||||
{2, 4, 6, 8, 10, 12, 14, 16, 18, 20},
|
||||
@@ -920,7 +897,7 @@ public class TestIntegerMatrix{
|
||||
{2, 4, 6, 8, 10, 12, 14, 16, 18, 20},
|
||||
{2, 4, 6, 8, 10, 12, 14, 16, 18, 20}
|
||||
});
|
||||
assertEquals("IntegerMatrix 10x10 failed multiplication scalar", correctMatrix, matrix.multiply(2));
|
||||
assertEquals("IntegerMatrix 10x10 failed multiplication scalar.", correctMatrix, matrix.multiply(2));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -928,27 +905,27 @@ public class TestIntegerMatrix{
|
||||
//1x1
|
||||
IntegerMatrix matrix = new IntegerMatrix(grid1);
|
||||
IntegerMatrix transformMatrix = new IntegerMatrix(transformGrid1_2);
|
||||
assertEquals("IntegerMatrix 1x1 failed dot product IntegerMatrix", 2, matrix.dotProduct(transformMatrix));
|
||||
assertEquals("IntegerMatrix 1x1 failed dot product IntegerMatrix.", 2, matrix.dotProduct(transformMatrix));
|
||||
|
||||
//2x2
|
||||
matrix = new IntegerMatrix(grid2);
|
||||
transformMatrix = new IntegerMatrix(transformGrid2_2);
|
||||
assertEquals("IntegerMatrix 2x2 failed dot product IntegerMatrix", 30, matrix.dotProduct(transformMatrix));
|
||||
assertEquals("IntegerMatrix 2x2 failed dot product IntegerMatrix.", 30, matrix.dotProduct(transformMatrix));
|
||||
|
||||
//3x3
|
||||
matrix = new IntegerMatrix(grid3);
|
||||
transformMatrix = new IntegerMatrix(transformGrid3_2);
|
||||
assertEquals("IntegerMatrix 3x3 failed dot product IntegerMatrix", 162, matrix.dotProduct(transformMatrix));
|
||||
assertEquals("IntegerMatrix 3x3 failed dot product IntegerMatrix.", 162, matrix.dotProduct(transformMatrix));
|
||||
|
||||
//4x4
|
||||
matrix = new IntegerMatrix(grid4);
|
||||
transformMatrix = new IntegerMatrix(transformGrid4_2);
|
||||
assertEquals("IntegerMatrix 4x4 failed dot product IntegerMatrix", 560, matrix.dotProduct(transformMatrix));
|
||||
assertEquals("IntegerMatrix 4x4 failed dot product IntegerMatrix.", 560, matrix.dotProduct(transformMatrix));
|
||||
|
||||
//10x10
|
||||
matrix = new IntegerMatrix(grid10);
|
||||
transformMatrix = new IntegerMatrix(transformGrid10_2);
|
||||
assertEquals("IntegerMatrix 10x10 failed dot product IntegerMatrix", 35750, matrix.dotProduct(transformMatrix));
|
||||
assertEquals("IntegerMatrix 10x10 failed dot product IntegerMatrix.", 35750, matrix.dotProduct(transformMatrix));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -957,7 +934,7 @@ public class TestIntegerMatrix{
|
||||
IntegerMatrix matrix = new IntegerMatrix(grid1);
|
||||
IntegerMatrix transformMatrix = new IntegerMatrix(transformGrid1_2);
|
||||
IntegerMatrix correctMatrix = new IntegerMatrix(new int[][]{{2}});
|
||||
assertEquals("IntegerMatrix 1x1 failed dot product IntegerMatrix", correctMatrix, matrix.hadamardProduct(transformMatrix));
|
||||
assertEquals("IntegerMatrix 1x1 failed hadamard product.", correctMatrix, matrix.hadamardProduct(transformMatrix));
|
||||
|
||||
//2x2
|
||||
matrix = new IntegerMatrix(grid2);
|
||||
@@ -966,7 +943,7 @@ public class TestIntegerMatrix{
|
||||
{2, 6},
|
||||
{2, 6}
|
||||
});
|
||||
assertEquals("IntegerMatrix 2x2 failed dot product IntegerMatrix", correctMatrix, matrix.hadamardProduct(transformMatrix));
|
||||
assertEquals("IntegerMatrix 2x2 failed hadamard product.", correctMatrix, matrix.hadamardProduct(transformMatrix));
|
||||
|
||||
//3x3
|
||||
matrix = new IntegerMatrix(grid3);
|
||||
@@ -976,7 +953,7 @@ public class TestIntegerMatrix{
|
||||
{2, 6, 12},
|
||||
{2, 6, 12}
|
||||
});
|
||||
assertEquals("IntegerMatrix 3x3 failed dot product IntegerMatrix", correctMatrix, matrix.hadamardProduct(transformMatrix));
|
||||
assertEquals("IntegerMatrix 3x3 failed hadamard product.", correctMatrix, matrix.hadamardProduct(transformMatrix));
|
||||
|
||||
//4x4
|
||||
matrix = new IntegerMatrix(grid4);
|
||||
@@ -987,7 +964,7 @@ public class TestIntegerMatrix{
|
||||
{2, 6, 12, 20},
|
||||
{2, 6, 12, 20}
|
||||
});
|
||||
assertEquals("IntegerMatrix 4x4 failed dot product IntegerMatrix", correctMatrix, matrix.hadamardProduct(transformMatrix));
|
||||
assertEquals("IntegerMatrix 4x4 failed hadamard product.", correctMatrix, matrix.hadamardProduct(transformMatrix));
|
||||
|
||||
//10x10
|
||||
matrix = new IntegerMatrix(grid10);
|
||||
@@ -1004,7 +981,7 @@ public class TestIntegerMatrix{
|
||||
{2, 6, 12, 20, 30, 42, 56, 72, 90, 110},
|
||||
{2, 6, 12, 20, 30, 42, 56, 72, 90, 110}
|
||||
});
|
||||
assertEquals("IntegerMatrix 10x10 failed dot product IntegerMatrix", correctMatrix, matrix.hadamardProduct(transformMatrix));
|
||||
assertEquals("IntegerMatrix 10x10 failed hadamard product.", correctMatrix, matrix.hadamardProduct(transformMatrix));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1062,41 +1039,41 @@ public class TestIntegerMatrix{
|
||||
public void testDeterminant(){
|
||||
//1x1
|
||||
IntegerMatrix matrix = new IntegerMatrix(grid1);
|
||||
assertEquals("IntegerMatrix 1x1 failed determinant", 1, matrix.determinant());
|
||||
assertEquals("IntegerMatrix 1x1 failed determinant.", 1, matrix.determinant());
|
||||
|
||||
//2x2
|
||||
matrix = new IntegerMatrix(grid2);
|
||||
assertEquals("IntegerMatrix 2x2 failed determinant1", 0, matrix.determinant());
|
||||
assertEquals("IntegerMatrix 2x2 failed determinant1.", 0, matrix.determinant());
|
||||
matrix = new IntegerMatrix(new int[][]{
|
||||
{1, 4},
|
||||
{4, 1}
|
||||
});
|
||||
assertEquals("IntegerMatrix 2x2 failed determinant2", -15, matrix.determinant());
|
||||
assertEquals("IntegerMatrix 2x2 failed determinant2.", -15, matrix.determinant());
|
||||
|
||||
//3x3
|
||||
matrix = new IntegerMatrix(grid3);
|
||||
assertEquals("IntegerMatrix 3x3 failed determinant1", 0, matrix.determinant());
|
||||
assertEquals("IntegerMatrix 3x3 failed determinant1.", 0, matrix.determinant());
|
||||
matrix = new IntegerMatrix(new int[][]{
|
||||
{1, 4, 2},
|
||||
{2, 4, 1},
|
||||
{4, 1, 2}
|
||||
});
|
||||
assertEquals("IntegerMatrix 3x3 failed determinant2", -21, matrix.determinant());
|
||||
assertEquals("IntegerMatrix 3x3 failed determinant2.", -21, matrix.determinant());
|
||||
|
||||
//4x4
|
||||
matrix = new IntegerMatrix(grid4);
|
||||
assertEquals("IntegerMatrix 4x4 failed determiant1", 0, matrix.determinant());
|
||||
assertEquals("IntegerMatrix 4x4 failed determiant1.", 0, matrix.determinant());
|
||||
matrix = new IntegerMatrix(new int[][]{
|
||||
{1, 2, 3, 4},
|
||||
{2, 3, 4, 1},
|
||||
{3, 4, 1, 2},
|
||||
{4, 1, 2, 3}
|
||||
});
|
||||
assertEquals("IntegerMatrix 4x4 failed determinant2", 160, matrix.determinant());
|
||||
assertEquals("IntegerMatrix 4x4 failed determinant2.", 160, matrix.determinant());
|
||||
|
||||
//10x10
|
||||
matrix = new IntegerMatrix(grid10);
|
||||
assertEquals("IntegerMatrix 10x10 failed determinant1", 0, matrix.determinant());
|
||||
assertEquals("IntegerMatrix 10x10 failed determinant1.", 0, matrix.determinant());
|
||||
matrix = new IntegerMatrix(new int[][]{
|
||||
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
|
||||
{2, 3, 4, 5, 6, 7, 8, 9, 10, 1},
|
||||
@@ -1109,7 +1086,7 @@ public class TestIntegerMatrix{
|
||||
{9, 10, 1, 2, 3, 4, 5, 6, 7, 8},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0, 1}
|
||||
});
|
||||
assertEquals("IntegerMatrix 10x10 failed determinant2", -10000000, matrix.determinant());
|
||||
assertEquals("IntegerMatrix 10x10 failed determinant2.", -10000000, matrix.determinant());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1117,7 +1094,7 @@ public class TestIntegerMatrix{
|
||||
//1x1
|
||||
IntegerMatrix matrix = new IntegerMatrix(grid1);
|
||||
IntegerMatrix correctMatrix = new IntegerMatrix(grid1);
|
||||
assertEquals("IntegerMatrix 1x1 failed cofactor", correctMatrix, matrix.cofactor());
|
||||
assertEquals("IntegerMatrix 1x1 failed cofactor.", correctMatrix, matrix.cofactor());
|
||||
|
||||
//2x2
|
||||
matrix = new IntegerMatrix(grid2);
|
||||
@@ -1125,12 +1102,12 @@ public class TestIntegerMatrix{
|
||||
{2, -1},
|
||||
{-2, 1}
|
||||
});
|
||||
assertEquals("IntegerMatrix 2x2 failed cofactor", correctMatrix, matrix.cofactor());
|
||||
assertEquals("IntegerMatrix 2x2 failed cofactor.", correctMatrix, matrix.cofactor());
|
||||
|
||||
//3x3
|
||||
matrix = new IntegerMatrix(grid3);
|
||||
correctMatrix = new IntegerMatrix(3, 3, 0);
|
||||
assertEquals("IntegerMatrix 3x3 failed cofactor1", correctMatrix, matrix.cofactor());
|
||||
assertEquals("IntegerMatrix 3x3 failed cofactor1.", correctMatrix, matrix.cofactor());
|
||||
matrix = new IntegerMatrix(new int[][]{
|
||||
{1, 4, 2},
|
||||
{2, 4, 1},
|
||||
@@ -1141,12 +1118,12 @@ public class TestIntegerMatrix{
|
||||
{-6, -6, 15},
|
||||
{-4, 3, -4}
|
||||
});
|
||||
assertEquals("IntegerMatrix 3x3 failed cofactor2", correctMatrix, matrix.cofactor());
|
||||
assertEquals("IntegerMatrix 3x3 failed cofactor2.", correctMatrix, matrix.cofactor());
|
||||
|
||||
//4x4
|
||||
matrix = new IntegerMatrix(grid4);
|
||||
correctMatrix = new IntegerMatrix(4, 4, 0);
|
||||
assertEquals("IntegerMatrix 4x4 failed cofactor1", correctMatrix, matrix.cofactor());
|
||||
assertEquals("IntegerMatrix 4x4 failed cofactor1.", correctMatrix, matrix.cofactor());
|
||||
matrix = new IntegerMatrix(new int[][]{
|
||||
{1, 2, 3, 4},
|
||||
{2, 3, 4, 1},
|
||||
@@ -1159,14 +1136,14 @@ public class TestIntegerMatrix{
|
||||
{4, 44, -36, 4},
|
||||
{44, -36, 4, 4}
|
||||
});
|
||||
assertEquals("IntegerMatrix 4x4 failed cofactor2", correctMatrix, matrix.cofactor());
|
||||
assertEquals("IntegerMatrix 4x4 failed cofactor2.", correctMatrix, matrix.cofactor());
|
||||
|
||||
//10x10
|
||||
//?Skipping 10x10 test because test took > 5s by itself
|
||||
/*
|
||||
matrix = new IntegerMatrix(grid10);
|
||||
correctMatrix = new IntegerMatrix(10, 10, 0);
|
||||
assertEquals("IntegerMatrix 10x10 failed cofactor1", correctMatrix, matrix.cofactor());
|
||||
assertEquals("IntegerMatrix 10x10 failed cofactor1.", correctMatrix, matrix.cofactor());
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -1175,7 +1152,7 @@ public class TestIntegerMatrix{
|
||||
//1x1
|
||||
IntegerMatrix matrix = new IntegerMatrix(grid1);
|
||||
IntegerMatrix correctMatrix = new IntegerMatrix(new int[][]{{1}});
|
||||
assertEquals("IntegerMatrix 1x1 failed power", correctMatrix, matrix.pow(3));
|
||||
assertEquals("IntegerMatrix 1x1 failed power.", correctMatrix, matrix.pow(3));
|
||||
|
||||
//2x2
|
||||
matrix = new IntegerMatrix(grid2);
|
||||
@@ -1183,7 +1160,7 @@ public class TestIntegerMatrix{
|
||||
{9, 18},
|
||||
{9, 18}
|
||||
});
|
||||
assertEquals("IntegerMatrix 2x2 failed power", correctMatrix, matrix.pow(3));
|
||||
assertEquals("IntegerMatrix 2x2 failed power.", correctMatrix, matrix.pow(3));
|
||||
|
||||
//3x3
|
||||
matrix = new IntegerMatrix(grid3);
|
||||
@@ -1192,7 +1169,7 @@ public class TestIntegerMatrix{
|
||||
{36, 72, 108},
|
||||
{36, 72, 108}
|
||||
});
|
||||
assertEquals("IntegerMatrix 3x3 failed power", correctMatrix, matrix.pow(3));
|
||||
assertEquals("IntegerMatrix 3x3 failed power.", correctMatrix, matrix.pow(3));
|
||||
|
||||
//4x4
|
||||
//0
|
||||
@@ -1203,7 +1180,7 @@ public class TestIntegerMatrix{
|
||||
{1, 1, 1, 1},
|
||||
{1, 1, 1, 1}
|
||||
});
|
||||
assertEquals("IntegerMatrix 4x4 failed power 0", correctMatrix, matrix.pow(0));
|
||||
assertEquals("IntegerMatrix 4x4 failed power 0.", correctMatrix, matrix.pow(0));
|
||||
//1
|
||||
correctMatrix = new IntegerMatrix(new int[][]{
|
||||
{1, 2, 3, 4},
|
||||
@@ -1211,7 +1188,7 @@ public class TestIntegerMatrix{
|
||||
{1, 2, 3, 4},
|
||||
{1, 2, 3, 4}
|
||||
});
|
||||
assertEquals("IntegerMatrix 4x4 failed power 1", correctMatrix, matrix.pow(1));
|
||||
assertEquals("IntegerMatrix 4x4 failed power 1.", correctMatrix, matrix.pow(1));
|
||||
//3
|
||||
correctMatrix = new IntegerMatrix(new int[][]{
|
||||
{100, 200, 300, 400},
|
||||
@@ -1219,22 +1196,23 @@ public class TestIntegerMatrix{
|
||||
{100, 200, 300, 400},
|
||||
{100, 200, 300, 400}
|
||||
});
|
||||
assertEquals("IntegerMatrix 4x4 failed power 3", correctMatrix, matrix.pow(3));
|
||||
assertEquals("IntegerMatrix 4x4 failed power 3.", correctMatrix, matrix.pow(3));
|
||||
|
||||
//10x10
|
||||
matrix = new IntegerMatrix(grid10);
|
||||
correctMatrix = new IntegerMatrix(new int[][]{
|
||||
{2475, 4950, 7425, 9900, 12375, 14850, 17325, 19800, 22275, 24750},
|
||||
{2475, 4950, 7425, 9900, 12375, 14850, 17325, 19800, 22275, 24750},
|
||||
{2475, 4950, 7425, 9900, 12375, 14850, 17325, 19800, 22275, 24750},
|
||||
{2475, 4950, 7425, 9900, 12375, 14850, 17325, 19800, 22275, 24750},
|
||||
{2475, 4950, 7425, 9900, 12375, 14850, 17325, 19800, 22275, 24750},
|
||||
{2475, 4950, 7425, 9900, 12375, 14850, 17325, 19800, 22275, 24750},
|
||||
{2475, 4950, 7425, 9900, 12375, 14850, 17325, 19800, 22275, 24750},
|
||||
{2475, 4950, 7425, 9900, 12375, 14850, 17325, 19800, 22275, 24750},
|
||||
{2475, 4950, 7425, 9900, 12375, 14850, 17325, 19800, 22275, 24750},
|
||||
{2475, 4950, 7425, 9900, 12375, 14850, 17325, 19800, 22275, 24750}
|
||||
{3025, 6050, 9075, 12100, 15125, 18150, 21175, 24200, 27225, 30250},
|
||||
{3025, 6050, 9075, 12100, 15125, 18150, 21175, 24200, 27225, 30250},
|
||||
{3025, 6050, 9075, 12100, 15125, 18150, 21175, 24200, 27225, 30250},
|
||||
{3025, 6050, 9075, 12100, 15125, 18150, 21175, 24200, 27225, 30250},
|
||||
{3025, 6050, 9075, 12100, 15125, 18150, 21175, 24200, 27225, 30250},
|
||||
{3025, 6050, 9075, 12100, 15125, 18150, 21175, 24200, 27225, 30250},
|
||||
{3025, 6050, 9075, 12100, 15125, 18150, 21175, 24200, 27225, 30250},
|
||||
{3025, 6050, 9075, 12100, 15125, 18150, 21175, 24200, 27225, 30250},
|
||||
{3025, 6050, 9075, 12100, 15125, 18150, 21175, 24200, 27225, 30250},
|
||||
{3025, 6050, 9075, 12100, 15125, 18150, 21175, 24200, 27225, 30250}
|
||||
});
|
||||
assertEquals("IntegerMatrix 10x10 failed power.", correctMatrix, matrix.pow(3));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1242,7 +1220,7 @@ public class TestIntegerMatrix{
|
||||
//1x1
|
||||
IntegerMatrix matrix = new IntegerMatrix(grid1);
|
||||
IntegerMatrix correctMatrix = new IntegerMatrix(grid1);
|
||||
assertEquals("IntegerMatrix 1x1 failed adjoint", correctMatrix, matrix.adjoint());
|
||||
assertEquals("IntegerMatrix 1x1 failed adjoint.", correctMatrix, matrix.adjoint());
|
||||
|
||||
//2x2
|
||||
matrix = new IntegerMatrix(grid2);
|
||||
@@ -1250,12 +1228,12 @@ public class TestIntegerMatrix{
|
||||
{2, -2},
|
||||
{-1, 1}
|
||||
});
|
||||
assertEquals("IntegerMatrix 2x2 failed adjoint", correctMatrix, matrix.adjoint());
|
||||
assertEquals("IntegerMatrix 2x2 failed adjoint.", correctMatrix, matrix.adjoint());
|
||||
|
||||
//3x3
|
||||
matrix = new IntegerMatrix(grid3);
|
||||
correctMatrix = new IntegerMatrix(3, 3, 0);
|
||||
assertEquals("IntegerMatrix 3x3 failed adjoint", correctMatrix, matrix.adjoint());
|
||||
assertEquals("IntegerMatrix 3x3 failed adjoint.", correctMatrix, matrix.adjoint());
|
||||
|
||||
//4x4
|
||||
matrix = new IntegerMatrix(new int[][]{
|
||||
@@ -1270,14 +1248,14 @@ public class TestIntegerMatrix{
|
||||
{4, 44, -36, 4},
|
||||
{44, -36, 4, 4}
|
||||
});
|
||||
assertEquals("IntegerMatrix 4x4 failed adjoint", correctMatrix, matrix.adjoint());
|
||||
assertEquals("IntegerMatrix 4x4 failed adjoint.", correctMatrix, matrix.adjoint());
|
||||
|
||||
//10x10
|
||||
//?Skipping 10x10 test because test took > 5s by itself
|
||||
/*
|
||||
matrix = new IntegerMatrix(grid10);
|
||||
correctMatrix = new IntegerMatrix(10, 10, 0);
|
||||
assertEquals("IntegerMatrix 10x10 failed adjoint", correctMatrix, matrix.adjoint());
|
||||
assertEquals("IntegerMatrix 10x10 failed adjoint.", correctMatrix, matrix.adjoint());
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -1286,7 +1264,7 @@ public class TestIntegerMatrix{
|
||||
//1x1
|
||||
IntegerMatrix matrix = new IntegerMatrix(grid1);
|
||||
IntegerMatrix correctMatrix = new IntegerMatrix(grid1);
|
||||
assertEquals("IntegerMatrix 1x1 failed inverse", correctMatrix, matrix.inverse());
|
||||
assertEquals("IntegerMatrix 1x1 failed inverse.", correctMatrix, matrix.inverse());
|
||||
|
||||
//2x2
|
||||
matrix = new IntegerMatrix(new int[][]{
|
||||
@@ -1297,7 +1275,7 @@ public class TestIntegerMatrix{
|
||||
{-0, 0},
|
||||
{0, -0}
|
||||
});
|
||||
assertEquals("IntegerMatrix 2x2 failed inverse", correctMatrix, matrix.inverse());
|
||||
assertEquals("IntegerMatrix 2x2 failed inverse.", correctMatrix, matrix.inverse());
|
||||
|
||||
//3x3
|
||||
matrix = new IntegerMatrix(new int[][]{
|
||||
@@ -1310,7 +1288,7 @@ public class TestIntegerMatrix{
|
||||
{0, 0, -0},
|
||||
{0, -0, 0}
|
||||
});
|
||||
assertEquals("IntegerMatrix 3x3 failed inverse", correctMatrix, matrix.inverse());
|
||||
assertEquals("IntegerMatrix 3x3 failed inverse.", correctMatrix, matrix.inverse());
|
||||
|
||||
//4x4
|
||||
matrix = new IntegerMatrix(new int[][]{
|
||||
@@ -1325,7 +1303,7 @@ public class TestIntegerMatrix{
|
||||
{0, 0, -0, 0},
|
||||
{0, -0, 0, 0}
|
||||
});
|
||||
assertEquals("IntegerMatrix 4x4 failed inverse", correctMatrix, matrix.inverse());
|
||||
assertEquals("IntegerMatrix 4x4 failed inverse.", correctMatrix, matrix.inverse());
|
||||
|
||||
//10x10
|
||||
//?Skipped 10x10 because it would take a long time to compute
|
||||
|
||||
Reference in New Issue
Block a user