mirror of
https://bitbucket.org/Mattrixwv/matrix.git
synced 2025-12-06 15:03:58 -05:00
Merge branch 'Matthew-Ellison/created-modmatrix-class-1644445517486' into develop
This commit is contained in:
369
src/main/java/com/mattrixwv/matrix/ModMatrix.java
Normal file
369
src/main/java/com/mattrixwv/matrix/ModMatrix.java
Normal file
@@ -0,0 +1,369 @@
|
||||
//Matrix/src/main/java/com/mattrixwv/matrix/ModMatrix.java
|
||||
//Mattrixwv
|
||||
// Created: 02-09-22
|
||||
//Modified: 02-09-22
|
||||
package com.mattrixwv.matrix;
|
||||
|
||||
|
||||
import com.mattrixwv.matrix.exceptions.InvalidGeometryException;
|
||||
import com.mattrixwv.matrix.exceptions.InvalidScalarException;
|
||||
|
||||
|
||||
public class ModMatrix extends IntegerMatrix{
|
||||
protected int mod;
|
||||
|
||||
//Helper functions
|
||||
protected void setMod(int mod){
|
||||
if(mod <= 0){
|
||||
throw new InvalidScalarException("The mod must be > 0");
|
||||
}
|
||||
|
||||
this.mod = mod;
|
||||
}
|
||||
protected int modValue(int value){
|
||||
int newValue = value % mod;
|
||||
|
||||
if(newValue < 0){
|
||||
newValue += mod;
|
||||
}
|
||||
|
||||
return newValue;
|
||||
}
|
||||
protected int[] modValues(int[] values){
|
||||
int[] newValues = new int[values.length];
|
||||
|
||||
for(int cnt = 0;cnt < values.length;++cnt){
|
||||
newValues[cnt] = modValue(values[cnt]);
|
||||
}
|
||||
|
||||
return newValues;
|
||||
}
|
||||
protected void modGrid(){
|
||||
for(int row = 0;row < getNumRows();++row){
|
||||
for(int col = 0;col < getNumCols();++col){
|
||||
grid[row][col] = modValue(grid[row][col]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void setGrid(int[][] grid){
|
||||
super.setGrid(grid);
|
||||
modGrid();
|
||||
}
|
||||
|
||||
//Constructors
|
||||
public ModMatrix(int mod){
|
||||
super();
|
||||
setMod(mod);
|
||||
modGrid();
|
||||
}
|
||||
public ModMatrix(int[][] grid, int mod){
|
||||
super();
|
||||
setMod(mod);
|
||||
setGrid(grid);
|
||||
}
|
||||
public ModMatrix(ModMatrix matrix){
|
||||
super();
|
||||
setMod(matrix.mod);
|
||||
setGrid(matrix.grid);
|
||||
}
|
||||
public ModMatrix(IntegerMatrix matrix, int mod){
|
||||
super();
|
||||
setMod(mod);
|
||||
setGrid(matrix.grid);
|
||||
}
|
||||
public ModMatrix(int rows, int cols, int fill, int mod){
|
||||
super(rows, cols, fill);
|
||||
setMod(mod);
|
||||
modGrid();
|
||||
}
|
||||
|
||||
//Gets
|
||||
public int getMod(){
|
||||
return mod;
|
||||
}
|
||||
@Override
|
||||
public ModMatrix getRow(int row){
|
||||
return new ModMatrix(super.getRow(row), mod);
|
||||
}
|
||||
@Override
|
||||
public ModMatrix getCol(int col){
|
||||
return new ModMatrix(super.getCol(col), mod);
|
||||
}
|
||||
//Sets
|
||||
@Override
|
||||
public void set(int row, int col, int value){
|
||||
super.set(row, col, modValue(value));
|
||||
}
|
||||
@Override
|
||||
public void setRow(int row, int[] elements){
|
||||
super.setRow(row, modValues(elements));
|
||||
}
|
||||
@Override
|
||||
public void setRow(int row, IntegerMatrix matrix){
|
||||
setRow(row, new ModMatrix(matrix, Integer.MAX_VALUE));
|
||||
}
|
||||
public void setRow(int row, ModMatrix matrix){
|
||||
super.setRow(row, matrix);
|
||||
modGrid();
|
||||
}
|
||||
@Override
|
||||
public void setCol(int col, int[] elements){
|
||||
super.setCol(col, elements);
|
||||
modGrid();
|
||||
}
|
||||
@Override
|
||||
public void setCol(int col, IntegerMatrix matrix){
|
||||
setCol(col, new ModMatrix(matrix, Integer.MAX_VALUE));
|
||||
}
|
||||
public void setCol(int col, ModMatrix matrix){
|
||||
super.setCol(col, matrix);
|
||||
modGrid();
|
||||
}
|
||||
//Adds
|
||||
@Override
|
||||
public void addRow(int[] elements){
|
||||
super.addRow(modValues(elements));
|
||||
}
|
||||
@Override
|
||||
public void addRow(IntegerMatrix matrix){
|
||||
addRow(new ModMatrix(matrix, Integer.MAX_VALUE));
|
||||
}
|
||||
public void addRow(ModMatrix matrix){
|
||||
super.addRow(matrix);
|
||||
modGrid();
|
||||
}
|
||||
@Override
|
||||
public void addCol(int[] elements){
|
||||
super.addCol(modValues(elements));
|
||||
}
|
||||
@Override
|
||||
public void addCol(IntegerMatrix matrix){
|
||||
addCol(new ModMatrix(matrix, Integer.MAX_VALUE));
|
||||
}
|
||||
public void addCol(ModMatrix matrix){
|
||||
super.addCol(matrix);
|
||||
modGrid();
|
||||
}
|
||||
@Override
|
||||
public ModMatrix appendRight(IntegerMatrix rightSide){
|
||||
return appendRight(new ModMatrix(rightSide, Integer.MAX_VALUE));
|
||||
}
|
||||
public ModMatrix appendRight(ModMatrix rightSide){
|
||||
return new ModMatrix(super.appendRight(rightSide), mod);
|
||||
}
|
||||
@Override
|
||||
public ModMatrix appendBottom(IntegerMatrix rightSide){
|
||||
return appendBottom(new ModMatrix(rightSide, Integer.MAX_VALUE));
|
||||
}
|
||||
public ModMatrix appendBottom(ModMatrix rightSide){
|
||||
return new ModMatrix(super.appendBottom(rightSide), mod);
|
||||
}
|
||||
|
||||
//Simple operations
|
||||
public static ModMatrix generateIdentity(int size){
|
||||
return generateIdentity(size, Integer.MAX_VALUE);
|
||||
}
|
||||
public static ModMatrix generateIdentity(int size, int mod){
|
||||
return new ModMatrix(IntegerMatrix.generateIdentity(size), mod);
|
||||
}
|
||||
@Override
|
||||
public ModMatrix add(IntegerMatrix rightSide){
|
||||
return add(new ModMatrix(rightSide, Integer.MAX_VALUE));
|
||||
}
|
||||
public ModMatrix add(ModMatrix rightSide){
|
||||
return new ModMatrix(super.add(rightSide), mod);
|
||||
}
|
||||
@Override
|
||||
public ModMatrix add(int scalar){
|
||||
return new ModMatrix(super.add(scalar), mod);
|
||||
}
|
||||
@Override
|
||||
public ModMatrix subtract(IntegerMatrix rightSide){
|
||||
return subtract(new ModMatrix(rightSide, Integer.MAX_VALUE));
|
||||
}
|
||||
public ModMatrix subtract(ModMatrix rightSide){
|
||||
return new ModMatrix(super.subtract(rightSide), mod);
|
||||
}
|
||||
@Override
|
||||
public ModMatrix subtract(int scalar){
|
||||
return new ModMatrix(super.subtract(scalar), mod);
|
||||
}
|
||||
@Override
|
||||
public ModMatrix multiply(IntegerMatrix matrix){
|
||||
return multiply(new ModMatrix(matrix, Integer.MAX_VALUE));
|
||||
}
|
||||
public ModMatrix multiply(ModMatrix matrix){
|
||||
return new ModMatrix(super.multiply(matrix), mod);
|
||||
}
|
||||
@Override
|
||||
public ModMatrix multiply(int scalar){
|
||||
return new ModMatrix(super.multiply(scalar), mod);
|
||||
}
|
||||
@Override
|
||||
public ModMatrix pow(int power){
|
||||
//Make sure the matrix is square so it can be multiplied
|
||||
if(!isSquare()){
|
||||
throw new InvalidGeometryException("The matrix must be square to raise it to a power");
|
||||
}
|
||||
//Make sure the power is positive
|
||||
if(power < 0){
|
||||
throw new InvalidScalarException("The power must be >= 0");
|
||||
}
|
||||
else if(power == 0){
|
||||
return new ModMatrix(getNumRows(), getNumCols(), 1, mod);
|
||||
}
|
||||
|
||||
//Create a new matrix for the product
|
||||
ModMatrix newMatrix = clone();
|
||||
//Multiply the current grid power times
|
||||
for(int currentPower = 1;currentPower < power;++currentPower){
|
||||
newMatrix = newMatrix.multiply(this);
|
||||
}
|
||||
|
||||
//Return the new grid
|
||||
return newMatrix;
|
||||
}
|
||||
@Override
|
||||
public int dotProduct(IntegerMatrix rightSide){
|
||||
return dotProduct(new ModMatrix(rightSide, Integer.MAX_VALUE));
|
||||
}
|
||||
public int dotProduct(ModMatrix rightSide){
|
||||
return super.dotProduct(rightSide);
|
||||
}
|
||||
@Override
|
||||
public ModMatrix hadamardProduct(IntegerMatrix rightSide){
|
||||
return hadamardProduct(new ModMatrix(rightSide, Integer.MAX_VALUE));
|
||||
}
|
||||
public ModMatrix hadamardProduct(ModMatrix rightSide){
|
||||
return new ModMatrix(super.hadamardProduct(rightSide), mod);
|
||||
}
|
||||
|
||||
//Complex operations
|
||||
@Override
|
||||
public ModMatrix transpose(){
|
||||
return new ModMatrix(super.transpose(), mod);
|
||||
}
|
||||
@Override
|
||||
public int det(){
|
||||
return determinant();
|
||||
}
|
||||
@Override
|
||||
public int determinant(){
|
||||
return super.determinant();
|
||||
}
|
||||
@Override
|
||||
public ModMatrix cof(){
|
||||
return cofactor();
|
||||
}
|
||||
@Override
|
||||
public ModMatrix cofactor(){
|
||||
//Make sure the matrix is square
|
||||
if(!isSquare()){
|
||||
throw new InvalidGeometryException("A matrix must be square to find the cofactor matrix");
|
||||
}
|
||||
|
||||
//Create a new grid
|
||||
int[][] newGrid = new int[getNumRows()][getNumCols()];
|
||||
//If the grid is 1x1 return the grid
|
||||
if(getNumRows() == 1){
|
||||
newGrid[0][0] = 1;
|
||||
}
|
||||
//Use the formula to find the cofactor matrix
|
||||
else{
|
||||
for(int row = 0;row < getNumRows();++row){
|
||||
int multiplier = ((row % 2) == 0) ? 1 : -1;
|
||||
for(int col = 0;col < getNumCols();++col){
|
||||
newGrid[row][col] = multiplier * laplaceExpansionHelper(row, col).determinant();
|
||||
multiplier = -multiplier;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Return the new matrix
|
||||
return new ModMatrix(newGrid, mod);
|
||||
}
|
||||
@Override
|
||||
public ModMatrix adj(){
|
||||
return adjoint();
|
||||
}
|
||||
@Override
|
||||
public ModMatrix adjoint(){
|
||||
return cofactor().transpose();
|
||||
}
|
||||
@Override
|
||||
public ModMatrix inverse(){
|
||||
//Make sure the matrix is square
|
||||
if(!isSquare()){
|
||||
throw new InvalidGeometryException("A matrix must be square for it to have an inverse");
|
||||
}
|
||||
|
||||
//Make sure the determinant is not 0
|
||||
int determinant = determinant();
|
||||
if(determinant == 0){
|
||||
throw new InvalidScalarException("The determinant cannot be 0");
|
||||
}
|
||||
//Find the inverse of determinant % mod
|
||||
int determinantInverse = -1;
|
||||
for(int num = 1;num < mod;++num){
|
||||
if(modValue(determinant * num) == 1){
|
||||
determinantInverse = num;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(determinantInverse < 0){
|
||||
throw new InvalidScalarException("There is no inverse for the determinant");
|
||||
}
|
||||
|
||||
//Find the matrix of cofactors and multiply the inverse determinant by cofactors and return
|
||||
return adjoint().multiply(determinantInverse);
|
||||
}
|
||||
|
||||
//Object functions
|
||||
@Override
|
||||
public boolean equals(Object rightSide){
|
||||
if(rightSide.getClass().equals(this.getClass())){
|
||||
ModMatrix rightMatrix = (ModMatrix)rightSide;
|
||||
|
||||
//Make sure they have the same number of elements
|
||||
if(getNumRows() != rightMatrix.getNumRows()){
|
||||
return false;
|
||||
}
|
||||
else if(getNumCols() != rightMatrix.getNumCols()){
|
||||
return false;
|
||||
}
|
||||
|
||||
//Check every element
|
||||
for(int row = 0;row < getNumRows();++row){
|
||||
for(int col = 0;col < getNumCols();++col){
|
||||
if(grid[row][col] != rightMatrix.grid[row][col]){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//If false hasn't been return yet then they are equal
|
||||
return true;
|
||||
}
|
||||
else if(rightSide.getClass().equals(int[][].class)){
|
||||
int[][] rightMatrix = (int[][])rightSide;
|
||||
|
||||
return equals(new ModMatrix(rightMatrix, mod));
|
||||
}
|
||||
else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public int hashCode(){
|
||||
return grid.hashCode();
|
||||
}
|
||||
@Override
|
||||
public String toString(){
|
||||
return super.toString() + "\nmod(" + mod + ")";
|
||||
}
|
||||
@Override
|
||||
public ModMatrix clone(){
|
||||
return new ModMatrix(grid, mod);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
//Matrix/src/test/java/com/mattrixwv/matrix/TestDoubleMatrix.java
|
||||
//Mattrixwv
|
||||
// Created: 02-07-22
|
||||
//Modified: 02-08-22
|
||||
//Modified: 02-09-22
|
||||
package com.mattrixwv.matrix;
|
||||
|
||||
|
||||
@@ -120,79 +120,82 @@ public class TestDoubleMatrix{
|
||||
assertTrue("DoubleMatrix 1x1 failed equals DoubleMatrix.", matrix.equals(matrix));
|
||||
@SuppressWarnings("unlikely-arg-type")
|
||||
boolean gridEquals = matrix.equals(grid1);
|
||||
assertTrue("DoubleMatrix 1x1 failed equals double[][]", gridEquals);
|
||||
assertTrue("DoubleMatrix 1x1 failed equals double[][].", gridEquals);
|
||||
|
||||
//2x2
|
||||
matrix = new DoubleMatrix(grid2);
|
||||
assertTrue("DoubleMatrix 2x2 failed equals DoubleMatrix.", matrix.equals(matrix));
|
||||
@SuppressWarnings("unlikely-arg-type")
|
||||
boolean gridEquals2 = matrix.equals(grid2);
|
||||
assertTrue("DoubleMatrix 2x2 failed equals double[][]", gridEquals2);
|
||||
assertTrue("DoubleMatrix 2x2 failed equals double[][].", gridEquals2);
|
||||
|
||||
//3x3
|
||||
matrix = new DoubleMatrix(grid3);
|
||||
assertTrue("DoubleMatrix 3x3 failed equals DoubleMatrix.", matrix.equals(matrix));
|
||||
@SuppressWarnings("unlikely-arg-type")
|
||||
boolean gridEquals3 = matrix.equals(grid3);
|
||||
assertTrue("DoubleMatrix 3x3 failed equals double[][]", gridEquals3);
|
||||
assertTrue("DoubleMatrix 3x3 failed equals double[][].", gridEquals3);
|
||||
|
||||
//4x4
|
||||
matrix = new DoubleMatrix(grid4);
|
||||
assertTrue("DoubleMatrix 4x4 failed equals DoubleMatrix.", matrix.equals(matrix));
|
||||
@SuppressWarnings("unlikely-arg-type")
|
||||
boolean gridEquals4 = matrix.equals(grid4);
|
||||
assertTrue("DoubleMatrix 4x4 failed equals double[][]", gridEquals4);
|
||||
assertTrue("DoubleMatrix 4x4 failed equals double[][].", gridEquals4);
|
||||
|
||||
//10x10
|
||||
matrix = new DoubleMatrix(grid10);
|
||||
assertTrue("DoubleMatrix 10x10 failed equals DoubleMatrix.", matrix.equals(matrix));
|
||||
@SuppressWarnings("unlikely-arg-type")
|
||||
boolean gridEquals10 = matrix.equals(grid10);
|
||||
assertTrue("DoubleMatrix 10x10 failed equals double[][]", gridEquals10);
|
||||
assertTrue("DoubleMatrix 10x10 failed equals double[][].", gridEquals10);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGets(){
|
||||
//1x1
|
||||
DoubleMatrix matrix = new DoubleMatrix(grid1);
|
||||
assertEquals("DoubleMatrix 1x1 failed get", 0.5, matrix.get(0, 0), 0.0000001);
|
||||
assertEquals("DoubleMatrix 1x1 failed get.", 0.5, matrix.get(0, 0), 0.0000001);
|
||||
//GetRow
|
||||
DoubleMatrix correctMatrix = new DoubleMatrix(new double[][]{{0.5}});
|
||||
assertEquals("DoubleMatrix 1x1 failed getRow", correctMatrix, matrix.getRow(0));
|
||||
assertEquals("DoubleMatrix 1x1 failed getRow.", correctMatrix, matrix.getRow(0));
|
||||
//GetColumn
|
||||
correctMatrix = new DoubleMatrix(new double[][]{{0.5}});
|
||||
assertEquals("DoubleMatrix 1x1 failed getCol.", correctMatrix, matrix.getCol(0));
|
||||
|
||||
//2x2
|
||||
matrix = new DoubleMatrix(grid2);
|
||||
assertEquals("DoubleMatrix 2x2 failed get", 0.5, matrix.get(0, 0), 0.0000001);
|
||||
assertEquals("DoubleMatrix 2x2 failed get.", 0.5, matrix.get(0, 0), 0.0000001);
|
||||
//GetRow
|
||||
correctMatrix = new DoubleMatrix(new double[][]{{0.5, 1.5}});
|
||||
assertEquals("DoubleMatrix 2x2 failed getRow", correctMatrix, matrix.getRow(0));
|
||||
assertEquals("DoubleMatrix 2x2 failed getRow.", correctMatrix, matrix.getRow(0));
|
||||
//GetColumn
|
||||
correctMatrix = new DoubleMatrix(new double[][]{
|
||||
{0.5},
|
||||
{0.5}
|
||||
});
|
||||
assertEquals("DoubleMatrix 2x2 failed getCol", correctMatrix, matrix.getCol(0));
|
||||
assertEquals("DoubleMatrix 2x2 failed getCol.", correctMatrix, matrix.getCol(0));
|
||||
|
||||
//3x3
|
||||
matrix = new DoubleMatrix(grid3);
|
||||
assertEquals("DoubleMatrix 3x3 failed get", 0.5, matrix.get(0, 0), 0.0000001);
|
||||
assertEquals("DoubleMatrix 3x3 failed get.", 0.5, matrix.get(0, 0), 0.0000001);
|
||||
//GetRow
|
||||
correctMatrix = new DoubleMatrix(new double[][]{{0.5, 1.5, 2.5}});
|
||||
assertEquals("DoubleMatrix 3x3 failed getRow", correctMatrix, matrix.getRow(0));
|
||||
assertEquals("DoubleMatrix 3x3 failed getRow.", correctMatrix, matrix.getRow(0));
|
||||
//GetColumn
|
||||
correctMatrix = new DoubleMatrix(new double[][]{
|
||||
{0.5},
|
||||
{0.5},
|
||||
{0.5}
|
||||
});
|
||||
assertEquals("DoubleMatrix 3x3 failed getCol", correctMatrix, matrix.getCol(0));
|
||||
assertEquals("DoubleMatrix 3x3 failed getCol.", correctMatrix, matrix.getCol(0));
|
||||
|
||||
//4x4
|
||||
matrix = new DoubleMatrix(grid4);
|
||||
assertEquals("DoubleMatrix 4x4 failed get", 0.5, matrix.get(0, 0), 0.0000001);
|
||||
assertEquals("DoubleMatrix 4x4 failed get.", 0.5, matrix.get(0, 0), 0.0000001);
|
||||
//GetRow
|
||||
correctMatrix = new DoubleMatrix(new double[][]{{0.5, 1.5, 2.5, 3.5}});
|
||||
assertEquals("DoubleMatrix 4x4 failed getRow", correctMatrix, matrix.getRow(0));
|
||||
assertEquals("DoubleMatrix 4x4 failed getRow.", correctMatrix, matrix.getRow(0));
|
||||
//GetColumn
|
||||
correctMatrix = new DoubleMatrix(new double[][]{
|
||||
{0.5},
|
||||
@@ -200,14 +203,14 @@ public class TestDoubleMatrix{
|
||||
{0.5},
|
||||
{0.5}
|
||||
});
|
||||
assertEquals("DoubleMatrix 4x4 failed getCol", correctMatrix, matrix.getCol(0));
|
||||
assertEquals("DoubleMatrix 4x4 failed getCol.", correctMatrix, matrix.getCol(0));
|
||||
|
||||
//10x10
|
||||
matrix = new DoubleMatrix(grid10);
|
||||
assertEquals("DoubleMatrix 10x10 failed get", 0.5, matrix.get(0, 0), 0.0000001);
|
||||
assertEquals("DoubleMatrix 10x10 failed get.", 0.5, matrix.get(0, 0), 0.0000001);
|
||||
//GetRow
|
||||
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("DoubleMatrix 10x10 failed getRow.", correctMatrix, matrix.getRow(0));
|
||||
//GetCol
|
||||
correctMatrix = new DoubleMatrix(new double[][]{
|
||||
{0.5},
|
||||
@@ -221,7 +224,7 @@ public class TestDoubleMatrix{
|
||||
{0.5},
|
||||
{0.5}
|
||||
});
|
||||
assertEquals("DoubleMatrix 10x10 failed getCol", correctMatrix, matrix.getCol(0));
|
||||
assertEquals("DoubleMatrix 10x10 failed getCol.", correctMatrix, matrix.getCol(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -231,15 +234,15 @@ public class TestDoubleMatrix{
|
||||
DoubleMatrix matrix = new DoubleMatrix(grid1);
|
||||
matrix.set(0, 0, 1.5);
|
||||
DoubleMatrix correctMatrix = new DoubleMatrix(new double[][]{{1.5}});
|
||||
assertEquals("DoubleMatrix 1x1 failed set", correctMatrix, matrix);
|
||||
assertEquals("DoubleMatrix 1x1 failed set.", correctMatrix, matrix);
|
||||
//SetRow
|
||||
matrix.setRow(0, new double[]{0.0});
|
||||
correctMatrix = new DoubleMatrix(new double[][]{{0.0}});
|
||||
assertEquals("DoubleMatrix 1x1 failed setRow", correctMatrix, matrix);
|
||||
assertEquals("DoubleMatrix 1x1 failed setRow.", correctMatrix, matrix);
|
||||
//SetCol
|
||||
matrix.setCol(0, new double[]{0.5});
|
||||
correctMatrix = new DoubleMatrix(new double[][]{{0.5}});
|
||||
assertEquals("DoubleMatrix 1x1 failed setCol", correctMatrix, matrix);
|
||||
assertEquals("DoubleMatrix 1x1 failed setCol.", correctMatrix, matrix);
|
||||
|
||||
//2x2
|
||||
//Set
|
||||
@@ -249,14 +252,14 @@ public class TestDoubleMatrix{
|
||||
{2.5, 1.5},
|
||||
{0.5, 1.5}
|
||||
});
|
||||
assertEquals("DoubleMatrix 2x2 failed set", correctMatrix, matrix);
|
||||
assertEquals("DoubleMatrix 2x2 failed set.", correctMatrix, matrix);
|
||||
//SetRow
|
||||
matrix.setRow(1, new double[]{1.5, 0.5});
|
||||
correctMatrix = new DoubleMatrix(new double[][]{
|
||||
{2.5, 1.5},
|
||||
{1.5, 0.5}
|
||||
});
|
||||
assertEquals("DoubleMatrix 2x2 failed setRow", correctMatrix, matrix);
|
||||
assertEquals("DoubleMatrix 2x2 failed setRow.", correctMatrix, matrix);
|
||||
//SetCol
|
||||
matrix = new DoubleMatrix(grid2);
|
||||
matrix.setCol(0, new double[]{2.5, 2.5});
|
||||
@@ -264,7 +267,7 @@ public class TestDoubleMatrix{
|
||||
{2.5, 1.5},
|
||||
{2.5, 1.5}
|
||||
});
|
||||
assertEquals("DoubleMatrix 2x2 failed setCol", correctMatrix, matrix);
|
||||
assertEquals("DoubleMatrix 2x2 failed setCol.", correctMatrix, matrix);
|
||||
|
||||
//3x3
|
||||
//Set
|
||||
@@ -275,7 +278,7 @@ public class TestDoubleMatrix{
|
||||
{0.5, 1.5, 2.5},
|
||||
{0.5, 1.5, 2.5}
|
||||
});
|
||||
assertEquals("DoubleMatrix 3x3 failed set", correctMatrix, matrix);
|
||||
assertEquals("DoubleMatrix 3x3 failed set.", correctMatrix, matrix);
|
||||
//SetRow
|
||||
matrix.setRow(0, new double[]{0, 0.5, 1.5});
|
||||
correctMatrix = new DoubleMatrix(new double[][]{
|
||||
@@ -283,7 +286,7 @@ public class TestDoubleMatrix{
|
||||
{0.5, 1.5, 2.5},
|
||||
{0.5, 1.5, 2.5}
|
||||
});
|
||||
assertEquals("DoubleMatrix 3x3 failed setRow", correctMatrix, matrix);
|
||||
assertEquals("DoubleMatrix 3x3 failed setRow.", correctMatrix, matrix);
|
||||
//SetCol
|
||||
matrix.setCol(0, new double[]{0, 0, 0});
|
||||
correctMatrix = new DoubleMatrix(new double[][]{
|
||||
@@ -291,7 +294,7 @@ public class TestDoubleMatrix{
|
||||
{0.0, 1.5, 2.5},
|
||||
{0.0, 1.5, 2.5}
|
||||
});
|
||||
assertEquals("DoubleMatrix 3x3 failed setCol", correctMatrix, matrix);
|
||||
assertEquals("DoubleMatrix 3x3 failed setCol.", correctMatrix, matrix);
|
||||
|
||||
//4x4
|
||||
//Set
|
||||
@@ -303,7 +306,7 @@ public class TestDoubleMatrix{
|
||||
{0.5, 1.5, 2.5, 3.5},
|
||||
{0.5, 1.5, 2.5, 3.5}
|
||||
});
|
||||
assertEquals("DoubleMatrix 4x4 failed set", correctMatrix, matrix);
|
||||
assertEquals("DoubleMatrix 4x4 failed set.", correctMatrix, matrix);
|
||||
//SetRow
|
||||
matrix.setRow(0, new double[]{3.5, 2.5, 1.5, 0.5});
|
||||
correctMatrix = new DoubleMatrix(new double[][]{
|
||||
@@ -312,7 +315,7 @@ public class TestDoubleMatrix{
|
||||
{0.5, 1.5, 2.5, 3.5},
|
||||
{0.5, 1.5, 2.5, 3.5}
|
||||
});
|
||||
assertEquals("DoubleMatrix 4x4 failed setRow", correctMatrix, matrix);
|
||||
assertEquals("DoubleMatrix 4x4 failed setRow.", correctMatrix, matrix);
|
||||
//SetCol
|
||||
matrix.setCol(0, new double[]{0, 0, 0, 0});
|
||||
correctMatrix = new DoubleMatrix(new double[][]{
|
||||
@@ -321,6 +324,7 @@ public class TestDoubleMatrix{
|
||||
{0.0, 1.5, 2.5, 3.5},
|
||||
{0.0, 1.5, 2.5, 3.5}
|
||||
});
|
||||
assertEquals("DoubleMatrix 4x4 failed setCol.", correctMatrix, matrix);
|
||||
|
||||
//10x10
|
||||
//Set
|
||||
@@ -338,7 +342,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}
|
||||
});
|
||||
assertEquals("DoubleMatrix 10x10 failed set", correctMatrix, matrix);
|
||||
assertEquals("DoubleMatrix 10x10 failed set.", correctMatrix, matrix);
|
||||
//SetRow
|
||||
matrix.setRow(0, new double[]{9.5, 8.5, 7.5, 6.5, 5.5, 4.5, 3.5, 2.5, 1.5, 0.5});
|
||||
correctMatrix = new DoubleMatrix(new double[][]{
|
||||
@@ -353,7 +357,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}
|
||||
});
|
||||
assertEquals("DoubleMatrix 10x10 failed set", correctMatrix, matrix);
|
||||
assertEquals("DoubleMatrix 10x10 failed setRow.", correctMatrix, matrix);
|
||||
//SetCol
|
||||
matrix.setCol(0, new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0});
|
||||
correctMatrix = new DoubleMatrix(new double[][]{
|
||||
@@ -368,7 +372,7 @@ public class TestDoubleMatrix{
|
||||
{0.0, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5},
|
||||
{0.0, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5}
|
||||
});
|
||||
assertEquals("DoubleMatrix 10x10 failed setCol", correctMatrix, matrix);
|
||||
assertEquals("DoubleMatrix 10x10 failed setCol.", correctMatrix, matrix);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -378,12 +382,12 @@ public class TestDoubleMatrix{
|
||||
DoubleMatrix matrix = new DoubleMatrix(grid1);
|
||||
matrix.addRow(new double[]{0.5});
|
||||
DoubleMatrix correctMatrix = new DoubleMatrix(new double[][]{{0.5}, {0.5}});
|
||||
assertEquals("DoubleMatrix 1x1 failed addRow", correctMatrix, matrix);
|
||||
assertEquals("DoubleMatrix 1x1 failed addRow.", correctMatrix, matrix);
|
||||
//AddColumn
|
||||
matrix = new DoubleMatrix(grid1);
|
||||
matrix.addCol(new double[]{0.5});
|
||||
correctMatrix = new DoubleMatrix(new double[][]{{0.5, 0.5}});
|
||||
assertEquals("DoubleMatrix 1x1 failed addCol", correctMatrix, matrix);
|
||||
assertEquals("DoubleMatrix 1x1 failed addCol.", correctMatrix, matrix);
|
||||
|
||||
//2x2
|
||||
//AddRow
|
||||
@@ -394,7 +398,7 @@ public class TestDoubleMatrix{
|
||||
{0.5, 1.5},
|
||||
{0.5, 1.5}
|
||||
});
|
||||
assertEquals("DoubleMatrix 2x2 failed addRow", correctMatrix, matrix);
|
||||
assertEquals("DoubleMatrix 2x2 failed addRow.", correctMatrix, matrix);
|
||||
//AddColumn
|
||||
matrix = new DoubleMatrix(grid2);
|
||||
matrix.addCol(new double[]{2.5, 2.5});
|
||||
@@ -402,7 +406,7 @@ public class TestDoubleMatrix{
|
||||
{0.5, 1.5, 2.5},
|
||||
{0.5, 1.5, 2.5}
|
||||
});
|
||||
assertEquals("DoubleMatrix 2x2 failed addCol", correctMatrix, matrix);
|
||||
assertEquals("DoubleMatrix 2x2 failed addCol.", correctMatrix, matrix);
|
||||
|
||||
//3x3
|
||||
//AddRow
|
||||
@@ -414,7 +418,7 @@ public class TestDoubleMatrix{
|
||||
{0.5, 1.5, 2.5},
|
||||
{0.5, 1.5, 2.5}
|
||||
});
|
||||
assertEquals("DoubleMatrix 3x3 failed addRow", correctMatrix, matrix);
|
||||
assertEquals("DoubleMatrix 3x3 failed addRow.", correctMatrix, matrix);
|
||||
//AddColumn
|
||||
matrix = new DoubleMatrix(grid3);
|
||||
matrix.addCol(new double[]{3.5, 3.5, 3.5});
|
||||
@@ -423,7 +427,7 @@ public class TestDoubleMatrix{
|
||||
{0.5, 1.5, 2.5, 3.5},
|
||||
{0.5, 1.5, 2.5, 3.5}
|
||||
});
|
||||
assertEquals("DoubleMatrix 3x3 failed addCol", correctMatrix, matrix);
|
||||
assertEquals("DoubleMatrix 3x3 failed addCol.", correctMatrix, matrix);
|
||||
|
||||
//4x4
|
||||
//AddRow
|
||||
@@ -436,7 +440,7 @@ public class TestDoubleMatrix{
|
||||
{0.5, 1.5, 2.5, 3.5},
|
||||
{0.5, 1.5, 2.5, 3.5}
|
||||
});
|
||||
assertEquals("DoubleMatrix 4x4 failed addRow", correctMatrix, matrix);
|
||||
assertEquals("DoubleMatrix 4x4 failed addRow.", correctMatrix, matrix);
|
||||
//AddColumn
|
||||
matrix = new DoubleMatrix(grid4);
|
||||
matrix.addCol(new double[]{4.5, 4.5, 4.5, 4.5});
|
||||
@@ -446,7 +450,7 @@ public class TestDoubleMatrix{
|
||||
{0.5, 1.5, 2.5, 3.5, 4.5},
|
||||
{0.5, 1.5, 2.5, 3.5, 4.5}
|
||||
});
|
||||
assertEquals("DoubleMatrix 4x4 failed addCol", correctMatrix, matrix);
|
||||
assertEquals("DoubleMatrix 4x4 failed addCol.", correctMatrix, matrix);
|
||||
|
||||
//10x10
|
||||
//AddRow
|
||||
@@ -465,7 +469,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}
|
||||
});
|
||||
assertEquals("DoubleMatrix 10x10 failed addRow", correctMatrix, matrix);
|
||||
assertEquals("DoubleMatrix 10x10 failed addRow.", correctMatrix, matrix);
|
||||
//AddColumn
|
||||
matrix = new DoubleMatrix(grid10);
|
||||
matrix.addCol(new double[]{10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5});
|
||||
@@ -481,7 +485,7 @@ public class TestDoubleMatrix{
|
||||
{0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5},
|
||||
{0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5}
|
||||
});
|
||||
assertEquals("DoubleMatrix 10x10 failed addCol", correctMatrix, matrix);
|
||||
assertEquals("DoubleMatrix 10x10 failed addCol.", correctMatrix, matrix);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -491,13 +495,13 @@ 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("DoubleMatrix 1x1 failed appendRight.", correctMatrix, matrix.appendRight(secondMatrix));
|
||||
//appendBottom
|
||||
correctMatrix = new DoubleMatrix(new double[][]{
|
||||
{0.5},
|
||||
{0.5}
|
||||
});
|
||||
assertEquals("DoubleMatrix 1x1 failed appendBottom", correctMatrix, matrix.appendBottom(secondMatrix));
|
||||
assertEquals("DoubleMatrix 1x1 failed appendBottom.", correctMatrix, matrix.appendBottom(secondMatrix));
|
||||
|
||||
//2x2
|
||||
//appendRight
|
||||
@@ -507,7 +511,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("DoubleMatrix 2x2 failed appendRight.", correctMatrix, matrix.appendRight(secondMatrix));
|
||||
//appendBottom
|
||||
correctMatrix = new DoubleMatrix(new double[][]{
|
||||
{0.5, 1.5},
|
||||
@@ -515,7 +519,7 @@ public class TestDoubleMatrix{
|
||||
{0.5, 1.5},
|
||||
{0.5, 1.5}
|
||||
});
|
||||
assertEquals("DoubleMatrix 2x2 failed appendBottom", correctMatrix, matrix.appendBottom(secondMatrix));
|
||||
assertEquals("DoubleMatrix 2x2 failed appendBottom.", correctMatrix, matrix.appendBottom(secondMatrix));
|
||||
|
||||
//3x3
|
||||
//appendRight
|
||||
@@ -526,7 +530,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("DoubleMatrix 3x3 failed appendRight.", correctMatrix, matrix.appendRight(secondMatrix));
|
||||
//appendBottom
|
||||
correctMatrix = new DoubleMatrix(new double[][]{
|
||||
{0.5, 1.5, 2.5},
|
||||
@@ -536,7 +540,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("DoubleMatrix 3x3 failed appendBottom.", correctMatrix, matrix.appendBottom(secondMatrix));
|
||||
|
||||
//4x4
|
||||
//appendRight
|
||||
@@ -548,7 +552,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("DoubleMatrix 4x4 failed appendRight.", correctMatrix, matrix.appendRight(secondMatrix));
|
||||
//appendBottom
|
||||
correctMatrix = new DoubleMatrix(new double[][]{
|
||||
{0.5, 1.5, 2.5, 3.5},
|
||||
@@ -560,7 +564,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("DoubleMatrix 4x4 failed appendBottom.", correctMatrix, matrix.appendBottom(secondMatrix));
|
||||
|
||||
//10x10
|
||||
//appendRight
|
||||
@@ -578,7 +582,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("DoubleMatrix 10x10 failed appendRight.", correctMatrix, matrix.appendRight(secondMatrix));
|
||||
//appendBottom
|
||||
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}, {0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5},
|
||||
@@ -592,7 +596,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("DoubleMatrix 10x10 failed appendBottom.", correctMatrix, matrix.appendBottom(secondMatrix));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//Matrix/src/test/java/com/mattrixwv/matrix/TestIntegerMatrix.java
|
||||
//Mattrixwv
|
||||
// Created: 02-01-22
|
||||
//Modified: 02-08-22
|
||||
//Modified: 02-09-22
|
||||
package com.mattrixwv.matrix;
|
||||
|
||||
|
||||
@@ -120,82 +120,82 @@ public class TestIntegerMatrix{
|
||||
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);
|
||||
assertTrue("IntegerMatrix 1x1 failed equals int[][].", gridEquals);
|
||||
|
||||
//2x2
|
||||
matrix = new IntegerMatrix(grid2);
|
||||
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);
|
||||
assertTrue("IntegerMatrix 2x2 failed equals int[][].", gridEquals2);
|
||||
|
||||
//3x3
|
||||
matrix = new IntegerMatrix(grid3);
|
||||
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);
|
||||
assertTrue("IntegerMatrix 3x3 failed equals int[][].", gridEquals3);
|
||||
|
||||
//4x4
|
||||
matrix = new IntegerMatrix(grid4);
|
||||
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);
|
||||
assertTrue("IntegerMatrix 4x4 failed equals int[][].", gridEquals4);
|
||||
|
||||
//10x10
|
||||
matrix = new IntegerMatrix(grid10);
|
||||
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);
|
||||
assertTrue("IntegerMatrix 10x10 failed equals int[][].", gridEquals10);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGets(){
|
||||
//1x1
|
||||
IntegerMatrix matrix = new IntegerMatrix(grid1);
|
||||
assertEquals("IntegerMatrix 1x1 failed get", 1, matrix.get(0, 0));
|
||||
assertEquals("IntegerMatrix 1x1 failed get.", 1, matrix.get(0, 0));
|
||||
//GetRow
|
||||
IntegerMatrix correctMatrix = new IntegerMatrix(new int[][]{{1}});
|
||||
assertEquals("IntegerMatrix 1x1 failed getRow", correctMatrix, matrix.getRow(0));
|
||||
assertEquals("IntegerMatrix 1x1 failed getRow.", correctMatrix, matrix.getRow(0));
|
||||
//GetColumn
|
||||
correctMatrix = new IntegerMatrix(new int[][]{{1}});
|
||||
assertEquals("IntegerMatrix 1x1 failed getColumn", correctMatrix, matrix.getCol(0));
|
||||
assertEquals("IntegerMatrix 1x1 failed getCol.", correctMatrix, matrix.getCol(0));
|
||||
|
||||
//2x2
|
||||
matrix = new IntegerMatrix(grid2);
|
||||
assertEquals("IntegerMatrix 2x2 failed get", 1, matrix.get(0, 0));
|
||||
assertEquals("IntegerMatrix 2x2 failed get.", 1, matrix.get(0, 0));
|
||||
//GetRow
|
||||
correctMatrix = new IntegerMatrix(new int[][]{{1, 2}});
|
||||
assertEquals("IntegerMatrix 2x2 failed getRow", correctMatrix, matrix.getRow(0));
|
||||
assertEquals("IntegerMatrix 2x2 failed getRow.", correctMatrix, matrix.getRow(0));
|
||||
//GetColumn
|
||||
correctMatrix = new IntegerMatrix(new int[][]{
|
||||
{1},
|
||||
{1}
|
||||
});
|
||||
assertEquals("IntegerMatrix 2x2 failed getColumns", correctMatrix, matrix.getCol(0));
|
||||
assertEquals("IntegerMatrix 2x2 failed getCol.", correctMatrix, matrix.getCol(0));
|
||||
|
||||
//3x3
|
||||
matrix = new IntegerMatrix(grid3);
|
||||
assertEquals("IntegerMatrix 3x3 failed get", 1, matrix.get(0, 0));
|
||||
assertEquals("IntegerMatrix 3x3 failed get.", 1, matrix.get(0, 0));
|
||||
//GetRow
|
||||
correctMatrix = new IntegerMatrix(new int[][]{{1, 2, 3}});
|
||||
assertEquals("IntegerMatrix 3x3 failed getRow", correctMatrix, matrix.getRow(0));
|
||||
assertEquals("IntegerMatrix 3x3 failed getRow.", correctMatrix, matrix.getRow(0));
|
||||
//GetColumn
|
||||
correctMatrix = new IntegerMatrix(new int[][]{
|
||||
{1},
|
||||
{1},
|
||||
{1}
|
||||
});
|
||||
assertEquals("IntegerMatrix 3x3 failed getCol", correctMatrix, matrix.getCol(0));
|
||||
assertEquals("IntegerMatrix 3x3 failed getCol.", correctMatrix, matrix.getCol(0));
|
||||
|
||||
//4x4
|
||||
matrix = new IntegerMatrix(grid4);
|
||||
assertEquals("IntegerMatrix 4x4 failed get", 1, matrix.get(0, 0));
|
||||
assertEquals("IntegerMatrix 4x4 failed get.", 1, matrix.get(0, 0));
|
||||
//GetRow
|
||||
correctMatrix = new IntegerMatrix(new int[][]{{1, 2, 3, 4}});
|
||||
assertEquals("IntegerMatrix 4x4 failed getRow", correctMatrix, matrix.getRow(0));
|
||||
assertEquals("IntegerMatrix 4x4 failed getRow.", correctMatrix, matrix.getRow(0));
|
||||
//GetColumn
|
||||
correctMatrix = new IntegerMatrix(new int[][]{
|
||||
{1},
|
||||
@@ -203,14 +203,14 @@ public class TestIntegerMatrix{
|
||||
{1},
|
||||
{1}
|
||||
});
|
||||
assertEquals("IntegerMatrix 4x4 failed getCol", correctMatrix, matrix.getCol(0));
|
||||
assertEquals("IntegerMatrix 4x4 failed getCol.", correctMatrix, matrix.getCol(0));
|
||||
|
||||
//10x10
|
||||
matrix = new IntegerMatrix(grid10);
|
||||
assertEquals("IntegerMatrix 10x10 failed get", 1, matrix.get(0, 0));
|
||||
assertEquals("IntegerMatrix 10x10 failed get.", 1, matrix.get(0, 0));
|
||||
//GetRow
|
||||
correctMatrix = new IntegerMatrix(new int[][]{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}});
|
||||
assertEquals("IntegerMatrix 10x10 failed getRow", correctMatrix, matrix.getRow(0));
|
||||
assertEquals("IntegerMatrix 10x10 failed getRow.", correctMatrix, matrix.getRow(0));
|
||||
//GetColumn
|
||||
correctMatrix = new IntegerMatrix(new int[][]{
|
||||
{1},
|
||||
@@ -224,7 +224,7 @@ public class TestIntegerMatrix{
|
||||
{1},
|
||||
{1}
|
||||
});
|
||||
assertEquals("IntegerMatrix 10x10 failed getColumn", correctMatrix, matrix.getCol(0));
|
||||
assertEquals("IntegerMatrix 10x10 failed getColumn.", correctMatrix, matrix.getCol(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -234,15 +234,15 @@ public class TestIntegerMatrix{
|
||||
IntegerMatrix matrix = new IntegerMatrix(grid1);
|
||||
matrix.set(0, 0, 2);
|
||||
IntegerMatrix correctMatrix = new IntegerMatrix(new int[][]{{2}});
|
||||
assertEquals("IntegerMatrix 1x1 failed set", correctMatrix, matrix);
|
||||
assertEquals("IntegerMatrix 1x1 failed set.", correctMatrix, matrix);
|
||||
//SetRow
|
||||
matrix.setRow(0, new int[]{0});
|
||||
correctMatrix = new IntegerMatrix(new int[][]{{0}});
|
||||
assertEquals("IntegerMatrix 1x1 failed setRow", correctMatrix, matrix);
|
||||
assertEquals("IntegerMatrix 1x1 failed setRow.", correctMatrix, matrix);
|
||||
//SetColumn
|
||||
matrix.setCol(0, new int[]{1});
|
||||
correctMatrix = new IntegerMatrix(new int[][]{{1}});
|
||||
assertEquals("IntegerMatrix 1x1 failed setCol", correctMatrix, matrix);
|
||||
assertEquals("IntegerMatrix 1x1 failed setCol.", correctMatrix, matrix);
|
||||
|
||||
//2x2
|
||||
//Set
|
||||
@@ -252,14 +252,14 @@ public class TestIntegerMatrix{
|
||||
{3, 2},
|
||||
{1, 2}
|
||||
});
|
||||
assertEquals("IntegerMatrix 2x2 failed set", correctMatrix, matrix);
|
||||
assertEquals("IntegerMatrix 2x2 failed set.", correctMatrix, matrix);
|
||||
//SetRow
|
||||
matrix.setRow(1, new int[]{2, 1});
|
||||
correctMatrix = new IntegerMatrix(new int[][]{
|
||||
{3, 2},
|
||||
{2, 1}
|
||||
});
|
||||
assertEquals("IntegerMatrix 2x2 failed set row", correctMatrix, matrix);
|
||||
assertEquals("IntegerMatrix 2x2 failed set row.", correctMatrix, matrix);
|
||||
//SetColumn
|
||||
matrix = new IntegerMatrix(grid2);
|
||||
matrix.setCol(0, new int[]{3, 3});
|
||||
@@ -267,7 +267,7 @@ public class TestIntegerMatrix{
|
||||
{3, 2},
|
||||
{3, 2}
|
||||
});
|
||||
assertEquals("IntegerMatrix 2x2 failed set row", correctMatrix, matrix);
|
||||
assertEquals("IntegerMatrix 2x2 failed set row.", correctMatrix, matrix);
|
||||
|
||||
//3x3
|
||||
//Set
|
||||
@@ -278,7 +278,7 @@ public class TestIntegerMatrix{
|
||||
{1, 2, 3},
|
||||
{1, 2, 3},
|
||||
});
|
||||
assertEquals("IntegerMatrix 3x3 failed set", correctMatrix, matrix);
|
||||
assertEquals("IntegerMatrix 3x3 failed set.", correctMatrix, matrix);
|
||||
//SetRow
|
||||
matrix.setRow(0, new int[]{0, 1, 2});
|
||||
correctMatrix = new IntegerMatrix(new int[][]{
|
||||
@@ -286,7 +286,7 @@ public class TestIntegerMatrix{
|
||||
{1, 2, 3},
|
||||
{1, 2, 3}
|
||||
});
|
||||
assertEquals("IntegerMatrix 3x3 failed setRow", correctMatrix, matrix);
|
||||
assertEquals("IntegerMatrix 3x3 failed setRow.", correctMatrix, matrix);
|
||||
//SetColumn
|
||||
matrix.setCol(0, new int[]{0, 0, 0});
|
||||
correctMatrix = new IntegerMatrix(new int[][]{
|
||||
@@ -294,7 +294,7 @@ public class TestIntegerMatrix{
|
||||
{0, 2, 3},
|
||||
{0, 2, 3}
|
||||
});
|
||||
assertEquals("IntegerMatrix 3x3 failed setColumn", correctMatrix, matrix);
|
||||
assertEquals("IntegerMatrix 3x3 failed setColumn.", correctMatrix, matrix);
|
||||
|
||||
//4x4
|
||||
//Set
|
||||
@@ -306,7 +306,7 @@ public class TestIntegerMatrix{
|
||||
{1, 2, 3, 4},
|
||||
{1, 2, 3, 4}
|
||||
});
|
||||
assertEquals("IntegerMatrix 4x4 failed set", correctMatrix, matrix);
|
||||
assertEquals("IntegerMatrix 4x4 failed set.", correctMatrix, matrix);
|
||||
//SetRow
|
||||
matrix.setRow(0, new int[]{4, 3, 2, 1});
|
||||
correctMatrix = new IntegerMatrix(new int[][]{
|
||||
@@ -315,7 +315,7 @@ public class TestIntegerMatrix{
|
||||
{1, 2, 3, 4},
|
||||
{1, 2, 3, 4}
|
||||
});
|
||||
assertEquals("IntegerMatrix 4x4 failed setRow", correctMatrix, matrix);
|
||||
assertEquals("IntegerMatrix 4x4 failed setRow.", correctMatrix, matrix);
|
||||
//SetColumn
|
||||
matrix.setCol(0, new int[]{0, 0, 0, 0});
|
||||
correctMatrix = new IntegerMatrix(new int[][]{
|
||||
@@ -324,7 +324,7 @@ public class TestIntegerMatrix{
|
||||
{0, 2, 3, 4},
|
||||
{0, 2, 3, 4}
|
||||
});
|
||||
assertEquals("IntegerMatrix 4x4 failed setCol", correctMatrix, matrix);
|
||||
assertEquals("IntegerMatrix 4x4 failed setCol.", correctMatrix, matrix);
|
||||
|
||||
//10x10
|
||||
//Set
|
||||
@@ -342,7 +342,7 @@ public class TestIntegerMatrix{
|
||||
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
|
||||
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
|
||||
});
|
||||
assertEquals("IntegerMatrix 10x10 failed set", correctMatrix, matrix);
|
||||
assertEquals("IntegerMatrix 10x10 failed setRow.", correctMatrix, matrix);
|
||||
//SetRow
|
||||
matrix.setRow(0, new int[]{10, 9, 8, 7, 6, 5, 4, 3, 2, 1});
|
||||
correctMatrix = new IntegerMatrix(new int[][]{
|
||||
@@ -357,7 +357,7 @@ public class TestIntegerMatrix{
|
||||
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
|
||||
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
|
||||
});
|
||||
assertEquals("IntegerMatrix 10x10 failed setRow", correctMatrix, matrix);
|
||||
assertEquals("IntegerMatrix 10x10 failed setRow.", correctMatrix, matrix);
|
||||
//SetColumn
|
||||
matrix.setCol(0, new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||
correctMatrix = new IntegerMatrix(new int[][]{
|
||||
@@ -372,7 +372,7 @@ public class TestIntegerMatrix{
|
||||
{0, 2, 3, 4, 5, 6, 7, 8, 9, 10},
|
||||
{0, 2, 3, 4, 5, 6, 7, 8, 9, 10}
|
||||
});
|
||||
assertEquals("IntegerMatrix 10x10 failed setColumn", correctMatrix, matrix);
|
||||
assertEquals("IntegerMatrix 10x10 failed setColumn.", correctMatrix, matrix);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -382,12 +382,12 @@ public class TestIntegerMatrix{
|
||||
IntegerMatrix matrix = new IntegerMatrix(grid1);
|
||||
matrix.addRow(new int[]{1});
|
||||
IntegerMatrix correctMatrix = new IntegerMatrix(new int[][]{{1}, {1}});
|
||||
assertEquals("IntegerMatrix 1x1 failed addRow", correctMatrix, matrix);
|
||||
assertEquals("IntegerMatrix 1x1 failed addRow.", correctMatrix, matrix);
|
||||
//AddColumn
|
||||
matrix = new IntegerMatrix(grid1);
|
||||
matrix.addCol(new int[]{1});
|
||||
correctMatrix = new IntegerMatrix(new int[][]{{1, 1}});
|
||||
assertEquals("IntegerMatrix 1x1 failed addCol", correctMatrix, matrix);
|
||||
assertEquals("IntegerMatrix 1x1 failed addCol.", correctMatrix, matrix);
|
||||
|
||||
//2x2
|
||||
//AddRow
|
||||
@@ -398,7 +398,7 @@ public class TestIntegerMatrix{
|
||||
{1, 2},
|
||||
{1, 2}
|
||||
});
|
||||
assertEquals("IntegerMatrix 2x2 failed addRow", correctMatrix, matrix);
|
||||
assertEquals("IntegerMatrix 2x2 failed addRow.", correctMatrix, matrix);
|
||||
//AddColumn
|
||||
matrix = new IntegerMatrix(grid2);
|
||||
matrix.addCol(new int[]{3, 3});
|
||||
@@ -406,7 +406,7 @@ public class TestIntegerMatrix{
|
||||
{1, 2, 3},
|
||||
{1, 2, 3}
|
||||
});
|
||||
assertEquals("IntegerMatrix 2x2 failed addCol", correctMatrix, matrix);
|
||||
assertEquals("IntegerMatrix 2x2 failed addCol.", correctMatrix, matrix);
|
||||
|
||||
//3x3
|
||||
//AddRow
|
||||
@@ -418,7 +418,7 @@ public class TestIntegerMatrix{
|
||||
{1, 2, 3},
|
||||
{1, 2, 3}
|
||||
});
|
||||
assertEquals("IntegerMatrix 3x3 failed addRow", correctMatrix, matrix);
|
||||
assertEquals("IntegerMatrix 3x3 failed addRow.", correctMatrix, matrix);
|
||||
//AddColumn
|
||||
matrix = new IntegerMatrix(grid3);
|
||||
matrix.addCol(new int[]{4, 4, 4});
|
||||
@@ -427,7 +427,7 @@ public class TestIntegerMatrix{
|
||||
{1, 2, 3, 4},
|
||||
{1, 2, 3, 4}
|
||||
});
|
||||
assertEquals("IntegerMatrix 3x3 failed addCol", correctMatrix, matrix);
|
||||
assertEquals("IntegerMatrix 3x3 failed addCol.", correctMatrix, matrix);
|
||||
|
||||
//4x4
|
||||
//AddRow
|
||||
@@ -440,7 +440,7 @@ public class TestIntegerMatrix{
|
||||
{1, 2, 3, 4},
|
||||
{1, 2, 3, 4}
|
||||
});
|
||||
assertEquals("IntegerMatrix 4x4 failed addRow", correctMatrix, matrix);
|
||||
assertEquals("IntegerMatrix 4x4 failed addRow.", correctMatrix, matrix);
|
||||
//AddColumn
|
||||
matrix.addCol(new int[]{5, 5, 5, 5, 5});
|
||||
correctMatrix = new IntegerMatrix(new int[][]{
|
||||
@@ -450,7 +450,7 @@ public class TestIntegerMatrix{
|
||||
{1, 2, 3, 4, 5},
|
||||
{1, 2, 3, 4, 5}
|
||||
});
|
||||
assertEquals("IntegerMatrix 4x4 failed addCol", correctMatrix, matrix);
|
||||
assertEquals("IntegerMatrix 4x4 failed addCol.", correctMatrix, matrix);
|
||||
|
||||
//10x10
|
||||
//AddRow
|
||||
@@ -469,7 +469,7 @@ public class TestIntegerMatrix{
|
||||
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
|
||||
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
|
||||
});
|
||||
assertEquals("IntegerMatrix 10x10 failed addRow", correctMatrix, matrix);
|
||||
assertEquals("IntegerMatrix 10x10 failed addRow.", correctMatrix, matrix);
|
||||
//AddColumn
|
||||
matrix = new IntegerMatrix(grid10);
|
||||
matrix.addCol(new int[]{11, 11, 11, 11, 11, 11, 11, 11, 11, 11});
|
||||
@@ -485,7 +485,7 @@ public class TestIntegerMatrix{
|
||||
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11},
|
||||
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
|
||||
});
|
||||
assertEquals("IntegerMatrix 10x10 failed addColumn", correctMatrix, matrix);
|
||||
assertEquals("IntegerMatrix 10x10 failed addColumn.", correctMatrix, matrix);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -495,13 +495,13 @@ public class TestIntegerMatrix{
|
||||
IntegerMatrix matrix = new IntegerMatrix(grid1);
|
||||
IntegerMatrix secondMatrix = new IntegerMatrix(grid1);
|
||||
IntegerMatrix correctMatrix = new IntegerMatrix(new int[][]{{1, 1}});
|
||||
assertEquals("IntegerMatrix 1x1 failed appendRight", correctMatrix, matrix.appendRight(secondMatrix));
|
||||
assertEquals("IntegerMatrix 1x1 failed appendRight.", correctMatrix, matrix.appendRight(secondMatrix));
|
||||
//appendBottom
|
||||
correctMatrix = new IntegerMatrix(new int[][]{
|
||||
{1},
|
||||
{1}
|
||||
});
|
||||
assertEquals("IntegerMatrix 1x1 failed appendBottom", correctMatrix, matrix.appendBottom(secondMatrix));
|
||||
assertEquals("IntegerMatrix 1x1 failed appendBottom.", correctMatrix, matrix.appendBottom(secondMatrix));
|
||||
|
||||
//2x2
|
||||
//appendRight
|
||||
@@ -511,7 +511,7 @@ public class TestIntegerMatrix{
|
||||
{1, 2, 1, 2},
|
||||
{1, 2, 1, 2}
|
||||
});
|
||||
assertEquals("IntegerMatrix 2x2 failed appendRight", correctMatrix, matrix.appendRight(secondMatrix));
|
||||
assertEquals("IntegerMatrix 2x2 failed appendRight.", correctMatrix, matrix.appendRight(secondMatrix));
|
||||
//appendBottom
|
||||
correctMatrix = new IntegerMatrix(new int[][]{
|
||||
{1, 2},
|
||||
@@ -519,7 +519,7 @@ public class TestIntegerMatrix{
|
||||
{1, 2},
|
||||
{1, 2}
|
||||
});
|
||||
assertEquals("IntegerMatrix 2x2 failed appendBottom", correctMatrix, matrix.appendBottom(secondMatrix));
|
||||
assertEquals("IntegerMatrix 2x2 failed appendBottom.", correctMatrix, matrix.appendBottom(secondMatrix));
|
||||
|
||||
//3x3
|
||||
//appendRight
|
||||
@@ -530,7 +530,7 @@ public class TestIntegerMatrix{
|
||||
{1, 2, 3, 1, 2, 3},
|
||||
{1, 2, 3, 1, 2, 3}
|
||||
});
|
||||
assertEquals("IntegerMatrix 3x3 failed appendRight", correctMatrix, matrix.appendRight(secondMatrix));
|
||||
assertEquals("IntegerMatrix 3x3 failed appendRight.", correctMatrix, matrix.appendRight(secondMatrix));
|
||||
//appendBottom
|
||||
correctMatrix = new IntegerMatrix(new int[][]{
|
||||
{1, 2, 3},
|
||||
@@ -540,7 +540,7 @@ public class TestIntegerMatrix{
|
||||
{1, 2, 3},
|
||||
{1, 2, 3}
|
||||
});
|
||||
assertEquals("IntegerMatrix 3x3 failed appendBottom", correctMatrix, matrix.appendBottom(secondMatrix));
|
||||
assertEquals("IntegerMatrix 3x3 failed appendBottom.", correctMatrix, matrix.appendBottom(secondMatrix));
|
||||
|
||||
//4x4
|
||||
//appendRight
|
||||
@@ -552,7 +552,7 @@ public class TestIntegerMatrix{
|
||||
{1, 2, 3, 4, 1, 2, 3, 4},
|
||||
{1, 2, 3, 4, 1, 2, 3, 4}
|
||||
});
|
||||
assertEquals("IntegerMatrix 4x4 failed appendRight", correctMatrix, matrix.appendRight(secondMatrix));
|
||||
assertEquals("IntegerMatrix 4x4 failed appendRight.", correctMatrix, matrix.appendRight(secondMatrix));
|
||||
//appendBottom
|
||||
correctMatrix = new IntegerMatrix(new int[][]{
|
||||
{1, 2, 3, 4},
|
||||
@@ -564,7 +564,7 @@ public class TestIntegerMatrix{
|
||||
{1, 2, 3, 4},
|
||||
{1, 2, 3, 4}
|
||||
});
|
||||
assertEquals("IntegerMatrix 4x4 failed appendBottom", correctMatrix, matrix.appendBottom(secondMatrix));
|
||||
assertEquals("IntegerMatrix 4x4 failed appendBottom.", correctMatrix, matrix.appendBottom(secondMatrix));
|
||||
|
||||
//10x10
|
||||
//appendRight
|
||||
@@ -582,7 +582,7 @@ public class TestIntegerMatrix{
|
||||
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
|
||||
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
|
||||
});
|
||||
assertEquals("IntegerMatrix 10x10 failed appendRight", correctMatrix, matrix.appendRight(secondMatrix));
|
||||
assertEquals("IntegerMatrix 10x10 failed appendRight.", correctMatrix, matrix.appendRight(secondMatrix));
|
||||
//appendBottom
|
||||
correctMatrix = new IntegerMatrix(new int[][]{
|
||||
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
|
||||
@@ -596,7 +596,7 @@ public class TestIntegerMatrix{
|
||||
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
|
||||
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
|
||||
});
|
||||
assertEquals("IntegerMatrix 10x10 failed appendBottom", correctMatrix, matrix.appendBottom(secondMatrix));
|
||||
assertEquals("IntegerMatrix 10x10 failed appendBottom.", correctMatrix, matrix.appendBottom(secondMatrix));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -926,7 +926,7 @@ public class TestIntegerMatrix{
|
||||
matrix = new IntegerMatrix(grid10);
|
||||
transformMatrix = new IntegerMatrix(transformGrid10_2);
|
||||
assertEquals("IntegerMatrix 10x10 failed dot product IntegerMatrix.", 35750, matrix.dotProduct(transformMatrix));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHadamardProduct(){
|
||||
@@ -989,7 +989,7 @@ public class TestIntegerMatrix{
|
||||
//1x1
|
||||
IntegerMatrix matrix = new IntegerMatrix(grid1);
|
||||
IntegerMatrix correctMatrix = new IntegerMatrix(new int[][]{{1}});
|
||||
assertEquals("IntegerMatrix 1x1 failed transpose", correctMatrix, matrix.transpose());
|
||||
assertEquals("IntegerMatrix 1x1 failed transpose.", correctMatrix, matrix.transpose());
|
||||
|
||||
//2x2
|
||||
matrix = new IntegerMatrix(grid2);
|
||||
@@ -997,7 +997,7 @@ public class TestIntegerMatrix{
|
||||
{1, 1},
|
||||
{2, 2}
|
||||
});
|
||||
assertEquals("IntegerMatrix 2x2 failed transpose", correctMatrix, matrix.transpose());
|
||||
assertEquals("IntegerMatrix 2x2 failed transpose.", correctMatrix, matrix.transpose());
|
||||
|
||||
//3x3
|
||||
matrix = new IntegerMatrix(grid3);
|
||||
@@ -1006,7 +1006,7 @@ public class TestIntegerMatrix{
|
||||
{2, 2, 2},
|
||||
{3, 3, 3}
|
||||
});
|
||||
assertEquals("IntegerMatrix 3x3 failed transpose", correctMatrix, matrix.transpose());
|
||||
assertEquals("IntegerMatrix 3x3 failed transpose.", correctMatrix, matrix.transpose());
|
||||
|
||||
//4x4
|
||||
matrix = new IntegerMatrix(grid4);
|
||||
@@ -1016,7 +1016,7 @@ public class TestIntegerMatrix{
|
||||
{3, 3, 3, 3},
|
||||
{4, 4, 4, 4}
|
||||
});
|
||||
assertEquals("IntegerMatrix 4x4 failed transpose", correctMatrix, matrix.transpose());
|
||||
assertEquals("IntegerMatrix 4x4 failed transpose.", correctMatrix, matrix.transpose());
|
||||
|
||||
//10x10
|
||||
matrix = new IntegerMatrix(grid10);
|
||||
@@ -1032,7 +1032,7 @@ public class TestIntegerMatrix{
|
||||
{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());
|
||||
assertEquals("IntegerMatrix 10x10 failed transpose.", correctMatrix, matrix.transpose());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
1311
src/test/java/com/mattrixwv/matrix/TestModMatrix.java
Normal file
1311
src/test/java/com/mattrixwv/matrix/TestModMatrix.java
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user