Class Calculator
java.lang.Object
ch.nolix.base.math.main.Calculator
The
Calculator provides mathematical functions.- Author:
- Silvan Wyss
-
Method Summary
Modifier and TypeMethodDescriptionstatic doublegetAbsoluteDifference(double value1, double value2) static intgetAbsoluteDifference(int value1, int value2) static longgetAbsoluteDifference(long value1, long value2) static doublegetAbsoluteValue(double value) The absolute value of a value x is -x if x is negative, x otherwise.static intgetAbsoluteValue(int value) The absolute value of a value x is -x if x is negative, x otherwise.static longgetAbsoluteValue(long value) The absolute value of a value x is -x if x is negative, x otherwise.static ARModelgetARModell(int pOrder, double[] inputValues) static doublegetAverage(double... values) static intgetAverage(int... values) static longgetAverage(long... values) static doublegetAverage(Iterable<Double> values) static PolynomgetFittingPolynom(int degree, double[] xValues, double[] yValues) static doublegetMax(double... values) static intgetMax(int... values) static longgetMax(long... values) static doublegetMin(double... values) static intgetMin(int... values) static longgetMin(long... values) static doublegetSquare(double value) static doublegetSquare(int value) static doublegetSquare(long value) static doublegetSum(double... values) static intgetSum(int... values) static longgetSum(long... values) static double
-
Method Details
-
getAbsoluteDifference
public static double getAbsoluteDifference(double value1, double value2) - Parameters:
value1-value2-- Returns:
- the absolute difference between the given 2 values.
-
getAbsoluteDifference
public static int getAbsoluteDifference(int value1, int value2) - Parameters:
value1-value2-- Returns:
- the absolute difference between the given 2 values.
-
getAbsoluteDifference
public static long getAbsoluteDifference(long value1, long value2) - Parameters:
value1-value2-- Returns:
- the absolute difference between the given 2 values.
-
getAbsoluteValue
public static double getAbsoluteValue(double value) The absolute value of a value x is -x if x is negative, x otherwise.- Parameters:
value-- Returns:
- the absolute value of the given value.
-
getAbsoluteValue
public static int getAbsoluteValue(int value) The absolute value of a value x is -x if x is negative, x otherwise.- Parameters:
value-- Returns:
- the absolute value of the given value.
-
getAbsoluteValue
public static long getAbsoluteValue(long value) The absolute value of a value x is -x if x is negative, x otherwise.- Parameters:
value-- Returns:
- the absolute value of the given value.
-
getAverage
public static double getAverage(double... values) - Parameters:
values-- Returns:
- the average of the given values.
- Throws:
RuntimeException- if the given values is null or empty.
-
getAverage
- Parameters:
values-- Returns:
- the average of the given values.
- Throws:
RuntimeException- if the given values is empty.
-
getAverage
public static int getAverage(int... values) - Parameters:
values-- Returns:
- the average of the given values.
- Throws:
RuntimeException- if the given values is null or empty.
-
getAverage
public static long getAverage(long... values) - Parameters:
values-- Returns:
- the average of the given values.
- Throws:
RuntimeException- if the given values is empty.RuntimeException- if the given values is null or empty.
-
getARModell
- Parameters:
pOrder-inputValues-- Returns:
- a new
ARModelwith the given pOrder and inputValues. - Throws:
RuntimeException- if the given pOrder is negative.
-
getFittingPolynom
- Parameters:
degree-xValues-yValues-- Returns:
- a new
Polynomthat has the given degree and fits the given values - Throws:
RuntimeException- if the given degree is negative.RuntimeException- if the given degree is bigger than the count of the given xValues.RuntimeException- if the count of the given yValues does not equal the count of the given xValues.
-
getMax
public static double getMax(double... values) - Parameters:
values-- Returns:
- the biggest value of the given values.
- Throws:
RuntimeException- if the given values is null or empty.
-
getMax
public static int getMax(int... values) - Parameters:
values-- Returns:
- the biggest value of the given values.
- Throws:
RuntimeException- if the given values is null or empty.
-
getMax
public static long getMax(long... values) - Parameters:
values-- Returns:
- the biggest value of the given values.
- Throws:
RuntimeException- if the given values is null or empty.
-
getMin
public static double getMin(double... values) - Parameters:
values-- Returns:
- the smallest value of the given values.
- Throws:
RuntimeException- if the given values is null or empty.
-
getMin
public static int getMin(int... values) - Parameters:
values-- Returns:
- the smallest value of the given values.
- Throws:
RuntimeException- if the given values is null or empty.
-
getMin
public static long getMin(long... values) - Parameters:
values-- Returns:
- the smallest value of the given values.
- Throws:
RuntimeException- if the given values is null or empty.
-
getSquare
public static double getSquare(double value) - Parameters:
value-- Returns:
- the square of the given value.
-
getSquare
public static double getSquare(int value) - Parameters:
value-- Returns:
- the square of the given value.
-
getSquare
public static double getSquare(long value) - Parameters:
value-- Returns:
- the square of the given value.
-
getSum
public static double getSum(double... values) - Parameters:
values-- Returns:
- the sum of the given values.
- Throws:
RuntimeException- if the given values is null.
-
getSum
public static int getSum(int... values) - Parameters:
values-- Returns:
- the sum of the given values.
- Throws:
RuntimeException- if the given values is null.
-
getSum
- Parameters:
values-- Returns:
- the sum of the given values.
- Throws:
RuntimeException- if the given values is null.
-
getSum
public static long getSum(long... values) - Parameters:
values-- Returns:
- the sum of the given values.
- Throws:
RuntimeException- if the given values is null.
-