diff --git a/src/main/java/io/rala/math/MathX.java b/src/main/java/io/rala/math/MathX.java index 37103024..bc7317bc 100644 --- a/src/main/java/io/rala/math/MathX.java +++ b/src/main/java/io/rala/math/MathX.java @@ -14,6 +14,7 @@ * collection of math functions similar to {@link Math} * * @see Math + * @since 1.0.0 */ public class MathX { private static final MathContext MATH_CONTEXT = @@ -33,6 +34,7 @@ private MathX() { * {@link Math#toIntExact(long)} * @see #gcd(int, int) * @see BigInteger#gcd(BigInteger) + * @since 1.0.0 */ public static int gcd(int... a) { return Math.toIntExact( @@ -47,6 +49,7 @@ public static int gcd(int... a) { * {@link BigInteger#longValueExact()} * @see #gcd(long, long) * @see BigInteger#gcd(BigInteger) + * @since 1.0.0 */ public static long gcd(long... a) { return gcd( @@ -62,6 +65,7 @@ public static long gcd(long... a) { * or {@code null} if parameter is {@code null} * @see #gcd(BigInteger, BigInteger) * @see BigInteger#gcd(BigInteger) + * @since 1.0.0 */ public static BigInteger gcd(BigInteger... a) { if (a == null) return null; @@ -81,6 +85,7 @@ public static BigInteger gcd(BigInteger... a) { * {@link Math#toIntExact(long)} * @see #gcd(int...) * @see BigInteger#gcd(BigInteger) + * @since 1.0.0 */ public static int gcd(int a, int b) { return Math.toIntExact(gcd((long) a, b)); @@ -94,6 +99,7 @@ public static int gcd(int a, int b) { * {@link BigInteger#longValueExact()} * @see #gcd(long...) * @see BigInteger#gcd(BigInteger) + * @since 1.0.0 */ public static long gcd(long a, long b) { return gcd(BigInteger.valueOf(a), BigInteger.valueOf(b)).longValueExact(); @@ -106,6 +112,7 @@ public static long gcd(long a, long b) { * or {@code null} if parameter is {@code null} * @see #gcd(BigInteger...) * @see BigInteger#gcd(BigInteger) + * @since 1.0.0 */ public static BigInteger gcd(BigInteger a, BigInteger b) { return a == null || b == null ? null : a.gcd(b); @@ -118,6 +125,7 @@ public static BigInteger gcd(BigInteger a, BigInteger b) { /** * @param a number to get factors of * @return list of factors + * @since 1.0.0 */ public static List factors(int a) { return factors((long) a).stream() @@ -128,6 +136,7 @@ public static List factors(int a) { /** * @param a number to get factors of * @return list of factors + * @since 1.0.0 */ public static List factors(long a) { // https://stackoverflow.com/a/6233030/2715720 @@ -150,6 +159,7 @@ public static List factors(long a) { * * @param a number * @return factorial + * @since 1.0.0 */ public static long factorial(int a) { return factorial((long) a); @@ -162,6 +172,7 @@ public static long factorial(int a) { * @return factorial * @throws ArithmeticException may be thrown for example by * {@link BigInteger#longValueExact()} + * @since 1.0.0 */ public static long factorial(long a) { return factorial(BigInteger.valueOf(a)).longValueExact(); @@ -173,6 +184,7 @@ public static long factorial(long a) { * @param a number * @return factorial * or {@code null} if parameter is {@code null} + * @since 1.0.0 */ public static BigInteger factorial(BigInteger a) { return a == null ? null : @@ -193,6 +205,7 @@ public static BigInteger factorial(BigInteger a) { * @throws ArithmeticException may be thrown for example by * {@link Math#toIntExact(long)} * @see #lcm(int, int) + * @since 1.0.0 */ public static int lcm(int... a) { return Math.toIntExact( @@ -208,6 +221,7 @@ public static int lcm(int... a) { * @throws ArithmeticException may be thrown for example by * {@link BigInteger#longValueExact()} * @see #lcm(long, long) + * @since 1.0.0 */ public static long lcm(long... a) { return lcm( @@ -224,6 +238,7 @@ public static long lcm(long... a) { * @return least common multiple * or {@code null} if parameter is {@code null} * @see #lcm(BigInteger, BigInteger) + * @since 1.0.0 */ public static BigInteger lcm(BigInteger... a) { if (a == null) return null; @@ -244,6 +259,7 @@ public static BigInteger lcm(BigInteger... a) { * @throws ArithmeticException may be thrown for example by * {@link Math#toIntExact(long)} * @see #lcm(int...) + * @since 1.0.0 */ public static int lcm(int a, int b) { return Math.toIntExact(lcm((long) a, b)); @@ -258,6 +274,7 @@ public static int lcm(int a, int b) { * @throws ArithmeticException may be thrown for example by * {@link BigInteger#longValueExact()} * @see #lcm(long...) + * @since 1.0.0 */ public static long lcm(long a, long b) { return lcm(BigInteger.valueOf(a), BigInteger.valueOf(b)).longValueExact(); @@ -271,6 +288,7 @@ public static long lcm(long a, long b) { * @return least common multiple * or {@code null} if parameter is {@code null} * @see #lcm(BigInteger...) + * @since 1.0.0 */ public static BigInteger lcm(BigInteger a, BigInteger b) { return a == null || b == null ? null : @@ -290,6 +308,7 @@ public static BigInteger lcm(BigInteger a, BigInteger b) { * @return calculated root * @throws IllegalArgumentException if a is not positive * @see Math#pow(double, double) + * @since 1.0.0 */ public static double root(double a, int n) { if (a < 0) @@ -306,6 +325,7 @@ public static double root(double a, int n) { * @param n number of root * @return calculated root * @see #root(BigDecimal, int) + * @since 1.0.0 */ public static BigDecimal root(BigDecimal a, int n) { return root(a, n, MATH_CONTEXT); @@ -320,6 +340,7 @@ public static BigDecimal root(BigDecimal a, int n) { * @return calculated root * or {@code null} if parameter is {@code null} * @throws IllegalArgumentException if a is not positive + * @since 1.0.0 */ public static BigDecimal root(BigDecimal a, int n, MathContext context) { // https://stackoverflow.com/a/34074999/2715720 diff --git a/src/main/java/io/rala/math/algebra/equation/AbstractEquationSystem.java b/src/main/java/io/rala/math/algebra/equation/AbstractEquationSystem.java index 665bfedc..da2df70e 100644 --- a/src/main/java/io/rala/math/algebra/equation/AbstractEquationSystem.java +++ b/src/main/java/io/rala/math/algebra/equation/AbstractEquationSystem.java @@ -5,10 +5,12 @@ * * @param class of equation system * @implSpec this class has only {@link #transpose()} at the moment + * @since 1.0.0 */ public abstract class AbstractEquationSystem> { /** * @return new transposed equation system + * @since 1.0.0 */ protected abstract T transpose(); } diff --git a/src/main/java/io/rala/math/algebra/equation/AbstractSolver.java b/src/main/java/io/rala/math/algebra/equation/AbstractSolver.java index 7659aac5..791afab9 100644 --- a/src/main/java/io/rala/math/algebra/equation/AbstractSolver.java +++ b/src/main/java/io/rala/math/algebra/equation/AbstractSolver.java @@ -7,6 +7,7 @@ * * @param class of {@link AbstractEquationSystem} * @param number class of {@link AbstractEquationSystem} + * @since 1.0.0 */ public abstract class AbstractSolver, T extends Number> { // region attributes @@ -20,6 +21,7 @@ public abstract class AbstractSolver, T exte * creates a {@link AbstractSolver} for given {@link AbstractEquationSystem} * * @param equationSystem equationSystem to store + * @since 1.0.0 */ protected AbstractSolver(E equationSystem) { this.equationSystem = equationSystem; @@ -29,6 +31,7 @@ protected AbstractSolver(E equationSystem) { /** * @return stored {@link AbstractEquationSystem} + * @since 1.0.0 */ public final E getEquationSystem() { return equationSystem; @@ -36,6 +39,7 @@ public final E getEquationSystem() { /** * @return current working instance + * @since 1.0.0 */ protected E getWorking() { return working; @@ -43,6 +47,7 @@ protected E getWorking() { /** * @param working new working instance + * @since 1.0.0 */ protected void setWorking(E working) { this.working = working; @@ -56,6 +61,7 @@ protected void setWorking(E working) { * solves {@link AbstractEquationSystem} and returns {@link Solution} * * @return solution of {@link AbstractEquationSystem} + * @since 1.0.0 */ public abstract Solution solve(); @@ -63,6 +69,7 @@ protected void setWorking(E working) { * resets solver * * @implSpec resets {@link #getWorking()} to {@link #getEquationSystem()} + * @since 1.0.0 */ protected void reset() { setWorking(getEquationSystem()); diff --git a/src/main/java/io/rala/math/algebra/equation/Solution.java b/src/main/java/io/rala/math/algebra/equation/Solution.java index 135612f6..6555000e 100644 --- a/src/main/java/io/rala/math/algebra/equation/Solution.java +++ b/src/main/java/io/rala/math/algebra/equation/Solution.java @@ -9,12 +9,15 @@ * * @param class of {@link AbstractEquationSystem} * @param number class + * @since 1.0.0 */ public class Solution, T extends Number> { /** * describes the state of the solution of a {@link AbstractEquationSystem} * which can either have a {@link #SINGLE} or {@link #INFINITE} solutions or * is {@link #UNSOLVABLE} + * + * @since 1.0.0 */ public enum State {SINGLE, UNSOLVABLE, INFINITE} @@ -33,6 +36,7 @@ public enum State {SINGLE, UNSOLVABLE, INFINITE} * @param solution solution values * @param state state of solution * @throws IllegalArgumentException if any argument is {@code null} + * @since 1.0.0 */ public Solution(E equationSystem, List solution, State state) { if (equationSystem == null || solution == null || state == null) @@ -46,6 +50,7 @@ public Solution(E equationSystem, List solution, State state) { /** * @return equation system of solution + * @since 1.0.0 */ public E getEquationSystem() { return equationSystem; @@ -53,6 +58,7 @@ public E getEquationSystem() { /** * @return solution values + * @since 1.0.0 */ public List getSolution() { return Collections.unmodifiableList(solution); @@ -60,6 +66,7 @@ public List getSolution() { /** * @return {@link State} of solution + * @since 1.0.0 */ public State getState() { return state; @@ -101,6 +108,7 @@ public String toString() { * @param evaluation class * @param number class * @return new {@link Solution} instance + * @since 1.0.0 */ public static , T extends Number> Solution single(E equationSystem, List solution) { @@ -114,6 +122,7 @@ Solution single(E equationSystem, List solution) { * @param evaluation class * @param number class * @return new {@link Solution} instance + * @since 1.0.0 */ public static , T extends Number> Solution unsolvable(E equationSystem) { @@ -127,6 +136,7 @@ Solution unsolvable(E equationSystem) { * @param evaluation class * @param number class * @return new {@link Solution} instance + * @since 1.0.0 */ public static , T extends Number> Solution infinite(E equationSystem) { diff --git a/src/main/java/io/rala/math/algebra/equation/linear/AbstractLinearSolver.java b/src/main/java/io/rala/math/algebra/equation/linear/AbstractLinearSolver.java index ee7d6b90..f10b5461 100644 --- a/src/main/java/io/rala/math/algebra/equation/linear/AbstractLinearSolver.java +++ b/src/main/java/io/rala/math/algebra/equation/linear/AbstractLinearSolver.java @@ -12,12 +12,14 @@ * class which allows solving {@link LinearEquationSystem}s * * @param number class + * @since 1.0.0 */ public abstract class AbstractLinearSolver extends AbstractSolver, T> { /** * creates a {@link AbstractLinearSolver} for given {@link LinearEquationSystem} * * @param equationSystem equationSystem to store + * @since 1.0.0 */ protected AbstractLinearSolver(LinearEquationSystem equationSystem) { super(equationSystem); @@ -25,6 +27,7 @@ protected AbstractLinearSolver(LinearEquationSystem equationSystem) { /** * @return {@link AbstractArithmetic} of {@link #getEquationSystem()} + * @since 1.0.0 */ protected final AbstractArithmetic getArithmetic() { return getEquationSystem().getMatrix().getArithmetic(); @@ -33,6 +36,7 @@ protected final AbstractArithmetic getArithmetic() { /** * @return current working matrix * @see #getWorking() + * @since 1.0.0 */ protected LinearEquationSystem.LinearEquationMatrix getWorkingMatrix() { return getWorking().getMatrix(); @@ -41,6 +45,7 @@ protected LinearEquationSystem.LinearEquationMatrix getWorkingMatrix() { /** * @return current working vector * @see #getWorking() + * @since 1.0.0 */ protected LinearEquationSystem.LinearEquationVector getWorkingVector() { return getWorking().getVector(); @@ -48,6 +53,7 @@ protected LinearEquationSystem.LinearEquationVector getWorkingVector() { /** * @param working new working instance + * @since 1.0.0 */ protected void setWorkingEquationSystem(LinearEquationSystem working) { setWorkingEquationSystem(working.getMatrix(), working.getVector()); @@ -56,6 +62,7 @@ protected void setWorkingEquationSystem(LinearEquationSystem working) { /** * @param workingMatrix new workingMatrix * @param workingVector new workingVector + * @since 1.0.0 */ protected void setWorkingEquationSystem( LinearEquationSystem.LinearEquationMatrix workingMatrix, @@ -69,6 +76,7 @@ protected void setWorkingEquationSystem( * {@link Solution} with state {@link Solution.State#SINGLE} * * @return {@link Solution} based on {@link #getWorkingVector()} + * @since 1.0.0 */ protected Solution, T> toSingleSolution() { return Solution.single(getEquationSystem(), @@ -81,6 +89,7 @@ protected Solution, T> toSingleSolution() { * * @implSpec transposes {@link #getWorking()} equation system * if {@link #getEquationSystem()} has solution {@link Vector.Type#ROW} + * @since 1.0.0 */ protected void reset() { if (getEquationSystem().getVector().getType().equals(Vector.Type.ROW)) @@ -96,6 +105,7 @@ protected void reset() { * matrix row and vector index are {@code 0} * @see #areAllZero(Collection) * @see #isZero(Number) + * @since 1.0.0 */ protected final boolean isZeroRow(int index) { return areAllZero(getWorkingMatrix().getRow(index)) && @@ -105,6 +115,7 @@ protected final boolean isZeroRow(int index) { /** * @param collection collection to check * @return {@code true} if all elements are {@code 0} + * @since 1.0.0 */ protected final boolean areAllZero(Collection collection) { return collection.stream().allMatch(this::isZero); @@ -113,6 +124,7 @@ protected final boolean areAllZero(Collection collection) { /** * @param t t to check * @return {@code} if {@link AbstractArithmetic#isZero(Number)} + * @since 1.0.0 */ protected final boolean isZero(T t) { return getArithmetic().isZero(t); diff --git a/src/main/java/io/rala/math/algebra/equation/linear/LinearEquationSystem.java b/src/main/java/io/rala/math/algebra/equation/linear/LinearEquationSystem.java index d0aeb243..7b3d3475 100644 --- a/src/main/java/io/rala/math/algebra/equation/linear/LinearEquationSystem.java +++ b/src/main/java/io/rala/math/algebra/equation/linear/LinearEquationSystem.java @@ -12,6 +12,7 @@ * class which holds a linear equation system * * @param number class of linear equation system + * @since 1.0.0 */ public class LinearEquationSystem extends AbstractEquationSystem> { // region protected exception messages @@ -36,6 +37,7 @@ public class LinearEquationSystem extends AbstractEquationSyst * @see LinearEquationMatrix#LinearEquationMatrix(Matrix) * @see LinearEquationVector#LinearEquationVector(Vector) * @see LinearEquationSystem#LinearEquationSystem(LinearEquationMatrix, LinearEquationVector) + * @since 1.0.0 */ public LinearEquationSystem(Matrix matrix, Vector vector) { this(new LinearEquationMatrix<>(matrix), new LinearEquationVector<>(vector)); @@ -47,6 +49,7 @@ public LinearEquationSystem(Matrix matrix, Vector vector) { * @param matrix matrix of linear equation system * @param vector vector of linear equation solution * @throws IllegalArgumentException if matrix and vector do not match + * @since 1.0.0 */ public LinearEquationSystem( LinearEquationMatrix matrix, LinearEquationVector vector @@ -61,6 +64,7 @@ public LinearEquationSystem( /** * @return stored matrix + * @since 1.0.0 */ public LinearEquationMatrix getMatrix() { return matrix; @@ -68,6 +72,7 @@ public LinearEquationMatrix getMatrix() { /** * @return stored vector + * @since 1.0.0 */ public LinearEquationVector getVector() { return vector; @@ -77,6 +82,7 @@ public LinearEquationVector getVector() { * solves an {@link AbstractEquationSystem} with {@link GaussSolver} * * @return {@link Solution} of {@link GaussSolver#solve()} + * @since 1.0.0 */ public Solution, T> solveWithGauss() { return new GaussSolver<>(this).solve(); @@ -90,6 +96,7 @@ public Solution, T> solveWithGauss() { * @return new equation system with changed values * @see LinearEquationMatrix#swapRows(int, int) * @see LinearEquationVector#swapValues(int, int) + * @since 1.0.0 */ public LinearEquationSystem swapRows(int row1, int row2) { return new LinearEquationSystem<>( @@ -104,6 +111,7 @@ public LinearEquationSystem swapRows(int row1, int row2) { * @return new equation system with changed values * @see LinearEquationMatrix#swapCols(int, int) * @see LinearEquationVector#swapValues(int, int) + * @since 1.0.0 */ public LinearEquationSystem swapCols(int col1, int col2) { return new LinearEquationSystem<>( @@ -118,6 +126,7 @@ public LinearEquationSystem swapCols(int col1, int col2) { * @return new equation system with changed values * @see LinearEquationMatrix#multiplyRow(int, Number) * @see LinearEquationVector#multiplyValue(int, Number) + * @since 1.0.0 */ public LinearEquationSystem multiplyRow(int row, T n) { return new LinearEquationSystem<>( @@ -132,6 +141,7 @@ public LinearEquationSystem multiplyRow(int row, T n) { * @return new equation system with changed values * @see LinearEquationMatrix#multiplyCol(int, Number) * @see LinearEquationVector#multiplyValue(int, Number) + * @since 1.0.0 */ public LinearEquationSystem multiplyCol(int col, T n) { return new LinearEquationSystem<>( @@ -147,6 +157,7 @@ public LinearEquationSystem multiplyCol(int col, T n) { * @return new equation system with changed values * @see LinearEquationMatrix#addRowMultipleTimes(int, int, Number) * @see LinearEquationVector#addValueMultiplyTimes(int, int, Number) + * @since 1.0.0 */ public LinearEquationSystem addRowMultipleTimes(int row1, int row2, T n) { return new LinearEquationSystem<>( @@ -162,6 +173,7 @@ public LinearEquationSystem addRowMultipleTimes(int row1, int row2, T n) { * @return new equation system with changed values * @see LinearEquationMatrix#addColMultipleTimes(int, int, Number) * @see LinearEquationVector#addValueMultiplyTimes(int, int, Number) + * @since 1.0.0 */ public LinearEquationSystem addColMultipleTimes(int col1, int col2, T n) { return new LinearEquationSystem<>( @@ -182,6 +194,7 @@ public LinearEquationSystem addColMultipleTimes(int col1, int col2, T n) { * @param number class of linear equation system * @return new linear equation system with * {@link LinearEquationMatrix} and {@link LinearEquationVector} + * @since 1.0.0 */ public static LinearEquationSystem ofMatrixWithSolutionColumn(Matrix matrix) { Matrix eMatrix = new Matrix<>(matrix.getArithmetic(), @@ -205,6 +218,7 @@ public static LinearEquationSystem ofMatrixWithSolutionCol * @param number class of linear equation system * @return new linear equation system with * {@link LinearEquationMatrix} and {@link LinearEquationVector} + * @since 1.0.0 */ public static LinearEquationSystem ofMatrixWithSolutionRow(Matrix matrix) { return ofMatrixWithSolutionColumn(matrix.transpose()); @@ -244,12 +258,14 @@ public String toString() { * special {@link Matrix} for linear equations * * @param number class of {@link Matrix} + * @since 1.0.0 */ public static class LinearEquationMatrix extends Matrix { /** * creates a new equation system from given matrix * * @param matrix matrix to store + * @since 1.0.0 */ public LinearEquationMatrix(Matrix matrix) { super(matrix); @@ -294,12 +310,14 @@ public LinearEquationMatrix addColMultipleTimes(int col1, int col2, T n) { * special {@link Vector} for linear equations * * @param number class of {@link Vector} + * @since 1.0.0 */ public static class LinearEquationVector extends Vector { /** * creates a new equation vector from given vector * * @param vector vector to store + * @since 1.0.0 */ public LinearEquationVector(Vector vector) { super(vector); @@ -310,6 +328,7 @@ public LinearEquationVector(Vector vector) { * @param index2 index2 to swap with index1 * @return new vector with swapped values * @throws IndexOutOfBoundsException if index1 or index2 is invalid + * @since 1.0.0 */ public LinearEquationVector swapValues(int index1, int index2) { if (!isValidIndex(index1)) @@ -329,6 +348,7 @@ public LinearEquationVector swapValues(int index1, int index2) { * @param n factor to use * @return new vector with multiplied index * @throws IndexOutOfBoundsException if index is invalid + * @since 1.0.0 */ public LinearEquationVector multiplyValue(int index, T n) { if (!isValidIndex(index)) @@ -350,6 +370,7 @@ public LinearEquationVector multiplyValue(int index, T n) { * @param n factor to use * @return new vector with multiplied value * @throws IndexOutOfBoundsException if index1 or index2 is invalid + * @since 1.0.0 */ public LinearEquationVector addValueMultiplyTimes(int index1, int index2, T n) { if (!isValidIndex(index1)) diff --git a/src/main/java/io/rala/math/algebra/equation/linear/solver/GaussSolver.java b/src/main/java/io/rala/math/algebra/equation/linear/solver/GaussSolver.java index b6cbd8c6..8ac25f1a 100644 --- a/src/main/java/io/rala/math/algebra/equation/linear/solver/GaussSolver.java +++ b/src/main/java/io/rala/math/algebra/equation/linear/solver/GaussSolver.java @@ -10,6 +10,7 @@ * solves a {@link LinearEquationSystem} based on Gauss * * @param number class + * @since 1.0.0 */ public class GaussSolver extends AbstractLinearSolver { private final Deque swappedCols = new LinkedList<>(); @@ -18,6 +19,7 @@ public class GaussSolver extends AbstractLinearSolver { * creates a new GaussSolver based on a {@link LinearEquationSystem} * * @param equationSystem equation system to solve + * @since 1.0.0 */ public GaussSolver(LinearEquationSystem equationSystem) { super(equationSystem); @@ -27,6 +29,7 @@ public GaussSolver(LinearEquationSystem equationSystem) { /** * @return current swappedCols instance + * @since 1.0.0 */ protected Deque getSwappedCols() { return swappedCols; @@ -62,6 +65,8 @@ public Solution, T> solve() { * {@link #prepareMatrixBySwapping(int)}, * {@link #prepareMatrixByMakingFieldToOne(int)} and * {@link #prepareMatrixByMakeColToZero(int)} + * + * @since 1.0.0 */ protected void prepareMatrix() { prepareMatrixBySwappingZeroRowsToBottom(); @@ -76,6 +81,8 @@ protected void prepareMatrix() { /** * moves zero rows to bottom + * + * @since 1.0.0 */ protected void prepareMatrixBySwappingZeroRowsToBottom() { for (int i = 0; i < getWorkingMatrix().getRows() - 1; i++) { @@ -96,6 +103,7 @@ protected void prepareMatrixBySwappingZeroRowsToBottom() { * * @param rowIndex rowIndex to handle * @implSpec pre: non zero row + * @since 1.0.0 */ protected void prepareMatrixBySwapping(int rowIndex) { List row = getWorkingMatrix().getRow(rowIndex); @@ -121,6 +129,7 @@ protected void prepareMatrixBySwapping(int rowIndex) { * @param rowIndex rowIndex to handle * @implSpec pre: see {@link #prepareMatrixBySwapping(int)} * and {@code rowIndex} is also a valid column index + * @since 1.0.0 */ protected void prepareMatrixByMakingFieldToOne(int rowIndex) { T rowIndexValue = getWorkingMatrix().getValue(rowIndex, rowIndex); @@ -137,6 +146,7 @@ protected void prepareMatrixByMakingFieldToOne(int rowIndex) { * * @param rowIndex rowIndex to handle * @implSpec pre: see {@link #prepareMatrixByMakingFieldToOne(int)} + * @since 1.0.0 */ protected void prepareMatrixByMakeColToZero(int rowIndex) { for (int i = rowIndex + 1; i < getWorkingMatrix().getRows(); i++) { @@ -154,6 +164,8 @@ protected void prepareMatrixByMakeColToZero(int rowIndex) { /** * clears all values above rows so that only the diagonal is left + * + * @since 1.0.0 */ protected void solveBottomUp() { for (int i = getWorkingMatrix().getRows() - 1; 0 < i; i--) { @@ -170,6 +182,8 @@ protected void solveBottomUp() { /** * reSwaps cols which have been swapped during {@link #prepareMatrixBySwapping(int)} + * + * @since 1.0.0 */ protected void reSwapCols() { while (!getSwappedCols().isEmpty()) { @@ -182,6 +196,7 @@ protected void reSwapCols() { * sorts rows after {@link #reSwapCols()} * * @implSpec suggested only if {@link #getSwappedCols()} was non-empty + * @since 1.0.0 */ protected void sortRows() { for (int i = 0; i < getWorkingMatrix().getRows(); i++) { @@ -201,6 +216,7 @@ protected void sortRows() { * @return {@code true} if current {@link #getWorkingMatrix()} has no solutions * @implSpec checks if a solution value is unequal zero and * matrix row values {@link #areAllZero(Collection)} + * @since 1.0.0 */ protected boolean hasNoSolutions() { for (int i = 0; i < getWorkingMatrix().getRows(); i++) { @@ -216,6 +232,7 @@ protected boolean hasNoSolutions() { * @implSpec pre: {@link #prepareMatrix()} and {@link #solveBottomUp()}; * all possible eliminations have been done - * it is checking for non-zero values between main diagonale and solution + * @since 1.0.0 */ protected boolean hasInfiniteSolutions() { for (int i = 0; i < getWorkingMatrix().getRows(); i++) { @@ -239,6 +256,8 @@ protected void reset() { /** * class which stores two col indices + * + * @since 1.0.0 */ protected static class ColPair { private final int col1; @@ -249,6 +268,7 @@ protected static class ColPair { * * @param col1 first col * @param col2 second col + * @since 1.0.0 */ public ColPair(int col1, int col2) { this.col1 = col1; @@ -257,6 +277,7 @@ public ColPair(int col1, int col2) { /** * @return col1 + * @since 1.0.0 */ public int getCol1() { return col1; @@ -264,6 +285,7 @@ public int getCol1() { /** * @return col2 + * @since 1.0.0 */ public int getCol2() { return col2; diff --git a/src/main/java/io/rala/math/algebra/matrix/Matrix.java b/src/main/java/io/rala/math/algebra/matrix/Matrix.java index 1728b124..e11ab691 100644 --- a/src/main/java/io/rala/math/algebra/matrix/Matrix.java +++ b/src/main/java/io/rala/math/algebra/matrix/Matrix.java @@ -20,6 +20,7 @@ * class which holds a matrix with {@code rows} and {@code cols} * * @param number class + * @since 1.0.0 */ public class Matrix implements Copyable>, StreamIterable.Field>, Serializable { @@ -67,6 +68,7 @@ public class Matrix * @param size size of matrix * @throws IllegalArgumentException if size is less than {@code 1} * @see #Matrix(AbstractArithmetic, int, int) + * @since 1.0.0 */ public Matrix(AbstractArithmetic arithmetic, int size) { this(arithmetic, size, size); @@ -85,6 +87,7 @@ public Matrix(AbstractArithmetic arithmetic, int size) { * - other values may not be handled correctly * (in {@link #equals(Object)}, ...) * @see #Matrix(AbstractArithmetic, int, Number) + * @since 1.0.0 */ protected Matrix(AbstractArithmetic arithmetic, int size, T defaultValue) { this(arithmetic, size, size, defaultValue); @@ -100,6 +103,7 @@ protected Matrix(AbstractArithmetic arithmetic, int size, T defaultValue) { * @param cols cols of matrix * @throws IllegalArgumentException if rows or cols is less than {@code 1} * @see #Matrix(AbstractArithmetic, int, int) + * @since 1.0.0 */ public Matrix(AbstractArithmetic arithmetic, int rows, int cols) { this(arithmetic, rows, cols, arithmetic.zero()); @@ -117,6 +121,7 @@ public Matrix(AbstractArithmetic arithmetic, int rows, int cols) { * @implSpec default value should be {@code 0} * - other values may not be handled correctly * (in {@link #equals(Object)}, ...) + * @since 1.0.0 */ protected Matrix(AbstractArithmetic arithmetic, int rows, int cols, T defaultValue) { if (rows <= 0 || cols <= 0) @@ -131,6 +136,7 @@ protected Matrix(AbstractArithmetic arithmetic, int rows, int cols, T default * creates a new matrix based on given one * * @param matrix matrix to copy + * @since 1.0.0 */ protected Matrix(Matrix matrix) { this( @@ -149,6 +155,7 @@ protected Matrix(Matrix matrix) { /** * @return stored arithmetic + * @since 1.0.0 */ public AbstractArithmetic getArithmetic() { return arithmetic; @@ -156,6 +163,7 @@ public AbstractArithmetic getArithmetic() { /** * @return matrix map which uses index as key + * @since 1.0.0 */ protected final Map> getMatrix() { return matrix; @@ -163,6 +171,7 @@ protected final Map> getMatrix() { /** * @return rows of matrix + * @since 1.0.0 */ public final int getRows() { return rows; @@ -170,6 +179,7 @@ public final int getRows() { /** * @return cols of matrix + * @since 1.0.0 */ public final int getCols() { return cols; @@ -177,6 +187,7 @@ public final int getCols() { /** * @return default value for non-existing values + * @since 1.0.0 */ protected final T getDefaultValue() { return defaultValue; @@ -184,6 +195,7 @@ protected final T getDefaultValue() { /** * @return {@link #getRows()} * {@link #getCols()} + * @since 1.0.0 */ public final long size() { return (long) getRows() * getCols(); @@ -197,6 +209,7 @@ public final long size() { * @param row row of matrix * @return list of fields in row * @throws IndexOutOfBoundsException if row is invalid + * @since 1.0.0 */ public List getRowFields(int row) { if (!isValidRow(row)) @@ -211,6 +224,7 @@ public List getRowFields(int row) { * @return list of values in row * @throws IndexOutOfBoundsException if row is invalid * @see #getRowFields(int) + * @since 1.0.0 */ public List getRow(int row) { return getRowFields(row).stream() @@ -222,6 +236,7 @@ public List getRow(int row) { * @param col col of matrix * @return list of fields in col * @throws IndexOutOfBoundsException if col is invalid + * @since 1.0.0 */ public List getColFields(int col) { if (!isValidCol(col)) @@ -236,6 +251,7 @@ public List getColFields(int col) { * @return list of values in col * @throws IndexOutOfBoundsException if col is invalid * @see #getColFields(int) + * @since 1.0.0 */ public List getCol(int col) { return getColFields(col).stream() @@ -253,6 +269,7 @@ public List getCol(int col) { * @return current value on given position * @throws IndexOutOfBoundsException if row or col is invalid * @see #getValue(long) + * @since 1.0.0 */ public T getValue(int row, int col) { return getValue(getIndexOfRowAndCol(row, col)); @@ -262,6 +279,7 @@ public T getValue(int row, int col) { * @param index index of requested value * @return current value on given position * @throws IndexOutOfBoundsException if index is invalid + * @since 1.0.0 */ public T getValue(long index) { if (!isValidIndex(index)) @@ -278,6 +296,7 @@ public T getValue(long index) { * @return old value if existed or {@link #getDefaultValue()} * @throws IndexOutOfBoundsException if row or col is invalid * @see #setValue(long, Number) + * @since 1.0.0 */ public T setValue(int row, int col, T value) { return setValue(getIndexOfRowAndCol(row, col), value); @@ -288,6 +307,7 @@ public T setValue(int row, int col, T value) { * @param value new value to store * @return old value if existed or {@link #getDefaultValue()} * @throws IndexOutOfBoundsException if index is invalid + * @since 1.0.0 */ public T setValue(long index, T value) { if (!isValidIndex(index)) @@ -315,6 +335,7 @@ public T setValue(long index, T value) { * @return old value if existed or {@link #getDefaultValue()} * @throws IndexOutOfBoundsException if row or col is invalid * @see #removeValue(long) + * @since 1.0.0 */ public T removeValue(int row, int col) { return removeValue(getIndexOfRowAndCol(row, col)); @@ -324,6 +345,7 @@ public T removeValue(int row, int col) { * @param index index of value to remove * @return old value if existed or {@link #getDefaultValue()} * @throws IndexOutOfBoundsException if index is invalid + * @since 1.0.0 */ public T removeValue(long index) { if (!isValidIndex(index)) @@ -352,6 +374,7 @@ public T removeValue(long index) { * @see #compute(long, UnaryOperator) * @see #setValue(int, int, Number) * @see #getValue(int, int) + * @since 1.0.0 */ public T compute(int row, int col, UnaryOperator operator) { return compute(getIndexOfRowAndCol(row, col), operator); @@ -366,6 +389,7 @@ public T compute(int row, int col, UnaryOperator operator) { * @see #compute(long, UnaryOperator) * @see #setValue(long, Number) * @see #getValue(long) + * @since 1.0.0 */ public T compute(long index, UnaryOperator operator) { return setValue(index, operator.apply(getValue(index))); @@ -382,6 +406,7 @@ public T compute(long index, UnaryOperator operator) { * @see #compute(long, Number, BinaryOperator) * @see #setValue(int, int, Number) * @see #getValue(int, int) + * @since 1.0.0 */ public T compute(int row, int col, T value, BinaryOperator operator) { return compute(getIndexOfRowAndCol(row, col), value, operator); @@ -396,6 +421,7 @@ public T compute(int row, int col, T value, BinaryOperator operator) { * @return old value if existed or {@link #getDefaultValue()} * @see #setValue(long, Number) * @see #getValue(long) + * @since 1.0.0 */ public T compute(long index, T value, BinaryOperator operator) { return setValue(index, operator.apply(getValue(index), value)); @@ -406,6 +432,7 @@ public T compute(long index, T value, BinaryOperator operator) { * * @param operator operator to apply on all fields * @see #setValue(long, Number) + * @since 1.0.0 */ public void computeAll(Function operator) { forEach(field -> setValue(field.getIndex(), operator.apply(field))); @@ -417,6 +444,7 @@ public void computeAll(Function operator) { * @param value function returning new value to use in computation * @param operator operator to apply on old and new value * @see #computeAll(Function) + * @since 1.0.0 */ public void computeAll(Function value, BinaryOperator operator) { computeAll(field -> operator.apply(field.getValue(), value.apply(field))); @@ -428,6 +456,7 @@ public void computeAll(Function value, BinaryOperator operator) { /** * @return {@code true} if amount of rows and cols is equal + * @since 1.0.0 */ public final boolean isSquare() { return getRows() == getCols(); @@ -435,6 +464,7 @@ public final boolean isSquare() { /** * @return {@code true} if only the diagonal has values + * @since 1.0.0 */ public final boolean isDiagonal() { return isSquare() && stream() @@ -447,6 +477,7 @@ public final boolean isDiagonal() { /** * @return {@code true} if {@link #isSquare()} * and {@link #determinante()}!={@code 0} + * @since 1.0.0 */ public final boolean isInvertible() { return isSquare() && !isZero(determinante()); @@ -460,6 +491,7 @@ public final boolean isInvertible() { * @param matrix matrix to add * @return new matrix with calculated values * @throws IllegalArgumentException if rows or cols are not equal + * @since 1.0.0 */ public Matrix add(Matrix matrix) { if (getRows() != matrix.getRows()) @@ -478,6 +510,7 @@ public Matrix add(Matrix matrix) { /** * @param t value to multiply * @return new matrix with calculated values + * @since 1.0.0 */ public Matrix multiply(T t) { Matrix result = copy(); @@ -490,6 +523,7 @@ public Matrix multiply(T t) { * @param matrix matrix to multiply * @return new matrix with calculated values * @throws IllegalArgumentException if cols are not equal param rows + * @since 1.0.0 */ public Matrix multiply(Matrix matrix) { if (getCols() != matrix.getRows()) @@ -519,6 +553,7 @@ public Matrix multiply(Matrix matrix) { * @return new matrix with calculated values * @throws IllegalArgumentException if no cols and rows match * @see #multiply(Matrix) + * @since 1.0.0 */ public Matrix multiplyTolerant(Matrix matrix) { if (getCols() == matrix.getRows()) @@ -535,6 +570,7 @@ else if (getRows() == matrix.getCols()) /** * @return new inverse matrix or {@code null} if there is none * @throws NotSupportedException if {@link #isSquare()} is {@code false} + * @since 1.0.0 */ public Matrix inverse() { if (!isSquare()) @@ -559,6 +595,7 @@ public Matrix inverse() { /** * @return new transposed matrix + * @since 1.0.0 */ public Matrix transpose() { Matrix result = new Matrix<>(getArithmetic(), @@ -573,6 +610,7 @@ public Matrix transpose() { /** * @return determinante of matrix or {@code 0} + * @since 1.0.0 */ public T determinante() { if (size() == 0 || !isSquare()) return getArithmetic().zero(); @@ -618,6 +656,7 @@ public T determinante() { * * @return determinante of matrix or {@code 0} * @see #determinante() + * @since 1.0.0 */ protected T determinanteRecursive() { if (size() == 0 || !isSquare()) return getArithmetic().zero(); @@ -654,6 +693,7 @@ protected T determinanteRecursive() { /** * @return rank of matrix * @see #rowEchelonForm() + * @since 1.0.0 */ public int rank() { Matrix matrix = rowEchelonForm(); @@ -663,6 +703,7 @@ public int rank() { /** * @return new matrix in row echelon form * (not necessary reduced) + * @since 1.0.0 */ public Matrix rowEchelonForm() { // see GaussSolver @@ -693,6 +734,7 @@ public Matrix rowEchelonForm() { * @return new vector from matrix row/column * prefers column vector if rows and columns are equal to one * @throws NotSupportedException if columns and rows are more than one + * @since 1.0.0 */ public Vector toVector() { if (getCols() == 1) @@ -705,6 +747,7 @@ public Vector toVector() { /** * @return only entry of 1x1 matrix * @throws NotSupportedException if matrix is not 1x1 + * @since 1.0.0 */ public T toParam() { if (getRows() == 1 && getCols() == 1) @@ -725,6 +768,7 @@ public T toParam() { * @param number class * @return new created matrix * @throws IllegalArgumentException if rows or cols is less than {@code 1} + * @since 1.0.0 */ public static Matrix identity( AbstractArithmetic arithmetic, int size @@ -739,6 +783,7 @@ public static Matrix identity( * @param number class * @return new created matrix * @throws IllegalArgumentException if rows or cols is less than {@code 1} + * @since 1.0.0 */ protected static Matrix identity( AbstractArithmetic arithmetic, int size, T defaultValue @@ -758,6 +803,7 @@ protected static Matrix identity( * @param number class * @return new created matrix * @throws IllegalArgumentException if rows or cols is less than {@code 1} + * @since 1.0.0 */ @SafeVarargs public static Matrix diagonal( @@ -773,6 +819,7 @@ public static Matrix diagonal( * @param number class * @return new created matrix * @throws IllegalArgumentException if rows or cols is less than {@code 1} + * @since 1.0.0 */ @SafeVarargs protected static Matrix diagonal( @@ -800,6 +847,7 @@ protected static Matrix diagonal( * @throws IllegalArgumentException if rows modulo {@code values.length} * is not congruent {@code 0} * @throws IllegalArgumentException if rows or cols is less than {@code 1} + * @since 1.0.0 */ @SafeVarargs public static Matrix ofValuesByRows( @@ -820,6 +868,7 @@ public static Matrix ofValuesByRows( * @throws IllegalArgumentException if rows modulo {@code values.length} * is not congruent {@code 0} * @throws IllegalArgumentException if rows or cols is less than {@code 1} + * @since 1.0.0 */ @SafeVarargs protected static Matrix ofValuesByRows( @@ -847,6 +896,7 @@ protected static Matrix ofValuesByRows( * @throws IllegalArgumentException if cols modulo {@code values.length} * is not congruent {@code 0} * @throws IllegalArgumentException if rows or cols is less than {@code 1} + * @since 1.0.0 */ @SafeVarargs public static Matrix ofValuesByCols( @@ -867,6 +917,7 @@ public static Matrix ofValuesByCols( * @throws IllegalArgumentException if cols modulo {@code values.length} * is not congruent {@code 0} * @throws IllegalArgumentException if rows or cols is less than {@code 1} + * @since 1.0.0 */ @SafeVarargs protected static Matrix ofValuesByCols( @@ -888,6 +939,7 @@ protected static Matrix ofValuesByCols( * @param map mapping function to convert current values to new one * @param new number class * @return mapped matrix + * @since 1.0.0 */ public Matrix map( AbstractArithmetic arithmetic, Function map @@ -904,6 +956,7 @@ arithmetic, getRows(), getCols(), map.apply(getDefaultValue()) /** * @param newDefaultValue new default value for matrix * @return mapped matrix + * @since 1.0.0 */ protected Matrix mapDefaultValue(T newDefaultValue) { if (isDefaultValue(newDefaultValue)) return copy(); @@ -975,6 +1028,7 @@ public String toString() { * @return new sub matrix excluding specified row and col * @throws NotSupportedException if {@link #isSquare()} is {@code false} * @throws IndexOutOfBoundsException if row or col is invalid + * @since 1.0.0 */ protected final Matrix subMatrix(int row, int col) { if (!isSquare()) @@ -1004,6 +1058,7 @@ protected final Matrix subMatrix(int row, int col) { * @throws IndexOutOfBoundsException if row or col is invalid * @see #subMatrix(int, int) * @see #signumFactor(int, int) + * @since 1.0.0 */ protected final T coFactor(int row, int col) { if (!isSquare()) @@ -1025,6 +1080,7 @@ protected final T coFactor(int row, int col) { * @return coFactor matrix * @throws NotSupportedException if {@link #isSquare()} is {@code false} * @see #coFactor(int, int) + * @since 1.0.0 */ protected final Matrix coFactorMatrix() { if (!isSquare()) @@ -1037,6 +1093,7 @@ protected final Matrix coFactorMatrix() { /** * @return transposed coFactorMatrix * @see #coFactorMatrix() + * @since 1.0.0 */ protected final Matrix adjunctMatrix() { return coFactorMatrix().transpose(); @@ -1046,6 +1103,7 @@ protected final Matrix adjunctMatrix() { * @param row row of matrix * @param col col of matrix * @return {@code (-1)^(row+col)} + * @since 1.0.0 */ protected static int signumFactor(int row, int col) { return (row + col) % 2 == 0 ? 1 : -1; @@ -1060,6 +1118,7 @@ protected static int signumFactor(int row, int col) { * @param row2 row2 to swap with row1 * @return new matrix with swapped values * @throws IndexOutOfBoundsException if row1 or row2 is invalid + * @since 1.0.0 */ protected Matrix swapRows(int row1, int row2) { if (!isValidRow(row1)) @@ -1080,6 +1139,7 @@ protected Matrix swapRows(int row1, int row2) { * @param col2 col2 to swap with col1 * @return new matrix with swapped values * @throws IndexOutOfBoundsException if col1 or col2 is invalid + * @since 1.0.0 */ protected Matrix swapCols(int col1, int col2) { if (!isValidCol(col1)) @@ -1100,6 +1160,7 @@ protected Matrix swapCols(int col1, int col2) { * @param n factor to use * @return new matrix with multiplied row * @throws IndexOutOfBoundsException if row is invalid + * @since 1.0.0 */ protected Matrix multiplyRow(int row, T n) { if (!isValidRow(row)) @@ -1122,6 +1183,7 @@ protected Matrix multiplyRow(int row, T n) { * @param n factor to use * @return new matrix with multiplied col * @throws IndexOutOfBoundsException if col is invalid + * @since 1.0.0 */ protected Matrix multiplyCol(int col, T n) { if (!isValidCol(col)) @@ -1145,6 +1207,7 @@ protected Matrix multiplyCol(int col, T n) { * @param n factor to use * @return new matrix with multiplied row * @throws IndexOutOfBoundsException if row1 or row2 is invalid + * @since 1.0.0 */ protected Matrix addRowMultipleTimes(int row1, int row2, T n) { if (!isValidRow(row1)) @@ -1169,6 +1232,7 @@ protected Matrix addRowMultipleTimes(int row1, int row2, T n) { * @param n factor to use * @return new matrix with multiplied col * @throws IndexOutOfBoundsException if col1 or col2 is invalid + * @since 1.0.0 */ protected Matrix addColMultipleTimes(int col1, int col2, T n) { if (!isValidCol(col1)) @@ -1195,6 +1259,7 @@ protected Matrix addColMultipleTimes(int col1, int col2, T n) { * swaps zero rows to bottom * * @return new matrix with swapped rows + * @since 1.0.0 */ protected Matrix swapZeroRowsToBottom() { // see GaussSolver#prepareMatrixBySwappingZeroRowsToBottom @@ -1215,6 +1280,7 @@ protected Matrix swapZeroRowsToBottom() { * * @return new matrix with swapped rows * @see #ensureDiagonalFieldsAreNonZero(boolean) + * @since 1.0.0 */ protected Matrix ensureDiagonalFieldsAreNonZero() { return ensureDiagonalFieldsAreNonZero(false); @@ -1225,6 +1291,7 @@ protected Matrix ensureDiagonalFieldsAreNonZero() { * * @param includeCols if {@code true} columns may be swapped if necessary * @return new matrix with swapped rows + * @since 1.0.0 */ protected Matrix ensureDiagonalFieldsAreNonZero(boolean includeCols) { // see GaussSolver#prepareMatrixBySwapping @@ -1259,6 +1326,7 @@ protected Matrix ensureDiagonalFieldsAreNonZero(boolean includeCols) { * @param col col of requested index * @return index of requested position * @throws IndexOutOfBoundsException if row or col is invalid + * @since 1.0.0 */ protected final long getIndexOfRowAndCol(int row, int col) { if (!isValidRow(row)) @@ -1271,6 +1339,7 @@ protected final long getIndexOfRowAndCol(int row, int col) { /** * @param index index to check * @return {@code true} if value is valid + * @since 1.0.0 */ protected final boolean isValidIndex(long index) { return 0 <= index && index < size(); @@ -1279,6 +1348,7 @@ protected final boolean isValidIndex(long index) { /** * @param row row to check * @return {@code true} if value is valid + * @since 1.0.0 */ protected final boolean isValidRow(int row) { return 0 <= row && row < getRows(); @@ -1287,6 +1357,7 @@ protected final boolean isValidRow(int row) { /** * @param col col to check * @return {@code true} if col is valid + * @since 1.0.0 */ protected final boolean isValidCol(int col) { return 0 <= col && col < getCols(); @@ -1296,6 +1367,7 @@ protected final boolean isValidCol(int col) { * @param t value to check * @return {@code true} if {@code t} is equal to {@link #getDefaultValue()} * @see AbstractArithmetic#isEqual(Number, Number) + * @since 1.0.0 */ protected final boolean isDefaultValue(T t) { return getArithmetic().isEqual(getDefaultValue(), t); @@ -1305,6 +1377,7 @@ protected final boolean isDefaultValue(T t) { * @param t value to check * @return {@code true} if {@link AbstractArithmetic#isZero(Number)} is * @see AbstractArithmetic#isZero(Number) + * @since 1.0.0 */ protected final boolean isZero(T t) { return getArithmetic().isZero(t); @@ -1315,6 +1388,7 @@ protected final boolean isZero(T t) { * @return {@code true} if value is valid * @throws IndexOutOfBoundsException if row is invalid * @see #getRow(int) + * @since 1.0.0 */ protected final boolean isZeroRow(int row) { return getRow(row).stream().allMatch(this::isZero); @@ -1349,6 +1423,8 @@ private void removeDefaultValues() { /** * class which holds a field of a matrix with immutable attributes + * + * @since 1.0.0 */ public class Field { private final long index; @@ -1361,6 +1437,7 @@ public class Field { * @throws IndexOutOfBoundsException if row or col is invalid * @see #Field(long, Number) * @see #getIndexOfRowAndCol(int, int) + * @since 1.0.0 */ protected Field(int row, int col, T value) { this(getIndexOfRowAndCol(row, col), value); @@ -1370,6 +1447,7 @@ protected Field(int row, int col, T value) { * @param index index of field * @param value value of field * @throws IndexOutOfBoundsException if index is invalid + * @since 1.0.0 */ protected Field(long index, T value) { if (!isValidIndex(index)) @@ -1380,6 +1458,7 @@ protected Field(long index, T value) { /** * @return row of field + * @since 1.0.0 */ public final int getRow() { return (int) (getIndex() / getCols()); @@ -1387,6 +1466,7 @@ public final int getRow() { /** * @return col of field + * @since 1.0.0 */ public final int getCol() { return (int) (getIndex() % getCols()); @@ -1394,6 +1474,7 @@ public final int getCol() { /** * @return index of field + * @since 1.0.0 */ public final long getIndex() { return index; @@ -1401,6 +1482,7 @@ public final long getIndex() { /** * @return value of field + * @since 1.0.0 */ public T getValue() { return value; @@ -1408,6 +1490,7 @@ public T getValue() { /** * @return Matrix instance of field + * @since 1.0.0 */ protected Matrix getMatrix() { return Matrix.this; diff --git a/src/main/java/io/rala/math/algebra/matrix/typed/BigDecimalMatrix.java b/src/main/java/io/rala/math/algebra/matrix/typed/BigDecimalMatrix.java index 76a8c8b3..08732aa1 100644 --- a/src/main/java/io/rala/math/algebra/matrix/typed/BigDecimalMatrix.java +++ b/src/main/java/io/rala/math/algebra/matrix/typed/BigDecimalMatrix.java @@ -10,6 +10,8 @@ /** * class which holds a matrix with {@code rows} and {@code cols} * storing {@link BigDecimal} + * + * @since 1.0.0 */ public class BigDecimalMatrix extends Matrix { // region constructor @@ -17,6 +19,7 @@ public class BigDecimalMatrix extends Matrix { /** * @param size size of matrix * @see Matrix#Matrix(AbstractArithmetic, int) + * @since 1.0.0 */ public BigDecimalMatrix(int size) { super(BigDecimalArithmetic.getInstance(), size); @@ -26,6 +29,7 @@ public BigDecimalMatrix(int size) { * @param size size of matrix * @param context context of {@link BigDecimalArithmetic} * @see Matrix#Matrix(AbstractArithmetic, int) + * @since 1.0.0 */ public BigDecimalMatrix(int size, MathContext context) { super(new BigDecimalArithmetic(context), size); @@ -35,6 +39,7 @@ public BigDecimalMatrix(int size, MathContext context) { * @param rows rows of matrix * @param cols cols of matrix * @see Matrix#Matrix(AbstractArithmetic, int, int) + * @since 1.0.0 */ public BigDecimalMatrix(int rows, int cols) { super(BigDecimalArithmetic.getInstance(), rows, cols); @@ -45,6 +50,7 @@ public BigDecimalMatrix(int rows, int cols) { * @param cols cols of matrix * @param context context of {@link BigDecimalArithmetic} * @see Matrix#Matrix(AbstractArithmetic, int, int) + * @since 1.0.0 */ public BigDecimalMatrix(int rows, int cols, MathContext context) { super(new BigDecimalArithmetic(context), rows, cols); @@ -54,6 +60,7 @@ public BigDecimalMatrix(int rows, int cols, MathContext context) { * creates a new matrix based on given one * * @param matrix matrix to copy + * @since 1.0.0 */ public BigDecimalMatrix(Matrix matrix) { super(matrix); @@ -67,6 +74,7 @@ public BigDecimalMatrix(Matrix matrix) { * @param size size of matrix * @return new created matrix * @see Matrix#identity(AbstractArithmetic, int) + * @since 1.0.0 */ public static BigDecimalMatrix identity(int size) { return new BigDecimalMatrix( @@ -78,6 +86,7 @@ public static BigDecimalMatrix identity(int size) { * @param values diagonal values of matrix * @return new created matrix * @see Matrix#diagonal(AbstractArithmetic, Number[]) + * @since 1.0.0 */ public static BigDecimalMatrix diagonal(BigDecimal... values) { return new BigDecimalMatrix( @@ -98,6 +107,7 @@ public static BigDecimalMatrix diagonal(BigDecimal... values) { * @throws IllegalArgumentException if rows modulo {@code values.length} * is not congruent {@code 0} * @see Matrix#ofValuesByRows(AbstractArithmetic, int, Number[]) + * @since 1.0.0 */ public static BigDecimalMatrix ofValuesByRows(int rows, BigDecimal... values) { return new BigDecimalMatrix(Matrix.ofValuesByRows( @@ -114,6 +124,7 @@ public static BigDecimalMatrix ofValuesByRows(int rows, BigDecimal... values) { * @throws IllegalArgumentException if cols modulo {@code values.length} * is not congruent {@code 0} * @see Matrix#ofValuesByCols(AbstractArithmetic, int, Number[]) + * @since 1.0.0 */ public static BigDecimalMatrix ofValuesByCols(int cols, BigDecimal... values) { return new BigDecimalMatrix(Matrix.ofValuesByCols( diff --git a/src/main/java/io/rala/math/algebra/matrix/typed/DoubleMatrix.java b/src/main/java/io/rala/math/algebra/matrix/typed/DoubleMatrix.java index 4e7ecca2..1f2ee51d 100644 --- a/src/main/java/io/rala/math/algebra/matrix/typed/DoubleMatrix.java +++ b/src/main/java/io/rala/math/algebra/matrix/typed/DoubleMatrix.java @@ -9,6 +9,8 @@ /** * class which holds a matrix with {@code rows} and {@code cols} * storing {@link Double} + * + * @since 1.0.0 */ public class DoubleMatrix extends Matrix { // region constructor @@ -16,6 +18,7 @@ public class DoubleMatrix extends Matrix { /** * @param size size of matrix * @see Matrix#Matrix(AbstractArithmetic, int) + * @since 1.0.0 */ public DoubleMatrix(int size) { super(DoubleArithmetic.getInstance(), size); @@ -25,6 +28,7 @@ public DoubleMatrix(int size) { * @param rows rows of matrix * @param cols cols of matrix * @see Matrix#Matrix(AbstractArithmetic, int, int) + * @since 1.0.0 */ public DoubleMatrix(int rows, int cols) { super(DoubleArithmetic.getInstance(), rows, cols); @@ -34,6 +38,7 @@ public DoubleMatrix(int rows, int cols) { * creates a new matrix based on given one * * @param matrix matrix to copy + * @since 1.0.0 */ public DoubleMatrix(Matrix matrix) { super(matrix); @@ -47,6 +52,7 @@ public DoubleMatrix(Matrix matrix) { * @param size size of matrix * @return new created matrix * @see Matrix#identity(AbstractArithmetic, int) + * @since 1.0.0 */ public static DoubleMatrix identity(int size) { return new DoubleMatrix( @@ -58,6 +64,7 @@ public static DoubleMatrix identity(int size) { * @param values diagonal values of matrix * @return new created matrix * @see Matrix#diagonal(AbstractArithmetic, Number[]) + * @since 1.0.0 */ public static DoubleMatrix diagonal(double... values) { Double[] boxed = Arrays.stream(values).boxed().toArray(Double[]::new); @@ -79,6 +86,7 @@ public static DoubleMatrix diagonal(double... values) { * @throws IllegalArgumentException if rows modulo {@code values.length} * is not congruent {@code 0} * @see Matrix#ofValuesByRows(AbstractArithmetic, int, Number[]) + * @since 1.0.0 */ public static DoubleMatrix ofValuesByRows(int rows, double... values) { Double[] boxed = Arrays.stream(values).boxed().toArray(Double[]::new); @@ -96,6 +104,7 @@ public static DoubleMatrix ofValuesByRows(int rows, double... values) { * @throws IllegalArgumentException if cols modulo {@code values.length} * is not congruent {@code 0} * @see Matrix#ofValuesByCols(AbstractArithmetic, int, Number[]) + * @since 1.0.0 */ public static DoubleMatrix ofValuesByCols(int cols, double... values) { Double[] boxed = Arrays.stream(values).boxed().toArray(Double[]::new); diff --git a/src/main/java/io/rala/math/algebra/numeric/Complex.java b/src/main/java/io/rala/math/algebra/numeric/Complex.java index 6188a517..096126b2 100644 --- a/src/main/java/io/rala/math/algebra/numeric/Complex.java +++ b/src/main/java/io/rala/math/algebra/numeric/Complex.java @@ -15,6 +15,7 @@ * class which holds a real and a imaginary part of a complex number * * @param number class + * @since 1.0.0 */ public class Complex extends Number implements Validatable, Copyable>, Comparable> { @@ -33,6 +34,7 @@ public class Complex extends Number implements Validatable, * calls {@link #Complex(AbstractArithmetic, Number, Number)} with {@code 0} * * @param arithmetic arithmetic for calculations + * @since 1.0.0 */ public Complex(AbstractArithmetic arithmetic) { this(arithmetic, @@ -46,6 +48,7 @@ public Complex(AbstractArithmetic arithmetic) { * @param arithmetic arithmetic for calculations * @param re real part * @param im imaginary part + * @since 1.0.0 */ public Complex(AbstractArithmetic arithmetic, T re, T im) { this.arithmetic = arithmetic; @@ -57,6 +60,7 @@ public Complex(AbstractArithmetic arithmetic, T re, T im) { * creates a new complex based on given one * * @param complex complex to copy + * @since 1.0.0 */ protected Complex(Complex complex) { this(complex.getArithmetic(), complex.getRe(), complex.getIm()); @@ -68,6 +72,7 @@ protected Complex(Complex complex) { /** * @return stored {@link AbstractArithmetic} + * @since 1.0.0 */ public AbstractArithmetic getArithmetic() { return arithmetic; @@ -75,6 +80,7 @@ public AbstractArithmetic getArithmetic() { /** * @return real part of complex number + * @since 1.0.0 */ public T getRe() { return re; @@ -82,6 +88,7 @@ public T getRe() { /** * @param re new real part of complex number + * @since 1.0.0 */ public void setRe(T re) { this.re = re; @@ -89,6 +96,7 @@ public void setRe(T re) { /** * @return imaginary part of complex number + * @since 1.0.0 */ public T getIm() { return im; @@ -96,6 +104,7 @@ public T getIm() { /** * @param im new imaginary part of complex number + * @since 1.0.0 */ public void setIm(T im) { this.im = im; @@ -131,6 +140,7 @@ public double doubleValue() { /** * @return absolute (modulus) value of complex based on pythagoras + * @since 1.0.0 */ public T absoluteValue() { return getArithmetic().root2(getArithmetic().sum( @@ -141,6 +151,7 @@ public T absoluteValue() { /** * @return argument value of complex + * @since 1.0.0 */ public T argument() { return getArithmetic().product( @@ -151,6 +162,7 @@ public T argument() { /** * @return {@code 0} if z is zero otherwise {@code z/|z|} + * @since 1.0.0 */ public Complex signum() { if (getArithmetic().isZero(getRe()) && @@ -162,6 +174,7 @@ public Complex signum() { /** * @return if re is not {@code 0} {@code sign(re)} otherwise {@code sign(im)} * @see Math#signum(double) + * @since 1.0.0 */ public double complexSignum() { return !getArithmetic().isZero(getRe()) ? @@ -174,6 +187,7 @@ public double complexSignum() { /** * @return {@link #inverseIm()} + * @since 1.0.0 */ public Complex conjugation() { return inverseIm(); @@ -181,6 +195,7 @@ public Complex conjugation() { /** * @return new reciprocal of complex + * @since 1.0.0 */ public Complex reciprocal() { T d = getArithmetic().sum( @@ -204,6 +219,7 @@ public Complex reciprocal() { * @param im imaginary value to add * @return new complex with sum of current and given parameters * @see #add(Complex) + * @since 1.0.0 */ public Complex add(T re, T im) { return add(new Complex<>(getArithmetic(), re, im)); @@ -212,6 +228,7 @@ public Complex add(T re, T im) { /** * @param complex complex value to add * @return new complex with sum of current and given complex + * @since 1.0.0 */ public Complex add(Complex complex) { return new Complex<>(getArithmetic(), @@ -227,6 +244,7 @@ public Complex add(Complex complex) { * @param im imaginary value to subtract * @return new complex with difference of current and given parameters * @see #subtract(Complex) + * @since 1.0.0 */ public Complex subtract(T re, T im) { return subtract(new Complex<>(getArithmetic(), re, im)); @@ -235,6 +253,7 @@ public Complex subtract(T re, T im) { /** * @param complex complex value to subtract * @return new complex with difference of current and given complex + * @since 1.0.0 */ public Complex subtract(Complex complex) { return add(complex.inverse()); @@ -247,6 +266,7 @@ public Complex subtract(Complex complex) { /** * @param i value to multiply with real & imaginary * @return new complex with multiplied real & imaginary values + * @since 1.0.0 */ public Complex multiply(T i) { return new Complex<>(getArithmetic(), @@ -258,6 +278,7 @@ public Complex multiply(T i) { /** * @param complex complex value to multiply * @return new complex with multiplied real & imaginary values + * @since 1.0.0 */ public Complex multiply(Complex complex) { return new Complex<>(getArithmetic(), @@ -275,6 +296,7 @@ public Complex multiply(Complex complex) { /** * @param i value to divide real & imaginary through * @return new complex with divided real & imaginary values + * @since 1.0.0 */ public Complex divide(T i) { return new Complex<>(getArithmetic(), @@ -286,6 +308,7 @@ public Complex divide(T i) { /** * @param complex complex value to divide through * @return new complex which is quotient of the division + * @since 1.0.0 */ public Complex divide(Complex complex) { return new Complex<>(getArithmetic(), @@ -319,6 +342,7 @@ public Complex divide(Complex complex) { /** * @param n number of power * @return new complex with powered real & imaginary values + * @since 1.0.0 */ public Complex pow(int n) { return Complex.of(getArithmetic(), @@ -331,6 +355,7 @@ public Complex pow(int n) { * @param n number of root * @return new complex with rooted real & imaginary values * @see MathX#root(double, int) + * @since 1.0.0 */ public List> root(int n) { List> list = new ArrayList<>(n - 1); @@ -359,6 +384,7 @@ public List> root(int n) { * @return new complex which has inverse real & imaginary values * @see #inverseRe() * @see #inverseIm() + * @since 1.0.0 */ public Complex inverse() { return inverseRe().inverseIm(); @@ -368,6 +394,7 @@ public Complex inverse() { * @return new complex which has inverse real value * @see #inverse() * @see #inverseIm() + * @since 1.0.0 */ public Complex inverseRe() { return new Complex<>(getArithmetic(), getArithmetic().negate(getRe()), getIm()); @@ -377,6 +404,7 @@ public Complex inverseRe() { * @return new complex which has inverse imaginary value * @see #inverse() * @see #inverseRe() + * @since 1.0.0 */ public Complex inverseIm() { return new Complex<>(getArithmetic(), getRe(), getArithmetic().negate(getIm())); @@ -392,6 +420,7 @@ public Complex inverseIm() { * @param argument argument of vector * @param number class of values * @return new complex based on absoluteValue and argument + * @since 1.0.0 */ public static Complex of( AbstractArithmetic arithmetic, T absoluteValue, T argument @@ -412,6 +441,7 @@ public static Complex of( * @return new vector representing * {@link #getRe()} as {@code x} and * {@link #getIm()} as {@code y} + * @since 1.0.0 */ public Vector asVector() { return new Vector<>(getArithmetic(), getRe(), getIm()); @@ -426,6 +456,7 @@ public Vector asVector() { * @param map mapping function to convert current values to new one * @param new number class * @return new mapped complex + * @since 1.0.0 */ public Complex map( AbstractArithmetic arithmetic, Function map diff --git a/src/main/java/io/rala/math/algebra/numeric/Fraction.java b/src/main/java/io/rala/math/algebra/numeric/Fraction.java index 8e5f25ff..01ecabb2 100644 --- a/src/main/java/io/rala/math/algebra/numeric/Fraction.java +++ b/src/main/java/io/rala/math/algebra/numeric/Fraction.java @@ -13,6 +13,7 @@ * * @param number class of fraction elements * @param number class of value + * @since 1.0.0 */ public class Fraction extends Number implements Copyable>, Comparable> { @@ -37,6 +38,7 @@ public class Fraction extends Number * * @param arithmetic arithmetic for calculations * @param numerator numerator of fraction + * @since 1.0.0 */ public Fraction(AbstractResultArithmetic arithmetic, T numerator) { this(arithmetic, numerator, null); @@ -49,6 +51,7 @@ public Fraction(AbstractResultArithmetic arithmetic, T numerator) { * @param arithmetic arithmetic for calculations * @param numerator numerator of fraction * @param denominator denominator of fraction + * @since 1.0.0 */ public Fraction( AbstractResultArithmetic arithmetic, T numerator, T denominator @@ -66,6 +69,7 @@ public Fraction( * creates a new fraction based on given one * * @param fraction fraction to copy + * @since 1.0.0 */ protected Fraction(Fraction fraction) { this(fraction.getArithmetic(), @@ -79,6 +83,7 @@ protected Fraction(Fraction fraction) { /** * @return stored {@link AbstractResultArithmetic} + * @since 1.0.0 */ public AbstractResultArithmetic getArithmetic() { return arithmetic; @@ -86,6 +91,7 @@ public AbstractResultArithmetic getArithmetic() { /** * @return numerator of fraction + * @since 1.0.0 */ public T getNumerator() { return numerator; @@ -94,6 +100,7 @@ public T getNumerator() { /** * @param numerator new numerator of fraction * @throws IllegalArgumentException if numerator is {@code null} + * @since 1.0.0 */ public void setNumerator(T numerator) { if (numerator == null) @@ -103,6 +110,7 @@ public void setNumerator(T numerator) { /** * @return denominator of fraction + * @since 1.0.0 */ public T getDenominator() { return denominator; @@ -111,6 +119,7 @@ public T getDenominator() { /** * @param denominator new denominator of fraction * @throws IllegalArgumentException if denominator is {@code 0} + * @since 1.0.0 */ public void setDenominator(T denominator) { if (denominator == null) @@ -128,6 +137,7 @@ public void setDenominator(T denominator) { /** * @return calculated value + * @since 1.0.0 */ public V value() { return getArithmetic().quotient(getNumerator(), getDenominator()); @@ -159,6 +169,7 @@ public double doubleValue() { /** * @return new fraction with negated {@link #getNumerator()} + * @since 1.0.0 */ public Fraction negate() { return createFromArithmetic( @@ -169,6 +180,7 @@ public Fraction negate() { /** * @return new fraction with flipped {@code numerator} and {@code denominator} + * @since 1.0.0 */ public Fraction inverse() { return createFromArithmetic(getDenominator(), getNumerator()); @@ -178,6 +190,7 @@ public Fraction inverse() { * both numbers are divided through {@link AbstractArithmetic#gcd(Number, Number)} * * @return simplified {@link Fraction} or {@link #copy()} + * @since 1.0.0 */ public Fraction simplify() { AbstractArithmetic tArithmetic = getArithmetic().getTArithmetic(); @@ -203,6 +216,7 @@ public Fraction simplify() { * @param denominator denominator value to add * @return new fraction with sum of current and given parameters * @see #add(Fraction) + * @since 1.0.0 */ public Fraction add(T numerator, T denominator) { return add(new Fraction<>(getArithmetic(), numerator, denominator)); @@ -211,6 +225,7 @@ public Fraction add(T numerator, T denominator) { /** * @param fraction fraction to add * @return new fraction with sum of current and given fraction + * @since 1.0.0 */ public Fraction add(Fraction fraction) { AbstractArithmetic tArithmetic = getArithmetic().getTArithmetic(); @@ -237,6 +252,7 @@ public Fraction add(Fraction fraction) { * @param denominator denominator value to subtract * @return new fraction with difference of current and given parameters * @see #subtract(Fraction) + * @since 1.0.0 */ public Fraction subtract(T numerator, T denominator) { return subtract(new Fraction<>(getArithmetic(), numerator, denominator)); @@ -245,6 +261,7 @@ public Fraction subtract(T numerator, T denominator) { /** * @param fraction fraction to subtract * @return new fraction with difference of current and given fraction + * @since 1.0.0 */ public Fraction subtract(Fraction fraction) { return add(fraction.negate()); @@ -260,6 +277,7 @@ public Fraction subtract(Fraction fraction) { * @param numerator numerator value to multiply * @return new fraction with product of current and given parameter * @see #multiply(Fraction) + * @since 1.0.0 */ public Fraction multiply(T numerator) { return multiply(new Fraction<>(getArithmetic(), numerator)); @@ -272,6 +290,7 @@ public Fraction multiply(T numerator) { * @param denominator denominator value to multiply * @return new fraction with product of current and given parameters * @see #multiply(Fraction) + * @since 1.0.0 */ public Fraction multiply(T numerator, T denominator) { return multiply(new Fraction<>(getArithmetic(), numerator, denominator)); @@ -280,6 +299,7 @@ public Fraction multiply(T numerator, T denominator) { /** * @param fraction fraction to multiply * @return new fraction with product of current and given fraction + * @since 1.0.0 */ public Fraction multiply(Fraction fraction) { AbstractArithmetic tArithmetic = getArithmetic().getTArithmetic(); @@ -298,6 +318,7 @@ public Fraction multiply(Fraction fraction) { * @param numerator numerator value to multiply * @return new fraction with quotient of current and given parameter * @see #divide(Fraction) + * @since 1.0.0 */ public Fraction divide(T numerator) { return divide(new Fraction<>(getArithmetic(), numerator)); @@ -310,6 +331,7 @@ public Fraction divide(T numerator) { * @param denominator denominator value to multiply * @return new fraction with quotient of current and given parameters * @see #divide(Fraction) + * @since 1.0.0 */ public Fraction divide(T numerator, T denominator) { return divide(new Fraction<>(getArithmetic(), numerator, denominator)); @@ -318,6 +340,7 @@ public Fraction divide(T numerator, T denominator) { /** * @param fraction fraction to divide * @return new fraction with quotient of current and given fraction + * @since 1.0.0 */ public Fraction divide(Fraction fraction) { return multiply(fraction.inverse()); @@ -330,6 +353,7 @@ public Fraction divide(Fraction fraction) { /** * @param n number of power * @return {@code pow(numerator,n)/pow(denominator,n)} + * @since 1.0.0 */ public Fraction pow(int n) { AbstractArithmetic tArithmetic = getArithmetic().getTArithmetic(); @@ -341,6 +365,7 @@ public Fraction pow(int n) { /** * @param n degree of root * @return {@code root(numerator,n)/root(denominator,n)} + * @since 1.0.0 */ public Fraction root(int n) { AbstractArithmetic tArithmetic = getArithmetic().getTArithmetic(); @@ -360,6 +385,7 @@ public Fraction root(int n) { * @return new fraction based on arguments * @see #of(AbstractArithmetic, Number, Number) * @see AbstractArithmetic#toResultArithmetic() + * @since 1.0.0 */ public static Fraction of( AbstractArithmetic arithmetic, T numerator @@ -375,6 +401,7 @@ public static Fraction of( * @return new fraction based on arguments * @see #of(AbstractArithmetic, Number) * @see AbstractArithmetic#toResultArithmetic() + * @since 1.0.0 */ public static Fraction of( AbstractArithmetic arithmetic, T numerator, T denominator @@ -392,6 +419,7 @@ public static Fraction of( * @param new number class * @param new value class * @return mapped fraction + * @since 1.0.0 */ public Fraction map( AbstractResultArithmetic arithmetic, Function map @@ -411,6 +439,7 @@ public Fraction map( * @return mapped fraction * @see #mapValues(AbstractResultArithmetic, Function) * @see AbstractResultArithmetic#map(AbstractArithmetic, Function) + * @since 1.0.0 */ public Fraction mapValues( AbstractArithmetic arithmetic, Function mapTR, Function mapRV @@ -424,6 +453,7 @@ public Fraction mapValues( * @param new number class * @return mapped fraction * @see #map(AbstractResultArithmetic, Function) + * @since 1.0.0 */ public Fraction mapValues( AbstractResultArithmetic arithmetic, Function map @@ -437,6 +467,7 @@ public Fraction mapValues( * @param new number class * @return mapped fraction * @see AbstractResultArithmetic#mapResult(AbstractArithmetic, Function) + * @since 1.0.0 */ public Fraction mapValue( AbstractArithmetic arithmetic, Function map @@ -490,6 +521,7 @@ public int compareTo(Fraction o) { * @return new fraction * @throws ArithmeticException if denominator is {@code 0} * @throws IllegalArgumentException if constructor throws one + * @since 1.0.0 */ protected final Fraction createFromArithmetic(T numerator, T denominator) { try { @@ -504,6 +536,8 @@ protected final Fraction createFromArithmetic(T numerator, T denominator) /** * ensures that if there is a signum it is on {@link #getNumerator()} + * + * @since 1.0.0 */ protected void simplifySignum() { if (getArithmetic().getTArithmetic().signum(getDenominator()) < 0) { diff --git a/src/main/java/io/rala/math/algebra/numeric/typed/BigDecimalComplex.java b/src/main/java/io/rala/math/algebra/numeric/typed/BigDecimalComplex.java index f06c209f..43884c17 100644 --- a/src/main/java/io/rala/math/algebra/numeric/typed/BigDecimalComplex.java +++ b/src/main/java/io/rala/math/algebra/numeric/typed/BigDecimalComplex.java @@ -10,12 +10,15 @@ /** * class which holds a real and a imaginary part of a complex number * storing {@link BigDecimal} + * + * @since 1.0.0 */ public class BigDecimalComplex extends Complex { // region constructor /** * @see Complex#Complex(AbstractArithmetic) + * @since 1.0.0 */ public BigDecimalComplex() { super(BigDecimalArithmetic.getInstance()); @@ -24,6 +27,7 @@ public BigDecimalComplex() { /** * @param context context of {@link BigDecimalArithmetic} * @see Complex#Complex(AbstractArithmetic) + * @since 1.0.0 */ public BigDecimalComplex(MathContext context) { super(new BigDecimalArithmetic(context)); @@ -33,6 +37,7 @@ public BigDecimalComplex(MathContext context) { * @param re real part * @param im imaginary part * @see Complex#Complex(AbstractArithmetic, Number, Number) + * @since 1.0.0 */ public BigDecimalComplex(BigDecimal re, BigDecimal im) { super(BigDecimalArithmetic.getInstance(), re, im); @@ -43,6 +48,7 @@ public BigDecimalComplex(BigDecimal re, BigDecimal im) { * @param im imaginary part * @param context context of {@link BigDecimalArithmetic} * @see Complex#Complex(AbstractArithmetic, Number, Number) + * @since 1.0.0 */ public BigDecimalComplex(BigDecimal re, BigDecimal im, MathContext context) { super(new BigDecimalArithmetic(context), re, im); @@ -53,6 +59,7 @@ public BigDecimalComplex(BigDecimal re, BigDecimal im, MathContext context) { * * @param complex complex to copy * @see Complex#Complex(Complex) + * @since 1.0.0 */ public BigDecimalComplex(Complex complex) { super(complex.getArithmetic(), complex.getRe(), complex.getIm()); @@ -66,6 +73,7 @@ public BigDecimalComplex(Complex complex) { * @param absoluteValue absolute value of complex * @param argument argument of vector * @return new complex based on absoluteValue and argument + * @since 1.0.0 */ public static BigDecimalComplex of(BigDecimal absoluteValue, BigDecimal argument) { return new BigDecimalComplex( diff --git a/src/main/java/io/rala/math/algebra/numeric/typed/BigIntegerBigDecimalFraction.java b/src/main/java/io/rala/math/algebra/numeric/typed/BigIntegerBigDecimalFraction.java index baac5eb0..53a2044d 100644 --- a/src/main/java/io/rala/math/algebra/numeric/typed/BigIntegerBigDecimalFraction.java +++ b/src/main/java/io/rala/math/algebra/numeric/typed/BigIntegerBigDecimalFraction.java @@ -10,6 +10,8 @@ /** * class which holds fraction values as {@link BigInteger} * and calculates its actual value as {@link BigDecimal} + * + * @since 1.0.0 */ public class BigIntegerBigDecimalFraction extends Fraction { // region constructors @@ -19,6 +21,7 @@ public class BigIntegerBigDecimalFraction extends Fraction fraction) { super(fraction); diff --git a/src/main/java/io/rala/math/algebra/numeric/typed/DoubleComplex.java b/src/main/java/io/rala/math/algebra/numeric/typed/DoubleComplex.java index 74a0f7a8..0b8a0f85 100644 --- a/src/main/java/io/rala/math/algebra/numeric/typed/DoubleComplex.java +++ b/src/main/java/io/rala/math/algebra/numeric/typed/DoubleComplex.java @@ -7,12 +7,15 @@ /** * class which holds a real and a imaginary part of a complex number * storing {@link Double} + * + * @since 1.0.0 */ public class DoubleComplex extends Complex { // region constructor /** * @see Complex#Complex(AbstractArithmetic) + * @since 1.0.0 */ public DoubleComplex() { super(DoubleArithmetic.getInstance()); @@ -22,6 +25,7 @@ public DoubleComplex() { * @param re real part * @param im imaginary part * @see Complex#Complex(AbstractArithmetic, Number, Number) + * @since 1.0.0 */ public DoubleComplex(Double re, Double im) { super(DoubleArithmetic.getInstance(), re, im); @@ -32,6 +36,7 @@ public DoubleComplex(Double re, Double im) { * * @param complex complex to copy * @see Complex#Complex(Complex) + * @since 1.0.0 */ public DoubleComplex(Complex complex) { super(complex.getArithmetic(), complex.getRe(), complex.getIm()); @@ -45,6 +50,7 @@ public DoubleComplex(Complex complex) { * @param absoluteValue absolute value of complex * @param argument argument of vector * @return new complex based on absoluteValue and argument + * @since 1.0.0 */ public static DoubleComplex of(double absoluteValue, double argument) { return new DoubleComplex( diff --git a/src/main/java/io/rala/math/algebra/numeric/typed/LongDoubleFraction.java b/src/main/java/io/rala/math/algebra/numeric/typed/LongDoubleFraction.java index 197b9960..d2dbac09 100644 --- a/src/main/java/io/rala/math/algebra/numeric/typed/LongDoubleFraction.java +++ b/src/main/java/io/rala/math/algebra/numeric/typed/LongDoubleFraction.java @@ -7,6 +7,8 @@ /** * class which holds fraction values as {@link Long} * and calculates its actual value as {@link Double} + * + * @since 1.0.0 */ public class LongDoubleFraction extends Fraction { // region constructors @@ -16,6 +18,7 @@ public class LongDoubleFraction extends Fraction { * * @param numerator numerator of fraction * @see Fraction#Fraction(io.rala.math.arithmetic.AbstractResultArithmetic, Number) + * @since 1.0.0 */ public LongDoubleFraction(long numerator) { super(LongDoubleResultArithmetic.getInstance(), numerator); @@ -27,6 +30,7 @@ public LongDoubleFraction(long numerator) { * @param numerator numerator of fraction * @param denominator denominator of fraction * @see Fraction#Fraction(AbstractResultArithmetic, Number, Number) + * @since 1.0.0 */ public LongDoubleFraction(long numerator, long denominator) { super(LongDoubleResultArithmetic.getInstance(), numerator, denominator); @@ -36,6 +40,7 @@ public LongDoubleFraction(long numerator, long denominator) { * creates a new fraction based on given one * * @param fraction fraction to copy + * @since 1.0.0 */ public LongDoubleFraction(Fraction fraction) { super(fraction); diff --git a/src/main/java/io/rala/math/algebra/vector/Vector.java b/src/main/java/io/rala/math/algebra/vector/Vector.java index aa56e875..b8f18289 100644 --- a/src/main/java/io/rala/math/algebra/vector/Vector.java +++ b/src/main/java/io/rala/math/algebra/vector/Vector.java @@ -19,12 +19,15 @@ * class which holds a vector of {@code size} * * @param number class + * @since 1.0.0 */ public class Vector implements Copyable>, StreamIterable.Entry>, Serializable { /** * describes whether a vector is {@link #COLUMN} or {@link #ROW} + * + * @since 1.0.0 */ public enum Type {ROW, COLUMN} @@ -62,6 +65,7 @@ public enum Type {ROW, COLUMN} * @param arithmetic arithmetic for calculations * @param size size of vector * @throws IllegalArgumentException if size is less than {@code 1} + * @since 1.0.0 */ public Vector(AbstractArithmetic arithmetic, int size) { this(arithmetic, size, arithmetic.zero()); @@ -75,6 +79,7 @@ public Vector(AbstractArithmetic arithmetic, int size) { * @param size size of vector * @param defaultValue default value of non-existing values * @throws IllegalArgumentException if size is less than {@code 1} + * @since 1.0.0 */ protected Vector(AbstractArithmetic arithmetic, int size, T defaultValue) { this(arithmetic, size, Type.COLUMN, defaultValue); @@ -88,6 +93,7 @@ protected Vector(AbstractArithmetic arithmetic, int size, T defaultValue) { * @param size size of vector * @param type type of vector * @throws IllegalArgumentException if size is less than {@code 1} + * @since 1.0.0 */ public Vector(AbstractArithmetic arithmetic, int size, Type type) { this(arithmetic, size, type, arithmetic.zero()); @@ -102,6 +108,7 @@ public Vector(AbstractArithmetic arithmetic, int size, Type type) { * @param defaultValue default value of non-existing values * @param type type of vector * @throws IllegalArgumentException if size is less than {@code 1} + * @since 1.0.0 */ protected Vector( AbstractArithmetic arithmetic, int size, Type type, T defaultValue @@ -118,6 +125,7 @@ protected Vector( * creates a new vector based on given one * * @param vector vector to copy + * @since 1.0.0 */ protected Vector(Vector vector) { this(vector.getArithmetic(), vector.getSize(), @@ -132,6 +140,7 @@ protected Vector(Vector vector) { /** * @return stored arithmetic + * @since 1.0.0 */ public AbstractArithmetic getArithmetic() { return arithmetic; @@ -139,6 +148,7 @@ public AbstractArithmetic getArithmetic() { /** * @return vector map using index as key + * @since 1.0.0 */ protected final Map getVector() { return vector; @@ -146,6 +156,7 @@ protected final Map getVector() { /** * @return size of vector + * @since 1.0.0 */ public final int getSize() { return size; @@ -153,6 +164,7 @@ public final int getSize() { /** * @return default value for non-existing values + * @since 1.0.0 */ protected final T getDefaultValue() { return defaultValue; @@ -160,6 +172,7 @@ protected final T getDefaultValue() { /** * @return type of vector + * @since 1.0.0 */ public final Type getType() { return type; @@ -168,6 +181,7 @@ public final Type getType() { /** * @return {@code true} if {@link #getType()} returns {@link Type#ROW} * @see #isColumn() + * @since 1.0.0 */ public final boolean isRow() { return Type.ROW.equals(getType()); @@ -176,6 +190,7 @@ public final boolean isRow() { /** * @return {@code true} if {@link #getType()} returns {@link Type#COLUMN} * @see #isRow() + * @since 1.0.0 */ public final boolean isColumn() { return Type.COLUMN.equals(getType()); @@ -183,6 +198,7 @@ public final boolean isColumn() { /** * @return {@link #euclideanNorm()} + * @since 1.0.0 */ public T length() { return euclideanNorm(); @@ -196,6 +212,7 @@ public T length() { * @param index of requested value * @return value at index if exists or {@link #getDefaultValue()} * @throws IndexOutOfBoundsException if index is invalid + * @since 1.0.0 */ public T getValue(int index) { if (!isValidIndex(index)) throw new IndexOutOfBoundsException(index + " / " + getSize()); @@ -207,6 +224,7 @@ public T getValue(int index) { * @param value new value to store * @return old value if existed or {@link #getDefaultValue()} * @throws IndexOutOfBoundsException if index is invalid + * @since 1.0.0 */ public T setValue(int index, T value) { if (!isValidIndex(index)) throw new IndexOutOfBoundsException(index + " / " + getSize()); @@ -220,6 +238,7 @@ public T setValue(int index, T value) { * @param index index of value to remove * @return old value if existed or {@link #getDefaultValue()} * @throws IndexOutOfBoundsException if index is invalid + * @since 1.0.0 */ public T removeValue(int index) { if (!isValidIndex(index)) throw new IndexOutOfBoundsException(index + " / " + getSize()); @@ -237,6 +256,7 @@ public T removeValue(int index) { * @return old value if existed or {@link #getDefaultValue()} * @see #setValue(int, Number) * @see #getValue(int) + * @since 1.0.0 */ public T compute(int index, UnaryOperator operator) { return setValue(index, operator.apply(getValue(index))); @@ -249,6 +269,7 @@ public T compute(int index, UnaryOperator operator) { * @return old value if existed or {@link #getDefaultValue()} * @see #setValue(int, Number) * @see #getValue(int) + * @since 1.0.0 */ public T compute(int index, T value, BinaryOperator operator) { return setValue(index, operator.apply(getValue(index), value)); @@ -257,6 +278,7 @@ public T compute(int index, T value, BinaryOperator operator) { /** * @param operator operator to apply to all entries * @see #setValue(int, Number) + * @since 1.0.0 */ public void computeAll(Function operator) { forEach(entry -> setValue(entry.getIndex(), operator.apply(entry))); @@ -266,6 +288,7 @@ public void computeAll(Function operator) { * @param value function returning new value to use in computation * @param operator operator to apply to all entries * @see #computeAll(Function) + * @since 1.0.0 */ public void computeAll(Function value, BinaryOperator operator) { computeAll(entry -> operator.apply(entry.getValue(), value.apply(entry))); @@ -277,6 +300,7 @@ public void computeAll(Function value, BinaryOperator operator) { /** * @return matrix equivalent to vector + * @since 1.0.0 */ public Matrix toMatrix() { Matrix matrix = new Matrix<>( @@ -291,6 +315,7 @@ public Matrix toMatrix() { /** * @return only entry of a size {@code 1} vector * @throws NotSupportedException if size is unequal to {@code 1} + * @since 1.0.0 */ public T toParam() { if (getSize() == 1) return getValue(0); @@ -304,6 +329,7 @@ public T toParam() { /** * @param vector vector to add * @return new vector with calculated values + * @since 1.0.0 */ public Vector add(Vector vector) { if (getSize() != vector.getSize()) @@ -319,6 +345,7 @@ public Vector add(Vector vector) { /** * @param vector vector to subtract * @return new vector with calculated values + * @since 1.0.0 */ public Vector subtract(Vector vector) { return add(vector.invert()); @@ -327,6 +354,7 @@ public Vector subtract(Vector vector) { /** * @param scalar scalar to multiply entries with * @return new vector with calculated values + * @since 1.0.0 */ public Vector multiply(T scalar) { Vector result = copy(); @@ -340,6 +368,7 @@ public Vector multiply(T scalar) { * @return product of matrix multiplication * @throws IllegalArgumentException if sizes do not match * @see Matrix#multiply(Matrix) + * @since 1.0.0 */ public Matrix multiply(Vector vector) { return toMatrix().multiply(vector.toMatrix()); @@ -351,6 +380,7 @@ public Matrix multiply(Vector vector) { * @throws IllegalArgumentException if sizes do not match * @see Matrix#multiply(Matrix) * @see #toParam() + * @since 1.0.0 */ public T dotProduct(Vector vector) { Vector v1 = @@ -368,6 +398,7 @@ public T dotProduct(Vector vector) { /** * @return new vector with opposite {@link Type} + * @since 1.0.0 */ public Vector transpose() { Vector flipped = @@ -382,6 +413,7 @@ public Vector transpose() { /** * @return new vector with inverted sign * @see #multiply(Number) + * @since 1.0.0 */ public Vector invert() { return multiply(getArithmetic().negate(getArithmetic().one())); @@ -393,6 +425,7 @@ public Vector invert() { /** * @return max-Norm of the vector, equal to the entry with highest absolute value + * @since 1.0.0 */ public T maxNorm() { return getVector().values().stream().max( @@ -407,6 +440,7 @@ public T maxNorm() { * calls {@link #pNorm(int)} with degree {@code 2} * * @return euclidean norm of the vector + * @since 1.0.0 */ public T euclideanNorm() { return pNorm(2); @@ -416,6 +450,7 @@ public T euclideanNorm() { * @param p degree of the norm * @return p-norm of the vector * @throws IllegalArgumentException if p is less than {@code 1} + * @since 1.0.0 */ public T pNorm(int p) { if (p <= 0) throw new IllegalArgumentException(EXCEPTION_NOT_POSITIV_P_NORM); @@ -438,6 +473,7 @@ public T pNorm(int p) { * * @return vector of {@link #length()} one * @throws NotSupportedException if all values are {@code 0} + * @since 1.0.0 */ public Vector normalize() { if (isZero()) @@ -462,6 +498,7 @@ public Vector normalize() { * @param vector second vector of angle to calculate * @return angle in radian * @throws NotSupportedException if any vector has only values equal {@code 0} + * @since 1.0.0 */ public T angle(Vector vector) { if (isZero() || vector.isZero()) @@ -489,6 +526,7 @@ public T angle(Vector vector) { * @param number class * @return new created vector * @throws IllegalArgumentException if size is less than {@code 1} + * @since 1.0.0 */ @SafeVarargs public static Vector ofValues( @@ -506,6 +544,7 @@ public static Vector ofValues( * @param number class * @return new created vector * @throws IllegalArgumentException if size is less than {@code 1} + * @since 1.0.0 */ @SafeVarargs private static Vector ofValues( @@ -526,6 +565,7 @@ private static Vector ofValues( * @param number class * @return new created vector * @throws IllegalArgumentException if size is less than {@code 1} + * @since 1.0.0 */ public static Vector ofList( AbstractArithmetic arithmetic, List values @@ -542,6 +582,7 @@ public static Vector ofList( * @param number class * @return new created vector * @throws IllegalArgumentException if size is less than {@code 1} + * @since 1.0.0 */ protected static Vector ofList( AbstractArithmetic arithmetic, List values, T defaultValue @@ -612,6 +653,7 @@ public String toString() { /** * @param index to be validated * @return {@code true} if value is valid + * @since 1.0.0 */ protected final boolean isValidIndex(int index) { return 0 <= index && index < getSize(); @@ -619,6 +661,7 @@ protected final boolean isValidIndex(int index) { /** * @return {@code true} if all values are zero + * @since 1.0.0 */ protected final boolean isZero() { return stream().allMatch( @@ -639,6 +682,8 @@ private void removeDefaultValues() { /** * class which holds an entry of a vector with immutable attributes + * + * @since 1.0.0 */ public class Entry { private final int index; @@ -648,6 +693,7 @@ public class Entry { * @param index index of entry * @param value value of entry * @throws IndexOutOfBoundsException if index is invalid + * @since 1.0.0 */ protected Entry(int index, T value) { if (!isValidIndex(index)) @@ -658,6 +704,7 @@ protected Entry(int index, T value) { /** * @return index of entry + * @since 1.0.0 */ public final int getIndex() { return index; @@ -665,6 +712,7 @@ public final int getIndex() { /** * @return value of entry + * @since 1.0.0 */ public T getValue() { return value; @@ -672,6 +720,7 @@ public T getValue() { /** * @return Vector instance of entry + * @since 1.0.0 */ protected Vector getVector() { return Vector.this; diff --git a/src/main/java/io/rala/math/algebra/vector/typed/BigDecimalVector.java b/src/main/java/io/rala/math/algebra/vector/typed/BigDecimalVector.java index 91ceb84c..9b21eb70 100644 --- a/src/main/java/io/rala/math/algebra/vector/typed/BigDecimalVector.java +++ b/src/main/java/io/rala/math/algebra/vector/typed/BigDecimalVector.java @@ -11,6 +11,8 @@ /** * class which holds a vector of {@code size} * storing {@link BigDecimal} + * + * @since 1.0.0 */ public class BigDecimalVector extends Vector { // region constructor @@ -18,6 +20,7 @@ public class BigDecimalVector extends Vector { /** * @param size size of vector * @see Vector#Vector(AbstractArithmetic, int) + * @since 1.0.0 */ public BigDecimalVector(int size) { super(BigDecimalArithmetic.getInstance(), size); @@ -27,6 +30,7 @@ public BigDecimalVector(int size) { * @param size size of vector * @param context context of {@link BigDecimalArithmetic} * @see Vector#Vector(AbstractArithmetic, int) + * @since 1.0.0 */ public BigDecimalVector(int size, MathContext context) { super(new BigDecimalArithmetic(context), size); @@ -36,6 +40,7 @@ public BigDecimalVector(int size, MathContext context) { * @param size size of vector * @param type type of vector * @see Vector#Vector(AbstractArithmetic, int, Type) + * @since 1.0.0 */ public BigDecimalVector(int size, Type type) { super(BigDecimalArithmetic.getInstance(), size, type); @@ -46,6 +51,7 @@ public BigDecimalVector(int size, Type type) { * @param type type of vector * @param context context of {@link BigDecimalArithmetic} * @see Vector#Vector(AbstractArithmetic, int, Type) + * @since 1.0.0 */ public BigDecimalVector(int size, Type type, MathContext context) { super(new BigDecimalArithmetic(context), size, type); @@ -55,6 +61,7 @@ public BigDecimalVector(int size, Type type, MathContext context) { * creates a new vector based on given one * * @param vector vector to copy + * @since 1.0.0 */ public BigDecimalVector(Vector vector) { super(vector); @@ -70,6 +77,7 @@ public BigDecimalVector(Vector vector) { * @param values values of vector * @return new created vector * @throws IllegalArgumentException if size is less than {@code 1} + * @since 1.0.0 */ public static BigDecimalVector ofValues(BigDecimal... values) { return new BigDecimalVector(Vector.ofValues(BigDecimalArithmetic.getInstance(), values)); @@ -81,6 +89,7 @@ public static BigDecimalVector ofValues(BigDecimal... values) { * @param values values of vector * @return new created vector * @throws IllegalArgumentException if size is less than {@code 1} + * @since 1.0.0 */ public static BigDecimalVector ofList(List values) { return new BigDecimalVector(Vector.ofList(BigDecimalArithmetic.getInstance(), values)); diff --git a/src/main/java/io/rala/math/algebra/vector/typed/DoubleVector.java b/src/main/java/io/rala/math/algebra/vector/typed/DoubleVector.java index 2a97758b..72d76333 100644 --- a/src/main/java/io/rala/math/algebra/vector/typed/DoubleVector.java +++ b/src/main/java/io/rala/math/algebra/vector/typed/DoubleVector.java @@ -10,6 +10,8 @@ /** * class which holds a vector of {@code size} * storing {@link Double} + * + * @since 1.0.0 */ public class DoubleVector extends Vector { // region constructor @@ -17,6 +19,7 @@ public class DoubleVector extends Vector { /** * @param size size of vector * @see Vector#Vector(AbstractArithmetic, int) + * @since 1.0.0 */ public DoubleVector(int size) { super(DoubleArithmetic.getInstance(), size); @@ -26,6 +29,7 @@ public DoubleVector(int size) { * @param size size of vector * @param type type of vector * @see Vector#Vector(AbstractArithmetic, int, Type) + * @since 1.0.0 */ public DoubleVector(int size, Type type) { super(DoubleArithmetic.getInstance(), size, type); @@ -35,6 +39,7 @@ public DoubleVector(int size, Type type) { * creates a new vector based on given one * * @param vector vector to copy + * @since 1.0.0 */ public DoubleVector(Vector vector) { super(vector); @@ -50,6 +55,7 @@ public DoubleVector(Vector vector) { * @param values values of vector * @return new created vector * @throws IllegalArgumentException if size is less than {@code 1} + * @since 1.0.0 */ public static DoubleVector ofValues(double... values) { Double[] boxed = Arrays.stream(values).boxed().toArray(Double[]::new); @@ -62,6 +68,7 @@ public static DoubleVector ofValues(double... values) { * @param values values of vector * @return new created vector * @throws IllegalArgumentException if size is less than {@code 1} + * @since 1.0.0 */ public static DoubleVector ofList(List values) { return new DoubleVector(Vector.ofList(DoubleArithmetic.getInstance(), values)); diff --git a/src/main/java/io/rala/math/arithmetic/AbstractArithmetic.java b/src/main/java/io/rala/math/arithmetic/AbstractArithmetic.java index 9e76d488..0423ff63 100644 --- a/src/main/java/io/rala/math/arithmetic/AbstractArithmetic.java +++ b/src/main/java/io/rala/math/arithmetic/AbstractArithmetic.java @@ -11,6 +11,7 @@ * class which defines required arithmetic for calculations * * @param number class of arithmetic + * @since 1.0.0 */ public abstract class AbstractArithmetic implements Serializable { // region fromInt, fromDouble and signum @@ -18,12 +19,14 @@ public abstract class AbstractArithmetic implements Serializab /** * @param a value from integer * @return number as {@code T} + * @since 1.0.0 */ public abstract T fromInt(int a); /** * @param a value from double * @return number as {@code T} + * @since 1.0.0 */ public abstract T fromDouble(double a); @@ -31,6 +34,7 @@ public abstract class AbstractArithmetic implements Serializab * @param a value to get signum * @return {@code -1} if negative, {@code 0} if zero or {@code 1} if positive * @throws NotSupportedException if operation is not supported + * @since 1.0.0 */ public abstract double signum(T a); @@ -43,6 +47,7 @@ public abstract class AbstractArithmetic implements Serializab * * @return {@code 0} * @see #fromInt(int) + * @since 1.0.0 */ public final T zero() { return fromInt(0); @@ -53,6 +58,7 @@ public final T zero() { * * @return {@code 1} * @see #fromInt(int) + * @since 1.0.0 */ public final T one() { return fromInt(1); @@ -66,6 +72,7 @@ public final T one() { * @param a value to make absolute * @return absolute value of a * @throws NotSupportedException if operation is not supported + * @since 1.0.0 */ public T absolute(T a) { return signum(a) < 0 || Double.valueOf(signum(a)).equals(-0d) ? negate(a) : a; @@ -75,6 +82,7 @@ public T absolute(T a) { * @param a value to negate * @return {@code -a} * @throws NotSupportedException if operation is not supported + * @since 1.0.0 */ public T negate(T a) { return product(a, fromInt(-1)); @@ -87,6 +95,7 @@ public T negate(T a) { * @throws NotSupportedException if operation is not supported * @implSpec default implementation uses {@link Double#compare(double, double)} * @see Comparable#compareTo(Object) + * @since 1.0.0 */ public int compare(T a, T b) { return Double.compare(a.doubleValue(), b.doubleValue()); @@ -97,6 +106,7 @@ public int compare(T a, T b) { * @param b second value of comparison * @return min value * @implSpec {@link #compare(Number, Number)} {@code <= 0 ? a : b} + * @since 1.0.0 */ public T min(T a, T b) { return compare(a, b) <= 0 ? a : b; @@ -107,6 +117,7 @@ public T min(T a, T b) { * @param b second value of comparison * @return max value * @implSpec {@link #compare(Number, Number)} {@code < 0 ? b : a} + * @since 1.0.0 */ public T max(T a, T b) { return compare(a, b) < 0 ? b : a; @@ -116,6 +127,7 @@ public T max(T a, T b) { * @param a number to check * @return {@code true} if {@code abs(a)} is {@code 0} * @see #absolute(Number) + * @since 1.0.0 */ public boolean isZero(T a) { return zero().equals(absolute(a)); @@ -125,6 +137,7 @@ public boolean isZero(T a) { * @param a first value of comparison * @param b second value of comparison * @return {@code true} if both values are equal + * @since 1.0.0 */ public boolean isEqual(T a, T b) { return a == null && b == null || @@ -141,6 +154,7 @@ public boolean isEqual(T a, T b) { * @param a first value of sum * @param b second value of sum * @return {@code a+b} + * @since 1.0.0 */ public abstract T sum(T a, T b); @@ -151,6 +165,7 @@ public boolean isEqual(T a, T b) { * @return {@code a+b+c} * @implSpec default implementation uses {@link #sum(Number, Number)} twice * @see #sum(Number, Number) + * @since 1.0.0 */ public T sum(T a, T b, T c) { return sum(sum(a, b), c); @@ -161,6 +176,7 @@ public T sum(T a, T b, T c) { * @return sum or {@link #zero()} if empty * @implSpec default implementation iterates over all elements * and starts with {@code 0} + * @since 1.0.0 */ public T sum(Iterable iterable) { return StreamSupport.stream(iterable.spliterator(), false) @@ -171,6 +187,7 @@ public T sum(Iterable iterable) { * @param a first value of difference * @param b second value of difference * @return {@code a-b} + * @since 1.0.0 */ public abstract T difference(T a, T b); @@ -178,6 +195,7 @@ public T sum(Iterable iterable) { * @param a first value of product * @param b second value of product * @return {@code a*b} + * @since 1.0.0 */ public abstract T product(T a, T b); @@ -188,6 +206,7 @@ public T sum(Iterable iterable) { * @return {@code a*b*c} * @implSpec default implementation uses {@link #product(Number, Number)} twice * @see #product(Number, Number) + * @since 1.0.0 */ public T product(T a, T b, T c) { return product(product(a, b), c); @@ -198,6 +217,7 @@ public T product(T a, T b, T c) { * @return product or {@link #one()} if empty * @implSpec default implementation iterates over all elements * and starts with {@code 1} + * @since 1.0.0 */ public T product(Iterable iterable) { return StreamSupport.stream(iterable.spliterator(), false) @@ -208,6 +228,7 @@ public T product(Iterable iterable) { * @param a first value of quotient * @param b second value of quotient * @return {@code a/b} + * @since 1.0.0 */ public abstract T quotient(T a, T b); @@ -216,6 +237,7 @@ public T product(Iterable iterable) { * @param b second value of quotient * @return reminder of division like {@code r=a-q*b} * @throws NotSupportedException if operation is not supported + * @since 1.0.0 */ public T modulo(T a, T b) { T quotient = quotient(a, b); @@ -232,6 +254,7 @@ public T modulo(T a, T b) { * @param b exponent of power * @return {@code a^b} * @throws NotSupportedException if operation is not supported + * @since 1.0.0 */ public abstract T power(T a, int b); @@ -240,6 +263,7 @@ public T modulo(T a, T b) { * @param b degree of root * @return {@code root(a, b)} * @throws NotSupportedException if operation is not supported + * @since 1.0.0 */ public abstract T root(T a, int b); @@ -248,6 +272,7 @@ public T modulo(T a, T b) { * @return {@code sqrt(a)} * @throws NotSupportedException if operation is not supported * @see #root(Number, int) + * @since 1.0.0 */ public T root2(T a) { return root(a, 2); @@ -261,6 +286,7 @@ public T root2(T a) { * @param a value to check * @return {@code true} if value is finite * @implSpec default implementation uses {@link Double#isInfinite(double)} + * @since 1.0.0 */ public boolean isFinite(T a) { return Double.isFinite(a.doubleValue()); @@ -270,6 +296,7 @@ public boolean isFinite(T a) { * @param a value to check * @return {@code true} if value is infinite * @implSpec default implementation uses {@link Double#isInfinite(double)} + * @since 1.0.0 */ public boolean isInfinite(T a) { return Double.isInfinite(a.doubleValue()); @@ -279,6 +306,7 @@ public boolean isInfinite(T a) { * @param a value to check * @return {@code true} if value is NaN * @implSpec default implementation uses {@link Double#isNaN(double)} + * @since 1.0.0 */ public boolean isNaN(T a) { return Double.isNaN(a.doubleValue()); @@ -293,6 +321,7 @@ public boolean isNaN(T a) { * @param b second value * @return greatest common divisor * @throws NotSupportedException if operation is not supported + * @since 1.0.0 */ public abstract T gcd(T a, T b); @@ -302,6 +331,7 @@ public boolean isNaN(T a) { * @return least common multiple * @throws NotSupportedException if operation is not supported * @implSpec default implementation uses {@code abs(a*b)/gcd(a,b)} + * @since 1.0.0 */ public T lcm(T a, T b) { return quotient(absolute(product(a, b)), gcd(a, b)); @@ -316,6 +346,7 @@ public T lcm(T a, T b) { * @return {@code sin(a)} * @throws NotSupportedException if operation is not supported * @implSpec default implementation uses {@link Math#sin(double)} + * @since 1.0.0 */ public T sin(T a) { return fromDouble(Math.sin(a.doubleValue())); @@ -326,6 +357,7 @@ public T sin(T a) { * @return {@code cos(a)} * @throws NotSupportedException if operation is not supported * @implSpec default implementation uses {@link Math#cos(double)} + * @since 1.0.0 */ public T cos(T a) { return fromDouble(Math.cos(a.doubleValue())); @@ -336,6 +368,7 @@ public T cos(T a) { * @return {@code tan(a)} * @throws NotSupportedException if operation is not supported * @implSpec default implementation uses {@link Math#tan(double)} + * @since 1.0.0 */ public T tan(T a) { return fromDouble(Math.tan(a.doubleValue())); @@ -346,6 +379,7 @@ public T tan(T a) { * @return {@code asin(a)} * @throws NotSupportedException if operation is not supported * @implSpec default implementation uses {@link Math#asin(double)} + * @since 1.0.0 */ public T asin(T a) { return fromDouble(Math.asin(a.doubleValue())); @@ -356,6 +390,7 @@ public T asin(T a) { * @return {@code acos(a)} * @throws NotSupportedException if operation is not supported * @implSpec default implementation uses {@link Math#acos(double)} + * @since 1.0.0 */ public T acos(T a) { return fromDouble(Math.acos(a.doubleValue())); @@ -366,6 +401,7 @@ public T acos(T a) { * @return {@code atan(a)} * @throws NotSupportedException if operation is not supported * @implSpec default implementation uses {@link Math#atan(double)} + * @since 1.0.0 */ public T atan(T a) { return fromDouble(Math.atan(a.doubleValue())); @@ -376,6 +412,7 @@ public T atan(T a) { * @return {@code sinh(a)} * @throws NotSupportedException if operation is not supported * @implSpec default implementation uses {@link Math#sinh(double)} + * @since 1.0.0 */ public T sinh(T a) { return fromDouble(Math.sinh(a.doubleValue())); @@ -386,6 +423,7 @@ public T sinh(T a) { * @return {@code cosh(a)} * @throws NotSupportedException if operation is not supported * @implSpec default implementation uses {@link Math#cosh(double)} + * @since 1.0.0 */ public T cosh(T a) { return fromDouble(Math.cosh(a.doubleValue())); @@ -396,6 +434,7 @@ public T cosh(T a) { * @return {@code tanh(a)} * @throws NotSupportedException if operation is not supported * @implSpec default implementation uses {@link Math#tanh(double)} + * @since 1.0.0 */ public T tanh(T a) { return fromDouble(Math.tanh(a.doubleValue())); @@ -408,6 +447,7 @@ public T tanh(T a) { /** * @return {@link AbstractResultArithmetic} with current arithmetic * @see AbstractResultArithmetic#of(AbstractArithmetic, AbstractArithmetic, Function) + * @since 1.0.0 */ public AbstractResultArithmetic toResultArithmetic() { return AbstractResultArithmetic.of(this, this, t -> t); @@ -421,6 +461,7 @@ public AbstractResultArithmetic toResultArithmetic() { * @see AbstractResultArithmetic#of(AbstractArithmetic, AbstractArithmetic, Function) * @see #toResultArithmetic() * @see AbstractResultArithmetic#mapResult(AbstractArithmetic, Function) + * @since 1.0.0 */ public AbstractResultArithmetic toResultArithmetic( AbstractArithmetic arithmetic, Function map diff --git a/src/main/java/io/rala/math/arithmetic/AbstractResultArithmetic.java b/src/main/java/io/rala/math/arithmetic/AbstractResultArithmetic.java index f5aae947..b3e6eb6b 100644 --- a/src/main/java/io/rala/math/arithmetic/AbstractResultArithmetic.java +++ b/src/main/java/io/rala/math/arithmetic/AbstractResultArithmetic.java @@ -11,6 +11,7 @@ * * @param number class of arithmetic input * @param number class of arithmetic result + * @since 1.0.0 */ public abstract class AbstractResultArithmetic implements Serializable { @@ -22,6 +23,7 @@ public abstract class AbstractResultArithmetic tArithmetic, AbstractArithmetic rArithmetic @@ -32,6 +34,7 @@ public AbstractResultArithmetic( /** * @return stored t {@link AbstractArithmetic} + * @since 1.0.0 */ public AbstractArithmetic getTArithmetic() { return tArithmetic; @@ -39,6 +42,7 @@ public AbstractArithmetic getTArithmetic() { /** * @return stored r {@link AbstractArithmetic} + * @since 1.0.0 */ public AbstractArithmetic getRArithmetic() { return rArithmetic; @@ -47,6 +51,7 @@ public AbstractArithmetic getRArithmetic() { /** * @param a value to convert * @return value as {@code R} + * @since 1.0.0 */ public abstract R fromT(T a); @@ -57,6 +62,7 @@ public AbstractArithmetic getRArithmetic() { * @param b second value of sum * @return {@code a+b} * @see AbstractArithmetic#sum(Number, Number) + * @since 1.0.0 */ public R sum(T a, T b) { return getRArithmetic().sum(fromT(a), fromT(b)); @@ -69,6 +75,7 @@ public R sum(T a, T b) { * @return {@code a+b+c} * @see #sum(Number, Number) * @see AbstractArithmetic#sum(Number, Number, Number) + * @since 1.0.0 */ public R sum(T a, T b, T c) { return getRArithmetic().sum(fromT(a), fromT(b), fromT(c)); @@ -79,6 +86,7 @@ public R sum(T a, T b, T c) { * @param b second value of difference * @return {@code a-b} * @see AbstractArithmetic#difference(Number, Number) + * @since 1.0.0 */ public R difference(T a, T b) { return getRArithmetic().difference(fromT(a), fromT(b)); @@ -89,6 +97,7 @@ public R difference(T a, T b) { * @param b second value of product * @return {@code a*b} * @see AbstractArithmetic#product(Number, Number) + * @since 1.0.0 */ public R product(T a, T b) { return getRArithmetic().product(fromT(a), fromT(b)); @@ -101,6 +110,7 @@ public R product(T a, T b) { * @return {@code a*b*c} * @see #product(Number, Number) * @see AbstractArithmetic#product(Number, Number, Number) + * @since 1.0.0 */ public R product(T a, T b, T c) { return getRArithmetic().product(fromT(a), fromT(b), fromT(c)); @@ -111,6 +121,7 @@ public R product(T a, T b, T c) { * @param b second value of quotient * @return {@code a/b} * @see AbstractArithmetic#quotient(Number, Number) + * @since 1.0.0 */ public R quotient(T a, T b) { return getRArithmetic().quotient(fromT(a), fromT(b)); @@ -122,6 +133,7 @@ public R quotient(T a, T b) { * @return reminder of division like {@code r=a-q*b} * @throws NotSupportedException if operation is not supported * @see AbstractArithmetic#modulo(Number, Number) + * @since 1.0.0 */ public R modulo(T a, T b) { return getRArithmetic().modulo(fromT(a), fromT(b)); @@ -136,6 +148,7 @@ public R modulo(T a, T b) { * @param map mapping function to convert current source to new one * @param number class of new source * @return new {@link AbstractResultArithmetic} wich uses {@code V} + * @since 1.0.0 */ public AbstractResultArithmetic map( AbstractArithmetic arithmetic, Function map @@ -150,6 +163,7 @@ arithmetic, getRArithmetic(), map * @param map mapping function to convert current result to new one * @param number class of target * @return new {@link AbstractResultArithmetic} wich returns {@code V} + * @since 1.0.0 */ public AbstractResultArithmetic mapResult( AbstractArithmetic arithmetic, Function map @@ -168,6 +182,7 @@ public AbstractResultArithmetic mapResult( * @param number class for storing * @param number class for result * @return {@link AbstractResultArithmetic} with given values + * @since 1.0.0 */ public static AbstractResultArithmetic of( AbstractArithmetic tArithmetic, diff --git a/src/main/java/io/rala/math/arithmetic/core/BigDecimalArithmetic.java b/src/main/java/io/rala/math/arithmetic/core/BigDecimalArithmetic.java index b880ed00..0f5c93ee 100644 --- a/src/main/java/io/rala/math/arithmetic/core/BigDecimalArithmetic.java +++ b/src/main/java/io/rala/math/arithmetic/core/BigDecimalArithmetic.java @@ -10,6 +10,8 @@ /** * class which handles {@link BigDecimal} arithmetic + * + * @since 1.0.0 */ public class BigDecimalArithmetic extends AbstractArithmetic { // region singleton @@ -18,6 +20,7 @@ public class BigDecimalArithmetic extends AbstractArithmetic { /** * @return default instance + * @since 1.0.0 */ public static BigDecimalArithmetic getInstance() { if (instance == null) instance = new BigDecimalArithmetic(); @@ -33,6 +36,7 @@ public static BigDecimalArithmetic getInstance() { * with a new {@link MathContext} which precision is {@code 10} * * @see MathContext#MathContext(int) + * @since 1.0.0 */ public BigDecimalArithmetic() { this(new MathContext(10)); @@ -42,6 +46,7 @@ public BigDecimalArithmetic() { * creates a new instance * * @param mathContext mathContext of arithmetic + * @since 1.0.0 */ public BigDecimalArithmetic(MathContext mathContext) { this.mathContext = mathContext; @@ -49,6 +54,7 @@ public BigDecimalArithmetic(MathContext mathContext) { /** * @return stored {@link MathContext} + * @since 1.0.0 */ public MathContext getMathContext() { return mathContext; diff --git a/src/main/java/io/rala/math/arithmetic/core/BigIntegerArithmetic.java b/src/main/java/io/rala/math/arithmetic/core/BigIntegerArithmetic.java index 4eb825bd..cf387f50 100644 --- a/src/main/java/io/rala/math/arithmetic/core/BigIntegerArithmetic.java +++ b/src/main/java/io/rala/math/arithmetic/core/BigIntegerArithmetic.java @@ -8,6 +8,8 @@ /** * class which handles {@link BigInteger} arithmetic + * + * @since 1.0.0 */ public class BigIntegerArithmetic extends AbstractArithmetic { // region singleton @@ -16,6 +18,7 @@ public class BigIntegerArithmetic extends AbstractArithmetic { /** * @return default instance + * @since 1.0.0 */ public static BigIntegerArithmetic getInstance() { if (instance == null) instance = new BigIntegerArithmetic(); diff --git a/src/main/java/io/rala/math/arithmetic/core/ComplexArithmetic.java b/src/main/java/io/rala/math/arithmetic/core/ComplexArithmetic.java index 222a7f9a..35d688e3 100644 --- a/src/main/java/io/rala/math/arithmetic/core/ComplexArithmetic.java +++ b/src/main/java/io/rala/math/arithmetic/core/ComplexArithmetic.java @@ -10,6 +10,7 @@ * class which handles {@link Complex} arithmetic * * @param number class + * @since 1.0.0 */ public class ComplexArithmetic extends AbstractArithmetic> { private final AbstractArithmetic arithmetic; @@ -18,6 +19,7 @@ public class ComplexArithmetic extends AbstractArithmetic arithmetic) { this.arithmetic = arithmetic; @@ -25,6 +27,7 @@ public ComplexArithmetic(AbstractArithmetic arithmetic) { /** * @return stored {@link AbstractArithmetic} of {@link Complex} + * @since 1.0.0 */ public AbstractArithmetic getArithmetic() { return arithmetic; diff --git a/src/main/java/io/rala/math/arithmetic/core/DoubleArithmetic.java b/src/main/java/io/rala/math/arithmetic/core/DoubleArithmetic.java index 310167a8..933e229e 100644 --- a/src/main/java/io/rala/math/arithmetic/core/DoubleArithmetic.java +++ b/src/main/java/io/rala/math/arithmetic/core/DoubleArithmetic.java @@ -6,6 +6,8 @@ /** * class which handles {@link Double} arithmetic + * + * @since 1.0.0 */ public class DoubleArithmetic extends AbstractArithmetic { // region singleton @@ -14,6 +16,7 @@ public class DoubleArithmetic extends AbstractArithmetic { /** * @return default instance + * @since 1.0.0 */ public static DoubleArithmetic getInstance() { if (instance == null) instance = new DoubleArithmetic(); diff --git a/src/main/java/io/rala/math/arithmetic/core/FloatArithmetic.java b/src/main/java/io/rala/math/arithmetic/core/FloatArithmetic.java index 534a1df4..52f342fd 100644 --- a/src/main/java/io/rala/math/arithmetic/core/FloatArithmetic.java +++ b/src/main/java/io/rala/math/arithmetic/core/FloatArithmetic.java @@ -6,6 +6,8 @@ /** * class which handles {@link Float} arithmetic + * + * @since 1.0.0 */ public class FloatArithmetic extends AbstractArithmetic { // region singleton @@ -14,6 +16,7 @@ public class FloatArithmetic extends AbstractArithmetic { /** * @return default instance + * @since 1.0.0 */ public static FloatArithmetic getInstance() { if (instance == null) instance = new FloatArithmetic(); diff --git a/src/main/java/io/rala/math/arithmetic/core/FractionArithmetic.java b/src/main/java/io/rala/math/arithmetic/core/FractionArithmetic.java index 3de943aa..bf1846bb 100644 --- a/src/main/java/io/rala/math/arithmetic/core/FractionArithmetic.java +++ b/src/main/java/io/rala/math/arithmetic/core/FractionArithmetic.java @@ -12,6 +12,7 @@ * * @param number class of values * @param number class of result of {@link Number} methods + * @since 1.0.0 */ public class FractionArithmetic extends AbstractArithmetic> { @@ -21,6 +22,7 @@ public class FractionArithmetic * creates a new {@link AbstractResultArithmetic} with given two arithmetic * * @param arithmetic arithmetic of {@link Fraction} + * @since 1.0.0 */ public FractionArithmetic(AbstractResultArithmetic arithmetic) { this.arithmetic = arithmetic; @@ -28,6 +30,7 @@ public FractionArithmetic(AbstractResultArithmetic arithmetic) { /** * @return stored {@link AbstractResultArithmetic} + * @since 1.0.0 */ public AbstractResultArithmetic getArithmetic() { return arithmetic; diff --git a/src/main/java/io/rala/math/arithmetic/core/IntegerArithmetic.java b/src/main/java/io/rala/math/arithmetic/core/IntegerArithmetic.java index 664c470b..38d04847 100644 --- a/src/main/java/io/rala/math/arithmetic/core/IntegerArithmetic.java +++ b/src/main/java/io/rala/math/arithmetic/core/IntegerArithmetic.java @@ -5,6 +5,8 @@ /** * class which handles {@link Integer} arithmetic + * + * @since 1.0.0 */ public class IntegerArithmetic extends AbstractArithmetic { // region singleton @@ -13,6 +15,7 @@ public class IntegerArithmetic extends AbstractArithmetic { /** * @return default instance + * @since 1.0.0 */ public static IntegerArithmetic getInstance() { if (instance == null) instance = new IntegerArithmetic(); diff --git a/src/main/java/io/rala/math/arithmetic/core/LongArithmetic.java b/src/main/java/io/rala/math/arithmetic/core/LongArithmetic.java index 0865eb7b..5eab0d1c 100644 --- a/src/main/java/io/rala/math/arithmetic/core/LongArithmetic.java +++ b/src/main/java/io/rala/math/arithmetic/core/LongArithmetic.java @@ -5,6 +5,8 @@ /** * class which handles {@link Long} arithmetic + * + * @since 1.0.0 */ public class LongArithmetic extends AbstractArithmetic { // region singleton @@ -13,6 +15,7 @@ public class LongArithmetic extends AbstractArithmetic { /** * @return default instance + * @since 1.0.0 */ public static LongArithmetic getInstance() { if (instance == null) instance = new LongArithmetic(); diff --git a/src/main/java/io/rala/math/arithmetic/result/BigIntegerBigDecimalResultArithmetic.java b/src/main/java/io/rala/math/arithmetic/result/BigIntegerBigDecimalResultArithmetic.java index 655b9ce0..34fa825a 100644 --- a/src/main/java/io/rala/math/arithmetic/result/BigIntegerBigDecimalResultArithmetic.java +++ b/src/main/java/io/rala/math/arithmetic/result/BigIntegerBigDecimalResultArithmetic.java @@ -11,6 +11,8 @@ /** * class which defines required arithmetic for calculations * which calculates {@link BigInteger} to {@link BigDecimal} + * + * @since 1.0.0 */ public class BigIntegerBigDecimalResultArithmetic extends AbstractResultArithmetic { // region singleton @@ -19,6 +21,7 @@ public class BigIntegerBigDecimalResultArithmetic extends AbstractResultArithmet /** * @return default instance + * @since 1.0.0 */ public static BigIntegerBigDecimalResultArithmetic getInstance() { if (instance == null) instance = new BigIntegerBigDecimalResultArithmetic(); @@ -32,6 +35,7 @@ public static BigIntegerBigDecimalResultArithmetic getInstance() { * {@link BigIntegerArithmetic} and {@link BigDecimalArithmetic} * * @see BigDecimalArithmetic#BigDecimalArithmetic() + * @since 1.0.0 */ public BigIntegerBigDecimalResultArithmetic() { super(BigIntegerArithmetic.getInstance(), BigDecimalArithmetic.getInstance()); @@ -43,6 +47,7 @@ public BigIntegerBigDecimalResultArithmetic() { * * @param context context of {@link BigDecimalArithmetic} * @see BigDecimalArithmetic#BigDecimalArithmetic(MathContext) + * @since 1.0.0 */ public BigIntegerBigDecimalResultArithmetic(MathContext context) { super(BigIntegerArithmetic.getInstance(), new BigDecimalArithmetic(context)); diff --git a/src/main/java/io/rala/math/arithmetic/result/LongDoubleResultArithmetic.java b/src/main/java/io/rala/math/arithmetic/result/LongDoubleResultArithmetic.java index 703c08a9..d73ec87c 100644 --- a/src/main/java/io/rala/math/arithmetic/result/LongDoubleResultArithmetic.java +++ b/src/main/java/io/rala/math/arithmetic/result/LongDoubleResultArithmetic.java @@ -7,6 +7,8 @@ /** * class which defines required arithmetic for calculations * which calculates {@link Long} to {@link Double} + * + * @since 1.0.0 */ public class LongDoubleResultArithmetic extends AbstractResultArithmetic { // region singleton @@ -15,6 +17,7 @@ public class LongDoubleResultArithmetic extends AbstractResultArithmetic * may be used in similar context like {@link UnsupportedOperationException} + * + * @since 1.0.0 */ public class NotSupportedException extends RuntimeException { /** * default message: {@code method not supported} + * + * @since 1.0.0 */ public NotSupportedException() { super("method not supported"); @@ -15,6 +19,7 @@ public NotSupportedException() { /** * @param message message of exception + * @since 1.0.0 */ public NotSupportedException(String message) { super(message); diff --git a/src/main/java/io/rala/math/geometry/Circle.java b/src/main/java/io/rala/math/geometry/Circle.java index 5ce42625..8146260a 100644 --- a/src/main/java/io/rala/math/geometry/Circle.java +++ b/src/main/java/io/rala/math/geometry/Circle.java @@ -14,6 +14,7 @@ * class which holds a circle a in 2d area with center & radius * * @param number class + * @since 1.0.0 */ public class Circle implements Validatable, Movable>, Rotatable>, @@ -34,6 +35,7 @@ public class Circle implements Validatable, * {@link Point#Point(AbstractArithmetic)} * * @param arithmetic arithmetic for calculations + * @since 1.0.0 */ public Circle(AbstractArithmetic arithmetic) { this(arithmetic, new Point<>(arithmetic)); @@ -44,6 +46,7 @@ public Circle(AbstractArithmetic arithmetic) { * * @param arithmetic arithmetic for calculations * @param center center point of circle + * @since 1.0.0 */ public Circle(AbstractArithmetic arithmetic, Point center) { this(arithmetic, center, arithmetic.one()); @@ -55,6 +58,7 @@ public Circle(AbstractArithmetic arithmetic, Point center) { * * @param arithmetic arithmetic for calculations * @param radius radius of circle + * @since 1.0.0 */ public Circle(AbstractArithmetic arithmetic, T radius) { this(arithmetic, new Point<>(arithmetic), radius); @@ -67,6 +71,7 @@ public Circle(AbstractArithmetic arithmetic, T radius) { * @param arithmetic arithmetic for calculations * @param center center point of circle * @param point point on circle + * @since 1.0.0 */ public Circle(AbstractArithmetic arithmetic, Point center, Point point) { this(arithmetic, center, new LineSegment<>(arithmetic, center, point).length()); @@ -78,6 +83,7 @@ public Circle(AbstractArithmetic arithmetic, Point center, Point point) * @param arithmetic arithmetic for calculations * @param center center point of circle * @param radius radius of circle + * @since 1.0.0 */ public Circle(AbstractArithmetic arithmetic, Point center, T radius) { this.arithmetic = arithmetic; @@ -91,6 +97,7 @@ public Circle(AbstractArithmetic arithmetic, Point center, T radius) { /** * @return stored arithmetic + * @since 1.0.0 */ public AbstractArithmetic getArithmetic() { return arithmetic; @@ -98,6 +105,7 @@ public AbstractArithmetic getArithmetic() { /** * @return center of circle + * @since 1.0.0 */ public Point getCenter() { return center; @@ -105,6 +113,7 @@ public Point getCenter() { /** * @param center new center of circle + * @since 1.0.0 */ public void setCenter(Point center) { this.center = center; @@ -112,6 +121,7 @@ public void setCenter(Point center) { /** * @return radius of circle + * @since 1.0.0 */ public T getRadius() { return radius; @@ -119,6 +129,7 @@ public T getRadius() { /** * @param radius new radius of circle + * @since 1.0.0 */ public void setRadius(T radius) { this.radius = radius; @@ -126,6 +137,7 @@ public void setRadius(T radius) { /** * @return {@link #getRadius()}{@code *2} + * @since 1.0.0 */ public T getDiameter() { return getArithmetic().product( @@ -138,6 +150,7 @@ public T getDiameter() { * * @param diameter new diameter of circle * @see #setRadius(Number) + * @since 1.0.0 */ public void setDiameter(T diameter) { setRadius(getArithmetic().quotient( @@ -151,6 +164,7 @@ diameter, getArithmetic().fromInt(2) /** * @return π{@code *r^2} + * @since 1.0.0 */ public T area() { return getArithmetic().product( @@ -161,6 +175,7 @@ public T area() { /** * @return {@code 2*}π{@code *r} + * @since 1.0.0 */ public T circumference() { return getArithmetic().product( @@ -176,6 +191,7 @@ public T circumference() { /** * @return {@code true} if {@link #getRadius()} is 1 + * @since 1.0.0 */ public boolean isUnitCircle() { return getArithmetic().one().equals(getRadius()); @@ -190,6 +206,7 @@ public boolean isUnitCircle() { * @param map mapping function to convert current values to new one * @param new number class * @return mapped circle + * @since 1.0.0 */ public Circle map( AbstractArithmetic arithmetic, Function map diff --git a/src/main/java/io/rala/math/geometry/Line.java b/src/main/java/io/rala/math/geometry/Line.java index 58f8cec5..03776dda 100644 --- a/src/main/java/io/rala/math/geometry/Line.java +++ b/src/main/java/io/rala/math/geometry/Line.java @@ -15,6 +15,7 @@ * {@code x=b} * * @param number class + * @since 1.0.0 */ public class Line implements Validatable, Copyable>, Comparable>, Serializable { @@ -36,6 +37,7 @@ public class Line implements Validatable, * * @param arithmetic arithmetic for calculations * @param x x value of line + * @since 1.0.0 */ public Line(AbstractArithmetic arithmetic, T x) { this(arithmetic, null, x); @@ -47,6 +49,7 @@ public Line(AbstractArithmetic arithmetic, T x) { * @param arithmetic arithmetic for calculations * @param m slope/gradient of line * @param b y-intercept of line + * @since 1.0.0 */ public Line(AbstractArithmetic arithmetic, T m, T b) { this.arithmetic = arithmetic; @@ -60,6 +63,7 @@ public Line(AbstractArithmetic arithmetic, T m, T b) { /** * @return stored arithmetic + * @since 1.0.0 */ public AbstractArithmetic getArithmetic() { return arithmetic; @@ -67,6 +71,7 @@ public AbstractArithmetic getArithmetic() { /** * @return m value of line - may return {@code null} if {@link #isVertical()} + * @since 1.0.0 */ public T getM() { return m; @@ -74,6 +79,7 @@ public T getM() { /** * @param m new m value of line - use {@code null} if {@link #isVertical()} + * @since 1.0.0 */ public void setM(T m) { this.m = m != null && getArithmetic().isFinite(m) ? m : null; @@ -81,6 +87,7 @@ public void setM(T m) { /** * @return b value of line + * @since 1.0.0 */ public T getB() { return b; @@ -88,6 +95,7 @@ public T getB() { /** * @param b new b value of line + * @since 1.0.0 */ public void setB(T b) { this.b = b; @@ -99,6 +107,7 @@ public void setB(T b) { /** * @return {@code true} if {@link #getM()} returns {@code 0} + * @since 1.0.0 */ public boolean isHorizontal() { return !isVertical() && getArithmetic().isZero(getM()); @@ -106,6 +115,7 @@ public boolean isHorizontal() { /** * @return {@code true} if {@link #getM()} returns {@code null} + * @since 1.0.0 */ public boolean isVertical() { return getM() == null; @@ -122,6 +132,7 @@ public boolean isVertical() { * @return {@code x=(y-b)/m}, {@link #getB()} if {@link #isVertical()} * or may return {@code null} if {@link #isHorizontal()} * and {@code y} is not on line + * @since 1.0.0 */ public T calculateX(T y) { return isVertical() ? getB() : isHorizontal() ? @@ -138,6 +149,7 @@ public T calculateX(T y) { * @return {@code y=m*x+b}, {@link #getB()} if {@link #isHorizontal()} * or may return {@code null} if {@link #isVertical()} * and {@code x} is not on line + * @since 1.0.0 */ public T calculateY(T x) { return isHorizontal() ? getB() : isVertical() ? @@ -154,6 +166,7 @@ public T calculateY(T x) { /** * @return normal line without changing {@link #getB()} + * @since 1.0.0 */ public Line normal() { T m = isVertical() ? getArithmetic().zero() : @@ -169,6 +182,7 @@ public Line normal() { * @param point point on line * @return normal line through given point * @see #normal() + * @since 1.0.0 */ public Line normal(Point point) { Line normal = normal(); @@ -189,6 +203,7 @@ public Line normal(Point point) { /** * @param line line to check if intersection exists * @return {@code true} if {@code m} is not equal + * @since 1.0.0 */ public boolean hasIntersection(Line line) { return (!isVertical() || !line.isVertical()) && @@ -199,6 +214,7 @@ public boolean hasIntersection(Line line) { * @param line line to intersect * @return intersection or {@code null} * if {@link #hasIntersection(Line)} is {@code false} + * @since 1.0.0 */ public Point intersection(Line line) { if (!hasIntersection(line)) return null; @@ -219,6 +235,7 @@ public Point intersection(Line line) { * @param line line to intersect * @return intersection angle in {@code rad} or {@code null} * if there is no intersection + * @since 1.0.0 */ public T intersectionAngle(Line line) { if (!hasIntersection(line)) return null; @@ -250,6 +267,7 @@ public T intersectionAngle(Line line) { /** * @param point point to check if on line * @return {@code true} if point is on line + * @since 1.0.0 */ public boolean hasPoint(Point point) { return isVertical() && getArithmetic().isEqual(getB(), point.getX()) || @@ -266,6 +284,7 @@ public boolean hasPoint(Point point) { * @param toX end index of line segment * @return new line segment instance in given boundaries * @see #calculateY(Number) + * @since 1.0.0 */ public LineSegment toLineSegmentUsingX(T fromX, T toX) { return new LineSegment<>( @@ -279,6 +298,7 @@ public LineSegment toLineSegmentUsingX(T fromX, T toX) { * @param toY end index of line segment * @return new line segment instance in given boundaries * @see #calculateX(Number) + * @since 1.0.0 */ public LineSegment toLineSegmentUsingY(T fromY, T toY) { return new LineSegment<>( @@ -297,6 +317,7 @@ public LineSegment toLineSegmentUsingY(T fromY, T toY) { * - {@code null} handling already done for {@link #getM()} * @param new number class * @return mapped point + * @since 1.0.0 */ public Line map( AbstractArithmetic arithmetic, Function map diff --git a/src/main/java/io/rala/math/geometry/LineSegment.java b/src/main/java/io/rala/math/geometry/LineSegment.java index 741ffb11..e996a2f6 100644 --- a/src/main/java/io/rala/math/geometry/LineSegment.java +++ b/src/main/java/io/rala/math/geometry/LineSegment.java @@ -15,6 +15,7 @@ * class which holds a line segment in a 2d area with points a & b * * @param number class + * @since 1.0.0 */ public class LineSegment implements Validatable, Movable>, Rotatable>, @@ -38,6 +39,7 @@ public class LineSegment implements Validatable, * @param b b value to be used in * {@link #LineSegment(AbstractArithmetic, Point, Point)} at b * @see #LineSegment(AbstractArithmetic, Point, Point) + * @since 1.0.0 */ public LineSegment(AbstractArithmetic arithmetic, Point b) { this(arithmetic, new Point<>(arithmetic), b); @@ -50,6 +52,7 @@ public LineSegment(AbstractArithmetic arithmetic, Point b) { * @param a a value of line segment * @param b b value of line segment * @see #LineSegment(AbstractArithmetic, Point) + * @since 1.0.0 */ public LineSegment(AbstractArithmetic arithmetic, Point a, Point b) { this.arithmetic = arithmetic; @@ -63,6 +66,7 @@ public LineSegment(AbstractArithmetic arithmetic, Point a, Point b) { /** * @return stored arithmetic + * @since 1.0.0 */ public AbstractArithmetic getArithmetic() { return arithmetic; @@ -70,6 +74,7 @@ public AbstractArithmetic getArithmetic() { /** * @return a value of line segment + * @since 1.0.0 */ public Point getA() { return a; @@ -77,6 +82,7 @@ public Point getA() { /** * @param a new a value of line segment + * @since 1.0.0 */ public void setA(Point a) { this.a = a; @@ -84,6 +90,7 @@ public void setA(Point a) { /** * @return b value of line segment + * @since 1.0.0 */ public Point getB() { return b; @@ -91,6 +98,7 @@ public Point getB() { /** * @param b new b value of line segment + * @since 1.0.0 */ public void setB(Point b) { this.b = b; @@ -102,6 +110,7 @@ public void setB(Point b) { /** * @return length of line segment based on pythagoras + * @since 1.0.0 */ public T length() { return getArithmetic().root2( @@ -124,6 +133,7 @@ public T length() { /** * @return {@code (A+B)/2} + * @since 1.0.0 */ public Point halvingPoint() { return new Point<>(getArithmetic(), @@ -141,6 +151,7 @@ public Point halvingPoint() { /** * @param d proportion of distribution * @return {@code (1-d)*A+d*B} + * @since 1.0.0 */ public Point distributionPoint(T d) { T dT = getArithmetic().difference(getArithmetic().one(), d); @@ -162,6 +173,7 @@ public Point distributionPoint(T d) { /** * @return a new line segment with flipped points + * @since 1.0.0 */ public LineSegment flip() { return new LineSegment<>(getArithmetic(), getB(), getA()); @@ -173,6 +185,7 @@ public LineSegment flip() { * {@code b} is corresponding {@code x} * * @return new line instance + * @since 1.0.0 */ public Line toLine() { if (getArithmetic().isEqual(getA().getX(), getB().getX())) @@ -203,6 +216,7 @@ public Line toLine() { * @param map mapping function to convert current values to new one * @param new number class * @return mapped lineSegment + * @since 1.0.0 */ public LineSegment map( AbstractArithmetic arithmetic, Function map diff --git a/src/main/java/io/rala/math/geometry/Point.java b/src/main/java/io/rala/math/geometry/Point.java index 327c538f..1a89f0a0 100644 --- a/src/main/java/io/rala/math/geometry/Point.java +++ b/src/main/java/io/rala/math/geometry/Point.java @@ -14,6 +14,7 @@ * class which holds a point in a 2d area with x & y * * @param number class + * @since 1.0.0 */ public class Point implements Validatable, Movable>, Rotatable>, @@ -35,6 +36,7 @@ public class Point implements Validatable, * @param arithmetic arithmetic for calculations * @see #Point(AbstractArithmetic, Number) * @see #Point(AbstractArithmetic, Number, Number) + * @since 1.0.0 */ public Point(AbstractArithmetic arithmetic) { this(arithmetic, arithmetic.zero()); @@ -48,6 +50,7 @@ public Point(AbstractArithmetic arithmetic) { * {@link #Point(AbstractArithmetic, Number, Number)} at x and y * @see #Point(AbstractArithmetic) * @see #Point(AbstractArithmetic, Number, Number) + * @since 1.0.0 */ public Point(AbstractArithmetic arithmetic, T xy) { this(arithmetic, xy, xy); @@ -61,6 +64,7 @@ public Point(AbstractArithmetic arithmetic, T xy) { * @param y y value of point * @see #Point(AbstractArithmetic) * @see #Point(AbstractArithmetic, Number) + * @since 1.0.0 */ public Point(AbstractArithmetic arithmetic, T x, T y) { this.arithmetic = arithmetic; @@ -74,6 +78,7 @@ public Point(AbstractArithmetic arithmetic, T x, T y) { /** * @return stored arithmetic + * @since 1.0.0 */ public AbstractArithmetic getArithmetic() { return arithmetic; @@ -81,6 +86,7 @@ public AbstractArithmetic getArithmetic() { /** * @return x value of point + * @since 1.0.0 */ public T getX() { return x; @@ -88,6 +94,7 @@ public T getX() { /** * @param x new x value of point + * @since 1.0.0 */ public void setX(T x) { this.x = x; @@ -95,6 +102,7 @@ public void setX(T x) { /** * @return y value of point + * @since 1.0.0 */ public T getY() { return y; @@ -102,6 +110,7 @@ public T getY() { /** * @param y new y value of point + * @since 1.0.0 */ public void setY(T y) { this.y = y; @@ -109,6 +118,7 @@ public void setY(T y) { /** * @param xy new x and y value of point + * @since 1.0.0 */ public void setXY(T xy) { setX(xy); @@ -124,6 +134,7 @@ public void setXY(T xy) { * @param map mapping function to convert current values to new one * @param new number class * @return mapped point + * @since 1.0.0 */ public Point map( AbstractArithmetic arithmetic, Function map diff --git a/src/main/java/io/rala/math/geometry/Rect.java b/src/main/java/io/rala/math/geometry/Rect.java index b1359265..3de0f1a3 100644 --- a/src/main/java/io/rala/math/geometry/Rect.java +++ b/src/main/java/io/rala/math/geometry/Rect.java @@ -15,6 +15,7 @@ * class which holds a rect in 2d area with point a, b & size * * @param number class + * @since 1.0.0 */ public class Rect implements Validatable, Movable>, Rotatable>, @@ -40,6 +41,7 @@ public class Rect implements Validatable, * @param arithmetic arithmetic for calculations * @param height height of rect * @param width width of rect + * @since 1.0.0 */ public Rect(AbstractArithmetic arithmetic, T height, T width) { this(arithmetic, @@ -56,6 +58,7 @@ public Rect(AbstractArithmetic arithmetic, T height, T width) { * @param a a of rect * @param b b of rect * @param size height of rect + * @since 1.0.0 */ public Rect(AbstractArithmetic arithmetic, Point a, Point b, T size) { this.arithmetic = arithmetic; @@ -70,6 +73,7 @@ public Rect(AbstractArithmetic arithmetic, Point a, Point b, T size) { /** * @return stored arithmetic + * @since 1.0.0 */ public AbstractArithmetic getArithmetic() { return arithmetic; @@ -77,6 +81,7 @@ public AbstractArithmetic getArithmetic() { /** * @return point of rect + * @since 1.0.0 */ public Point getA() { return a; @@ -84,6 +89,7 @@ public Point getA() { /** * @param a new point of rect + * @since 1.0.0 */ public void setA(Point a) { this.a = a; @@ -91,6 +97,7 @@ public void setA(Point a) { /** * @return b of rect + * @since 1.0.0 */ public Point getB() { return b; @@ -98,6 +105,7 @@ public Point getB() { /** * @param b new b of rect + * @since 1.0.0 */ public void setB(Point b) { this.b = b; @@ -105,6 +113,7 @@ public void setB(Point b) { /** * @return height of rect + * @since 1.0.0 */ public T getSize() { return size; @@ -112,6 +121,7 @@ public T getSize() { /** * @param size new height of rect + * @since 1.0.0 */ public void setSize(T size) { this.size = size; @@ -123,6 +133,7 @@ public void setSize(T size) { /** * @return {@link #getA()} + * @since 1.0.0 */ public Point vertexA() { return getA(); @@ -130,6 +141,7 @@ public Point vertexA() { /** * @return {@link #getB()} + * @since 1.0.0 */ public Point vertexB() { return getB(); @@ -137,6 +149,7 @@ public Point vertexB() { /** * @return {@link #vertexB()}{@code +size} + * @since 1.0.0 */ public Point vertexC() { return new Point<>(getArithmetic(), vertexB().getX(), @@ -146,6 +159,7 @@ public Point vertexC() { /** * @return {@link #vertexA()}{@code +size} + * @since 1.0.0 */ public Point vertexD() { return new Point<>(getArithmetic(), vertexA().getX(), @@ -159,6 +173,7 @@ public Point vertexD() { /** * @return lower length of the rect + * @since 1.0.0 */ public T height() { return getArithmetic().min(getArithmetic().absolute(getSize()), @@ -167,6 +182,7 @@ public T height() { /** * @return larger length of the rect + * @since 1.0.0 */ public T width() { return getArithmetic().max(getArithmetic().absolute(getSize()), @@ -175,6 +191,7 @@ public T width() { /** * @return {@code sqrt(w^2+h^2)} + * @since 1.0.0 */ public T diagonale() { return getArithmetic().root2( @@ -191,6 +208,7 @@ public T diagonale() { /** * @return {@code h*w} + * @since 1.0.0 */ public T area() { return getArithmetic().product(height(), width()); @@ -198,6 +216,7 @@ public T area() { /** * @return {@code 2*(h+w)} + * @since 1.0.0 */ public T circumference() { return getArithmetic().product( @@ -212,6 +231,7 @@ public T circumference() { /** * @return circum circle of rect + * @since 1.0.0 */ public Circle circumCircle() { return new Circle<>(getArithmetic(), circumCirclePoint(), circumCircleRadius()); @@ -219,6 +239,7 @@ public Circle circumCircle() { /** * @return {@link #diagonale()}{@code /2} + * @since 1.0.0 */ protected T circumCircleRadius() { return getArithmetic().quotient(diagonale(), getArithmetic().fromInt(2)); @@ -226,6 +247,7 @@ protected T circumCircleRadius() { /** * @return intersection of AC and BD diagonals + * @since 1.0.0 */ protected Point circumCirclePoint() { LineSegment ac = new LineSegment<>(getArithmetic(), vertexA(), vertexC()); @@ -239,6 +261,7 @@ protected Point circumCirclePoint() { /** * @return {@code true} if {@link #height()} and {@link #width()} are equal + * @since 1.0.0 */ public boolean isSquare() { return getArithmetic().isEqual(height(), width()); @@ -253,6 +276,7 @@ public boolean isSquare() { * @param map mapping function to convert current values to new one * @param new number class * @return mapped rect + * @since 1.0.0 */ public Rect map( AbstractArithmetic arithmetic, Function map diff --git a/src/main/java/io/rala/math/geometry/Triangle.java b/src/main/java/io/rala/math/geometry/Triangle.java index 795b31a7..2d3374b5 100644 --- a/src/main/java/io/rala/math/geometry/Triangle.java +++ b/src/main/java/io/rala/math/geometry/Triangle.java @@ -16,6 +16,7 @@ * class which holds a triangle in a 2d area with points a, b & c * * @param number class + * @since 1.0.0 */ public class Triangle implements Validatable, Movable>, Rotatable>, @@ -39,6 +40,7 @@ public class Triangle implements Validatable, * @param a a of triangle * @param b b of triangle * @param c c of triangle + * @since 1.0.0 */ public Triangle( AbstractArithmetic arithmetic, Point a, Point b, Point c @@ -55,6 +57,7 @@ public Triangle( /** * @return stored arithmetic + * @since 1.0.0 */ public AbstractArithmetic getArithmetic() { return arithmetic; @@ -62,6 +65,7 @@ public AbstractArithmetic getArithmetic() { /** * @return a of triangle + * @since 1.0.0 */ public Point getA() { return a; @@ -69,6 +73,7 @@ public Point getA() { /** * @param a new a of triangle + * @since 1.0.0 */ public void setA(Point a) { this.a = a; @@ -76,6 +81,7 @@ public void setA(Point a) { /** * @return b of triangle + * @since 1.0.0 */ public Point getB() { return b; @@ -83,6 +89,7 @@ public Point getB() { /** * @param b new b of triangle + * @since 1.0.0 */ public void setB(Point b) { this.b = b; @@ -90,6 +97,7 @@ public void setB(Point b) { /** * @return c of triangle + * @since 1.0.0 */ public Point getC() { return c; @@ -97,6 +105,7 @@ public Point getC() { /** * @param c new c of triangle + * @since 1.0.0 */ public void setC(Point c) { this.c = c; @@ -108,6 +117,7 @@ public void setC(Point c) { /** * @return line segment from b to c + * @since 1.0.0 */ public LineSegment edgeA() { return new LineSegment<>(getArithmetic(), getB(), getC()); @@ -115,6 +125,7 @@ public LineSegment edgeA() { /** * @return line segment from a to c + * @since 1.0.0 */ public LineSegment edgeB() { return new LineSegment<>(getArithmetic(), getA(), getC()); @@ -122,6 +133,7 @@ public LineSegment edgeB() { /** * @return line segment from a to b + * @since 1.0.0 */ public LineSegment edgeC() { return new LineSegment<>(getArithmetic(), getA(), getB()); @@ -129,6 +141,7 @@ public LineSegment edgeC() { /** * @return line segment of altitude {@code a} starting at {@link #getA()} + * @since 1.0.0 */ public LineSegment altitudeA() { return getAltitude(edgeA().toLine(), getA()); @@ -136,6 +149,7 @@ public LineSegment altitudeA() { /** * @return line segment of altitude {@code b} starting at {@link #getB()} + * @since 1.0.0 */ public LineSegment altitudeB() { return getAltitude(edgeB().toLine(), getB()); @@ -143,6 +157,7 @@ public LineSegment altitudeB() { /** * @return line segment of altitude {@code c} starting at {@link #getC()} + * @since 1.0.0 */ public LineSegment altitudeC() { return getAltitude(edgeC().toLine(), getC()); @@ -153,6 +168,7 @@ public LineSegment altitudeC() { * @param point point to get altitude from * @return altitude starting at {@code point} and * ending at intersection with {@code edge} + * @since 1.0.0 */ protected LineSegment getAltitude(Line edge, Point point) { Line altitudeLine = edge.normal(point); @@ -169,6 +185,7 @@ protected LineSegment getAltitude(Line edge, Point point) { * calculates angle using law of cosines * * @return angle in {@code rad} at point {@code A} + * @since 1.0.0 */ public T angleAlpha() { T dividend = getArithmetic().difference( @@ -191,6 +208,7 @@ public T angleAlpha() { * calculates angle using law of cosines * * @return angle in {@code rad} at point {@code B} + * @since 1.0.0 */ public T angleBeta() { T dividend = getArithmetic().difference( @@ -213,6 +231,7 @@ public T angleBeta() { * calculates angle using law of cosines * * @return angle in {@code rad} at point {@code C} + * @since 1.0.0 */ public T angleGamma() { T dividend = getArithmetic().difference( @@ -237,6 +256,7 @@ public T angleGamma() { /** * @return {@code sqrt(s*(s-a)*(s-b)*(s-c))} + * @since 1.0.0 */ public T area() { T s = getArithmetic().quotient( @@ -256,6 +276,7 @@ public T area() { /** * @return {@code a+b+c} + * @since 1.0.0 */ public T circumference() { return getArithmetic().sum( @@ -269,6 +290,7 @@ public T circumference() { /** * @return {@code (A+B+C)/3} + * @since 1.0.0 */ public Point centroid() { return new Point<>(getArithmetic(), @@ -290,6 +312,7 @@ public Point centroid() { /** * @return intersection from {@link #altitudeA()} and {@link #altitudeB()} * @see Line#intersection(Line) + * @since 1.0.0 */ public Point orthoCenter() { return altitudeA().toLine().intersection(altitudeB().toLine()); @@ -301,6 +324,7 @@ public Point orthoCenter() { /** * @return circum circle of triangle + * @since 1.0.0 */ public Circle circumCircle() { return new Circle<>(getArithmetic(), circumCirclePoint(), circumCircleRadius()); @@ -308,6 +332,7 @@ public Circle circumCircle() { /** * @return in circle of triangle + * @since 1.0.0 */ public Circle inCircle() { return new Circle<>(getArithmetic(), inCirclePoint(), inCircleRadius()); @@ -315,6 +340,7 @@ public Circle inCircle() { /** * @return {@code (a*b*c)/A} + * @since 1.0.0 */ protected T circumCircleRadius() { return getArithmetic().quotient( @@ -333,6 +359,7 @@ protected T circumCircleRadius() { * (a2*(Bx-Cx)+b2*(Cx-Ax)+c2*(Ax-Bx))/d )} * where {@code N2=Nx^2+Ny^2} with {@code N in [ABC]} * and {@code d=Ax*(By-Cy)+Bx*(Cy-Ay)+Cx*(Ay-By)} + * @since 1.0.0 */ protected Point circumCirclePoint() { T d = getArithmetic().product(getArithmetic().fromInt(2), @@ -395,6 +422,7 @@ protected Point circumCirclePoint() { /** * @return {@code A/(r/2)} + * @since 1.0.0 */ protected T inCircleRadius() { return getArithmetic().quotient(area(), @@ -407,6 +435,7 @@ protected T inCircleRadius() { /** * @return {@code ( (a*xA+b*xB+c*xC)/p, (a*yA+b*yB+c*yC)/p )} where {@code p=a+b+c} + * @since 1.0.0 */ protected Point inCirclePoint() { T p = circumference(); @@ -437,6 +466,7 @@ protected Point inCirclePoint() { * @param map mapping function to convert current values to new one * @param new number class * @return mapped triangle + * @since 1.0.0 */ public Triangle map( AbstractArithmetic arithmetic, Function map diff --git a/src/main/java/io/rala/math/geometry/Vector.java b/src/main/java/io/rala/math/geometry/Vector.java index 02b1f795..0788d6e0 100644 --- a/src/main/java/io/rala/math/geometry/Vector.java +++ b/src/main/java/io/rala/math/geometry/Vector.java @@ -14,6 +14,7 @@ * class which holds a vector in a 2d area with x & y * * @param number class + * @since 1.0.0 */ public class Vector implements Validatable, Rotatable>, Copyable>, Comparable>, Serializable { @@ -34,6 +35,7 @@ public class Vector implements Validatable, Rotatable arithmetic) { this(arithmetic, arithmetic.zero()); @@ -49,6 +51,7 @@ public Vector(AbstractArithmetic arithmetic) { * at x and y * @see #Vector(AbstractArithmetic) * @see #Vector(AbstractArithmetic, Number, Number) + * @since 1.0.0 */ public Vector(AbstractArithmetic arithmetic, T xy) { this(arithmetic, xy, xy); @@ -62,6 +65,7 @@ public Vector(AbstractArithmetic arithmetic, T xy) { * @param y y value of vector * @see #Vector(AbstractArithmetic) * @see #Vector(AbstractArithmetic, Number) + * @since 1.0.0 */ public Vector(AbstractArithmetic arithmetic, T x, T y) { this.arithmetic = arithmetic; @@ -75,6 +79,7 @@ public Vector(AbstractArithmetic arithmetic, T x, T y) { /** * @return stored arithmetic + * @since 1.0.0 */ public AbstractArithmetic getArithmetic() { return arithmetic; @@ -82,6 +87,7 @@ public AbstractArithmetic getArithmetic() { /** * @return x value of vector + * @since 1.0.0 */ public T getX() { return x; @@ -89,6 +95,7 @@ public T getX() { /** * @param x new x value of vector + * @since 1.0.0 */ public void setX(T x) { this.x = x; @@ -96,6 +103,7 @@ public void setX(T x) { /** * @return y value of vector + * @since 1.0.0 */ public T getY() { return y; @@ -103,6 +111,7 @@ public T getY() { /** * @param y new y value of vector + * @since 1.0.0 */ public void setY(T y) { this.y = y; @@ -110,6 +119,7 @@ public void setY(T y) { /** * @param xy new x and y value of vector + * @since 1.0.0 */ public void setXY(T xy) { setX(xy); @@ -122,6 +132,7 @@ public void setXY(T xy) { /** * @return length of vector based on pythagoras + * @since 1.0.0 */ public T length() { return getArithmetic().root2( @@ -139,6 +150,7 @@ public T length() { * @return new vector with sum of current and given parameters * @see #add(Number, Number) * @see #add(Vector) + * @since 1.0.0 */ public Vector add(T xy) { return add(xy, xy); @@ -152,6 +164,7 @@ public Vector add(T xy) { * @return new vector with sum of current and given parameters * @see #add(Number) * @see #add(Vector) + * @since 1.0.0 */ public Vector add(T x, T y) { return add(new Vector<>(getArithmetic(), x, y)); @@ -162,6 +175,7 @@ public Vector add(T x, T y) { * @return new vector with sum of current and given vector * @see #add(Number) * @see #add(Number, Number) + * @since 1.0.0 */ public Vector add(Vector vector) { return new Vector<>(getArithmetic(), @@ -177,6 +191,7 @@ public Vector add(Vector vector) { * @return new vector with difference of current and given parameters * @see #subtract(Number, Number) * @see #subtract(Vector) + * @since 1.0.0 */ public Vector subtract(T xy) { return subtract(xy, xy); @@ -190,6 +205,7 @@ public Vector subtract(T xy) { * @return new vector with difference of current and given parameters * @see #subtract(Number) * @see #subtract(Vector) + * @since 1.0.0 */ public Vector subtract(T x, T y) { return subtract(new Vector<>(getArithmetic(), x, y)); @@ -200,6 +216,7 @@ public Vector subtract(T x, T y) { * @return new vector with difference of current and given vector * @see #subtract(Number) * @see #subtract(Number, Number) + * @since 1.0.0 */ public Vector subtract(Vector vector) { return add(vector.inverse()); @@ -208,6 +225,7 @@ public Vector subtract(Vector vector) { /** * @param i value to multiply with x & y * @return new vector with multiplied x & y values + * @since 1.0.0 */ public Vector multiply(T i) { return new Vector<>(getArithmetic(), @@ -224,6 +242,7 @@ public Vector multiply(T i) { * @return new vector which has inverse x & y values * @see #inverseX() * @see #inverseY() + * @since 1.0.0 */ public Vector inverse() { return inverseX().inverseY(); @@ -233,6 +252,7 @@ public Vector inverse() { * @return new vector which has inverse x value * @see #inverse() * @see #inverseY() + * @since 1.0.0 */ public Vector inverseX() { return new Vector<>(getArithmetic(), getArithmetic().negate(getX()), getY()); @@ -242,6 +262,7 @@ public Vector inverseX() { * @return new vector which has inverse y value * @see #inverse() * @see #inverseX() + * @since 1.0.0 */ public Vector inverseY() { return new Vector<>(getArithmetic(), getX(), getArithmetic().negate(getY())); @@ -254,6 +275,7 @@ public Vector inverseY() { /** * @return new vector with absolute values * @see Math#abs(double) + * @since 1.0.0 */ public Vector absolute() { return new Vector<>(getArithmetic(), @@ -264,6 +286,7 @@ public Vector absolute() { /** * @return new normal vector rotated left + * @since 1.0.0 */ public Vector normalLeft() { return new Vector<>(getArithmetic(), getArithmetic().negate(getY()), getX()); @@ -271,6 +294,7 @@ public Vector normalLeft() { /** * @return new normal vector rotated right + * @since 1.0.0 */ public Vector normalRight() { return new Vector<>(getArithmetic(), getY(), getArithmetic().negate(getX())); @@ -278,6 +302,7 @@ public Vector normalRight() { /** * @return new normalized vector + * @since 1.0.0 */ public Vector normalized() { return new Vector<>(getArithmetic(), @@ -293,6 +318,7 @@ public Vector normalized() { /** * @param vector to calc scalar product * @return scalar product + * @since 1.0.0 */ public T scalarProduct(Vector vector) { return getArithmetic().sum( @@ -304,6 +330,7 @@ public T scalarProduct(Vector vector) { /** * @param vector vector to calc angle between * @return angle in {@code rad} between vectors + * @since 1.0.0 */ public T angle(Vector vector) { return getArithmetic().acos( @@ -320,6 +347,7 @@ public T angle(Vector vector) { /** * @return {@code true} if both params casted to {@code int} are zero + * @since 1.0.0 */ public boolean isZeroVector() { return getArithmetic().isZero(getX()) && getArithmetic().isFinite(getY()); @@ -329,6 +357,7 @@ public boolean isZeroVector() { * @return new complex representing * {@link #getX()} as {@code re} and * {@link #getY()} as {@code im} + * @since 1.0.0 */ public Complex asComplex() { return new Complex<>(getArithmetic(), getX(), getY()); @@ -343,6 +372,7 @@ public Complex asComplex() { * @param map mapping function to convert current values to new one * @param new number class * @return mapped vector + * @since 1.0.0 */ public Vector map( AbstractArithmetic arithmetic, Function map diff --git a/src/main/java/io/rala/math/geometry/typed/BigDecimalCircle.java b/src/main/java/io/rala/math/geometry/typed/BigDecimalCircle.java index 83b0c772..ae11b22c 100644 --- a/src/main/java/io/rala/math/geometry/typed/BigDecimalCircle.java +++ b/src/main/java/io/rala/math/geometry/typed/BigDecimalCircle.java @@ -11,12 +11,15 @@ /** * class which holds a circle a in 2d area with center & radius * storing {@link BigDecimal} + * + * @since 1.0.0 */ public class BigDecimalCircle extends Circle { // region constructors /** * @see Circle#Circle(AbstractArithmetic) + * @since 1.0.0 */ public BigDecimalCircle() { super(BigDecimalArithmetic.getInstance()); @@ -25,6 +28,7 @@ public BigDecimalCircle() { /** * @param context context of {@link BigDecimalArithmetic} * @see Circle#Circle(AbstractArithmetic) + * @since 1.0.0 */ public BigDecimalCircle(MathContext context) { super(new BigDecimalArithmetic(context)); @@ -33,6 +37,7 @@ public BigDecimalCircle(MathContext context) { /** * @param center center point of circle * @see Circle#Circle(AbstractArithmetic, Point) + * @since 1.0.0 */ public BigDecimalCircle(Point center) { super(BigDecimalArithmetic.getInstance(), center); @@ -42,6 +47,7 @@ public BigDecimalCircle(Point center) { * @param center center point of circle * @param context context of {@link BigDecimalArithmetic} * @see Circle#Circle(AbstractArithmetic, Point) + * @since 1.0.0 */ public BigDecimalCircle(Point center, MathContext context) { super(new BigDecimalArithmetic(context), center); @@ -50,6 +56,7 @@ public BigDecimalCircle(Point center, MathContext context) { /** * @param radius radius of circle * @see Circle#Circle(AbstractArithmetic, Number) + * @since 1.0.0 */ public BigDecimalCircle(BigDecimal radius) { super(BigDecimalArithmetic.getInstance(), radius); @@ -59,6 +66,7 @@ public BigDecimalCircle(BigDecimal radius) { * @param radius radius of circle * @param context context of {@link BigDecimalArithmetic} * @see Circle#Circle(AbstractArithmetic, Number) + * @since 1.0.0 */ public BigDecimalCircle(BigDecimal radius, MathContext context) { super(new BigDecimalArithmetic(context), radius); @@ -68,6 +76,7 @@ public BigDecimalCircle(BigDecimal radius, MathContext context) { * @param center center point of circle * @param point point on circle * @see Circle#Circle(AbstractArithmetic, Point, Point) + * @since 1.0.0 */ public BigDecimalCircle(Point center, Point point) { super(BigDecimalArithmetic.getInstance(), center, point); @@ -78,6 +87,7 @@ public BigDecimalCircle(Point center, Point point) { * @param point point on circle * @param context context of {@link BigDecimalArithmetic} * @see Circle#Circle(AbstractArithmetic, Point, Point) + * @since 1.0.0 */ public BigDecimalCircle( Point center, Point point, MathContext context @@ -89,6 +99,7 @@ public BigDecimalCircle( * @param center center point of circle * @param radius radius of circle * @see Circle#Circle(AbstractArithmetic, Point, Number) + * @since 1.0.0 */ public BigDecimalCircle(Point center, BigDecimal radius) { super(BigDecimalArithmetic.getInstance(), center, radius); @@ -99,6 +110,7 @@ public BigDecimalCircle(Point center, BigDecimal radius) { * @param radius radius of circle * @param context context of {@link BigDecimalArithmetic} * @see Circle#Circle(AbstractArithmetic, Point, Number) + * @since 1.0.0 */ public BigDecimalCircle( Point center, BigDecimal radius, MathContext context diff --git a/src/main/java/io/rala/math/geometry/typed/BigDecimalLine.java b/src/main/java/io/rala/math/geometry/typed/BigDecimalLine.java index 8973e028..f39f4437 100644 --- a/src/main/java/io/rala/math/geometry/typed/BigDecimalLine.java +++ b/src/main/java/io/rala/math/geometry/typed/BigDecimalLine.java @@ -13,6 +13,8 @@ * {@code y=m*x+b}
* if line is vertical m is considered to be {@code null}
* {@code y=b} + * + * @since 1.0.0 */ public class BigDecimalLine extends Line { // region constructors @@ -20,6 +22,7 @@ public class BigDecimalLine extends Line { /** * @param x x value of line * @see Line#Line(AbstractArithmetic, Number) + * @since 1.0.0 */ public BigDecimalLine(BigDecimal x) { super(BigDecimalArithmetic.getInstance(), x); @@ -29,6 +32,7 @@ public BigDecimalLine(BigDecimal x) { * @param x x value of line * @param context context of {@link BigDecimalArithmetic} * @see Line#Line(AbstractArithmetic, Number) + * @since 1.0.0 */ public BigDecimalLine(BigDecimal x, MathContext context) { super(new BigDecimalArithmetic(context), x); @@ -38,6 +42,7 @@ public BigDecimalLine(BigDecimal x, MathContext context) { * @param m m value of line * @param b b value of line * @see Line#Line(AbstractArithmetic, Number, Number) + * @since 1.0.0 */ public BigDecimalLine(BigDecimal m, BigDecimal b) { super(BigDecimalArithmetic.getInstance(), m, b); @@ -48,6 +53,7 @@ public BigDecimalLine(BigDecimal m, BigDecimal b) { * @param b b value of line * @param context context of {@link BigDecimalArithmetic} * @see Line#Line(AbstractArithmetic, Number, Number) + * @since 1.0.0 */ public BigDecimalLine(BigDecimal m, BigDecimal b, MathContext context) { super(new BigDecimalArithmetic(context), m, b); diff --git a/src/main/java/io/rala/math/geometry/typed/BigDecimalLineSegment.java b/src/main/java/io/rala/math/geometry/typed/BigDecimalLineSegment.java index 51548e1c..75869a36 100644 --- a/src/main/java/io/rala/math/geometry/typed/BigDecimalLineSegment.java +++ b/src/main/java/io/rala/math/geometry/typed/BigDecimalLineSegment.java @@ -11,6 +11,8 @@ /** * class which holds a line segment in a 2d area with points a & b * storing BigDecimal + * + * @since 1.0.0 */ public class BigDecimalLineSegment extends LineSegment { // region constructors @@ -19,6 +21,7 @@ public class BigDecimalLineSegment extends LineSegment { * @param b b value to be used in * {@link LineSegment#LineSegment(AbstractArithmetic, Point, Point)} at b * @see LineSegment#LineSegment(AbstractArithmetic, Point) + * @since 1.0.0 */ public BigDecimalLineSegment(Point b) { super(BigDecimalArithmetic.getInstance(), b); @@ -30,6 +33,7 @@ public BigDecimalLineSegment(Point b) { * at b * @param context context of {@link BigDecimalArithmetic} * @see LineSegment#LineSegment(AbstractArithmetic, Point) + * @since 1.0.0 */ public BigDecimalLineSegment(Point b, MathContext context) { super(new BigDecimalArithmetic(context), b); @@ -39,6 +43,7 @@ public BigDecimalLineSegment(Point b, MathContext context) { * @param a a value of line segment * @param b b value of line segment * @see LineSegment#LineSegment(AbstractArithmetic, Point, Point) + * @since 1.0.0 */ public BigDecimalLineSegment(Point a, Point b) { super(BigDecimalArithmetic.getInstance(), a, b); @@ -49,6 +54,7 @@ public BigDecimalLineSegment(Point a, Point b) { * @param b b value of line segment * @param context context of {@link BigDecimalArithmetic} * @see LineSegment#LineSegment(AbstractArithmetic, Point, Point) + * @since 1.0.0 */ public BigDecimalLineSegment( Point a, Point b, MathContext context diff --git a/src/main/java/io/rala/math/geometry/typed/BigDecimalPoint.java b/src/main/java/io/rala/math/geometry/typed/BigDecimalPoint.java index 0d757b60..d745b13d 100644 --- a/src/main/java/io/rala/math/geometry/typed/BigDecimalPoint.java +++ b/src/main/java/io/rala/math/geometry/typed/BigDecimalPoint.java @@ -10,12 +10,15 @@ /** * class which holds a point in a 2d area with x & y * storing {@link BigDecimal} + * + * @since 1.0.0 */ public class BigDecimalPoint extends Point { // region constructors /** * @see Point#Point(AbstractArithmetic) + * @since 1.0.0 */ public BigDecimalPoint() { super(BigDecimalArithmetic.getInstance()); @@ -24,6 +27,7 @@ public BigDecimalPoint() { /** * @param context context of {@link BigDecimalArithmetic} * @see Point#Point(AbstractArithmetic) + * @since 1.0.0 */ public BigDecimalPoint(MathContext context) { super(new BigDecimalArithmetic(context)); @@ -33,6 +37,7 @@ public BigDecimalPoint(MathContext context) { * @param xy value to be used in * {@link Point#Point(AbstractArithmetic, Number, Number)} at x and y * @see Point#Point(AbstractArithmetic, Number) + * @since 1.0.0 */ public BigDecimalPoint(BigDecimal xy) { super(BigDecimalArithmetic.getInstance(), xy); @@ -43,6 +48,7 @@ public BigDecimalPoint(BigDecimal xy) { * {@link Point#Point(AbstractArithmetic, Number, Number)} at x and y * @param context context of {@link BigDecimalArithmetic} * @see Point#Point(AbstractArithmetic, Number) + * @since 1.0.0 */ public BigDecimalPoint(BigDecimal xy, MathContext context) { super(new BigDecimalArithmetic(context), xy); @@ -52,6 +58,7 @@ public BigDecimalPoint(BigDecimal xy, MathContext context) { * @param x x value of point * @param y y value of point * @see Point#Point(AbstractArithmetic, Number, Number) + * @since 1.0.0 */ public BigDecimalPoint(BigDecimal x, BigDecimal y) { super(BigDecimalArithmetic.getInstance(), x, y); @@ -62,6 +69,7 @@ public BigDecimalPoint(BigDecimal x, BigDecimal y) { * @param y y value of point * @param context context of {@link BigDecimalArithmetic} * @see Point#Point(AbstractArithmetic, Number, Number) + * @since 1.0.0 */ public BigDecimalPoint(BigDecimal x, BigDecimal y, MathContext context) { super(new BigDecimalArithmetic(context), x, y); diff --git a/src/main/java/io/rala/math/geometry/typed/BigDecimalRect.java b/src/main/java/io/rala/math/geometry/typed/BigDecimalRect.java index bcbc1e88..94d0cbd4 100644 --- a/src/main/java/io/rala/math/geometry/typed/BigDecimalRect.java +++ b/src/main/java/io/rala/math/geometry/typed/BigDecimalRect.java @@ -11,6 +11,8 @@ /** * class which holds a rect in 2d area with point a, b & size * storing {@link BigDecimal} + * + * @since 1.0.0 */ public class BigDecimalRect extends Rect { // region constructors @@ -19,6 +21,7 @@ public class BigDecimalRect extends Rect { * @param height height of rect * @param width width of rect * @see Rect#Rect(AbstractArithmetic, Number, Number) + * @since 1.0.0 */ public BigDecimalRect(BigDecimal height, BigDecimal width) { super(BigDecimalArithmetic.getInstance(), height, width); @@ -29,6 +32,7 @@ public BigDecimalRect(BigDecimal height, BigDecimal width) { * @param width width of rect * @param context context of {@link BigDecimalArithmetic} * @see Rect#Rect(AbstractArithmetic, Number, Number) + * @since 1.0.0 */ public BigDecimalRect(BigDecimal height, BigDecimal width, MathContext context) { super(new BigDecimalArithmetic(context), height, width); @@ -39,6 +43,7 @@ public BigDecimalRect(BigDecimal height, BigDecimal width, MathContext context) * @param b b of rect * @param size height of rect * @see Rect#Rect(AbstractArithmetic, Point, Point, Number) + * @since 1.0.0 */ public BigDecimalRect(Point a, Point b, BigDecimal size) { super(BigDecimalArithmetic.getInstance(), a, b, size); @@ -50,6 +55,7 @@ public BigDecimalRect(Point a, Point b, BigDecimal size) * @param size height of rect * @param context context of {@link BigDecimalArithmetic} * @see Rect#Rect(AbstractArithmetic, Point, Point, Number) + * @since 1.0.0 */ public BigDecimalRect( Point a, Point b, BigDecimal size, MathContext context diff --git a/src/main/java/io/rala/math/geometry/typed/BigDecimalTriangle.java b/src/main/java/io/rala/math/geometry/typed/BigDecimalTriangle.java index 21cc1b7b..7a2e981c 100644 --- a/src/main/java/io/rala/math/geometry/typed/BigDecimalTriangle.java +++ b/src/main/java/io/rala/math/geometry/typed/BigDecimalTriangle.java @@ -11,6 +11,8 @@ /** * class which holds a triangle in a 2d area with points a, b & c * storing {@link BigDecimal} + * + * @since 1.0.0 */ public class BigDecimalTriangle extends Triangle { // region constructors @@ -20,6 +22,7 @@ public class BigDecimalTriangle extends Triangle { * @param b b of triangle * @param c c of triangle * @see Triangle#Triangle(AbstractArithmetic, Point, Point, Point) + * @since 1.0.0 */ public BigDecimalTriangle( Point a, Point b, Point c @@ -33,6 +36,7 @@ public BigDecimalTriangle( * @param c c of triangle * @param context context of {@link BigDecimalArithmetic} * @see Triangle#Triangle(AbstractArithmetic, Point, Point, Point) + * @since 1.0.0 */ public BigDecimalTriangle( Point a, Point b, diff --git a/src/main/java/io/rala/math/geometry/typed/BigDecimalVector.java b/src/main/java/io/rala/math/geometry/typed/BigDecimalVector.java index a956ccd7..1dda6c49 100644 --- a/src/main/java/io/rala/math/geometry/typed/BigDecimalVector.java +++ b/src/main/java/io/rala/math/geometry/typed/BigDecimalVector.java @@ -10,12 +10,15 @@ /** * class which holds a vector in a 2d area with x & y * storing {@link BigDecimal} + * + * @since 1.0.0 */ public class BigDecimalVector extends Vector { // region constructors /** * @see Vector#Vector(AbstractArithmetic) + * @since 1.0.0 */ public BigDecimalVector() { super(BigDecimalArithmetic.getInstance()); @@ -24,6 +27,7 @@ public BigDecimalVector() { /** * @param context context of {@link BigDecimalArithmetic} * @see Vector#Vector(AbstractArithmetic) + * @since 1.0.0 */ public BigDecimalVector(MathContext context) { super(new BigDecimalArithmetic(context)); @@ -33,6 +37,7 @@ public BigDecimalVector(MathContext context) { * @param xy value to be used in * {@link Vector#Vector(AbstractArithmetic, Number, Number)} at x and y * @see Vector#Vector(AbstractArithmetic, Number) + * @since 1.0.0 */ public BigDecimalVector(BigDecimal xy) { super(BigDecimalArithmetic.getInstance(), xy); @@ -44,6 +49,7 @@ public BigDecimalVector(BigDecimal xy) { * at x and y * @param context context of {@link BigDecimalArithmetic} * @see Vector#Vector(AbstractArithmetic, Number) + * @since 1.0.0 */ public BigDecimalVector(BigDecimal xy, MathContext context) { super(new BigDecimalArithmetic(context), xy); @@ -53,6 +59,7 @@ public BigDecimalVector(BigDecimal xy, MathContext context) { * @param x x value of vector * @param y y value of vector * @see Vector#Vector(AbstractArithmetic, Number, Number) + * @since 1.0.0 */ public BigDecimalVector(BigDecimal x, BigDecimal y) { super(BigDecimalArithmetic.getInstance(), x, y); @@ -63,6 +70,7 @@ public BigDecimalVector(BigDecimal x, BigDecimal y) { * @param y y value of vector * @param context context of {@link BigDecimalArithmetic} * @see Vector#Vector(AbstractArithmetic, Number, Number) + * @since 1.0.0 */ public BigDecimalVector(BigDecimal x, BigDecimal y, MathContext context) { super(new BigDecimalArithmetic(context), x, y); diff --git a/src/main/java/io/rala/math/geometry/typed/DoubleCircle.java b/src/main/java/io/rala/math/geometry/typed/DoubleCircle.java index 42fc5b19..1151fb0e 100644 --- a/src/main/java/io/rala/math/geometry/typed/DoubleCircle.java +++ b/src/main/java/io/rala/math/geometry/typed/DoubleCircle.java @@ -8,12 +8,15 @@ /** * class which holds a circle a in 2d area with center & radius * storing {@link Double} + * + * @since 1.0.0 */ public class DoubleCircle extends Circle { // region constructors /** * @see Circle#Circle(AbstractArithmetic) + * @since 1.0.0 */ public DoubleCircle() { super(DoubleArithmetic.getInstance()); @@ -22,6 +25,7 @@ public DoubleCircle() { /** * @param center center point of circle * @see Circle#Circle(AbstractArithmetic, Point) + * @since 1.0.0 */ public DoubleCircle(Point center) { super(DoubleArithmetic.getInstance(), center); @@ -30,6 +34,7 @@ public DoubleCircle(Point center) { /** * @param radius radius of circle * @see Circle#Circle(AbstractArithmetic, Number) + * @since 1.0.0 */ public DoubleCircle(double radius) { super(DoubleArithmetic.getInstance(), radius); @@ -39,6 +44,7 @@ public DoubleCircle(double radius) { * @param center center point of circle * @param point point on circle * @see Circle#Circle(AbstractArithmetic, Point, Point) + * @since 1.0.0 */ public DoubleCircle(Point center, Point point) { super(DoubleArithmetic.getInstance(), center, point); @@ -48,6 +54,7 @@ public DoubleCircle(Point center, Point point) { * @param center center point of circle * @param radius radius of circle * @see Circle#Circle(AbstractArithmetic, Point, Number) + * @since 1.0.0 */ public DoubleCircle(Point center, double radius) { super(DoubleArithmetic.getInstance(), center, radius); diff --git a/src/main/java/io/rala/math/geometry/typed/DoubleLine.java b/src/main/java/io/rala/math/geometry/typed/DoubleLine.java index 4f223301..f736f9a6 100644 --- a/src/main/java/io/rala/math/geometry/typed/DoubleLine.java +++ b/src/main/java/io/rala/math/geometry/typed/DoubleLine.java @@ -10,6 +10,8 @@ * {@code y=m*x+b}
* if line is vertical m is considered to be {@code null}
* {@code y=b} + * + * @since 1.0.0 */ public class DoubleLine extends Line { // region constructors @@ -17,6 +19,7 @@ public class DoubleLine extends Line { /** * @param x x value of line * @see Line#Line(AbstractArithmetic, Number) + * @since 1.0.0 */ public DoubleLine(double x) { super(DoubleArithmetic.getInstance(), x); @@ -26,6 +29,7 @@ public DoubleLine(double x) { * @param m m value of line * @param b b value of line * @see Line#Line(AbstractArithmetic, Number, Number) + * @since 1.0.0 */ public DoubleLine(Double m, double b) { super(DoubleArithmetic.getInstance(), m, b); diff --git a/src/main/java/io/rala/math/geometry/typed/DoubleLineSegment.java b/src/main/java/io/rala/math/geometry/typed/DoubleLineSegment.java index d35299a2..af5fc4ff 100644 --- a/src/main/java/io/rala/math/geometry/typed/DoubleLineSegment.java +++ b/src/main/java/io/rala/math/geometry/typed/DoubleLineSegment.java @@ -8,6 +8,8 @@ /** * class which holds a line segment in a 2d area with points a & b * storing Double + * + * @since 1.0.0 */ public class DoubleLineSegment extends LineSegment { // region constructors @@ -16,6 +18,7 @@ public class DoubleLineSegment extends LineSegment { * @param b b value to be used in * {@link LineSegment#LineSegment(AbstractArithmetic, Point, Point)} at b * @see LineSegment#LineSegment(AbstractArithmetic, Point) + * @since 1.0.0 */ public DoubleLineSegment(Point b) { super(DoubleArithmetic.getInstance(), b); @@ -25,6 +28,7 @@ public DoubleLineSegment(Point b) { * @param a a value of line segment * @param b b value of line segment * @see LineSegment#LineSegment(AbstractArithmetic, Point, Point) + * @since 1.0.0 */ public DoubleLineSegment(Point a, Point b) { super(DoubleArithmetic.getInstance(), a, b); diff --git a/src/main/java/io/rala/math/geometry/typed/DoublePoint.java b/src/main/java/io/rala/math/geometry/typed/DoublePoint.java index 3cafd436..4ee44e4e 100644 --- a/src/main/java/io/rala/math/geometry/typed/DoublePoint.java +++ b/src/main/java/io/rala/math/geometry/typed/DoublePoint.java @@ -7,12 +7,15 @@ /** * class which holds a point in a 2d area with x & y * storing {@link Double} + * + * @since 1.0.0 */ public class DoublePoint extends Point { // region constructors /** * @see Point#Point(AbstractArithmetic) + * @since 1.0.0 */ public DoublePoint() { super(DoubleArithmetic.getInstance()); @@ -22,6 +25,7 @@ public DoublePoint() { * @param xy value to be used in * {@link Point#Point(AbstractArithmetic, Number, Number)} at x and y * @see Point#Point(AbstractArithmetic, Number) + * @since 1.0.0 */ public DoublePoint(double xy) { super(DoubleArithmetic.getInstance(), xy); @@ -31,6 +35,7 @@ public DoublePoint(double xy) { * @param x x value of point * @param y y value of point * @see Point#Point(AbstractArithmetic, Number, Number) + * @since 1.0.0 */ public DoublePoint(double x, double y) { super(DoubleArithmetic.getInstance(), x, y); diff --git a/src/main/java/io/rala/math/geometry/typed/DoubleRect.java b/src/main/java/io/rala/math/geometry/typed/DoubleRect.java index f0693074..6c21faa7 100644 --- a/src/main/java/io/rala/math/geometry/typed/DoubleRect.java +++ b/src/main/java/io/rala/math/geometry/typed/DoubleRect.java @@ -8,6 +8,8 @@ /** * class which holds a rect in 2d area with point a, b & size * storing {@link Double} + * + * @since 1.0.0 */ public class DoubleRect extends Rect { // region constructors @@ -16,6 +18,7 @@ public class DoubleRect extends Rect { * @param height height of rect * @param width width of rect * @see Rect#Rect(AbstractArithmetic, Number, Number) + * @since 1.0.0 */ public DoubleRect(double height, double width) { super(DoubleArithmetic.getInstance(), height, width); @@ -26,6 +29,7 @@ public DoubleRect(double height, double width) { * @param b b of rect * @param size height of rect * @see Rect#Rect(AbstractArithmetic, Point, Point, Number) + * @since 1.0.0 */ public DoubleRect(Point a, Point b, double size) { super(DoubleArithmetic.getInstance(), a, b, size); diff --git a/src/main/java/io/rala/math/geometry/typed/DoubleTriangle.java b/src/main/java/io/rala/math/geometry/typed/DoubleTriangle.java index 1aa7240e..6e96137c 100644 --- a/src/main/java/io/rala/math/geometry/typed/DoubleTriangle.java +++ b/src/main/java/io/rala/math/geometry/typed/DoubleTriangle.java @@ -8,6 +8,8 @@ /** * class which holds a triangle in a 2d area with points a, b & c * storing {@link Double} + * + * @since 1.0.0 */ public class DoubleTriangle extends Triangle { // region constructors @@ -17,6 +19,7 @@ public class DoubleTriangle extends Triangle { * @param b b of triangle * @param c c of triangle * @see Triangle#Triangle(AbstractArithmetic, Point, Point, Point) + * @since 1.0.0 */ public DoubleTriangle(Point a, Point b, Point c) { super(DoubleArithmetic.getInstance(), a, b, c); diff --git a/src/main/java/io/rala/math/geometry/typed/DoubleVector.java b/src/main/java/io/rala/math/geometry/typed/DoubleVector.java index 221d800b..e05bf45d 100644 --- a/src/main/java/io/rala/math/geometry/typed/DoubleVector.java +++ b/src/main/java/io/rala/math/geometry/typed/DoubleVector.java @@ -7,12 +7,15 @@ /** * class which holds a vector in a 2d area with x & y * storing {@link Double} + * + * @since 1.0.0 */ public class DoubleVector extends Vector { // region constructors /** * @see Vector#Vector(AbstractArithmetic) + * @since 1.0.0 */ public DoubleVector() { super(DoubleArithmetic.getInstance()); @@ -22,6 +25,7 @@ public DoubleVector() { * @param xy value to be used in * {@link Vector#Vector(AbstractArithmetic, Number, Number)} at x and y * @see Vector#Vector(AbstractArithmetic, Number) + * @since 1.0.0 */ public DoubleVector(double xy) { super(DoubleArithmetic.getInstance(), xy); @@ -31,6 +35,7 @@ public DoubleVector(double xy) { * @param x x value of vector * @param y y value of vector * @see Vector#Vector(AbstractArithmetic, Number, Number) + * @since 1.0.0 */ public DoubleVector(double x, double y) { super(DoubleArithmetic.getInstance(), x, y); diff --git a/src/main/java/io/rala/math/probability/EnumerativeCombinatoric.java b/src/main/java/io/rala/math/probability/EnumerativeCombinatoric.java index 2ecf82f5..d35f0632 100644 --- a/src/main/java/io/rala/math/probability/EnumerativeCombinatoric.java +++ b/src/main/java/io/rala/math/probability/EnumerativeCombinatoric.java @@ -7,6 +7,8 @@ /** * collection of enumerative combinatoric math functions + * + * @since 1.0.0 */ public class EnumerativeCombinatoric { private EnumerativeCombinatoric() { @@ -18,6 +20,7 @@ private EnumerativeCombinatoric() { * @param n number of elements * @return {@code n!} * @see MathX#factorial(int) + * @since 1.0.0 */ public static long permutationsWithoutRepetition(int n) { return permutationsWithoutRepetition((long) n); @@ -29,6 +32,7 @@ public static long permutationsWithoutRepetition(int n) { * @throws ArithmeticException may be thrown for example by * {@link BigInteger#longValueExact()} * @see MathX#factorial(long) + * @since 1.0.0 */ public static long permutationsWithoutRepetition(long n) { return permutationsWithoutRepetition(BigInteger.valueOf(n)).longValueExact(); @@ -38,6 +42,7 @@ public static long permutationsWithoutRepetition(long n) { * @param n number of elements * @return {@code n!} * @see MathX#factorial(BigInteger) + * @since 1.0.0 */ public static BigInteger permutationsWithoutRepetition(BigInteger n) { return MathX.factorial(n); @@ -50,6 +55,7 @@ public static BigInteger permutationsWithoutRepetition(BigInteger n) { * @param k sub number of elements * @return {@code n! / product(k)} * @see MathX#factorial(int) + * @since 1.0.0 */ public static long permutationsWithRepetition(int n, int... k) { return permutationsWithRepetition(n, @@ -66,6 +72,7 @@ public static long permutationsWithRepetition(int n, int... k) { * @throws ArithmeticException may be thrown for example by * {@link BigInteger#longValueExact()} * @see MathX#factorial(long) + * @since 1.0.0 */ public static long permutationsWithRepetition(long n, long... k) { return permutationsWithRepetition(BigInteger.valueOf(n), @@ -80,6 +87,7 @@ public static long permutationsWithRepetition(long n, long... k) { * @param k sub number of elements * @return {@code n! / product(k)} * @see MathX#factorial(BigInteger) + * @since 1.0.0 */ public static BigInteger permutationsWithRepetition(BigInteger n, BigInteger... k) { return MathX.factorial(n).divide( @@ -97,6 +105,7 @@ public static BigInteger permutationsWithRepetition(BigInteger n, BigInteger... * @param k sub number of elements * @return {@code nPr(n,k)} * @see MathX#factorial(int) + * @since 1.0.0 */ public static long variationsWithoutRepetition(int n, int k) { return variationsWithoutRepetition((long) n, k); @@ -109,6 +118,7 @@ public static long variationsWithoutRepetition(int n, int k) { * @throws ArithmeticException may be thrown for example by * {@link BigInteger#longValueExact()} * @see MathX#factorial(long) + * @since 1.0.0 */ public static long variationsWithoutRepetition(long n, long k) { return variationsWithoutRepetition( @@ -121,6 +131,7 @@ public static long variationsWithoutRepetition(long n, long k) { * @param k sub number of elements * @return {@code nPr(n,k)} * @see MathX#factorial(BigInteger) + * @since 1.0.0 */ public static BigInteger variationsWithoutRepetition(BigInteger n, BigInteger k) { return MathX.factorial(n).divide(MathX.factorial(n.subtract(k))); @@ -131,6 +142,7 @@ public static BigInteger variationsWithoutRepetition(BigInteger n, BigInteger k) * @param k sub number of elements * @return n^k * @see BigInteger#pow(int) + * @since 1.0.0 */ public static long variationsWithRepetition(int n, int k) { return variationsWithRepetition((long) n, k); @@ -143,6 +155,7 @@ public static long variationsWithRepetition(int n, int k) { * @throws ArithmeticException may be thrown for example by * {@link BigInteger#longValueExact()} * @see BigInteger#pow(int) + * @since 1.0.0 */ public static long variationsWithRepetition(long n, long k) { return variationsWithRepetition( @@ -157,6 +170,7 @@ public static long variationsWithRepetition(long n, long k) { * @throws ArithmeticException may be thrown for example by * {@link BigInteger#longValueExact()} * @see BigInteger#pow(int) + * @since 1.0.0 */ public static BigInteger variationsWithRepetition(BigInteger n, BigInteger k) { return n == null || k == null ? null : n.pow(k.intValueExact()); @@ -171,6 +185,7 @@ public static BigInteger variationsWithRepetition(BigInteger n, BigInteger k) { * @param k sub number of elements * @return {@code nCr(n,k)} * @see MathX#factorial(int) + * @since 1.0.0 */ public static long combinationsWithoutRepetition(int n, int k) { return combinationsWithoutRepetition((long) n, k); @@ -183,6 +198,7 @@ public static long combinationsWithoutRepetition(int n, int k) { * @throws ArithmeticException may be thrown for example by * {@link BigInteger#longValueExact()} * @see MathX#factorial(long) + * @since 1.0.0 */ public static long combinationsWithoutRepetition(long n, long k) { return combinationsWithoutRepetition( @@ -195,6 +211,7 @@ public static long combinationsWithoutRepetition(long n, long k) { * @param k sub number of elements * @return {@code nCr(n,k)} * @see MathX#factorial(BigInteger) + * @since 1.0.0 */ public static BigInteger combinationsWithoutRepetition(BigInteger n, BigInteger k) { if (n == null || k == null) return null; @@ -210,6 +227,7 @@ public static BigInteger combinationsWithoutRepetition(BigInteger n, BigInteger * @param k sub number of elements * @return {@code nCr(n+k-1,k)} * @see #combinationsWithoutRepetition(int, int) + * @since 1.0.0 */ public static long combinationsWithRepetition(int n, int k) { return combinationsWithRepetition((long) n, k); @@ -222,6 +240,7 @@ public static long combinationsWithRepetition(int n, int k) { * @throws ArithmeticException may be thrown for example by * {@link BigInteger#longValueExact()} * @see #combinationsWithoutRepetition(long, long) + * @since 1.0.0 */ public static long combinationsWithRepetition(long n, long k) { return combinationsWithRepetition(BigInteger.valueOf(n), BigInteger.valueOf(k)) @@ -233,6 +252,7 @@ public static long combinationsWithRepetition(long n, long k) { * @param k sub number of elements * @return {@code nCr(n+k-1,k)} * @see #combinationsWithoutRepetition(BigInteger, BigInteger) + * @since 1.0.0 */ public static BigInteger combinationsWithRepetition(BigInteger n, BigInteger k) { return n == null || k == null ? null : diff --git a/src/main/java/io/rala/math/utils/Copyable.java b/src/main/java/io/rala/math/utils/Copyable.java index 00fec437..c38e4d19 100644 --- a/src/main/java/io/rala/math/utils/Copyable.java +++ b/src/main/java/io/rala/math/utils/Copyable.java @@ -4,11 +4,13 @@ * This interface allows to generate copy instances. * * @param class to copy + * @since 1.0.0 */ @SuppressWarnings("unused") public interface Copyable { /** * @return a new instance with same properties + * @since 1.0.0 */ T copy(); } diff --git a/src/main/java/io/rala/math/utils/Movable.java b/src/main/java/io/rala/math/utils/Movable.java index 2ff2f21c..6ac85885 100644 --- a/src/main/java/io/rala/math/utils/Movable.java +++ b/src/main/java/io/rala/math/utils/Movable.java @@ -7,6 +7,7 @@ * * @param number class of {@code T} * @param class to move + * @since 1.0.0 */ public interface Movable { /** @@ -16,6 +17,7 @@ public interface Movable { * with value at x and y * @see #move(Number, Number) * @see #move(Vector) + * @since 1.0.0 */ default T move(N xy) { return move(xy, xy); @@ -27,6 +29,7 @@ default T move(N xy) { * @return a new instance moved by values * @see #move(Number) * @see #move(Vector) + * @since 1.0.0 */ T move(N x, N y); @@ -37,6 +40,7 @@ default T move(N xy) { * {@link #move(Number, Number)} with vector attributes * @see #move(Number) * @see #move(Number, Number) + * @since 1.0.0 */ default T move(Vector vector) { return move(vector.getX(), vector.getY()); diff --git a/src/main/java/io/rala/math/utils/Rotatable.java b/src/main/java/io/rala/math/utils/Rotatable.java index fa6d6a7b..f75d69ae 100644 --- a/src/main/java/io/rala/math/utils/Rotatable.java +++ b/src/main/java/io/rala/math/utils/Rotatable.java @@ -8,6 +8,7 @@ * * @param number class of {@code T} * @param class to rotate + * @since 1.0.0 */ public interface Rotatable { /** @@ -16,6 +17,7 @@ public interface Rotatable { * @implSpec default implementation should call * {@link #rotate(Point, Number)} * with {@link Point#Point(AbstractArithmetic)} + * @since 1.0.0 */ T rotate(N phi); @@ -23,6 +25,7 @@ public interface Rotatable { * @param center rotation center to rotate - class without position ignore this value * @param phi angle in radiant * @return a new instance with rotated properties + * @since 1.0.0 */ T rotate(Point center, N phi); } diff --git a/src/main/java/io/rala/math/utils/StreamIterable.java b/src/main/java/io/rala/math/utils/StreamIterable.java index ec56d16c..ac34a5c8 100644 --- a/src/main/java/io/rala/math/utils/StreamIterable.java +++ b/src/main/java/io/rala/math/utils/StreamIterable.java @@ -9,11 +9,13 @@ * {@link #stream()} and {@link #parallelStream()}. * * @param class used in iteration + * @since 1.0.0 */ public interface StreamIterable extends Iterable { /** * @return a sequential {@code Stream} * @see StreamSupport#stream(Spliterator, boolean) + * @since 1.0.0 */ default Stream stream() { return StreamSupport.stream(spliterator(), false); @@ -22,6 +24,7 @@ default Stream stream() { /** * @return a possibly parallel {@code Stream} * @see StreamSupport#stream(Spliterator, boolean) + * @since 1.0.0 */ default Stream parallelStream() { return StreamSupport.stream(spliterator(), true); diff --git a/src/main/java/io/rala/math/utils/Validatable.java b/src/main/java/io/rala/math/utils/Validatable.java index fc1c45d2..a5a9933c 100644 --- a/src/main/java/io/rala/math/utils/Validatable.java +++ b/src/main/java/io/rala/math/utils/Validatable.java @@ -2,11 +2,14 @@ /** * This interface allows to validate instances. + * + * @since 1.0.0 */ @SuppressWarnings("unused") public interface Validatable { /** * @return {@code true} if valid + * @since 1.0.0 */ boolean isValid(); }