reciprocal is a free software library for the JVM that provides or will provide implementations of fractions, complex numbers, vectors, matrices, polynomials and geometric shapes and their arithmetic and properties.
What reciprocal will provide:
- Fractions and complex numbers
- Vectors and matrices
- Determinant calculation
- Polynomials
- Circles and rectangles
- Pseudorandom number generators
- Kotlin module
- Scala module
- Custom assertions for AssertJ
- Custom matchers for Kotest
What reciprocal will not provide:
- Solver for equations
- Matrix decomposition, reduction or factorization
A JDK in version 17 and Maven in version 3.8 is needed to build this project.
mvn install site
- Java 17
- All types are immutable.
- Absolutely no null values
- Numbers extend
java.lang.Number
and fractions implementsjava.lang.Comparable
- Comparators implement
java.lang.Comparator
- Numbers, vectors, matrices and polynomials implement
java.io.Serializable
- Classes of numbers, vectors and matrices are final.
- Useful hashCode, equals and toString methods
- Builders for vectors and matrices
- Parameter validation and fast failing
- Nullability annotations
class Class {
void method() {
// arithmetic methods follow the naming scheme of BigInteger/BigDecimal
new Fraction(2L, 3L).add(new Fraction(3L, 4L));
// getting an element of a vector or matrix
vector.get(1);
matrix.get(2, 3);
// check if an element is contained in a vector or matrix
if (vector.contains(0L)) {
doSomethingCool();
}
// classic builders for vectors and matrices with a fluent API
LongVector.ofSize(3)
.computationOfAbsentees(i -> new SecureRandom().nextLong()) // default: i -> 0L
.set(1, 1L)
.set(3, 2L)
.build();
}
}
- Complete Javadoc
- Clean code
- High code quality with the help of Checkstyle, PMD, SpotBugs, SonarLint and SonarCloud
- High code coverage with the help of JUnit, AssertJ, Mockito, JaCoCo and SonarCloud
- Stay up-to-date with versions of libraries and plugins
- Object-oriented design with functional abstraction
- Being Groovy, Kotlin and Scala friendly
- Use nullability annotations as much as possible