Skip to content

Commit

Permalink
add @SInCE to javaDoc
Browse files Browse the repository at this point in the history
  • Loading branch information
rala72 committed Jan 31, 2021
1 parent 0ba5cde commit abed5a7
Show file tree
Hide file tree
Showing 59 changed files with 714 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/main/java/io/rala/math/MathX.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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;
Expand All @@ -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));
Expand All @@ -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();
Expand All @@ -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);
Expand All @@ -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<Integer> factors(int a) {
return factors((long) a).stream()
Expand All @@ -128,6 +136,7 @@ public static List<Integer> factors(int a) {
/**
* @param a number to get factors of
* @return list of factors
* @since 1.0.0
*/
public static List<Long> factors(long a) {
// https://stackoverflow.com/a/6233030/2715720
Expand All @@ -150,6 +159,7 @@ public static List<Long> factors(long a) {
*
* @param a number
* @return factorial
* @since 1.0.0
*/
public static long factorial(int a) {
return factorial((long) a);
Expand All @@ -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();
Expand All @@ -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 :
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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;
Expand All @@ -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));
Expand All @@ -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();
Expand All @@ -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 :
Expand All @@ -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)
Expand All @@ -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);
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
*
* @param <T> class of equation system
* @implSpec this class has only {@link #transpose()} at the moment
* @since 1.0.0
*/
public abstract class AbstractEquationSystem<T extends AbstractEquationSystem<T>> {
/**
* @return new transposed equation system
* @since 1.0.0
*/
protected abstract T transpose();
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*
* @param <E> class of {@link AbstractEquationSystem}
* @param <T> number class of {@link AbstractEquationSystem}
* @since 1.0.0
*/
public abstract class AbstractSolver<E extends AbstractEquationSystem<E>, T extends Number> {
// region attributes
Expand All @@ -20,6 +21,7 @@ public abstract class AbstractSolver<E extends AbstractEquationSystem<E>, 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;
Expand All @@ -29,20 +31,23 @@ protected AbstractSolver(E equationSystem) {

/**
* @return stored {@link AbstractEquationSystem}
* @since 1.0.0
*/
public final E getEquationSystem() {
return equationSystem;
}

/**
* @return current working instance
* @since 1.0.0
*/
protected E getWorking() {
return working;
}

/**
* @param working new working instance
* @since 1.0.0
*/
protected void setWorking(E working) {
this.working = working;
Expand All @@ -56,13 +61,15 @@ protected void setWorking(E working) {
* solves {@link AbstractEquationSystem} and returns {@link Solution}
*
* @return solution of {@link AbstractEquationSystem}
* @since 1.0.0
*/
public abstract Solution<E, T> solve();

/**
* resets solver
*
* @implSpec resets {@link #getWorking()} to {@link #getEquationSystem()}
* @since 1.0.0
*/
protected void reset() {
setWorking(getEquationSystem());
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/io/rala/math/algebra/equation/Solution.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@
*
* @param <E> class of {@link AbstractEquationSystem}
* @param <T> number class
* @since 1.0.0
*/
public class Solution<E extends AbstractEquationSystem<E>, 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}

Expand All @@ -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<T> solution, State state) {
if (equationSystem == null || solution == null || state == null)
Expand All @@ -46,20 +50,23 @@ public Solution(E equationSystem, List<T> solution, State state) {

/**
* @return equation system of solution
* @since 1.0.0
*/
public E getEquationSystem() {
return equationSystem;
}

/**
* @return solution values
* @since 1.0.0
*/
public List<T> getSolution() {
return Collections.unmodifiableList(solution);
}

/**
* @return {@link State} of solution
* @since 1.0.0
*/
public State getState() {
return state;
Expand Down Expand Up @@ -101,6 +108,7 @@ public String toString() {
* @param <E> evaluation class
* @param <T> number class
* @return new {@link Solution} instance
* @since 1.0.0
*/
public static <E extends AbstractEquationSystem<E>, T extends Number>
Solution<E, T> single(E equationSystem, List<T> solution) {
Expand All @@ -114,6 +122,7 @@ Solution<E, T> single(E equationSystem, List<T> solution) {
* @param <E> evaluation class
* @param <T> number class
* @return new {@link Solution} instance
* @since 1.0.0
*/
public static <E extends AbstractEquationSystem<E>, T extends Number>
Solution<E, T> unsolvable(E equationSystem) {
Expand All @@ -127,6 +136,7 @@ Solution<E, T> unsolvable(E equationSystem) {
* @param <E> evaluation class
* @param <T> number class
* @return new {@link Solution} instance
* @since 1.0.0
*/
public static <E extends AbstractEquationSystem<E>, T extends Number>
Solution<E, T> infinite(E equationSystem) {
Expand Down
Loading

0 comments on commit abed5a7

Please sign in to comment.