Updated dependencies

This commit is contained in:
2022-07-09 02:00:12 -04:00
parent b0530bb6ae
commit 55debc9821
7 changed files with 763 additions and 736 deletions

View File

@@ -1,19 +1,20 @@
//Matrix/src/test/java/com/mattrixwv/matrix/TestDoubleMatrix.java
//Mattrixwv
// Created: 02-07-22
//Modified: 02-09-22
//Modified: 07-09-22
package com.mattrixwv.matrix;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Arrays;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import com.mattrixwv.matrix.exceptions.InvalidCoordinatesException;
import com.mattrixwv.matrix.exceptions.InvalidGeometryException;
@@ -199,16 +200,16 @@ public class TestDoubleMatrix{
public void testEquals(){
//Invalid equals
DoubleMatrix matrix = new DoubleMatrix(grid1);
assertNotEquals(matrix, null);
assertNotEquals(matrix, new int[0]);
assertNotEquals(null, matrix);
assertNotEquals(new int[0], matrix);
//1x1
matrix = new DoubleMatrix(grid1);
boolean gridEquals = matrix.equals(matrix);
assertTrue("DoubleMatrix 1x1 failed equals DoubleMatrix.", gridEquals);
assertTrue(gridEquals);
@SuppressWarnings("unlikely-arg-type")
boolean gridEquals1 = matrix.equals(grid1);
assertTrue("DoubleMatrix 1x1 failed equals double[][].", gridEquals1);
assertTrue(gridEquals1);
//With delta
boolean gridEquals12 = matrix.equals(matrix, 0.0001);
assertTrue(gridEquals12);
@@ -216,10 +217,10 @@ public class TestDoubleMatrix{
//2x2
matrix = new DoubleMatrix(grid2);
boolean gridEquals2 = matrix.equals(matrix);
assertTrue("DoubleMatrix 2x2 failed equals DoubleMatrix.", gridEquals2);
assertTrue(gridEquals2);
@SuppressWarnings("unlikely-arg-type")
boolean gridEquals21 = matrix.equals(grid2);
assertTrue("DoubleMatrix 2x2 failed equals double[][].", gridEquals21);
assertTrue(gridEquals21);
//false
@SuppressWarnings("unlikely-arg-type")
boolean gridEquals22 = matrix.equals(transformGrid2_1);
@@ -235,33 +236,33 @@ public class TestDoubleMatrix{
//3x3
matrix = new DoubleMatrix(grid3);
boolean gridEquals3 = matrix.equals(matrix);
assertTrue("DoubleMatrix 3x3 failed equals DoubleMatrix.", gridEquals3);
assertTrue(gridEquals3);
@SuppressWarnings("unlikely-arg-type")
boolean gridEquals31 = matrix.equals(grid3);
assertTrue("DoubleMatrix 3x3 failed equals double[][].", gridEquals31);
assertTrue(gridEquals31);
//4x4
matrix = new DoubleMatrix(grid4);
boolean gridEquals4 = matrix.equals(matrix);
assertTrue("DoubleMatrix 4x4 failed equals DoubleMatrix.", gridEquals4);
assertTrue(gridEquals4);
@SuppressWarnings("unlikely-arg-type")
boolean gridEquals41 = matrix.equals(grid4);
assertTrue("DoubleMatrix 4x4 failed equals double[][].", gridEquals41);
assertTrue(gridEquals41);
//10x10
matrix = new DoubleMatrix(grid10);
boolean gridEquals10 = matrix.equals(matrix);
assertTrue("DoubleMatrix 10x10 failed equals DoubleMatrix.", gridEquals10);
assertTrue(gridEquals10);
@SuppressWarnings("unlikely-arg-type")
boolean gridEquals101 = matrix.equals(grid10);
assertTrue("DoubleMatrix 10x10 failed equals double[][].", gridEquals101);
assertTrue(gridEquals101);
}
@Test
public void testGet(){
//1x1
DoubleMatrix matrix = new DoubleMatrix(grid1);
assertEquals("DoubleMatrix 1x1 failed get.", 0.5, matrix.get(0, 0), 0.0000001);
assertEquals(0.5, matrix.get(0, 0), 0.0000001);
//Invalid gets
final DoubleMatrix testMatrix = new DoubleMatrix(matrix);
@@ -280,19 +281,19 @@ public class TestDoubleMatrix{
//2x2
matrix = new DoubleMatrix(grid2);
assertEquals("DoubleMatrix 2x2 failed get.", 0.5, matrix.get(0, 0), 0.0000001);
assertEquals(0.5, matrix.get(0, 0), 0.0000001);
//3x3
matrix = new DoubleMatrix(grid3);
assertEquals("DoubleMatrix 3x3 failed get.", 0.5, matrix.get(0, 0), 0.0000001);
assertEquals(0.5, matrix.get(0, 0), 0.0000001);
//4x4
matrix = new DoubleMatrix(grid4);
assertEquals("DoubleMatrix 4x4 failed get.", 0.5, matrix.get(0, 0), 0.0000001);
assertEquals(0.5, matrix.get(0, 0), 0.0000001);
//10x10
matrix = new DoubleMatrix(grid10);
assertEquals("DoubleMatrix 10x10 failed get.", 0.5, matrix.get(0, 0), 0.0000001);
assertEquals(0.5, matrix.get(0, 0), 0.0000001);
}
@Test
@@ -300,7 +301,7 @@ public class TestDoubleMatrix{
//1x1
DoubleMatrix matrix = new DoubleMatrix(grid1);
DoubleMatrix correctMatrix = new DoubleMatrix(new double[][]{{0.5}});
assertEquals("DoubleMatrix 1x1 failed getRow.", correctMatrix, matrix.getRow(0));
assertEquals(correctMatrix, matrix.getRow(0));
//Invalid gets
final DoubleMatrix testMatrix = new DoubleMatrix(matrix);
@@ -314,22 +315,22 @@ public class TestDoubleMatrix{
//2x2
matrix = new DoubleMatrix(grid2);
correctMatrix = new DoubleMatrix(new double[][]{{0.5, 1.5}});
assertEquals("DoubleMatrix 2x2 failed getRow.", correctMatrix, matrix.getRow(0));
assertEquals(correctMatrix, matrix.getRow(0));
//3x3
matrix = new DoubleMatrix(grid3);
correctMatrix = new DoubleMatrix(new double[][]{{0.5, 1.5, 2.5}});
assertEquals("DoubleMatrix 3x3 failed getRow.", correctMatrix, matrix.getRow(0));
assertEquals(correctMatrix, matrix.getRow(0));
//4x4
matrix = new DoubleMatrix(grid4);
correctMatrix = new DoubleMatrix(new double[][]{{0.5, 1.5, 2.5, 3.5}});
assertEquals("DoubleMatrix 4x4 failed getRow.", correctMatrix, matrix.getRow(0));
assertEquals(correctMatrix, matrix.getRow(0));
//10x10
matrix = new DoubleMatrix(grid10);
correctMatrix = new DoubleMatrix(new double[][]{{0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5}});
assertEquals("DoubleMatrix 10x10 failed getRow.", correctMatrix, matrix.getRow(0));
assertEquals(correctMatrix, matrix.getRow(0));
}
@Test
@@ -337,7 +338,7 @@ public class TestDoubleMatrix{
//1x1
DoubleMatrix matrix = new DoubleMatrix(grid1);
DoubleMatrix correctMatrix = new DoubleMatrix(new double[][]{{0.5}});
assertEquals("DoubleMatrix 1x1 failed getCol.", correctMatrix, matrix.getCol(0));
assertEquals(correctMatrix, matrix.getCol(0));
//Invalid gets
final DoubleMatrix testMatrix = new DoubleMatrix();
@@ -358,7 +359,7 @@ public class TestDoubleMatrix{
{0.5},
{0.5}
});
assertEquals("DoubleMatrix 2x2 failed getCol.", correctMatrix, matrix.getCol(0));
assertEquals(correctMatrix, matrix.getCol(0));
//3x3
matrix = new DoubleMatrix(grid3);
@@ -367,7 +368,7 @@ public class TestDoubleMatrix{
{0.5},
{0.5}
});
assertEquals("DoubleMatrix 3x3 failed getCol.", correctMatrix, matrix.getCol(0));
assertEquals(correctMatrix, matrix.getCol(0));
//4x4
matrix = new DoubleMatrix(grid4);
@@ -377,7 +378,7 @@ public class TestDoubleMatrix{
{0.5},
{0.5}
});
assertEquals("DoubleMatrix 4x4 failed getCol.", correctMatrix, matrix.getCol(0));
assertEquals(correctMatrix, matrix.getCol(0));
//10x10
matrix = new DoubleMatrix(grid10);
@@ -393,7 +394,7 @@ public class TestDoubleMatrix{
{0.5},
{0.5}
});
assertEquals("DoubleMatrix 10x10 failed getCol.", correctMatrix, matrix.getCol(0));
assertEquals(correctMatrix, matrix.getCol(0));
}
@Test
@@ -823,7 +824,7 @@ public class TestDoubleMatrix{
DoubleMatrix matrix = new DoubleMatrix(grid1);
DoubleMatrix secondMatrix = new DoubleMatrix(grid1);
DoubleMatrix correctMatrix = new DoubleMatrix(new double[][]{{0.5, 0.5}});
assertEquals("DoubleMatrix 1x1 failed appendRight.", correctMatrix, matrix.appendRight(secondMatrix));
assertEquals(correctMatrix, matrix.appendRight(secondMatrix));
//Invalid appends
final DoubleMatrix testMatrix = new DoubleMatrix(grid1);
@@ -842,7 +843,7 @@ public class TestDoubleMatrix{
{0.5, 1.5, 0.5, 1.5},
{0.5, 1.5, 0.5, 1.5}
});
assertEquals("DoubleMatrix 2x2 failed appendRight.", correctMatrix, matrix.appendRight(secondMatrix));
assertEquals(correctMatrix, matrix.appendRight(secondMatrix));
//3x3
matrix = new DoubleMatrix(grid3);
@@ -852,7 +853,7 @@ public class TestDoubleMatrix{
{0.5, 1.5, 2.5, 0.5, 1.5, 2.5},
{0.5, 1.5, 2.5, 0.5, 1.5, 2.5}
});
assertEquals("DoubleMatrix 3x3 failed appendRight.", correctMatrix, matrix.appendRight(secondMatrix));
assertEquals(correctMatrix, matrix.appendRight(secondMatrix));
//4x4
matrix = new DoubleMatrix(grid4);
@@ -863,7 +864,7 @@ public class TestDoubleMatrix{
{0.5, 1.5, 2.5, 3.5, 0.5, 1.5, 2.5, 3.5},
{0.5, 1.5, 2.5, 3.5, 0.5, 1.5, 2.5, 3.5}
});
assertEquals("DoubleMatrix 4x4 failed appendRight.", correctMatrix, matrix.appendRight(secondMatrix));
assertEquals(correctMatrix, matrix.appendRight(secondMatrix));
//10x10
matrix = new DoubleMatrix(grid10);
@@ -880,7 +881,7 @@ public class TestDoubleMatrix{
{0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5},
{0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5}
});
assertEquals("DoubleMatrix 10x10 failed appendRight.", correctMatrix, matrix.appendRight(secondMatrix));
assertEquals(correctMatrix, matrix.appendRight(secondMatrix));
}
@Test
@@ -892,7 +893,7 @@ public class TestDoubleMatrix{
{0.5},
{0.5}
});
assertEquals("DoubleMatrix 1x1 failed appendBottom.", correctMatrix, matrix.appendBottom(secondMatrix));
assertEquals(correctMatrix, matrix.appendBottom(secondMatrix));
//Invalid appends
final DoubleMatrix testMatrix = new DoubleMatrix(grid1);
@@ -913,7 +914,7 @@ public class TestDoubleMatrix{
{0.5, 1.5},
{0.5, 1.5}
});
assertEquals("DoubleMatrix 2x2 failed appendBottom.", correctMatrix, matrix.appendBottom(secondMatrix));
assertEquals(correctMatrix, matrix.appendBottom(secondMatrix));
//3x3
matrix = new DoubleMatrix(grid3);
@@ -926,7 +927,7 @@ public class TestDoubleMatrix{
{0.5, 1.5, 2.5},
{0.5, 1.5, 2.5}
});
assertEquals("DoubleMatrix 3x3 failed appendBottom.", correctMatrix, matrix.appendBottom(secondMatrix));
assertEquals(correctMatrix, matrix.appendBottom(secondMatrix));
//4x4
matrix = new DoubleMatrix(grid4);
@@ -941,7 +942,7 @@ public class TestDoubleMatrix{
{0.5, 1.5, 2.5, 3.5},
{0.5, 1.5, 2.5, 3.5}
});
assertEquals("DoubleMatrix 4x4 failed appendBottom.", correctMatrix, matrix.appendBottom(secondMatrix));
assertEquals(correctMatrix, matrix.appendBottom(secondMatrix));
//10x10
matrix = new DoubleMatrix(grid10);
@@ -958,7 +959,7 @@ public class TestDoubleMatrix{
{0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5}, {0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5},
{0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5}, {0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5}
});
assertEquals("DoubleMatrix 10x10 failed appendBottom.", correctMatrix, matrix.appendBottom(secondMatrix));
assertEquals(correctMatrix, matrix.appendBottom(secondMatrix));
}
@Test
@@ -979,8 +980,8 @@ public class TestDoubleMatrix{
DoubleMatrix matrix = new DoubleMatrix(grid1);
DoubleMatrix transformMatrix = new DoubleMatrix(transformGrid1_1);
DoubleMatrix correctMatrix = new DoubleMatrix(new double[][]{{1.0}});
assertEquals("DoubleMatrix 1x1 failed add DoubleMatrix.", correctMatrix, matrix.add(transformMatrix));
assertEquals("DoubleMatrix 1x1 failed add scalar.", correctMatrix, matrix.add(0.5));
assertEquals(correctMatrix, matrix.add(transformMatrix));
assertEquals(correctMatrix, matrix.add(0.5));
//Invalid adds
final DoubleMatrix testMatrix = new DoubleMatrix(grid1);
@@ -1000,12 +1001,12 @@ public class TestDoubleMatrix{
{1.0, 1.5},
{1.0, 1.5}
});
assertEquals("DoubleMatrix 1x1 failed add DoubleMatrix.", correctMatrix, matrix.add(transformMatrix));
assertEquals(correctMatrix, matrix.add(transformMatrix));
correctMatrix = new DoubleMatrix(new double[][]{
{1.0, 2.0},
{1.0, 2.0}
});
assertEquals("DoubleMatrix 2x2 failed add scalar.", correctMatrix, matrix.add(0.5));
assertEquals(correctMatrix, matrix.add(0.5));
//3x3
matrix = new DoubleMatrix(grid3);
@@ -1015,13 +1016,13 @@ public class TestDoubleMatrix{
{2.0, 2.0, 2.5},
{2.0, 2.0, 2.5}
});
assertEquals("DoubleMatrix 3x3 failed add DoubleMatrix.", correctMatrix, matrix.add(transformMatrix));
assertEquals(correctMatrix, matrix.add(transformMatrix));
correctMatrix = new DoubleMatrix(new double[][]{
{1.0, 2.0, 3.0},
{1.0, 2.0, 3.0},
{1.0, 2.0, 3.0}
});
assertEquals("DoubleMatrix 3x3 failed add scalar.", correctMatrix, matrix.add(0.5));
assertEquals(correctMatrix, matrix.add(0.5));
//4x4
matrix = new DoubleMatrix(grid4);
@@ -1032,14 +1033,14 @@ public class TestDoubleMatrix{
{3.0, 3.0, 3.0, 3.5},
{3.0, 3.0, 3.0, 3.5}
});
assertEquals("DoubleMatrix 4x4 failed add DoubleMatrix.", correctMatrix, matrix.add(transformMatrix));
assertEquals(correctMatrix, matrix.add(transformMatrix));
correctMatrix = new DoubleMatrix(new double[][]{
{1.0, 2.0, 3.0, 4.0},
{1.0, 2.0, 3.0, 4.0},
{1.0, 2.0, 3.0, 4.0},
{1.0, 2.0, 3.0, 4.0}
});
assertEquals("DoubleMatrix 4x4 failed add scalar.", correctMatrix, matrix.add(0.5));
assertEquals(correctMatrix, matrix.add(0.5));
//10x10
matrix = new DoubleMatrix(grid10);
@@ -1056,7 +1057,7 @@ public class TestDoubleMatrix{
{9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.5},
{9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.5}
});
assertEquals("DoubleMatrix 10x10 failed add DoubleMatrix.", correctMatrix, matrix.add(transformMatrix));
assertEquals(correctMatrix, matrix.add(transformMatrix));
correctMatrix = new DoubleMatrix(new double[][]{
{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0},
{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0},
@@ -1069,7 +1070,7 @@ public class TestDoubleMatrix{
{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0},
{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0}
});
assertEquals("DoubleMatrix 10x10 failed add scalar.", correctMatrix, matrix.add(0.5));
assertEquals(correctMatrix, matrix.add(0.5));
}
@Test
@@ -1078,8 +1079,8 @@ public class TestDoubleMatrix{
DoubleMatrix matrix = new DoubleMatrix(grid1);
DoubleMatrix transformMatrix = new DoubleMatrix(grid1);
DoubleMatrix correctMatrix = new DoubleMatrix(1, 1, 0);
assertEquals("DoubleMatrix 1x1 failed subtract DoubleMatrix.", correctMatrix, matrix.subtract(transformMatrix));
assertEquals("DoubleMatrix 1x1 failed subtract scalar.", correctMatrix, matrix.subtract(0.5));
assertEquals(correctMatrix, matrix.subtract(transformMatrix));
assertEquals(correctMatrix, matrix.subtract(0.5));
//Invalid subtracts
final DoubleMatrix testMatrix = new DoubleMatrix(grid1);
@@ -1096,43 +1097,43 @@ public class TestDoubleMatrix{
matrix = new DoubleMatrix(grid2);
transformMatrix = new DoubleMatrix(grid2);
correctMatrix = new DoubleMatrix(2, 2, 0);
assertEquals("DoubleMatrix 2x2 failed subtract DoubleMatrix.", correctMatrix, matrix.subtract(transformMatrix));
assertEquals(correctMatrix, matrix.subtract(transformMatrix));
correctMatrix = new DoubleMatrix(new double[][]{
{0.0, 1.0},
{0.0, 1.0}
});
assertEquals("DoubleMatrix 2x2 failed subtract scalar.", correctMatrix, matrix.subtract(0.5));
assertEquals(correctMatrix, matrix.subtract(0.5));
//3x3
matrix = new DoubleMatrix(grid3);
transformMatrix = new DoubleMatrix(grid3);
correctMatrix = new DoubleMatrix(3, 3, 0);
assertEquals("DoubleMatrix 3x3 failed subtract DoubleMatrix.", correctMatrix, matrix.subtract(transformMatrix));
assertEquals(correctMatrix, matrix.subtract(transformMatrix));
correctMatrix = new DoubleMatrix(new double[][]{
{0.0, 1.0, 2.0},
{0.0, 1.0, 2.0},
{0.0, 1.0, 2.0}
});
assertEquals("DoubleMatrix 3x3 failed subtract scalar.", correctMatrix, matrix.subtract(0.5));
assertEquals(correctMatrix, matrix.subtract(0.5));
//4x4
matrix = new DoubleMatrix(grid4);
transformMatrix = new DoubleMatrix(grid4);
correctMatrix = new DoubleMatrix(4, 4, 0);
assertEquals("DoubleMatrix 4x4 failed subtract DoubleMatrix.", correctMatrix, matrix.subtract(transformMatrix));
assertEquals(correctMatrix, matrix.subtract(transformMatrix));
correctMatrix = new DoubleMatrix(new double[][]{
{0.0, 1.0, 2.0, 3.0},
{0.0, 1.0, 2.0, 3.0},
{0.0, 1.0, 2.0, 3.0},
{0.0, 1.0, 2.0, 3.0}
});
assertEquals("DoubleMatrix 4x4 failed subtract scalar.", correctMatrix, matrix.subtract(0.5));
assertEquals(correctMatrix, matrix.subtract(0.5));
//10x10
matrix = new DoubleMatrix(grid10);
transformMatrix = new DoubleMatrix(grid10);
correctMatrix = new DoubleMatrix(10, 10, 0);
assertEquals("DoubleMatrix 10x10 failed subtract DoubleMatrix.", correctMatrix, matrix.subtract(transformMatrix));
assertEquals(correctMatrix, matrix.subtract(transformMatrix));
correctMatrix = new DoubleMatrix(new double[][]{
{0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0},
{0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0},
@@ -1145,7 +1146,7 @@ public class TestDoubleMatrix{
{0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0},
{0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0}
});
assertEquals("DoubleMatrix 10x10 failed subtract scalar.", correctMatrix, matrix.subtract(0.5));
assertEquals(correctMatrix, matrix.subtract(0.5));
}
@Test
@@ -1154,9 +1155,9 @@ public class TestDoubleMatrix{
DoubleMatrix matrix = new DoubleMatrix(grid1);
DoubleMatrix transformMatrix = new DoubleMatrix(transformGrid1_2);
DoubleMatrix correctMatrix = new DoubleMatrix(new double[][]{{0.75}});
assertEquals("DoubleMatrix 1x1 failed multiplication DoubleMatrix.", correctMatrix, matrix.multiply(transformMatrix));
assertEquals(correctMatrix, matrix.multiply(transformMatrix));
correctMatrix = new DoubleMatrix(new double[][]{{1.0}});
assertEquals("DoubleMatrix 1x1 failed multiplication scalar.", correctMatrix, matrix.multiply(2.0));
assertEquals(correctMatrix, matrix.multiply(2.0));
//Invalid multiplication
final DoubleMatrix testMatrix = new DoubleMatrix(grid1);
@@ -1172,7 +1173,7 @@ public class TestDoubleMatrix{
{3.0, 5.0},
{3.0, 5.0}
});
assertEquals("DoubleMatrix 2x2 failed multiplication DoubleMatrix.", correctMatrix, matrix.multiply(transformMatrix));
assertEquals(correctMatrix, matrix.multiply(transformMatrix));
DoubleMatrix vector = new DoubleMatrix(new double[][]{
{1.5},
{2.5}
@@ -1181,12 +1182,12 @@ public class TestDoubleMatrix{
{4.5},
{4.5}
});
assertEquals("DoubleMatrix 2x2 failed multiplication vector.", correctMatrix, matrix.multiply(vector));
assertEquals(correctMatrix, matrix.multiply(vector));
correctMatrix = new DoubleMatrix(new double[][]{
{1.0, 3.0},
{1.0, 3.0}
});
assertEquals("DoubleMatrix 2x2 failed multiplication scalar.", correctMatrix, matrix.multiply(2.0));
assertEquals(correctMatrix, matrix.multiply(2.0));
//3x3
matrix = new DoubleMatrix(grid3);
@@ -1196,7 +1197,7 @@ public class TestDoubleMatrix{
{6.75, 11.25, 15.75},
{6.75, 11.25, 15.75}
});
assertEquals("DoubleMatrix 3x3 failed multiplication DoubleMatrix.", correctMatrix, matrix.multiply(transformMatrix));
assertEquals(correctMatrix, matrix.multiply(transformMatrix));
vector = new DoubleMatrix(new double[][]{
{1.5},
{2.5},
@@ -1207,13 +1208,13 @@ public class TestDoubleMatrix{
{13.25},
{13.25}
});
assertEquals("DoubleMatrix 3x3 failed multiplication vector.", correctMatrix, matrix.multiply(vector));
assertEquals(correctMatrix, matrix.multiply(vector));
correctMatrix = new DoubleMatrix(new double[][]{
{1.0, 3.0, 5.0},
{1.0, 3.0, 5.0},
{1.0, 3.0, 5.0}
});
assertEquals("DoubleMatrix 3x3 failed multiplication vector.", correctMatrix, matrix.multiply(2.0));
assertEquals(correctMatrix, matrix.multiply(2.0));
//4x4
matrix = new DoubleMatrix(grid4);
@@ -1224,7 +1225,7 @@ public class TestDoubleMatrix{
{20, 12, 4, 0},
{20, 12, 4, 0}
});
assertEquals("DoubleMatrix 4x4 failed multiplication DoubleMatrix.", correctMatrix, matrix.multiply(transformMatrix));
assertEquals(correctMatrix, matrix.multiply(transformMatrix));
vector = new DoubleMatrix(new double[][]{
{2.5},
{1.5},
@@ -1237,14 +1238,14 @@ public class TestDoubleMatrix{
{4.75},
{4.75}
});
assertEquals("DoubleMatrix 4x4 failed multiplication vector.", correctMatrix, matrix.multiply(vector));
assertEquals(correctMatrix, matrix.multiply(vector));
correctMatrix = new DoubleMatrix(new double[][]{
{1.0, 3.0, 5.0, 7.0},
{1.0, 3.0, 5.0, 7.0},
{1.0, 3.0, 5.0, 7.0},
{1.0, 3.0, 5.0, 7.0}
});
assertEquals("DoubleMatrix 4x4 failed multiplication scalar.", correctMatrix, matrix.multiply(2.0));
assertEquals(correctMatrix, matrix.multiply(2.0));
//10x10
matrix = new DoubleMatrix(grid10);
@@ -1261,7 +1262,7 @@ public class TestDoubleMatrix{
{75, 125, 175, 225, 275, 325, 375, 425, 475, 525},
{75, 125, 175, 225, 275, 325, 375, 425, 475, 525}
});
assertEquals("DoubleMatrix 10x10 failed multiplication DoubleMatrix.", correctMatrix, matrix.multiply(transformMatrix));
assertEquals(correctMatrix, matrix.multiply(transformMatrix));
vector = new DoubleMatrix(new double[][]{
{1.5},
{2.5},
@@ -1286,7 +1287,7 @@ public class TestDoubleMatrix{
{382.5},
{382.5}
});
assertEquals("DoubleMatrix 10x10 failed multiplication vector.", correctMatrix, matrix.multiply(vector));
assertEquals(correctMatrix, matrix.multiply(vector));
correctMatrix = new DoubleMatrix(new double[][]{
{1.0, 3.0, 5.0, 7.0, 9.0, 11.0, 13.0, 15.0, 17.0, 19.0},
{1.0, 3.0, 5.0, 7.0, 9.0, 11.0, 13.0, 15.0, 17.0, 19.0},
@@ -1299,7 +1300,7 @@ public class TestDoubleMatrix{
{1.0, 3.0, 5.0, 7.0, 9.0, 11.0, 13.0, 15.0, 17.0, 19.0},
{1.0, 3.0, 5.0, 7.0, 9.0, 11.0, 13.0, 15.0, 17.0, 19.0}
});
assertEquals("DoubleMatrix 10x10 failed multiplication scalar.", correctMatrix, matrix.multiply(2.0));
assertEquals(correctMatrix, matrix.multiply(2.0));
}
@Test
@@ -1307,7 +1308,7 @@ public class TestDoubleMatrix{
//1x1
DoubleMatrix matrix = new DoubleMatrix(grid1);
DoubleMatrix transformMatrix = new DoubleMatrix(transformGrid1_2);
assertEquals("DoubleMatrix 1x1 failed dot product DoubleMatrix.", 0.75, matrix.dotProduct(transformMatrix), 0.0000001);
assertEquals(0.75, matrix.dotProduct(transformMatrix), 0.0000001);
//Invalid products
DoubleMatrix testMatrix = new DoubleMatrix(grid1);
@@ -1319,22 +1320,22 @@ public class TestDoubleMatrix{
//2x2
matrix = new DoubleMatrix(grid2);
transformMatrix = new DoubleMatrix(transformGrid2_2);
assertEquals("DoubleMatrix 2x2 failed dot product DoubleMatrix.", 16, matrix.dotProduct(transformMatrix), 0.0000001);
assertEquals(16, matrix.dotProduct(transformMatrix), 0.0000001);
//3x3
matrix = new DoubleMatrix(grid3);
transformMatrix = new DoubleMatrix(transformGrid3_2);
assertEquals("DoubleMatrix 3x3 failed dot product DoubleMatrix.", 101.25, matrix.dotProduct(transformMatrix), 0.0000001);
assertEquals(101.25, matrix.dotProduct(transformMatrix), 0.0000001);
//4x4
matrix = new DoubleMatrix(grid4);
transformMatrix = new DoubleMatrix(transformGrid4_2);
assertEquals("DoubleMatrix 4x4 failed dot product DoubleMatrix.", 144, matrix.dotProduct(transformMatrix), 0.0000001);
assertEquals(144, matrix.dotProduct(transformMatrix), 0.0000001);
//10x10
matrix = new DoubleMatrix(grid10);
transformMatrix = new DoubleMatrix(transformGrid10_2);
assertEquals("DoubleMatrix 10x10 failed dot product DoubleMatrix.", 30000, matrix.dotProduct(transformMatrix), 0.0000001);
assertEquals(30000, matrix.dotProduct(transformMatrix), 0.0000001);
}
@Test
@@ -1343,7 +1344,7 @@ public class TestDoubleMatrix{
DoubleMatrix matrix = new DoubleMatrix(grid1);
DoubleMatrix transformMatrix = new DoubleMatrix(transformGrid1_2);
DoubleMatrix correctMatrix = new DoubleMatrix(new double[][]{{0.75}});
assertEquals("DoubleMatrix 1x1 failed hadamard product.", correctMatrix, matrix.hadamardProduct(transformMatrix));
assertEquals(correctMatrix, matrix.hadamardProduct(transformMatrix));
//Invalid hadamard products
DoubleMatrix testMatrix = new DoubleMatrix(grid1);
@@ -1363,7 +1364,7 @@ public class TestDoubleMatrix{
{0.75, 3.75},
{0.75, 3.75}
});
assertEquals("DoubleMatrix 2x2 failed hadamard product.", correctMatrix, matrix.hadamardProduct(transformMatrix));
assertEquals(correctMatrix, matrix.hadamardProduct(transformMatrix));
//3x3
matrix = new DoubleMatrix(grid3);
@@ -1373,7 +1374,7 @@ public class TestDoubleMatrix{
{0.75, 3.75, 8.75},
{0.75, 3.75, 8.75}
});
assertEquals("DoubleMatrix 3x3 failed hadamard product.", correctMatrix, matrix.hadamardProduct(transformMatrix));
assertEquals(correctMatrix, matrix.hadamardProduct(transformMatrix));
//4x4
matrix = new DoubleMatrix(grid4);
@@ -1384,7 +1385,7 @@ public class TestDoubleMatrix{
{1.25, 2.25, 1.25, 0},
{1.25, 2.25, 1.25, 0}
});
assertEquals("DoubleMatrix 4x4 failed hadamard product.", correctMatrix, matrix.hadamardProduct(transformMatrix));
assertEquals(correctMatrix, matrix.hadamardProduct(transformMatrix));
//10x10
matrix = new DoubleMatrix(grid10);
@@ -1401,7 +1402,7 @@ public class TestDoubleMatrix{
{0.75, 3.75, 8.75, 15.75, 24.75, 35.75, 48.75, 63.75, 80.75, 99.75},
{0.75, 3.75, 8.75, 15.75, 24.75, 35.75, 48.75, 63.75, 80.75, 99.75}
});
assertEquals("DoubleMatrix 10x10 failed hadamard product.", correctMatrix, matrix.hadamardProduct(transformMatrix));
assertEquals(correctMatrix, matrix.hadamardProduct(transformMatrix));
}
@Test
@@ -1409,7 +1410,7 @@ public class TestDoubleMatrix{
//1x1
DoubleMatrix matrix = new DoubleMatrix(grid1);
DoubleMatrix correctMatrix = new DoubleMatrix(new double[][]{{0.5}});
assertEquals("DoubleMatrix 1x1 failed transpose.", correctMatrix, matrix.transpose());
assertEquals(correctMatrix, matrix.transpose());
//2x2
matrix = new DoubleMatrix(grid2);
@@ -1417,7 +1418,7 @@ public class TestDoubleMatrix{
{0.5, 0.5},
{1.5, 1.5}
});
assertEquals("DoubleMatrix 2x2 failed transpose.", correctMatrix, matrix.transpose());
assertEquals(correctMatrix, matrix.transpose());
//3x3
matrix = new DoubleMatrix(grid3);
@@ -1426,7 +1427,7 @@ public class TestDoubleMatrix{
{1.5, 1.5, 1.5},
{2.5, 2.5, 2.5}
});
assertEquals("DoubleMatrix 3x3 failed transpose.", correctMatrix, matrix.transpose());
assertEquals(correctMatrix, matrix.transpose());
//4x4
matrix = new DoubleMatrix(grid4);
@@ -1436,7 +1437,7 @@ public class TestDoubleMatrix{
{2.5, 2.5, 2.5, 2.5},
{3.5, 3.5, 3.5, 3.5}
});
assertEquals("DoubleMatrix 4x4 failed transpose.", correctMatrix, matrix.transpose());
assertEquals(correctMatrix, matrix.transpose());
//10x10
matrix = new DoubleMatrix(grid10);
@@ -1452,14 +1453,14 @@ public class TestDoubleMatrix{
{8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 8.5},
{9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5}
});
assertEquals("DoubleMatrix 10x10 failed transpose.", correctMatrix, matrix.transpose());
assertEquals(correctMatrix, matrix.transpose());
}
@Test
public void testDeterminant(){
//1x1
DoubleMatrix matrix = new DoubleMatrix(grid1);
assertEquals("DoubleMatrix 1x1 failed determinant.", 0.5, matrix.determinant(), 0.0000001);
assertEquals(0.5, matrix.determinant(), 0.0000001);
//Invalid determinants
DoubleMatrix testMatrix = new DoubleMatrix(new double[][]{{0.0, 0.0}});
@@ -1469,35 +1470,35 @@ public class TestDoubleMatrix{
//2x2
matrix = new DoubleMatrix(grid2);
assertEquals("IntegerMatrix 2x2 failed determinant1.", 0, matrix.determinant(), 0.0000001);
assertEquals(0, matrix.determinant(), 0.0000001);
matrix = new DoubleMatrix(new double[][]{
{0.5, 3.5},
{3.5, 0.5}
});
assertEquals("DoubleMatrix 2x2 failed determinant2.", -12.0, matrix.determinant(), 0.0000001);
assertEquals(-12.0, matrix.determinant(), 0.0000001);
//det
assertEquals(matrix.determinant(), matrix.det(), 0.0000001);
//3x3
matrix = new DoubleMatrix(grid3);
assertEquals("IntegerMatrix 3x3 failed determinant1.", 0, matrix.determinant(), 0.0000001);
assertEquals(0, matrix.determinant(), 0.0000001);
matrix = new DoubleMatrix(new double[][]{
{0.5, 1.5, 2.5},
{1.5, 2.5, 0.5},
{2.5, 0.5, 1.5}
});
assertEquals("DoubleMatrix 3x3 failed determinant2.", -13.5, matrix.determinant(), 0.0000001);
assertEquals(-13.5, matrix.determinant(), 0.0000001);
//4x4
matrix = new DoubleMatrix(grid4);
assertEquals("DoubleMatrix 4x4 failed determinant1.", 0, matrix.determinant(), 0.0000001);
assertEquals(0, matrix.determinant(), 0.0000001);
matrix = new DoubleMatrix(new double[][]{
{0.5, 1.5, 2.5, 3.5},
{1.5, 2.5, 3.5, 0.5},
{2.5, 3.5, 0.5, 1.5},
{3.5, 0.5, 1.5, 2.5}
});
assertEquals("DoubleMatrix 4x4 failed determinant2.", 128.0, matrix.determinant(), 0.0000001);
assertEquals(128.0, matrix.determinant(), 0.0000001);
//Column
matrix = new DoubleMatrix(new double[][]{
{0.5, 1.5, 2.5, 3.5},
@@ -1517,7 +1518,7 @@ public class TestDoubleMatrix{
//10x10
matrix = new DoubleMatrix(grid10);
assertEquals("DoubleMatrix 10x10 failed determinant1.", 0, matrix.determinant(), 0.0000001);
assertEquals(0, matrix.determinant(), 0.0000001);
matrix = new DoubleMatrix(new double[][]{
{0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5},
{1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 0.5},
@@ -1530,7 +1531,7 @@ public class TestDoubleMatrix{
{8.5, 9.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5},
{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0},
});
assertEquals("DoubleMatrix 10x10 failed determinatn2.", -10000000.0, matrix.determinant(), 0.0000001);
assertEquals(-10000000.0, matrix.determinant(), 0.0000001);
}
@Test
@@ -1538,7 +1539,7 @@ public class TestDoubleMatrix{
//1x1
DoubleMatrix matrix = new DoubleMatrix(grid1);
DoubleMatrix correctMatrix = new DoubleMatrix(new double[][]{{1}});
assertEquals("DoubleMatrix 1x1 failed cofactor.", correctMatrix, matrix.cofactor());
assertEquals(correctMatrix, matrix.cofactor());
//Invalid cofactor
DoubleMatrix testMatrix = new DoubleMatrix(new double[][]{{0.0, 0.0}});
@@ -1552,14 +1553,14 @@ public class TestDoubleMatrix{
{1.5, -0.5},
{-1.5, 0.5}
});
assertEquals("DoubleMatrix 2x2 failed cofactor.", correctMatrix, matrix.cofactor());
assertEquals(correctMatrix, matrix.cofactor());
//cof
assertEquals(matrix.cofactor(), matrix.cof());
//3x3
matrix = new DoubleMatrix(grid3);
correctMatrix = new DoubleMatrix(3, 3, 0);
assertEquals("DoubleMatrix 3x3 failed cofactor1.", correctMatrix, matrix.cofactor());
assertEquals(correctMatrix, matrix.cofactor());
matrix = new DoubleMatrix(new double[][]{
{0.5, 1.5, 2.5},
{1.5, 2.5, 0.5},
@@ -1570,12 +1571,12 @@ public class TestDoubleMatrix{
{-1, -5.5, 3.5},
{-5.5, 3.5, -1}
});
assertEquals("DoubleMatrix 3x3 failed cofactor2.", correctMatrix, matrix.cofactor());
assertEquals(correctMatrix, matrix.cofactor());
//4x4
matrix = new DoubleMatrix(grid4);
correctMatrix = new DoubleMatrix(4, 4, 0);
assertEquals("DoubleMatrix 4x4 failed cofactor1.", correctMatrix, matrix.cofactor());
assertEquals(correctMatrix, matrix.cofactor());
matrix = new DoubleMatrix(new double[][]{
{0.5, 1.5, 2.5, 3.5},
{1.5, 2.5, 3.5, 0.5},
@@ -1588,14 +1589,14 @@ public class TestDoubleMatrix{
{4, 36, -28, 4},
{36, -28, 4, 4}
});
assertEquals("DoubleMatrix 4x4 failed cofactor2.", correctMatrix, matrix.cofactor());
assertEquals(correctMatrix, matrix.cofactor());
//10x10
//?Skipping 10x10 test because test took > 5s by itself
/*
matrix = new DoubleMatrix(grid10);
correctMatrix = new DoubleMatrix(10, 10, 0);
assertEquals("DoubleMatrix 10x10 failed cofactor1.", correctMatrix, matrix.cofactor());
assertEquals(correctMatrix, matrix.cofactor());
*/
}
@@ -1604,7 +1605,7 @@ public class TestDoubleMatrix{
//1x1
DoubleMatrix matrix = new DoubleMatrix(grid1);
DoubleMatrix correctMatrix = new DoubleMatrix(new double[][]{{0.125}});
assertEquals("DoubleMatrix 1x1 failed power.", correctMatrix, matrix.pow(3));
assertEquals(correctMatrix, matrix.pow(3));
//Invalid powers
final DoubleMatrix testMatrix = new DoubleMatrix(new double[][]{{0.0}, {0.0}});
@@ -1622,7 +1623,7 @@ public class TestDoubleMatrix{
{2, 6},
{2, 6}
});
assertEquals("DoubleMatrix 2x2 failed power.", correctMatrix, matrix.pow(3));
assertEquals(correctMatrix, matrix.pow(3));
//3x3
matrix = new DoubleMatrix(grid3);
@@ -1631,7 +1632,7 @@ public class TestDoubleMatrix{
{10.125, 30.375, 50.625},
{10.125, 30.375, 50.625}
});
assertEquals("DoubleMatrix 3x3 failed power.", correctMatrix, matrix.pow(3));
assertEquals(correctMatrix, matrix.pow(3));
//4x4
//0
@@ -1658,7 +1659,7 @@ public class TestDoubleMatrix{
{32.0, 96.0, 160.0, 224.0},
{32.0, 96.0, 160.0, 224.0}
});
assertEquals("DoubleMatrix 4x4 failed power.", correctMatrix, matrix.pow(3));
assertEquals(correctMatrix, matrix.pow(3));
//10x10
matrix = new DoubleMatrix(grid10);
@@ -1674,7 +1675,7 @@ public class TestDoubleMatrix{
{1250, 3750, 6250, 8750, 11250, 13750, 16250, 18750, 21250, 23750},
{1250, 3750, 6250, 8750, 11250, 13750, 16250, 18750, 21250, 23750}
});
assertEquals("DoubleMatrix 10x10 failed power.", correctMatrix, matrix.pow(3));
assertEquals(correctMatrix, matrix.pow(3));
}
@Test
@@ -1682,7 +1683,7 @@ public class TestDoubleMatrix{
//1x1
DoubleMatrix matrix = new DoubleMatrix(grid1);
DoubleMatrix correctMatrix = new DoubleMatrix(new double[][]{{1.0}});
assertEquals("DoubleMatrix 1x1 failed adjoint.", correctMatrix, matrix.adjoint());
assertEquals(correctMatrix, matrix.adjoint());
//2x2
matrix = new DoubleMatrix(grid2);
@@ -1690,14 +1691,14 @@ public class TestDoubleMatrix{
{1.5, -1.5},
{-0.5, 0.5}
});
assertEquals("DoubleMatrix 2x2 failed adjoint.", correctMatrix, matrix.adjoint());
assertEquals(correctMatrix, matrix.adjoint());
//adj
assertEquals(matrix.adjoint(), matrix.adj());
//3x3
matrix = new DoubleMatrix(grid3);
correctMatrix = new DoubleMatrix(3, 3, 0);
assertEquals("DoubleMatrix 3x3 failed adjoint.", correctMatrix, matrix.adjoint());
assertEquals(correctMatrix, matrix.adjoint());
//4x4
matrix = new DoubleMatrix(new double[][]{
@@ -1712,14 +1713,14 @@ public class TestDoubleMatrix{
{4, 36, -28, 4},
{36, -28, 4, 4}
});
assertEquals("DoubleMatrix 4x4 failed adjoint.", correctMatrix, matrix.adjoint());
assertEquals(correctMatrix, matrix.adjoint());
//10x10
//?Skippng 10x10 test because test took > 5s by itself
/*
matrix = new DoubleMatrix(grid10);
correctMatrix = new DoubleMatrix(10, 10, 0);
assertEquals("DoubleMatrix 10x10 failed adjoint.", correctMatrix, matrix.adjoint());
assertEquals(correctMatrix, matrix.adjoint());
*/
}
@@ -1728,7 +1729,7 @@ public class TestDoubleMatrix{
//1x1
DoubleMatrix matrix = new DoubleMatrix(grid1);
DoubleMatrix correctMatrix = new DoubleMatrix(new double[][]{{2.0}});
assertEquals("DoubleMatrix 1x1 failed inverse.", correctMatrix, matrix.inverse());
assertEquals(correctMatrix, matrix.inverse());
//Invalid inverse
DoubleMatrix testMatrix = new DoubleMatrix(new double[][]{{0.0, 0.0}});
@@ -1753,7 +1754,7 @@ public class TestDoubleMatrix{
{-0.25, 0.75},
{0.75, -0.25}
});
assertEquals("DoubleMatrix 2x2 failed inverse.", correctMatrix, matrix.inverse());
assertEquals(correctMatrix, matrix.inverse());
//3x3
matrix = new DoubleMatrix(new double[][]{
@@ -1766,7 +1767,7 @@ public class TestDoubleMatrix{
{2.0/27.0, 11.0/27.0, -7.0/27.0},
{11.0/27.0, -7.0/27.0, 2.0/27.0}
});
assertEquals("DoubleMatrix 3x3 failed inverse.", correctMatrix, matrix.inverse());
assertEquals(correctMatrix, matrix.inverse());
//4x4
matrix = new DoubleMatrix(new double[][]{
@@ -1781,7 +1782,7 @@ public class TestDoubleMatrix{
{0.03125, 0.28125, -0.21875, 0.03125},
{0.28125, -0.21875, 0.03125, 0.03125}
});
assertEquals("DoubleMatrix 4x4 failed inverse.", correctMatrix, matrix.inverse());
assertEquals(correctMatrix, matrix.inverse());
//10x10
//?Skipped 10x10 because it would take a long time to compute