12 Commits

22 changed files with 753 additions and 1220 deletions

7
README.md Normal file
View File

@@ -0,0 +1,7 @@
# Matrix
[![Quality Gate Status](https://sonarqube.mattrixwv.com/api/project_badges/measure?project=matrix&metric=alert_status&token=sqb_b6f7219a7b625b1ab2964e9dfa90e58a7c4c4e57)](https://sonarqube.mattrixwv.com/dashboard?id=matrix)
This is my matrix library, created as curiosity and to fit into my [Cipher Stream](https://git.mattrixwv.com/BaseLibraries/CipherStream) project.
TODO: Fill this is better information about library usage.

61
pom.xml
View File

@@ -22,12 +22,12 @@
<scm> <scm>
<connection>scm:git:git://bitbucket.org/Mattrixwv/Matrix.git</connection> <connection>scm:git:git://bitbucket.org/Mattrixwv/Matrix.git</connection>
<developerConnection>scm:git:ssh://bitbucket.org:Mattrixwv/Matrix.git</developerConnection> <developerConnection>scm:git:ssh://bitbucket.org:Mattrixwv/Matrix.git</developerConnection>
<url>https://bitbucket.org/Mattrixwv/Matrix/src</url> <url>https://git.mattrixwv.com/BaseLibraries/Matrix</url>
</scm> </scm>
<groupId>com.mattrixwv</groupId> <groupId>com.mattrixwv</groupId>
<artifactId>matrix</artifactId> <artifactId>matrix</artifactId>
<version>1.2.4-SNAPSHOT</version> <version>1.3.2</version>
<name>Matrix</name> <name>Matrix</name>
<description>A library for performing Matrix operations</description> <description>A library for performing Matrix operations</description>
@@ -38,11 +38,11 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>25</java.version> <java.version>25</java.version>
<maven.compiler.source>21</maven.compiler.source> <maven.compiler.source>25</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target> <maven.compiler.target>25</maven.compiler.target>
<!--Sonarqube--> <!--Sonarqube-->
<sonar.java.source>21</sonar.java.source> <sonar.java.source>25</sonar.java.source>
<sonar.dependencyCheck.jsonReportPath>target/dependency-check-report.json</sonar.dependencyCheck.jsonReportPath> <sonar.dependencyCheck.jsonReportPath>target/dependency-check-report.json</sonar.dependencyCheck.jsonReportPath>
<sonar.dependencyCheck.htmlReportPath>target/dependency-check-report.html</sonar.dependencyCheck.htmlReportPath> <sonar.dependencyCheck.htmlReportPath>target/dependency-check-report.html</sonar.dependencyCheck.htmlReportPath>
</properties> </properties>
@@ -51,7 +51,7 @@
<dependency> <dependency>
<groupId>org.junit.jupiter</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId> <artifactId>junit-jupiter</artifactId>
<version>6.0.1</version> <version>6.0.2</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
@@ -60,11 +60,12 @@
<plugins> <plugins>
<!--Ensure maven is the correct version--> <!--Ensure maven is the correct version-->
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId> <artifactId>maven-enforcer-plugin</artifactId>
<executions> <executions>
<execution> <execution>
<id>enforce-maven</id> <id>enforce-maven</id>
<phase>enforce</phase> <phase>validate</phase>
<goals> <goals>
<goal>enforce</goal> <goal>enforce</goal>
</goals> </goals>
@@ -73,26 +74,6 @@
</plugin> </plugin>
<!--Sonarqube--> <!--Sonarqube-->
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>jacoco-initialize</id>
<phase>none</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>jacoco-site</id>
<phase>none</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin> <plugin>
<groupId>org.owasp</groupId> <groupId>org.owasp</groupId>
<artifactId>dependency-check-maven</artifactId> <artifactId>dependency-check-maven</artifactId>
@@ -108,6 +89,11 @@
</plugin> </plugin>
<!--Deployment--> <!--Deployment-->
<plugin>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
</plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId> <artifactId>maven-source-plugin</artifactId>
@@ -145,10 +131,6 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
</plugin>
</plugins> </plugins>
<pluginManagement> <pluginManagement>
@@ -166,6 +148,7 @@
</rules> </rules>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<artifactId>maven-clean-plugin</artifactId> <artifactId>maven-clean-plugin</artifactId>
<version>3.5.0</version> <version>3.5.0</version>
@@ -173,45 +156,53 @@
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging --> <!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId> <artifactId>maven-resources-plugin</artifactId>
<version>3.4.0</version> <version>3.4.0</version>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.14.1</version> <version>3.14.1</version>
<configuration> <configuration>
<release>${java.version}</release> <release>${java.version}</release>
<compilerArgs> <compilerArgs>
<arg>-Xlint:all</arg> <arg>-Xlint:all</arg>
<arg>-Xlint:-serial</arg>
</compilerArgs> </compilerArgs>
<showWarnings>true</showWarnings> <showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation> <showDeprecation>true</showDeprecation>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>3.5.4</version> <version>3.5.4</version>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId> <artifactId>maven-jar-plugin</artifactId>
<version>3.5.0</version> <version>3.5.0</version>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId> <artifactId>maven-install-plugin</artifactId>
<version>3.1.4</version> <version>3.1.4</version>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId> <artifactId>maven-site-plugin</artifactId>
<version>3.21.0</version> <version>3.21.0</version>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId> <artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.9.0</version> <version>3.9.0</version>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.codehaus.mojo</groupId> <groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId> <artifactId>versions-maven-plugin</artifactId>
<version>2.20.1</version> <version>2.21.0</version>
<configuration> <configuration>
<rulesUri>file://${session.executionRootDirectory}/version-rules.xml</rulesUri> <rulesUri>file://${session.executionRootDirectory}/version-rules.xml</rulesUri>
</configuration> </configuration>
@@ -236,7 +227,7 @@
<plugin> <plugin>
<groupId>org.owasp</groupId> <groupId>org.owasp</groupId>
<artifactId>dependency-check-maven</artifactId> <artifactId>dependency-check-maven</artifactId>
<version>12.1.9</version> <version>12.2.0</version>
<configuration> <configuration>
<formats> <formats>
<format>json</format> <format>json</format>
@@ -244,7 +235,7 @@
</formats> </formats>
<nvdApiServerId>nvd</nvdApiServerId> <nvdApiServerId>nvd</nvdApiServerId>
<failBuildOnCVSS>7</failBuildOnCVSS> <failBuildOnCVSS>7</failBuildOnCVSS>
<ossIndexServerId>ossrh</ossIndexServerId> <ossIndexServerId>ossindex</ossIndexServerId>
</configuration> </configuration>
</plugin> </plugin>
@@ -252,7 +243,7 @@
<plugin> <plugin>
<groupId>org.sonatype.central</groupId> <groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId> <artifactId>central-publishing-maven-plugin</artifactId>
<version>0.9.0</version> <version>0.10.0</version>
<extensions>true</extensions> <extensions>true</extensions>
<configuration> <configuration>
<publishingServerId>central</publishingServerId> <publishingServerId>central</publishingServerId>

View File

@@ -1,7 +1,3 @@
//Matrix/src/main/java/com/mattrixwv/BigIntegerMatrix.java
//Mattrixwv
// Created: 02-10-22
//Modified: 08-11-24
package com.mattrixwv.matrix; package com.mattrixwv.matrix;
@@ -27,18 +23,17 @@ public class BigIntegerMatrix{
//?Helper functions //?Helper functions
/** /**
* Sets the matrix grid to the specified 2D array. Validates the input to ensure * Validates the input to ensure all rows are of equal length.
* all rows are of equal length.
* *
* @param grid The 2D array to set as the matrix grid. * @param grid The 2D array to set as the matrix grid.
* @throws InvalidRowSizeException If the rows of the matrix are not all the same length. * @return the new validated grid
*/ */
protected void setGrid(BigInteger[][] grid){ private BigInteger[][] validateGrid(BigInteger[][] grid){
if(grid.length == 0){ if(grid.length == 0){
this.grid = new BigInteger[0][0]; return new BigInteger[0][0];
} }
else if(grid[0].length == 0){ else if(grid[0].length == 0){
this.grid = new BigInteger[grid.length][0]; return new BigInteger[grid.length][0];
} }
else{ else{
//Make sure all rows are the same length //Make sure all rows are the same length
@@ -56,9 +51,19 @@ public class BigIntegerMatrix{
} }
//Save the new grid //Save the new grid
this.grid = newGrid; return newGrid;
} }
} }
/**
* Sets the matrix grid to the specified 2D array. Validates the input to ensure
* all rows are of equal length.
*
* @param grid The 2D array to set as the matrix grid.
* @throws InvalidRowSizeException If the rows of the matrix are not all the same length.
*/
protected void setGrid(BigInteger[][] grid){
this.grid = validateGrid(grid);
}
/** /**
* Creates a deep copy of the matrix grid. * Creates a deep copy of the matrix grid.
* *
@@ -159,7 +164,7 @@ public class BigIntegerMatrix{
* @param grid The 2D array to initialize the matrix with. * @param grid The 2D array to initialize the matrix with.
*/ */
public BigIntegerMatrix(BigInteger[][] grid){ public BigIntegerMatrix(BigInteger[][] grid){
setGrid(grid); this.grid = validateGrid(grid);
} }
/** /**
* Constructs a copy of the specified matrix. * Constructs a copy of the specified matrix.
@@ -167,7 +172,7 @@ public class BigIntegerMatrix{
* @param matrix The matrix to copy. * @param matrix The matrix to copy.
*/ */
public BigIntegerMatrix(BigIntegerMatrix matrix){ public BigIntegerMatrix(BigIntegerMatrix matrix){
setGrid(matrix.grid); this.grid = validateGrid(matrix.grid);
} }
/** /**
* Constructs a matrix with the specified number of rows and columns, filled with the specified value. * Constructs a matrix with the specified number of rows and columns, filled with the specified value.

View File

@@ -1,7 +1,3 @@
//Matrix/src/main/java/com/mattrixwv/matrix/DoubleMatrix.java
//Mattrixwv
// Created: 02-07-22
//Modified: 08-11-24
package com.mattrixwv.matrix; package com.mattrixwv.matrix;
@@ -30,18 +26,17 @@ public class DoubleMatrix{
//?Helper functions //?Helper functions
/** /**
* Sets the matrix grid to the specified 2D array. Validates the input to ensure * Validates the input to ensure all rows are of equal length.
* all rows are of equal length.
* *
* @param grid The 2D array to set as the matrix grid. * @param grid The 2D array to set as the matrix grid.
* @throws InvalidRowSizeException If the rows of the matrix are not all the same length. * @return the new validated grid
*/ */
protected void setGrid(double[][] grid){ private double[][] validateGrid(double[][] grid){
if(grid.length == 0){ if(grid.length == 0){
this.grid = new double[0][0]; return new double[0][0];
} }
else if(grid[0].length == 0){ else if(grid[0].length == 0){
this.grid = new double[grid.length][0]; return new double[grid.length][0];
} }
else{ else{
//Make sure all rows are the same length //Make sure all rows are the same length
@@ -59,9 +54,19 @@ public class DoubleMatrix{
} }
//Save the new grid //Save the new grid
this.grid = newGrid; return newGrid;
} }
} }
/**
* Sets the matrix grid to the specified 2D array. Validates the input to ensure
* all rows are of equal length.
*
* @param grid The 2D array to set as the matrix grid.
* @throws InvalidRowSizeException If the rows of the matrix are not all the same length.
*/
protected void setGrid(double[][] grid){
this.grid = validateGrid(grid);
}
/** /**
* Creates a deep copy of the matrix grid. * Creates a deep copy of the matrix grid.
* *
@@ -163,7 +168,7 @@ public class DoubleMatrix{
* @param grid The 2D array to initialize the matrix with. * @param grid The 2D array to initialize the matrix with.
*/ */
public DoubleMatrix(double[][] grid){ public DoubleMatrix(double[][] grid){
setGrid(grid); this.grid = validateGrid(grid);
delta = 0.0; delta = 0.0;
} }
/** /**
@@ -172,7 +177,7 @@ public class DoubleMatrix{
* @param matrix The matrix to copy. * @param matrix The matrix to copy.
*/ */
public DoubleMatrix(DoubleMatrix matrix){ public DoubleMatrix(DoubleMatrix matrix){
setGrid(matrix.grid); this.grid = validateGrid(matrix.grid);
delta = 0.0; delta = 0.0;
} }
/** /**

View File

@@ -1,7 +1,3 @@
//Matrix/src/main/java/com/mattrixwv/IntegerMatrix.java
//Mattrixwv
// Created: 02-01-22
//Modified: 08-11-24
package com.mattrixwv.matrix; package com.mattrixwv.matrix;
@@ -26,18 +22,17 @@ public class IntegerMatrix{
//?Helper functions //?Helper functions
/** /**
* Sets the matrix grid to the specified 2D array. Validates the input to ensure * Validates that all rows in the grid are of equal length.
* all rows are of equal length.
* *
* @param grid The 2D array to set as the matrix grid. * @param grid The 2D array to validate.
* @throws InvalidRowSizeException If the rows of the matrix are not all the same length. * @throws InvalidRowSizeException If the rows of the matrix are not all the same length.
*/ */
protected void setGrid(int[][] grid){ private int[][] validateGrid(int[][] grid){
if(grid.length == 0){ if(grid.length == 0){
this.grid = new int[0][0]; return new int[0][0];
} }
else if(grid[0].length == 0){ else if(grid[0].length == 0){
this.grid = new int[grid.length][0]; return new int[grid.length][0];
} }
else{ else{
//Make sure all rows are the same length //Make sure all rows are the same length
@@ -55,9 +50,19 @@ public class IntegerMatrix{
} }
//Save the new grid //Save the new grid
this.grid = newGrid; return newGrid;
} }
} }
/**
* Sets the matrix grid to the specified 2D array. Validates the input to ensure
* all rows are of equal length.
*
* @param grid The 2D array to set as the matrix grid.
* @throws InvalidRowSizeException If the rows of the matrix are not all the same length.
*/
protected void setGrid(int[][] grid){
this.grid = validateGrid(grid);
}
/** /**
* Creates a deep copy of the matrix grid. * Creates a deep copy of the matrix grid.
* *
@@ -158,7 +163,7 @@ public class IntegerMatrix{
* @param grid The 2D array to initialize the matrix with. * @param grid The 2D array to initialize the matrix with.
*/ */
public IntegerMatrix(int[][] grid){ public IntegerMatrix(int[][] grid){
setGrid(grid); this.grid = validateGrid(grid);
} }
/** /**
* Constructs a copy of the specified matrix. * Constructs a copy of the specified matrix.
@@ -166,7 +171,7 @@ public class IntegerMatrix{
* @param matrix The matrix to copy. * @param matrix The matrix to copy.
*/ */
public IntegerMatrix(IntegerMatrix matrix){ public IntegerMatrix(IntegerMatrix matrix){
setGrid(matrix.grid); this.grid = validateGrid(matrix.grid);
} }
/** /**
* Constructs a matrix with the specified number of rows and columns, filled with the specified value. * Constructs a matrix with the specified number of rows and columns, filled with the specified value.

View File

@@ -1,7 +1,3 @@
//Matrix/src/main/java/com/mattrixwv/matrix/LongMatrix.java
//Mattrixwv
// Created: 02-10-22
//Modified: 08-11-24
package com.mattrixwv.matrix; package com.mattrixwv.matrix;
@@ -26,18 +22,17 @@ public class LongMatrix{
//?Helper functions //?Helper functions
/** /**
* Sets the matrix grid to the specified 2D array. Validates the input to ensure * Validates the input to ensure all rows are of equal length.
* all rows are of equal length.
* *
* @param grid The 2D array to set as the matrix grid. * @param grid The 2D array to set as the matrix grid.
* @throws InvalidRowSizeException If the rows of the matrix are not all the same length. * @return the new validated grid
*/ */
protected void setGrid(long[][] grid){ private long[][] validateGrid(long[][] grid){
if(grid.length == 0){ if(grid.length == 0){
this.grid = new long[0][0]; return new long[0][0];
} }
else if(grid[0].length == 0){ else if(grid[0].length == 0){
this.grid = new long[grid.length][0]; return new long[grid.length][0];
} }
else{ else{
//Make sure all rows are the same length //Make sure all rows are the same length
@@ -55,9 +50,19 @@ public class LongMatrix{
} }
//Save the new grid //Save the new grid
this.grid = newGrid; return newGrid;
} }
} }
/**
* Sets the matrix grid to the specified 2D array. Validates the input to ensure
* all rows are of equal length.
*
* @param grid The 2D array to set as the matrix grid.
* @throws InvalidRowSizeException If the rows of the matrix are not all the same length.
*/
protected void setGrid(long[][] grid){
this.grid = validateGrid(grid);
}
/** /**
* Creates a deep copy of the matrix grid. * Creates a deep copy of the matrix grid.
* *
@@ -158,7 +163,7 @@ public class LongMatrix{
* @param grid The 2D array to initialize the matrix with. * @param grid The 2D array to initialize the matrix with.
*/ */
public LongMatrix(long[][] grid){ public LongMatrix(long[][] grid){
setGrid(grid); this.grid = validateGrid(grid);
} }
/** /**
* Constructs a copy of the specified matrix. * Constructs a copy of the specified matrix.
@@ -166,7 +171,7 @@ public class LongMatrix{
* @param matrix The matrix to copy. * @param matrix The matrix to copy.
*/ */
public LongMatrix(LongMatrix matrix){ public LongMatrix(LongMatrix matrix){
setGrid(matrix.grid); this.grid = validateGrid(matrix.grid);
} }
/** /**
* Constructs a matrix with the specified number of rows and columns, filled with the specified value. * Constructs a matrix with the specified number of rows and columns, filled with the specified value.

View File

@@ -1,7 +1,3 @@
//Matrix/src/main/java/com/mattrixwv/matrix/ModMatrix.java
//Mattrixwv
// Created: 02-09-22
//Modified: 08-11-24
package com.mattrixwv.matrix; package com.mattrixwv.matrix;
@@ -17,13 +13,26 @@ import com.mattrixwv.matrix.exceptions.NullMatrixException;
/** /**
* Represents a matrix of integers that have been run through a modulus function, and provides various matrix operations. * Represents a matrix of integers that have been run through a modulus function, and provides various matrix operations.
*/ */
public class ModMatrix extends IntegerMatrix{ public final class ModMatrix extends IntegerMatrix{
/** /**
* The mod used on each element of the matrix * The mod used on each element of the matrix
*/ */
protected int mod; protected int mod;
//?Helper functions //?Helper functions
/**
* Validate the mod values
*
* @param mod The new mod value
* @throws InvalidScalarException If the mod value is less than or equal to 0
*/
private int validateMod(int mod){
if(mod <= 0){
throw new InvalidScalarException("The mod must be > 0");
}
return mod;
}
/** /**
* Set the mod values * Set the mod values
* *
@@ -31,11 +40,7 @@ public class ModMatrix extends IntegerMatrix{
* @throws InvalidScalarException If the mod value is less than or equal to 0 * @throws InvalidScalarException If the mod value is less than or equal to 0
*/ */
protected void setMod(int mod){ protected void setMod(int mod){
if(mod <= 0){ this.mod = validateMod(mod);
throw new InvalidScalarException("The mod must be > 0");
}
this.mod = mod;
} }
/** /**
* Get the mod value of a number * Get the mod value of a number
@@ -103,7 +108,7 @@ public class ModMatrix extends IntegerMatrix{
*/ */
public ModMatrix(int mod){ public ModMatrix(int mod){
super(); super();
setMod(mod); this.mod = validateMod(mod);
modGrid(); modGrid();
} }
/** /**
@@ -114,7 +119,7 @@ public class ModMatrix extends IntegerMatrix{
*/ */
public ModMatrix(int[][] grid, int mod){ public ModMatrix(int[][] grid, int mod){
super(); super();
setMod(mod); this.mod = validateMod(mod);
setGrid(grid); setGrid(grid);
} }
/** /**
@@ -124,7 +129,7 @@ public class ModMatrix extends IntegerMatrix{
*/ */
public ModMatrix(ModMatrix matrix){ public ModMatrix(ModMatrix matrix){
super(); super();
setMod(matrix.mod); this.mod = validateMod(matrix.mod);
setGrid(matrix.grid); setGrid(matrix.grid);
} }
/** /**
@@ -135,7 +140,7 @@ public class ModMatrix extends IntegerMatrix{
*/ */
public ModMatrix(IntegerMatrix matrix, int mod){ public ModMatrix(IntegerMatrix matrix, int mod){
super(); super();
setMod(mod); this.mod = validateMod(mod);
setGrid(matrix.grid); setGrid(matrix.grid);
} }
/** /**
@@ -149,7 +154,7 @@ public class ModMatrix extends IntegerMatrix{
*/ */
public ModMatrix(int rows, int cols, int fill, int mod){ public ModMatrix(int rows, int cols, int fill, int mod){
super(rows, cols, fill); super(rows, cols, fill);
setMod(mod); this.mod = validateMod(mod);
modGrid(); modGrid();
} }

View File

@@ -1,7 +1,3 @@
//Matrix/src/main/java/com/mattrixwv/exceptions/InvalidCoordinatesException.java
//Mattrixwv
// Created: 02-01-22
//Modified: 08-08-24
package com.mattrixwv.matrix.exceptions; package com.mattrixwv.matrix.exceptions;
@@ -11,12 +7,6 @@ package com.mattrixwv.matrix.exceptions;
* @author Mattrixwv * @author Mattrixwv
*/ */
public class InvalidCoordinatesException extends RuntimeException{ public class InvalidCoordinatesException extends RuntimeException{
/**
* Serialization identifier for this class.
*/
public static final long serialVersionUID = 1;
/** /**
* Constructs a new {@code InvalidCoordinatesException} with {@code null} as its detail message. * Constructs a new {@code InvalidCoordinatesException} with {@code null} as its detail message.
* The cause is not initialized, and may subsequently be initialized by a call to {@link #initCause}. * The cause is not initialized, and may subsequently be initialized by a call to {@link #initCause}.

View File

@@ -1,7 +1,3 @@
//Matrix/src/main/java/com/mattrixwv/exceptions/InvalidGeometryException.java
//Mattrixwv
// Created: 02-01-22
//Modified: 08-08-24
package com.mattrixwv.matrix.exceptions; package com.mattrixwv.matrix.exceptions;
@@ -11,12 +7,6 @@ package com.mattrixwv.matrix.exceptions;
* @author Mattrixwv * @author Mattrixwv
*/ */
public class InvalidGeometryException extends RuntimeException{ public class InvalidGeometryException extends RuntimeException{
/**
* Serialization identifier for this class.
*/
public static final long serialVersionUID = 1;
/** /**
* Constructs a new {@code InvalidGeometryException} with {@code null} as its detail message. * Constructs a new {@code InvalidGeometryException} with {@code null} as its detail message.
* The cause is not initialized and may subsequently be initialized by a call to {@link #initCause}. * The cause is not initialized and may subsequently be initialized by a call to {@link #initCause}.

View File

@@ -1,7 +1,3 @@
//Matrix/src/main/java/com/mattrixwv/exceptions/InvalidRowSizeException.java
//Mattrixwv
// Created: 02-01-22
//Modified: 08-08-24
package com.mattrixwv.matrix.exceptions; package com.mattrixwv.matrix.exceptions;
@@ -9,12 +5,6 @@ package com.mattrixwv.matrix.exceptions;
* Exception thrown to indicate that the size of a row is invalid for a given matrix. * Exception thrown to indicate that the size of a row is invalid for a given matrix.
*/ */
public class InvalidRowSizeException extends RuntimeException{ public class InvalidRowSizeException extends RuntimeException{
/**
* Serialization identifier for this class.
*/
public static final long serialVersionUID = 1;
/** /**
* Constructs a new {@code InvalidRowSizeException} with {@code null} as its detail message. * Constructs a new {@code InvalidRowSizeException} with {@code null} as its detail message.
* The cause is not initialized and may subsequently be initialized by a call to {@link #initCause}. * The cause is not initialized and may subsequently be initialized by a call to {@link #initCause}.

View File

@@ -1,7 +1,3 @@
//Matrix/src/main/java/com/mattrixwv/matrix/exceptions/InvalidScalarException.java
//Mattrixwv
// Created: 02-07-22
//Modified: 08-08-24
package com.mattrixwv.matrix.exceptions; package com.mattrixwv.matrix.exceptions;
@@ -9,12 +5,6 @@ package com.mattrixwv.matrix.exceptions;
* Exception thrown to indicate that a scalar value passed to a matrix is invalid * Exception thrown to indicate that a scalar value passed to a matrix is invalid
*/ */
public class InvalidScalarException extends RuntimeException{ public class InvalidScalarException extends RuntimeException{
/**
* Serialization identifier for this class.
*/
public static final long serialVersionUID = 1;
/** /**
* Constructs a new {@code InvalidScalarException} with {@code null} as its detail message. * Constructs a new {@code InvalidScalarException} with {@code null} as its detail message.
* The cause is not initialized and may subsequently be initialized by a call to {@link #initCause}. * The cause is not initialized and may subsequently be initialized by a call to {@link #initCause}.

View File

@@ -1,7 +1,3 @@
//Matrix/src/main/java/com/mattrixwv/exceptions/NullMatrixException.java
//Mattrixwv
// Created: 06-30-22
//Modified: 08-08-24
package com.mattrixwv.matrix.exceptions; package com.mattrixwv.matrix.exceptions;
@@ -9,12 +5,6 @@ package com.mattrixwv.matrix.exceptions;
* Exception thrown to indicate that a null matrix has been illegally passed to a method * Exception thrown to indicate that a null matrix has been illegally passed to a method
*/ */
public class NullMatrixException extends RuntimeException{ public class NullMatrixException extends RuntimeException{
/**
* Serialization identifier for this class.
*/
public static final long serialVersionUID = 1;
/** /**
* Constructs a new {@code NullMatrixException} with {@code null} as its detail message. * Constructs a new {@code NullMatrixException} with {@code null} as its detail message.
* The cause is not initialized and may subsequently be initialized by a call to {@link #initCause}. * The cause is not initialized and may subsequently be initialized by a call to {@link #initCause}.

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,3 @@
//Matrix/src/test/java/com/mattrixwv/matrix/TestDoubleMatrix.java
//Mattrixwv
// Created: 02-07-22
//Modified: 08-10-24
package com.mattrixwv.matrix; package com.mattrixwv.matrix;
@@ -1773,12 +1769,8 @@ public class TestDoubleMatrix{
public void testDeterminant_size0(){ public void testDeterminant_size0(){
DoubleMatrix matrix = new DoubleMatrix(); DoubleMatrix matrix = new DoubleMatrix();
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, matrix::determinant);
matrix.determinant(); assertThrows(InvalidGeometryException.class, matrix::det);
});
assertThrows(InvalidGeometryException.class, () -> {
matrix.det();
});
} }
@Test @Test
@@ -1817,24 +1809,16 @@ public class TestDoubleMatrix{
public void testDeterminant_size2x10(){ public void testDeterminant_size2x10(){
DoubleMatrix matrix = new DoubleMatrix(negativeGrid2x10); DoubleMatrix matrix = new DoubleMatrix(negativeGrid2x10);
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, matrix::determinant);
matrix.determinant(); assertThrows(InvalidGeometryException.class, matrix::det);
});
assertThrows(InvalidGeometryException.class, () -> {
matrix.det();
});
} }
@Test @Test
public void testDeterminant_size10x2(){ public void testDeterminant_size10x2(){
DoubleMatrix matrix = new DoubleMatrix(negativeGrid10x2); DoubleMatrix matrix = new DoubleMatrix(negativeGrid10x2);
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, matrix::determinant);
matrix.determinant(); assertThrows(InvalidGeometryException.class, matrix::det);
});
assertThrows(InvalidGeometryException.class, () -> {
matrix.det();
});
} }
//! cofactor() / cof() //! cofactor() / cof()
@@ -1842,12 +1826,8 @@ public class TestDoubleMatrix{
public void testCofactor_size0(){ public void testCofactor_size0(){
DoubleMatrix matrix = new DoubleMatrix(); DoubleMatrix matrix = new DoubleMatrix();
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, matrix::cofactor);
matrix.cofactor(); assertThrows(InvalidGeometryException.class, matrix::cof);
});
assertThrows(InvalidGeometryException.class, () -> {
matrix.cof();
});
} }
@Test @Test
@@ -1892,24 +1872,16 @@ public class TestDoubleMatrix{
public void testCofactor_size2x10(){ public void testCofactor_size2x10(){
DoubleMatrix matrix = new DoubleMatrix(negativeGrid2x10); DoubleMatrix matrix = new DoubleMatrix(negativeGrid2x10);
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, matrix::cofactor);
matrix.cofactor(); assertThrows(InvalidGeometryException.class, matrix::cof);
});
assertThrows(InvalidGeometryException.class, () -> {
matrix.cof();
});
} }
@Test @Test
public void testCofactor_size10x2(){ public void testCofactor_size10x2(){
DoubleMatrix matrix = new DoubleMatrix(negativeGrid10x2); DoubleMatrix matrix = new DoubleMatrix(negativeGrid10x2);
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, matrix::cofactor);
matrix.cofactor(); assertThrows(InvalidGeometryException.class, matrix::cof);
});
assertThrows(InvalidGeometryException.class, () -> {
matrix.cof();
});
} }
//! adjoint() / adj() //! adjoint() / adj()
@@ -1917,12 +1889,8 @@ public class TestDoubleMatrix{
public void testAdjoint_size0(){ public void testAdjoint_size0(){
DoubleMatrix matrix = new DoubleMatrix(); DoubleMatrix matrix = new DoubleMatrix();
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, matrix::adjoint);
matrix.adjoint(); assertThrows(InvalidGeometryException.class, matrix::adj);
});
assertThrows(InvalidGeometryException.class, () -> {
matrix.adj();
});
} }
@Test @Test
@@ -1967,24 +1935,16 @@ public class TestDoubleMatrix{
public void testAdjoint_size2x10(){ public void testAdjoint_size2x10(){
DoubleMatrix matrix = new DoubleMatrix(negativeGrid2x10); DoubleMatrix matrix = new DoubleMatrix(negativeGrid2x10);
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, matrix::adjoint);
matrix.adjoint(); assertThrows(InvalidGeometryException.class, matrix::adj);
});
assertThrows(InvalidGeometryException.class, () -> {
matrix.adj();
});
} }
@Test @Test
public void testAdjoint_size10x2(){ public void testAdjoint_size10x2(){
DoubleMatrix matrix = new DoubleMatrix(negativeGrid10x2); DoubleMatrix matrix = new DoubleMatrix(negativeGrid10x2);
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, matrix::adjoint);
matrix.adjoint(); assertThrows(InvalidGeometryException.class, matrix::adj);
});
assertThrows(InvalidGeometryException.class, () -> {
matrix.adj();
});
} }
//! inverse() //! inverse()
@@ -1992,9 +1952,7 @@ public class TestDoubleMatrix{
public void testInverse_size0(){ public void testInverse_size0(){
DoubleMatrix matrix = new DoubleMatrix(); DoubleMatrix matrix = new DoubleMatrix();
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, matrix::inverse);
matrix.inverse();
});
} }
@Test @Test
@@ -2017,27 +1975,21 @@ public class TestDoubleMatrix{
public void testInverse_size10(){ public void testInverse_size10(){
DoubleMatrix matrix = new DoubleMatrix(negativeGrid10); DoubleMatrix matrix = new DoubleMatrix(negativeGrid10);
assertThrows(InvalidScalarException.class, () -> { assertThrows(InvalidScalarException.class, matrix::inverse);
matrix.inverse();
});
} }
@Test @Test
public void testInverse_size2x10(){ public void testInverse_size2x10(){
DoubleMatrix matrix = new DoubleMatrix(negativeGrid2x10); DoubleMatrix matrix = new DoubleMatrix(negativeGrid2x10);
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, matrix::inverse);
matrix.inverse();
});
} }
@Test @Test
public void testInverse_size10x2(){ public void testInverse_size10x2(){
DoubleMatrix matrix = new DoubleMatrix(negativeGrid10x2); DoubleMatrix matrix = new DoubleMatrix(negativeGrid10x2);
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, matrix::inverse);
matrix.inverse();
});
} }
//! equals() //! equals()
@@ -2181,16 +2133,17 @@ public class TestDoubleMatrix{
DoubleMatrix matrix = new DoubleMatrix(negativeGrid10); DoubleMatrix matrix = new DoubleMatrix(negativeGrid10);
assertEquals( assertEquals(
"[-1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0, -8.0, -9.0, -10.0]\n" + """
"[-11.0, -12.0, -13.0, -14.0, -15.0, -16.0, -17.0, -18.0, -19.0, -20.0]\n" + [-1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0, -8.0, -9.0, -10.0]
"[-21.0, -22.0, -23.0, -24.0, -25.0, -26.0, -27.0, -28.0, -29.0, -30.0]\n" + [-11.0, -12.0, -13.0, -14.0, -15.0, -16.0, -17.0, -18.0, -19.0, -20.0]
"[-31.0, -32.0, -33.0, -34.0, -35.0, -36.0, -37.0, -38.0, -39.0, -40.0]\n" + [-21.0, -22.0, -23.0, -24.0, -25.0, -26.0, -27.0, -28.0, -29.0, -30.0]
"[-41.0, -42.0, -43.0, -44.0, -45.0, -46.0, -47.0, -48.0, -49.0, -50.0]\n" + [-31.0, -32.0, -33.0, -34.0, -35.0, -36.0, -37.0, -38.0, -39.0, -40.0]
"[-51.0, -52.0, -53.0, -54.0, -55.0, -56.0, -57.0, -58.0, -59.0, -60.0]\n" + [-41.0, -42.0, -43.0, -44.0, -45.0, -46.0, -47.0, -48.0, -49.0, -50.0]
"[-61.0, -62.0, -63.0, -64.0, -65.0, -66.0, -67.0, -68.0, -69.0, -70.0]\n" + [-51.0, -52.0, -53.0, -54.0, -55.0, -56.0, -57.0, -58.0, -59.0, -60.0]
"[-71.0, -72.0, -73.0, -74.0, -75.0, -76.0, -77.0, -78.0, -79.0, -80.0]\n" + [-61.0, -62.0, -63.0, -64.0, -65.0, -66.0, -67.0, -68.0, -69.0, -70.0]
"[-81.0, -82.0, -83.0, -84.0, -85.0, -86.0, -87.0, -88.0, -89.0, -90.0]\n" + [-71.0, -72.0, -73.0, -74.0, -75.0, -76.0, -77.0, -78.0, -79.0, -80.0]
"[-91.0, -92.0, -93.0, -94.0, -95.0, -96.0, -97.0, -98.0, -99.0, -100.0]", [-81.0, -82.0, -83.0, -84.0, -85.0, -86.0, -87.0, -88.0, -89.0, -90.0]
[-91.0, -92.0, -93.0, -94.0, -95.0, -96.0, -97.0, -98.0, -99.0, -100.0]""",
matrix.toString()); matrix.toString());
} }

View File

@@ -1,7 +1,3 @@
//Matrix/src/test/java/com/mattrixwv/matrix/TestIntegerMatrix.java
//Mattrixwv
// Created: 02-01-22
//Modified: 08-10-24
package com.mattrixwv.matrix; package com.mattrixwv.matrix;
@@ -1773,12 +1769,8 @@ public class TestIntegerMatrix{
public void testDeterminant_size0(){ public void testDeterminant_size0(){
IntegerMatrix matrix = new IntegerMatrix(); IntegerMatrix matrix = new IntegerMatrix();
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, matrix::determinant);
matrix.determinant(); assertThrows(InvalidGeometryException.class, matrix::det);
});
assertThrows(InvalidGeometryException.class, () -> {
matrix.det();
});
} }
@Test @Test
@@ -1817,24 +1809,16 @@ public class TestIntegerMatrix{
public void testDeterminant_size2x10(){ public void testDeterminant_size2x10(){
IntegerMatrix matrix = new IntegerMatrix(negativeGrid2x10); IntegerMatrix matrix = new IntegerMatrix(negativeGrid2x10);
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, matrix::determinant);
matrix.determinant(); assertThrows(InvalidGeometryException.class, matrix::det);
});
assertThrows(InvalidGeometryException.class, () -> {
matrix.det();
});
} }
@Test @Test
public void testDeterminant_size10x2(){ public void testDeterminant_size10x2(){
IntegerMatrix matrix = new IntegerMatrix(negativeGrid10x2); IntegerMatrix matrix = new IntegerMatrix(negativeGrid10x2);
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, matrix::determinant);
matrix.determinant(); assertThrows(InvalidGeometryException.class, matrix::det);
});
assertThrows(InvalidGeometryException.class, () -> {
matrix.det();
});
} }
//! cofactor() / cof() //! cofactor() / cof()
@@ -1842,12 +1826,8 @@ public class TestIntegerMatrix{
public void testCofactor_size0(){ public void testCofactor_size0(){
IntegerMatrix matrix = new IntegerMatrix(); IntegerMatrix matrix = new IntegerMatrix();
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, matrix::cofactor);
matrix.cofactor(); assertThrows(InvalidGeometryException.class, matrix::cof);
});
assertThrows(InvalidGeometryException.class, () -> {
matrix.cof();
});
} }
@Test @Test
@@ -1892,24 +1872,16 @@ public class TestIntegerMatrix{
public void testCofactor_size2x10(){ public void testCofactor_size2x10(){
IntegerMatrix matrix = new IntegerMatrix(negativeGrid2x10); IntegerMatrix matrix = new IntegerMatrix(negativeGrid2x10);
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, matrix::cofactor);
matrix.cofactor(); assertThrows(InvalidGeometryException.class, matrix::cof);
});
assertThrows(InvalidGeometryException.class, () -> {
matrix.cof();
});
} }
@Test @Test
public void testCofactor_size10x2(){ public void testCofactor_size10x2(){
IntegerMatrix matrix = new IntegerMatrix(negativeGrid10x2); IntegerMatrix matrix = new IntegerMatrix(negativeGrid10x2);
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, matrix::cofactor);
matrix.cofactor(); assertThrows(InvalidGeometryException.class, matrix::cof);
});
assertThrows(InvalidGeometryException.class, () -> {
matrix.cof();
});
} }
//! adjoint() / adj() //! adjoint() / adj()
@@ -1917,12 +1889,8 @@ public class TestIntegerMatrix{
public void testAdjoint_size0(){ public void testAdjoint_size0(){
IntegerMatrix matrix = new IntegerMatrix(); IntegerMatrix matrix = new IntegerMatrix();
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, matrix::adjoint);
matrix.adjoint(); assertThrows(InvalidGeometryException.class, matrix::adj);
});
assertThrows(InvalidGeometryException.class, () -> {
matrix.adj();
});
} }
@Test @Test
@@ -1967,24 +1935,16 @@ public class TestIntegerMatrix{
public void testAdjoint_size2x10(){ public void testAdjoint_size2x10(){
IntegerMatrix matrix = new IntegerMatrix(negativeGrid2x10); IntegerMatrix matrix = new IntegerMatrix(negativeGrid2x10);
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, matrix::adjoint);
matrix.adjoint(); assertThrows(InvalidGeometryException.class, matrix::adj);
});
assertThrows(InvalidGeometryException.class, () -> {
matrix.adj();
});
} }
@Test @Test
public void testAdjoint_size10x2(){ public void testAdjoint_size10x2(){
IntegerMatrix matrix = new IntegerMatrix(negativeGrid10x2); IntegerMatrix matrix = new IntegerMatrix(negativeGrid10x2);
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, matrix::adjoint);
matrix.adjoint(); assertThrows(InvalidGeometryException.class, matrix::adj);
});
assertThrows(InvalidGeometryException.class, () -> {
matrix.adj();
});
} }
//! inverse() //! inverse()
@@ -1992,9 +1952,7 @@ public class TestIntegerMatrix{
public void testInverse_size0(){ public void testInverse_size0(){
IntegerMatrix matrix = new IntegerMatrix(); IntegerMatrix matrix = new IntegerMatrix();
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, matrix::inverse);
matrix.inverse();
});
} }
@Test @Test
@@ -2017,27 +1975,21 @@ public class TestIntegerMatrix{
public void testInverse_size10(){ public void testInverse_size10(){
IntegerMatrix matrix = new IntegerMatrix(negativeGrid10); IntegerMatrix matrix = new IntegerMatrix(negativeGrid10);
assertThrows(InvalidScalarException.class, () -> { assertThrows(InvalidScalarException.class, matrix::inverse);
matrix.inverse();
});
} }
@Test @Test
public void testInverse_size2x10(){ public void testInverse_size2x10(){
IntegerMatrix matrix = new IntegerMatrix(negativeGrid2x10); IntegerMatrix matrix = new IntegerMatrix(negativeGrid2x10);
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, matrix::inverse);
matrix.inverse();
});
} }
@Test @Test
public void testInverse_size10x2(){ public void testInverse_size10x2(){
IntegerMatrix matrix = new IntegerMatrix(negativeGrid10x2); IntegerMatrix matrix = new IntegerMatrix(negativeGrid10x2);
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, matrix::inverse);
matrix.inverse();
});
} }
//! equals() //! equals()
@@ -2182,16 +2134,17 @@ public class TestIntegerMatrix{
IntegerMatrix matrix = new IntegerMatrix(negativeGrid10); IntegerMatrix matrix = new IntegerMatrix(negativeGrid10);
assertEquals( assertEquals(
"[-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]\n" + """
"[-11, -12, -13, -14, -15, -16, -17, -18, -19, -20]\n" + [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]
"[-21, -22, -23, -24, -25, -26, -27, -28, -29, -30]\n" + [-11, -12, -13, -14, -15, -16, -17, -18, -19, -20]
"[-31, -32, -33, -34, -35, -36, -37, -38, -39, -40]\n" + [-21, -22, -23, -24, -25, -26, -27, -28, -29, -30]
"[-41, -42, -43, -44, -45, -46, -47, -48, -49, -50]\n" + [-31, -32, -33, -34, -35, -36, -37, -38, -39, -40]
"[-51, -52, -53, -54, -55, -56, -57, -58, -59, -60]\n" + [-41, -42, -43, -44, -45, -46, -47, -48, -49, -50]
"[-61, -62, -63, -64, -65, -66, -67, -68, -69, -70]\n" + [-51, -52, -53, -54, -55, -56, -57, -58, -59, -60]
"[-71, -72, -73, -74, -75, -76, -77, -78, -79, -80]\n" + [-61, -62, -63, -64, -65, -66, -67, -68, -69, -70]
"[-81, -82, -83, -84, -85, -86, -87, -88, -89, -90]\n" + [-71, -72, -73, -74, -75, -76, -77, -78, -79, -80]
"[-91, -92, -93, -94, -95, -96, -97, -98, -99, -100]", [-81, -82, -83, -84, -85, -86, -87, -88, -89, -90]
[-91, -92, -93, -94, -95, -96, -97, -98, -99, -100]""",
matrix.toString()); matrix.toString());
} }

View File

@@ -1,7 +1,3 @@
//Matrix/src/test/java/com/mattrixwv/matrix/TestLongMatrix.java
//Mattrixwv
// Created: 02-10-22
//Modified: 08-10-24
package com.mattrixwv.matrix; package com.mattrixwv.matrix;
@@ -1774,12 +1770,8 @@ public class TestLongMatrix{
public void testDeterminant_size0(){ public void testDeterminant_size0(){
LongMatrix matrix = new LongMatrix(); LongMatrix matrix = new LongMatrix();
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, matrix::determinant);
matrix.determinant(); assertThrows(InvalidGeometryException.class, matrix::det);
});
assertThrows(InvalidGeometryException.class, () -> {
matrix.det();
});
} }
@Test @Test
@@ -1818,24 +1810,16 @@ public class TestLongMatrix{
public void testDeterminant_size2x10(){ public void testDeterminant_size2x10(){
LongMatrix matrix = new LongMatrix(negativeGrid2x10); LongMatrix matrix = new LongMatrix(negativeGrid2x10);
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, matrix::determinant);
matrix.determinant(); assertThrows(InvalidGeometryException.class, matrix::det);
});
assertThrows(InvalidGeometryException.class, () -> {
matrix.det();
});
} }
@Test @Test
public void testDeterminant_size10x2(){ public void testDeterminant_size10x2(){
LongMatrix matrix = new LongMatrix(negativeGrid10x2); LongMatrix matrix = new LongMatrix(negativeGrid10x2);
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, matrix::determinant);
matrix.determinant(); assertThrows(InvalidGeometryException.class, matrix::det);
});
assertThrows(InvalidGeometryException.class, () -> {
matrix.det();
});
} }
//! cofactor() / cof() //! cofactor() / cof()
@@ -1843,12 +1827,8 @@ public class TestLongMatrix{
public void testCofactor_size0(){ public void testCofactor_size0(){
LongMatrix matrix = new LongMatrix(); LongMatrix matrix = new LongMatrix();
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, matrix::cofactor);
matrix.cofactor(); assertThrows(InvalidGeometryException.class, matrix::cof);
});
assertThrows(InvalidGeometryException.class, () -> {
matrix.cof();
});
} }
@Test @Test
@@ -1893,24 +1873,16 @@ public class TestLongMatrix{
public void testCofactor_size2x10(){ public void testCofactor_size2x10(){
LongMatrix matrix = new LongMatrix(negativeGrid2x10); LongMatrix matrix = new LongMatrix(negativeGrid2x10);
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, matrix::cofactor);
matrix.cofactor(); assertThrows(InvalidGeometryException.class, matrix::cof);
});
assertThrows(InvalidGeometryException.class, () -> {
matrix.cof();
});
} }
@Test @Test
public void testCofactor_size10x2(){ public void testCofactor_size10x2(){
LongMatrix matrix = new LongMatrix(negativeGrid10x2); LongMatrix matrix = new LongMatrix(negativeGrid10x2);
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, matrix::cofactor);
matrix.cofactor(); assertThrows(InvalidGeometryException.class, matrix::cof);
});
assertThrows(InvalidGeometryException.class, () -> {
matrix.cof();
});
} }
//! adjoint() / adj() //! adjoint() / adj()
@@ -1918,12 +1890,8 @@ public class TestLongMatrix{
public void testAdjoint_size0(){ public void testAdjoint_size0(){
LongMatrix matrix = new LongMatrix(); LongMatrix matrix = new LongMatrix();
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, matrix::adjoint);
matrix.adjoint(); assertThrows(InvalidGeometryException.class, matrix::adj);
});
assertThrows(InvalidGeometryException.class, () -> {
matrix.adj();
});
} }
@Test @Test
@@ -1968,24 +1936,16 @@ public class TestLongMatrix{
public void testAdjoint_size2x10(){ public void testAdjoint_size2x10(){
LongMatrix matrix = new LongMatrix(negativeGrid2x10); LongMatrix matrix = new LongMatrix(negativeGrid2x10);
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, matrix::adjoint);
matrix.adjoint(); assertThrows(InvalidGeometryException.class, matrix::adj);
});
assertThrows(InvalidGeometryException.class, () -> {
matrix.adj();
});
} }
@Test @Test
public void testAdjoint_size10x2(){ public void testAdjoint_size10x2(){
LongMatrix matrix = new LongMatrix(negativeGrid10x2); LongMatrix matrix = new LongMatrix(negativeGrid10x2);
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, matrix::adjoint);
matrix.adjoint(); assertThrows(InvalidGeometryException.class, matrix::adj);
});
assertThrows(InvalidGeometryException.class, () -> {
matrix.adj();
});
} }
//! inverse() //! inverse()
@@ -1993,9 +1953,7 @@ public class TestLongMatrix{
public void testInverse_size0(){ public void testInverse_size0(){
LongMatrix matrix = new LongMatrix(); LongMatrix matrix = new LongMatrix();
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, matrix::inverse);
matrix.inverse();
});
} }
@Test @Test
@@ -2018,27 +1976,21 @@ public class TestLongMatrix{
public void testInverse_size10(){ public void testInverse_size10(){
LongMatrix matrix = new LongMatrix(negativeGrid10); LongMatrix matrix = new LongMatrix(negativeGrid10);
assertThrows(InvalidScalarException.class, () -> { assertThrows(InvalidScalarException.class, matrix::inverse);
matrix.inverse();
});
} }
@Test @Test
public void testInverse_size2x10(){ public void testInverse_size2x10(){
LongMatrix matrix = new LongMatrix(negativeGrid2x10); LongMatrix matrix = new LongMatrix(negativeGrid2x10);
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, matrix::inverse);
matrix.inverse();
});
} }
@Test @Test
public void testInverse_size10x2(){ public void testInverse_size10x2(){
LongMatrix matrix = new LongMatrix(negativeGrid10x2); LongMatrix matrix = new LongMatrix(negativeGrid10x2);
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, matrix::inverse);
matrix.inverse();
});
} }
//! equals() //! equals()
@@ -2182,16 +2134,17 @@ public class TestLongMatrix{
LongMatrix matrix = new LongMatrix(negativeGrid10); LongMatrix matrix = new LongMatrix(negativeGrid10);
assertEquals( assertEquals(
"[-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]\n" + """
"[-11, -12, -13, -14, -15, -16, -17, -18, -19, -20]\n" + [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]
"[-21, -22, -23, -24, -25, -26, -27, -28, -29, -30]\n" + [-11, -12, -13, -14, -15, -16, -17, -18, -19, -20]
"[-31, -32, -33, -34, -35, -36, -37, -38, -39, -40]\n" + [-21, -22, -23, -24, -25, -26, -27, -28, -29, -30]
"[-41, -42, -43, -44, -45, -46, -47, -48, -49, -50]\n" + [-31, -32, -33, -34, -35, -36, -37, -38, -39, -40]
"[-51, -52, -53, -54, -55, -56, -57, -58, -59, -60]\n" + [-41, -42, -43, -44, -45, -46, -47, -48, -49, -50]
"[-61, -62, -63, -64, -65, -66, -67, -68, -69, -70]\n" + [-51, -52, -53, -54, -55, -56, -57, -58, -59, -60]
"[-71, -72, -73, -74, -75, -76, -77, -78, -79, -80]\n" + [-61, -62, -63, -64, -65, -66, -67, -68, -69, -70]
"[-81, -82, -83, -84, -85, -86, -87, -88, -89, -90]\n" + [-71, -72, -73, -74, -75, -76, -77, -78, -79, -80]
"[-91, -92, -93, -94, -95, -96, -97, -98, -99, -100]", [-81, -82, -83, -84, -85, -86, -87, -88, -89, -90]
[-91, -92, -93, -94, -95, -96, -97, -98, -99, -100]""",
matrix.toString()); matrix.toString());
} }

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,3 @@
//Matrix/src/test/java/com/mattrixwv/matrix/exceptions/TestInvalidCoordinatesException.java
//Mattrixwv
// Created: 04-13-23
//Modified: 08-11-24
package com.mattrixwv.matrix.exceptions; package com.mattrixwv.matrix.exceptions;
@@ -11,8 +7,8 @@ import org.junit.jupiter.api.Test;
public class TestInvalidCoordinatesException{ public class TestInvalidCoordinatesException{
private static final String message = "message"; private static final String MESSAGE = "message";
private static final Throwable cause = new Exception(); private static final Throwable CAUSE = new Exception();
@Test @Test
@@ -23,22 +19,22 @@ public class TestInvalidCoordinatesException{
} }
@Test @Test
public void testConstructor_message(){ public void testConstructor_message(){
InvalidCoordinatesException exception = new InvalidCoordinatesException(message); InvalidCoordinatesException exception = new InvalidCoordinatesException(MESSAGE);
assertEquals(message, exception.getMessage()); assertEquals(MESSAGE, exception.getMessage());
assertNull(exception.getCause()); assertNull(exception.getCause());
} }
@Test @Test
public void testConstructor_cause(){ public void testConstructor_cause(){
InvalidCoordinatesException exception = new InvalidCoordinatesException(cause); InvalidCoordinatesException exception = new InvalidCoordinatesException(CAUSE);
assertEquals(cause.toString(), exception.getMessage()); assertEquals(CAUSE.toString(), exception.getMessage());
assertEquals(cause, exception.getCause()); assertEquals(CAUSE, exception.getCause());
} }
@Test @Test
public void testConstructor_messageCause(){ public void testConstructor_messageCause(){
InvalidCoordinatesException exception = new InvalidCoordinatesException(message, cause); InvalidCoordinatesException exception = new InvalidCoordinatesException(MESSAGE, CAUSE);
assertEquals(message, exception.getMessage()); assertEquals(MESSAGE, exception.getMessage());
assertEquals(cause, exception.getCause()); assertEquals(CAUSE, exception.getCause());
} }
@Test @Test

View File

@@ -1,7 +1,3 @@
//Matrix/src/test/java/com/mattrixwv/matrix/exceptions/TestInvalidGeometryException.java
//Mattrixwv
// Created: 04-13-23
//Modified: 08-11-24
package com.mattrixwv.matrix.exceptions; package com.mattrixwv.matrix.exceptions;
@@ -11,8 +7,8 @@ import org.junit.jupiter.api.Test;
public class TestInvalidGeometryException{ public class TestInvalidGeometryException{
private static final String message = "message"; private static final String MESSAGE = "message";
private static final Throwable cause = new Exception(); private static final Throwable CAUSE = new Exception();
@Test @Test
@@ -24,22 +20,22 @@ public class TestInvalidGeometryException{
@Test @Test
public void testConstructor_message(){ public void testConstructor_message(){
InvalidGeometryException exception = new InvalidGeometryException(message); InvalidGeometryException exception = new InvalidGeometryException(MESSAGE);
assertEquals(message, exception.getMessage()); assertEquals(MESSAGE, exception.getMessage());
assertNull(exception.getCause()); assertNull(exception.getCause());
} }
@Test @Test
public void testConstructor_cause(){ public void testConstructor_cause(){
InvalidGeometryException exception = new InvalidGeometryException(cause); InvalidGeometryException exception = new InvalidGeometryException(CAUSE);
assertEquals(cause.toString(), exception.getMessage()); assertEquals(CAUSE.toString(), exception.getMessage());
assertEquals(cause, exception.getCause()); assertEquals(CAUSE, exception.getCause());
} }
@Test @Test
public void testConstructor_messageCause(){ public void testConstructor_messageCause(){
InvalidGeometryException exception = new InvalidGeometryException(message, cause); InvalidGeometryException exception = new InvalidGeometryException(MESSAGE, CAUSE);
assertEquals(message, exception.getMessage()); assertEquals(MESSAGE, exception.getMessage());
assertEquals(cause, exception.getCause()); assertEquals(CAUSE, exception.getCause());
} }
} }

View File

@@ -1,7 +1,3 @@
//Matrix/src/test/java/com/mattrixwv/matrix/exceptions/TestInvalidRowSizeException.java
//Mattrixwv
// Created: 04-13-23
//Modified: 08-11-24
package com.mattrixwv.matrix.exceptions; package com.mattrixwv.matrix.exceptions;
@@ -11,8 +7,8 @@ import org.junit.jupiter.api.Test;
public class TestInvalidRowSizeException{ public class TestInvalidRowSizeException{
private static final String message = "message"; private static final String MESSAGE = "message";
private static final Throwable cause = new Exception(); private static final Throwable CAUSE = new Exception();
@Test @Test
@@ -24,22 +20,22 @@ public class TestInvalidRowSizeException{
@Test @Test
public void testConstructor_message(){ public void testConstructor_message(){
InvalidRowSizeException exception = new InvalidRowSizeException(message); InvalidRowSizeException exception = new InvalidRowSizeException(MESSAGE);
assertEquals(message, exception.getMessage()); assertEquals(MESSAGE, exception.getMessage());
assertNull(exception.getCause()); assertNull(exception.getCause());
} }
@Test @Test
public void testConstructor_cause(){ public void testConstructor_cause(){
InvalidRowSizeException exception = new InvalidRowSizeException(cause); InvalidRowSizeException exception = new InvalidRowSizeException(CAUSE);
assertEquals(cause.toString(), exception.getMessage()); assertEquals(CAUSE.toString(), exception.getMessage());
assertEquals(cause, exception.getCause()); assertEquals(CAUSE, exception.getCause());
} }
@Test @Test
public void testConstructor_messageCause(){ public void testConstructor_messageCause(){
InvalidRowSizeException exception = new InvalidRowSizeException(message, cause); InvalidRowSizeException exception = new InvalidRowSizeException(MESSAGE, CAUSE);
assertEquals(message, exception.getMessage()); assertEquals(MESSAGE, exception.getMessage());
assertEquals(cause, exception.getCause()); assertEquals(CAUSE, exception.getCause());
} }
} }

View File

@@ -1,7 +1,3 @@
//Matrix/src/test/java/com/mattrixwv/matrix/exceptions/TestInvalidScalarException.java
//Mattrixwv
// Created: 04-13-23
//Modified: 08-11-24
package com.mattrixwv.matrix.exceptions; package com.mattrixwv.matrix.exceptions;
@@ -11,8 +7,8 @@ import org.junit.jupiter.api.Test;
public class TestInvalidScalarException{ public class TestInvalidScalarException{
private static final String message = "message"; private static final String MESSAGE = "message";
private static final Throwable cause = new Exception(); private static final Throwable CAUSE = new Exception();
@Test @Test
@@ -24,22 +20,22 @@ public class TestInvalidScalarException{
@Test @Test
public void testConstructor_message(){ public void testConstructor_message(){
InvalidScalarException exception = new InvalidScalarException(message); InvalidScalarException exception = new InvalidScalarException(MESSAGE);
assertEquals(message, exception.getMessage()); assertEquals(MESSAGE, exception.getMessage());
assertNull(exception.getCause()); assertNull(exception.getCause());
} }
@Test @Test
public void testConstructor_cause(){ public void testConstructor_cause(){
InvalidScalarException exception = new InvalidScalarException(cause); InvalidScalarException exception = new InvalidScalarException(CAUSE);
assertEquals(cause.toString(), exception.getMessage()); assertEquals(CAUSE.toString(), exception.getMessage());
assertEquals(cause, exception.getCause()); assertEquals(CAUSE, exception.getCause());
} }
@Test @Test
public void testConstructor_messageCause(){ public void testConstructor_messageCause(){
InvalidScalarException exception = new InvalidScalarException(message, cause); InvalidScalarException exception = new InvalidScalarException(MESSAGE, CAUSE);
assertEquals(message, exception.getMessage()); assertEquals(MESSAGE, exception.getMessage());
assertEquals(cause, exception.getCause()); assertEquals(CAUSE, exception.getCause());
} }
} }

View File

@@ -1,7 +1,3 @@
//Matrix/src/test/java/com/mattrixwv/matrix/exceptions/TestNullMatrixException.java
//Mattrixwv
// Created: 04-13-23
//Modified: 08-11-24
package com.mattrixwv.matrix.exceptions; package com.mattrixwv.matrix.exceptions;
@@ -11,8 +7,8 @@ import org.junit.jupiter.api.Test;
public class TestNullMatrixException{ public class TestNullMatrixException{
private static final String message = "message"; private static final String MESSAGE = "message";
private static final Throwable cause = new Exception(); private static final Throwable CAUSE = new Exception();
@Test @Test
@@ -24,21 +20,21 @@ public class TestNullMatrixException{
@Test @Test
public void testConstructor_message(){ public void testConstructor_message(){
NullMatrixException exception = new NullMatrixException(message); NullMatrixException exception = new NullMatrixException(MESSAGE);
assertEquals(message, exception.getMessage()); assertEquals(MESSAGE, exception.getMessage());
assertNull(exception.getCause()); assertNull(exception.getCause());
} }
@Test @Test
public void testConstructor_cause(){ public void testConstructor_cause(){
NullMatrixException exception = new NullMatrixException(cause); NullMatrixException exception = new NullMatrixException(CAUSE);
assertEquals(cause.toString(), exception.getMessage()); assertEquals(CAUSE.toString(), exception.getMessage());
assertEquals(cause, exception.getCause()); assertEquals(CAUSE, exception.getCause());
} }
@Test @Test
public void testConstructor_messageCause(){ public void testConstructor_messageCause(){
NullMatrixException exception = new NullMatrixException(message, cause); NullMatrixException exception = new NullMatrixException(MESSAGE, CAUSE);
assertEquals(message, exception.getMessage()); assertEquals(MESSAGE, exception.getMessage());
assertEquals(cause, exception.getCause()); assertEquals(CAUSE, exception.getCause());
} }
} }