public final class NumberTheory
extends java.lang.Object
Constructor and Description |
---|
NumberTheory() |
Modifier and Type | Method and Description |
---|---|
static double |
argmax(double... numbers)
Arg-Max function.
|
static double |
argmin(double... numbers)
Arg-Min function.
|
static java.lang.String |
convDecimal2OthBase(double decimalNumber,
int numeralSystemBase)
Decimal number to other numeral system conversion with base
between 1 and 36.
|
static java.lang.String |
convDecimal2OthBase(double decimalNumber,
int numeralSystemBase,
int format)
Decimal number to other numeral system conversion with base
between 1 and 36.
|
static double |
convOthBase2Decimal(double[] baseAndDigits)
Other base to decimal conversion.
|
static double |
convOthBase2Decimal(double numeralSystemBase,
double... digits)
Other base to decimal conversion.
|
static double |
convOthBase2Decimal(int[] baseAndDigits)
Other base to decimal conversion.
|
static double |
convOthBase2Decimal(int numeralSystemBase,
int... digits)
Other base to decimal conversion.
|
static double |
convOthBase2Decimal(java.lang.String numberLiteral)
Other base (base between 1 and 36) number literal conversion to decimal number.
|
static double |
convOthBase2Decimal(java.lang.String numberLiteral,
int numeralSystemBase)
Other base (base between 1 and 36) number literal conversion to decimal number.
|
static double |
digitAtPosition(double number,
double position)
Digit at position - numeral system with base 10
|
static double |
digitAtPosition(double number,
double position,
double numeralSystemBase)
Digit at position - numeral system with given base
|
static int |
digitAtPosition(long number,
int position)
Digit at position - numeral system with base 10
|
static int |
digitAtPosition(long number,
int position,
int numeralSystemBase)
Digit at position - numeral system with given base
|
static char |
digitChar(int digitIndex)
Character representing digit for numeral systems with base
between 1 and 36.
|
static int |
digitIndex(char digitChar)
Digit index based on digit character for numeral systems with
base between 1 and 36.
|
static double |
gcd(double... numbers)
Greatest common divisor (GCD)
|
static double |
gcd(double a,
double b)
Greatest common divisor (GCD)
|
static long |
gcd(long... numbers)
Greatest common divisor (GCD)
|
static long |
gcd(long a,
long b)
Greatest common divisor (GCD)
|
static double[][] |
getDistValues(double[] array,
boolean returnOrderByDescFreqAndAscOrigPos)
Returns list of distinct values found in a given array.
|
static int |
getNumeralSystemBase(java.lang.String numberLiteral)
Recognition of numeral system base in which number literal represents
number.
|
static double |
lcm(double... numbers)
Latest common multiply (LCM)
|
static double |
lcm(double a,
double b)
Latest common multiply (LCM)
|
static long |
lcm(long... numbers)
Latest common multiply (LCM)
|
static long |
lcm(long a,
long b)
Latest common multiply (LCM)
|
static double |
max(double... numbers)
Maximum function.
|
static double |
max(double a,
double b)
Maximum function.
|
static double |
max(Expression f,
Argument index,
double from,
double to,
double delta)
Maximum value - iterative operator.
|
static double |
min(double... numbers)
Minimum function.
|
static double |
min(double a,
double b)
Minimum function.
|
static double |
min(Expression f,
Argument index,
double from,
double to,
double delta)
Minimum value - iterative operator.
|
static double |
numberOfDigits(double number)
Number of digits needed to represent given number in base 10 numeral system.
|
static double |
numberOfDigits(double number,
double numeralSystemBase)
Number of digits needed to represent given number (its integer part) in numeral system with given base.
|
static int |
numberOfDigits(long number)
Number of digits needed to represent given number in base 10 numeral system.
|
static long |
numberOfDigits(long number,
long numeralSystemBase)
Number of digits needed to represent given number in numeral system with given base.
|
static double |
numberOfDistValues(double... numbers)
Returns number of unique values found the list of numbers
|
static double |
numberOfPrimeFactors(double number)
Prime decomposition (prime factorization) - returns number of distinct prime factors
|
static double |
piProduct(Expression f,
Argument index,
double from,
double to,
double delta)
Product operator
|
static double |
primeCount(double n)
Prime counting function
|
static long |
primeCount(long n)
Prime counting function
|
static double |
primeFactorExponent(double number,
double id)
Prime decomposition (prime factorization) - returns prime factor exponent
|
static double[] |
primeFactors(double number)
Prime decomposition (prime factorization)
|
static long[] |
primeFactors(long number)
Prime decomposition (prime factorization)
|
static double |
primeFactorValue(double number,
double id)
Prime decomposition (prime factorization) - returns prime factor value
|
static double |
primeTest(double n)
Prime test
|
static boolean |
primeTest(long n)
Prime test
|
static double |
prod(double... numbers)
Numbers multiplication.
|
static double |
sigmaSummation(Expression f,
Argument index,
double from,
double to,
double delta)
Summation operator (SIGMA FROM i = a, to b, f(i) by delta
|
static int[] |
sortAsc(double[] array)
Array sort - ascending - quick sort algorithm.
|
static double |
sum(double... numbers)
Adding numbers.
|
public static final double min(double a, double b)
a
- the a function parameterb
- the b function parameterpublic static final double min(double... numbers)
numbers
- the a function parameterpublic static final double argmin(double... numbers)
numbers
- the a function parameterpublic static final double max(double a, double b)
a
- the a function parameterb
- the b function parameterpublic static final double max(double... numbers)
numbers
- the a function parameterpublic static final double argmax(double... numbers)
numbers
- the a function parameterpublic static final int[] sortAsc(double[] array)
array
- Array to be sortedpublic static final double[][] getDistValues(double[] array, boolean returnOrderByDescFreqAndAscOrigPos)
array
- The arrayreturnOrderByDescFreqAndAscOrigPos
- Indicator whether to apply final ordering based
on descending value frequency and ascending initial position.public static final double numberOfDistValues(double... numbers)
numbers
- The list of numberspublic static final long gcd(long a, long b)
a
- the a function parameterb
- the b function parameterpublic static final double gcd(double a, double b)
a
- the a function parameterb
- the b function parameterpublic static final long gcd(long... numbers)
numbers
- the numberspublic static final double gcd(double... numbers)
numbers
- the numberspublic static final long lcm(long a, long b)
a
- the a function parameterb
- the b function parameterpublic static final double lcm(double a, double b)
a
- the a function parameterb
- the b function parameterpublic static final long lcm(long... numbers)
numbers
- the numberspublic static final double lcm(double... numbers)
numbers
- the numberspublic static final double sum(double... numbers)
numbers
- the numberspublic static final double prod(double... numbers)
numbers
- the numberspublic static final boolean primeTest(long n)
n
- The number to be tested.public static final double primeTest(double n)
n
- The number to be tested.public static final long primeCount(long n)
n
- numberpublic static final double primeCount(double n)
n
- numberpublic static final double sigmaSummation(Expression f, Argument index, double from, double to, double delta)
f
- the expressionindex
- the name of index argumentfrom
- FROM index = formto
- TO index = todelta
- BY deltapublic static final double piProduct(Expression f, Argument index, double from, double to, double delta)
f
- the expressionindex
- the name of index argumentfrom
- FROM index = formto
- TO index = todelta
- BY deltaExpression
,
Argument
public static final double min(Expression f, Argument index, double from, double to, double delta)
f
- the expressionindex
- the name of index argumentfrom
- FROM index = formto
- TO index = todelta
- BY deltaExpression
,
Argument
public static final double max(Expression f, Argument index, double from, double to, double delta)
f
- the expressionindex
- the name of index argumentfrom
- FROM index = formto
- TO index = todelta
- BY deltaExpression
,
Argument
public static final int digitIndex(char digitChar)
digitChar
- Digit character (lower or upper case) representing digit in numeral
systems with base between 1 and 36. Digits:
0:0, 1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8,
9:9, 10:A, 11:B, 12:C, 13:D, 14:E, 15:F, 16:G,
17:H, 18:I, 19:J, 20:K, 21:L, 22:M, 23:N, 24:O,
25:P, 26:Q, 27:R, 28:S, 29:T, 30:U, 31:V, 32:W,
33:X, 34:Y, 35:Zpublic static final char digitChar(int digitIndex)
digitIndex
- Digit index between 0 and 35public static final int getNumeralSystemBase(java.lang.String numberLiteral)
numberLiteral
- Number literal string.
Base format: b1. b2. b. b3. b4. b5. b6. b7. b8. o. b9. b10. b11. b12.
b13. b14. b15. b16. h. b17. b18. b19. b20. b21. b22. b23. b24. b25. b26.
b27. b28. b29. b30. b31. b32. b33. b34. b35. b36.
Digits: 0:0, 1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8, 9:9, 10:A, 11:B, 12:C,
13:D, 14:E, 15:F, 16:G, 17:H, 18:I, 19:J, 20:K, 21:L, 22:M, 23:N, 24:O, 25:P,
26:Q, 27:R, 28:S, 29:T, 30:U, 31:V, 32:W, 33:X, 34:Y, 35:Zpublic static final double convOthBase2Decimal(java.lang.String numberLiteral, int numeralSystemBase)
numberLiteral
- Number literal in given numeral system with base between
1 and 36. Digits: 0:0, 1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7,
8:8, 9:9, 10:A, 11:B, 12:C, 13:D, 14:E, 15:F, 16:G, 17:H,
18:I, 19:J, 20:K, 21:L, 22:M, 23:N, 24:O, 25:P, 26:Q, 27:R,
28:S, 29:T, 30:U, 31:V, 32:W, 33:X, 34:Y, 35:ZnumeralSystemBase
- Numeral system base, between 1 and 36public static final double convOthBase2Decimal(java.lang.String numberLiteral)
numberLiteral
- Number literal string.
Base format: b1. b2. b. b3. b4. b5. b6. b7. b8. o. b9. b10. b11. b12.
b13. b14. b15. b16. h. b17. b18. b19. b20. b21. b22. b23. b24. b25. b26.
b27. b28. b29. b30. b31. b32. b33. b34. b35. b36.
Digits: 0:0, 1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8, 9:9, 10:A, 11:B, 12:C,
13:D, 14:E, 15:F, 16:G, 17:H, 18:I, 19:J, 20:K, 21:L, 22:M, 23:N, 24:O, 25:P,
26:Q, 27:R, 28:S, 29:T, 30:U, 31:V, 32:W, 33:X, 34:Y, 35:Zpublic static final double convOthBase2Decimal(int numeralSystemBase, int... digits)
numeralSystemBase
- Numeral system base has to be above 0.digits
- List of digitspublic static final double convOthBase2Decimal(double numeralSystemBase, double... digits)
numeralSystemBase
- Numeral system base has to be above 0.digits
- List of digitspublic static final double convOthBase2Decimal(int[] baseAndDigits)
baseAndDigits
- Numeral system base and digits specification.
Numeral system base is placed at index 0, rest of
array is interpreted as digits. Numeral system base
has to be above 0.public static final double convOthBase2Decimal(double[] baseAndDigits)
baseAndDigits
- Numeral system base and digits specification.
Numeral system base is placed at index 0, rest of
array is interpreted as digits. Numeral system base
has to be above 0.public static final java.lang.String convDecimal2OthBase(double decimalNumber, int numeralSystemBase)
decimalNumber
- Decimal numbernumeralSystemBase
- Numeral system base between 1 and 36public static final java.lang.String convDecimal2OthBase(double decimalNumber, int numeralSystemBase, int format)
decimalNumber
- Decimal numbernumeralSystemBase
- Numeral system base between 1 and 36format
- If 1 then always bxx. is used, i.e. b1. or b16.
If 2 then for binary b. is used, for octal o. is used,
for hexadecimal h. is used, otherwise bxx. is used
where xx is the numeral system base specification.public static final int numberOfDigits(long number)
number
- The numberpublic static final double numberOfDigits(double number)
number
- The numberpublic static final long numberOfDigits(long number, long numeralSystemBase)
number
- The numbernumeralSystemBase
- Numeral system base above 0public static final double numberOfDigits(double number, double numeralSystemBase)
number
- The numbernumeralSystemBase
- Numeral system base above 0public static final int digitAtPosition(long number, int position, int numeralSystemBase)
number
- The numberposition
- Position from 1 ... n (left to right) or from 0 ... -(n-1) (right to left).numeralSystemBase
- Base of numeral system - above 0public static final int digitAtPosition(long number, int position)
number
- The numberposition
- Position from 1 ... n (left to right) or from 0 ... -(n-1) (right to left).public static final double digitAtPosition(double number, double position, double numeralSystemBase)
number
- The numberposition
- Position from 1 ... n (left to right) or from 0 ... -(n-1) (right to left).numeralSystemBase
- Base of numeral system - above 0public static final double digitAtPosition(double number, double position)
number
- The numberposition
- Position from 1 ... n (left to right) or from 0 ... -(n-1) (right to left).public static final long[] primeFactors(long number)
number
- Number to be decomposedpublic static final double[] primeFactors(double number)
number
- Number to be decomposedpublic static final double numberOfPrimeFactors(double number)
number
- Number to be decomposedpublic static final double primeFactorValue(double number, double id)
number
- Number to be decomposedid
- Factor idpublic static final double primeFactorExponent(double number, double id)
number
- Number to be decomposedid
- Factor id