Compare commits
12 Commits
50e1ec67e8
...
v1.3.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
799eb03397
|
|||
|
ac332f9740
|
|||
|
8275608730
|
|||
|
63d9d1d488
|
|||
|
a16577be96
|
|||
|
0f4283bc7f
|
|||
|
02e5ed607e
|
|||
|
bd11bd240e
|
|||
|
dc6c94216d
|
|||
| 6d5eff2ebc | |||
| e1b2a4ca94 | |||
| 5873d77dce |
2
.mvn/maven.config
Normal file
2
.mvn/maven.config
Normal file
@@ -0,0 +1,2 @@
|
||||
-Dstyle.color=always
|
||||
-T1C
|
||||
309
pom.xml
309
pom.xml
@@ -27,7 +27,7 @@
|
||||
|
||||
<groupId>com.mattrixwv</groupId>
|
||||
<artifactId>matrix</artifactId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.3.0</version>
|
||||
|
||||
<name>Matrix</name>
|
||||
<description>A library for performing Matrix operations</description>
|
||||
@@ -37,24 +37,21 @@
|
||||
<!--Compile-->
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>21</java.version>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<java.version>25</java.version>
|
||||
<maven.compiler.source>25</maven.compiler.source>
|
||||
<maven.compiler.target>25</maven.compiler.target>
|
||||
|
||||
<!--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.htmlReportPath>target/dependency-check-report.html</sonar.dependencyCheck.htmlReportPath>
|
||||
|
||||
<!--Deployment-->
|
||||
<gpg.keyname>3BA6515C8FF145249BEBBEABA52FDEC4259179D4</gpg.keyname>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>5.12.2</version>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<version>6.0.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
@@ -65,157 +62,36 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-enforcer-plugin</artifactId>
|
||||
<version>3.5.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>enforce-maven</id>
|
||||
<phase>validate</phase>
|
||||
<goals>
|
||||
<goal>enforce</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<rules>
|
||||
<requireMavenVersion>
|
||||
<version>3.8.6</version>
|
||||
</requireMavenVersion>
|
||||
</rules>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-clean-plugin</artifactId>
|
||||
<version>3.4.1</version>
|
||||
</plugin>
|
||||
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.3.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.14.0</version>
|
||||
<configuration>
|
||||
<release>${java.version}</release>
|
||||
<compilerArgs>
|
||||
<arg>-Xlint:all</arg>
|
||||
</compilerArgs>
|
||||
<showWarnings>true</showWarnings>
|
||||
<showDeprecation>true</showDeprecation>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.5.3</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.4.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-install-plugin</artifactId>
|
||||
<version>3.1.4</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>3.1.4</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-site-plugin</artifactId>
|
||||
<version>3.21.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||
<version>3.9.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>versions-maven-plugin</artifactId>
|
||||
<version>2.18.0</version>
|
||||
<configuration>
|
||||
<rulesUri>file://${session.executionRootDirectory}/version-rules.xml</rulesUri>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
</plugin>
|
||||
|
||||
<!--Sonarqube-->
|
||||
<plugin>
|
||||
<groupId>org.sonarsource.scanner.maven</groupId>
|
||||
<artifactId>sonar-maven-plugin</artifactId>
|
||||
<version>5.1.0.4751</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<version>0.8.13</version>
|
||||
<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>
|
||||
<groupId>org.owasp</groupId>
|
||||
<artifactId>dependency-check-maven</artifactId>
|
||||
<version>12.1.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>none</phase>
|
||||
<id>dependency-check</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>check</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<formats>
|
||||
<format>json</format>
|
||||
<format>html</format>
|
||||
</formats>
|
||||
<nvdApiServerId>nvd</nvdApiServerId>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!--Deployment-->
|
||||
<plugin>
|
||||
<groupId>org.sonatype.central</groupId>
|
||||
<artifactId>central-publishing-maven-plugin</artifactId>
|
||||
<version>0.7.0</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<publishingServerId>ossrh</publishingServerId>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||
<version>1.7.0</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<serverId>ossrh</serverId>
|
||||
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
|
||||
<autoReleaseAfterClose>true</autoReleaseAfterClose>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>3.3.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
@@ -225,11 +101,9 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.11.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
@@ -239,11 +113,9 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<version>3.2.7</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>sign-artifacts</id>
|
||||
@@ -251,23 +123,156 @@
|
||||
<goals>
|
||||
<goal>sign</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<keyname>${gpg.keyname}</keyname>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>ossrh</id>
|
||||
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
|
||||
</snapshotRepository>
|
||||
<repository>
|
||||
<id>ossrh</id>
|
||||
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<!--Ensure maven is the correct version-->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-enforcer-plugin</artifactId>
|
||||
<version>3.6.2</version>
|
||||
<configuration>
|
||||
<rules>
|
||||
<requireMavenVersion>
|
||||
<version>3.8.6</version>
|
||||
</requireMavenVersion>
|
||||
</rules>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-clean-plugin</artifactId>
|
||||
<version>3.5.0</version>
|
||||
</plugin>
|
||||
|
||||
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.4.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.14.1</version>
|
||||
<configuration>
|
||||
<release>${java.version}</release>
|
||||
<compilerArgs>
|
||||
<arg>-Xlint:all</arg>
|
||||
<arg>-Xlint:-serial</arg>
|
||||
</compilerArgs>
|
||||
<showWarnings>true</showWarnings>
|
||||
<showDeprecation>true</showDeprecation>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.5.4</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.5.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-install-plugin</artifactId>
|
||||
<version>3.1.4</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-site-plugin</artifactId>
|
||||
<version>3.21.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||
<version>3.9.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>versions-maven-plugin</artifactId>
|
||||
<version>2.21.0</version>
|
||||
<configuration>
|
||||
<rulesUri>file://${session.executionRootDirectory}/version-rules.xml</rulesUri>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>3.9.0</version>
|
||||
</plugin>
|
||||
|
||||
<!--Sonarqube-->
|
||||
<plugin>
|
||||
<groupId>org.sonarsource.scanner.maven</groupId>
|
||||
<artifactId>sonar-maven-plugin</artifactId>
|
||||
<version>5.5.0.6356</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<version>0.8.14</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.owasp</groupId>
|
||||
<artifactId>dependency-check-maven</artifactId>
|
||||
<version>12.2.0</version>
|
||||
<configuration>
|
||||
<formats>
|
||||
<format>json</format>
|
||||
<format>html</format>
|
||||
</formats>
|
||||
<nvdApiServerId>nvd</nvdApiServerId>
|
||||
<failBuildOnCVSS>7</failBuildOnCVSS>
|
||||
<ossIndexServerId>ossindex</ossIndexServerId>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!--Deployment-->
|
||||
<plugin>
|
||||
<groupId>org.sonatype.central</groupId>
|
||||
<artifactId>central-publishing-maven-plugin</artifactId>
|
||||
<version>0.10.0</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<publishingServerId>central</publishingServerId>
|
||||
<autoPublish>true</autoPublish>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>3.1.4</version>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>3.4.0</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.12.0</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<version>3.2.8</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
</project>
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -27,18 +23,17 @@ public class BigIntegerMatrix{
|
||||
|
||||
//?Helper functions
|
||||
/**
|
||||
* Sets the matrix grid to the specified 2D array. Validates the input to ensure
|
||||
* all rows are of equal length.
|
||||
* 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.
|
||||
* @return the new validated grid
|
||||
*/
|
||||
protected void setGrid(BigInteger[][] grid){
|
||||
private BigInteger[][] validateGrid(BigInteger[][] grid){
|
||||
if(grid.length == 0){
|
||||
this.grid = new BigInteger[0][0];
|
||||
return new BigInteger[0][0];
|
||||
}
|
||||
else if(grid[0].length == 0){
|
||||
this.grid = new BigInteger[grid.length][0];
|
||||
return new BigInteger[grid.length][0];
|
||||
}
|
||||
else{
|
||||
//Make sure all rows are the same length
|
||||
@@ -56,9 +51,19 @@ public class BigIntegerMatrix{
|
||||
}
|
||||
|
||||
//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.
|
||||
*
|
||||
@@ -159,7 +164,7 @@ public class BigIntegerMatrix{
|
||||
* @param grid The 2D array to initialize the matrix with.
|
||||
*/
|
||||
public BigIntegerMatrix(BigInteger[][] grid){
|
||||
setGrid(grid);
|
||||
this.grid = validateGrid(grid);
|
||||
}
|
||||
/**
|
||||
* Constructs a copy of the specified matrix.
|
||||
@@ -167,7 +172,7 @@ public class BigIntegerMatrix{
|
||||
* @param matrix The matrix to copy.
|
||||
*/
|
||||
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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -30,18 +26,17 @@ public class DoubleMatrix{
|
||||
|
||||
//?Helper functions
|
||||
/**
|
||||
* Sets the matrix grid to the specified 2D array. Validates the input to ensure
|
||||
* all rows are of equal length.
|
||||
* 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.
|
||||
* @return the new validated grid
|
||||
*/
|
||||
protected void setGrid(double[][] grid){
|
||||
private double[][] validateGrid(double[][] grid){
|
||||
if(grid.length == 0){
|
||||
this.grid = new double[0][0];
|
||||
return new double[0][0];
|
||||
}
|
||||
else if(grid[0].length == 0){
|
||||
this.grid = new double[grid.length][0];
|
||||
return new double[grid.length][0];
|
||||
}
|
||||
else{
|
||||
//Make sure all rows are the same length
|
||||
@@ -59,9 +54,19 @@ public class DoubleMatrix{
|
||||
}
|
||||
|
||||
//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.
|
||||
*
|
||||
@@ -163,7 +168,7 @@ public class DoubleMatrix{
|
||||
* @param grid The 2D array to initialize the matrix with.
|
||||
*/
|
||||
public DoubleMatrix(double[][] grid){
|
||||
setGrid(grid);
|
||||
this.grid = validateGrid(grid);
|
||||
delta = 0.0;
|
||||
}
|
||||
/**
|
||||
@@ -172,7 +177,7 @@ public class DoubleMatrix{
|
||||
* @param matrix The matrix to copy.
|
||||
*/
|
||||
public DoubleMatrix(DoubleMatrix matrix){
|
||||
setGrid(matrix.grid);
|
||||
this.grid = validateGrid(matrix.grid);
|
||||
delta = 0.0;
|
||||
}
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -26,18 +22,17 @@ public class IntegerMatrix{
|
||||
|
||||
//?Helper functions
|
||||
/**
|
||||
* Sets the matrix grid to the specified 2D array. Validates the input to ensure
|
||||
* all rows are of equal length.
|
||||
* Validates that all rows in the grid 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.
|
||||
*/
|
||||
protected void setGrid(int[][] grid){
|
||||
private int[][] validateGrid(int[][] grid){
|
||||
if(grid.length == 0){
|
||||
this.grid = new int[0][0];
|
||||
return new int[0][0];
|
||||
}
|
||||
else if(grid[0].length == 0){
|
||||
this.grid = new int[grid.length][0];
|
||||
return new int[grid.length][0];
|
||||
}
|
||||
else{
|
||||
//Make sure all rows are the same length
|
||||
@@ -55,9 +50,19 @@ public class IntegerMatrix{
|
||||
}
|
||||
|
||||
//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.
|
||||
*
|
||||
@@ -158,7 +163,7 @@ public class IntegerMatrix{
|
||||
* @param grid The 2D array to initialize the matrix with.
|
||||
*/
|
||||
public IntegerMatrix(int[][] grid){
|
||||
setGrid(grid);
|
||||
this.grid = validateGrid(grid);
|
||||
}
|
||||
/**
|
||||
* Constructs a copy of the specified matrix.
|
||||
@@ -166,7 +171,7 @@ public class IntegerMatrix{
|
||||
* @param matrix The matrix to copy.
|
||||
*/
|
||||
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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -26,18 +22,17 @@ public class LongMatrix{
|
||||
|
||||
//?Helper functions
|
||||
/**
|
||||
* Sets the matrix grid to the specified 2D array. Validates the input to ensure
|
||||
* all rows are of equal length.
|
||||
* 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.
|
||||
* @return the new validated grid
|
||||
*/
|
||||
protected void setGrid(long[][] grid){
|
||||
private long[][] validateGrid(long[][] grid){
|
||||
if(grid.length == 0){
|
||||
this.grid = new long[0][0];
|
||||
return new long[0][0];
|
||||
}
|
||||
else if(grid[0].length == 0){
|
||||
this.grid = new long[grid.length][0];
|
||||
return new long[grid.length][0];
|
||||
}
|
||||
else{
|
||||
//Make sure all rows are the same length
|
||||
@@ -55,9 +50,19 @@ public class LongMatrix{
|
||||
}
|
||||
|
||||
//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.
|
||||
*
|
||||
@@ -158,7 +163,7 @@ public class LongMatrix{
|
||||
* @param grid The 2D array to initialize the matrix with.
|
||||
*/
|
||||
public LongMatrix(long[][] grid){
|
||||
setGrid(grid);
|
||||
this.grid = validateGrid(grid);
|
||||
}
|
||||
/**
|
||||
* Constructs a copy of the specified matrix.
|
||||
@@ -166,7 +171,7 @@ public class LongMatrix{
|
||||
* @param matrix The matrix to copy.
|
||||
*/
|
||||
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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
public class ModMatrix extends IntegerMatrix{
|
||||
public final class ModMatrix extends IntegerMatrix{
|
||||
/**
|
||||
* The mod used on each element of the matrix
|
||||
*/
|
||||
protected int mod;
|
||||
|
||||
//?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
|
||||
*
|
||||
@@ -31,11 +40,7 @@ public class ModMatrix extends IntegerMatrix{
|
||||
* @throws InvalidScalarException If the mod value is less than or equal to 0
|
||||
*/
|
||||
protected void setMod(int mod){
|
||||
if(mod <= 0){
|
||||
throw new InvalidScalarException("The mod must be > 0");
|
||||
}
|
||||
|
||||
this.mod = mod;
|
||||
this.mod = validateMod(mod);
|
||||
}
|
||||
/**
|
||||
* Get the mod value of a number
|
||||
@@ -103,7 +108,7 @@ public class ModMatrix extends IntegerMatrix{
|
||||
*/
|
||||
public ModMatrix(int mod){
|
||||
super();
|
||||
setMod(mod);
|
||||
this.mod = validateMod(mod);
|
||||
modGrid();
|
||||
}
|
||||
/**
|
||||
@@ -114,7 +119,7 @@ public class ModMatrix extends IntegerMatrix{
|
||||
*/
|
||||
public ModMatrix(int[][] grid, int mod){
|
||||
super();
|
||||
setMod(mod);
|
||||
this.mod = validateMod(mod);
|
||||
setGrid(grid);
|
||||
}
|
||||
/**
|
||||
@@ -124,7 +129,7 @@ public class ModMatrix extends IntegerMatrix{
|
||||
*/
|
||||
public ModMatrix(ModMatrix matrix){
|
||||
super();
|
||||
setMod(matrix.mod);
|
||||
this.mod = validateMod(matrix.mod);
|
||||
setGrid(matrix.grid);
|
||||
}
|
||||
/**
|
||||
@@ -135,7 +140,7 @@ public class ModMatrix extends IntegerMatrix{
|
||||
*/
|
||||
public ModMatrix(IntegerMatrix matrix, int mod){
|
||||
super();
|
||||
setMod(mod);
|
||||
this.mod = validateMod(mod);
|
||||
setGrid(matrix.grid);
|
||||
}
|
||||
/**
|
||||
@@ -149,7 +154,7 @@ public class ModMatrix extends IntegerMatrix{
|
||||
*/
|
||||
public ModMatrix(int rows, int cols, int fill, int mod){
|
||||
super(rows, cols, fill);
|
||||
setMod(mod);
|
||||
this.mod = validateMod(mod);
|
||||
modGrid();
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -11,12 +7,6 @@ package com.mattrixwv.matrix.exceptions;
|
||||
* @author Mattrixwv
|
||||
*/
|
||||
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.
|
||||
* The cause is not initialized, and may subsequently be initialized by a call to {@link #initCause}.
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -11,12 +7,6 @@ package com.mattrixwv.matrix.exceptions;
|
||||
* @author Mattrixwv
|
||||
*/
|
||||
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.
|
||||
* The cause is not initialized and may subsequently be initialized by a call to {@link #initCause}.
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
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.
|
||||
* The cause is not initialized and may subsequently be initialized by a call to {@link #initCause}.
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -9,12 +5,6 @@ package com.mattrixwv.matrix.exceptions;
|
||||
* Exception thrown to indicate that a scalar value passed to a matrix is invalid
|
||||
*/
|
||||
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.
|
||||
* The cause is not initialized and may subsequently be initialized by a call to {@link #initCause}.
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -9,12 +5,6 @@ package com.mattrixwv.matrix.exceptions;
|
||||
* Exception thrown to indicate that a null matrix has been illegally passed to a method
|
||||
*/
|
||||
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.
|
||||
* The cause is not initialized and may subsequently be initialized by a call to {@link #initCause}.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#junit.jupiter.execution.parallel.enabled=true
|
||||
#junit.jupiter.execution.parallel.config.strategy=dynamic
|
||||
#junit.jupiter.execution.parallel.mode.default=concurrent
|
||||
#junit.jupiter.execution.parallel.mode.classes.default=concurrent
|
||||
#Enable parallel test execution
|
||||
junit.jupiter.execution.parallel.enabled=true
|
||||
#Per-function behavior
|
||||
junit.jupiter.execution.parallel.mode.default=concurrent
|
||||
#Per-class behavior
|
||||
junit.jupiter.execution.parallel.mode.classes.default=concurrent
|
||||
|
||||
Reference in New Issue
Block a user