public final class MathPlume
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static int |
bitwiseAnd(int x,
int y)
Returns x & y, the bitwise and of its arguments.
|
static long |
bitwiseAnd(long x,
long y)
Returns x & y, the bitwise and of its arguments.
|
static int |
bitwiseComplement(int a)
Returns ~a, the bitwise complement of its argument.
|
static long |
bitwiseComplement(long a)
Returns ~a, the bitwise complement of its argument.
|
static int |
bitwiseOr(int x,
int y)
Returns x | y, the bitwise or of its arguments.
|
static long |
bitwiseOr(long x,
long y)
Returns x | y, the bitwise or of its arguments.
|
static int |
bitwiseXor(int x,
int y)
Returns x ^ y, the bitwise xor of its arguments.
|
static long |
bitwiseXor(long x,
long y)
Returns x ^ y, the bitwise xor of its arguments.
|
static double |
div(double x,
double y)
Divides its arguments.
|
static int |
div(int x,
int y)
Divides its arguments.
|
static long |
div(long x,
long y)
Divides its arguments.
|
static double |
gcd(double[] a)
Return the greatest common divisor of the elements of double array a.
|
static double |
gcd(double a,
double b)
Return the greatest common divisor of the two arguments.
|
static int |
gcd(int[] a)
Return the greatest common divisor of the elements of int array a.
|
static int |
gcd(int a,
int b)
Return the greatest common divisor of the two arguments.
|
static long |
gcd(long[] a)
Return the greatest common divisor of the elements of long array a.
|
static long |
gcd(long a,
long b)
Return the greatest common divisor of the two arguments.
|
static double |
gcdDifferences(double[] a)
Return the gcd (greatest common divisor) of the differences between the elements of double
array a.
|
static int |
gcdDifferences(int[] a)
Return the gcd (greatest common divisor) of the differences between the elements of int array
a.
|
static long |
gcdDifferences(long[] a)
Return the gcd (greatest common divisor) of the differences between the elements of long array
a.
|
static int |
logicalAnd(int x,
int y)
Returns the logical and of its arguments.
|
static long |
logicalAnd(long x,
long y)
Returns the logical and of its arguments.
|
static int |
logicalOr(int x,
int y)
Returns the logical or of its arguments.
|
static long |
logicalOr(long x,
long y)
Returns the logical or of its arguments.
|
static int |
logicalXor(int x,
int y)
Returns the logical xor of its arguments.
|
static long |
logicalXor(long x,
long y)
Returns the logical xor of its arguments.
|
static int |
lshift(int x,
int y)
Returns x << y, the left-shift operation applied to its arguments.
|
static long |
lshift(long x,
long y)
Returns x << y, the left-shift operation applied to its arguments.
|
static int[] |
missingNumbers(int[] nums)
Return an array containing all the numbers not in its argument array (which must be
non-empty) but in the argument's range; that is, bigger than its argument's minimum value and
smaller than its argument's maximum value.
|
static long[] |
missingNumbers(long[] nums)
Return an array containing all the numbers not in its argument array (which must be
non-empty) but in the argument's range; that is, bigger than its argument's minimum value and
smaller than its argument's maximum value.
|
static int |
mod(int x,
int y)
Returns x % y, the modulus operation applied to its arguments.
|
static long |
mod(long x,
long y)
Returns x % y, the modulus operation applied to its arguments.
|
static int |
modNonnegative(int x,
int y)
Return z such that
(z == x mod y) && (0 <= z < abs(y)). |
static long |
modNonnegative(long x,
long y)
Return z such that
(z == x mod y) && (0 <= z < abs(y)). |
static int |
modPositive(int x,
int y)
Deprecated.
use modNonnegative instead
|
static long |
modPositive(long x,
long y)
Deprecated.
use modNonnegative instead
|
static int[] |
modulus(int[] nums)
Return an array of two integers (r,m) such that each number in NUMS is equal to r (mod m).
|
static long[] |
modulus(long[] nums)
Return an array of two integers (r,m) such that each number in NUMS is equal to r (mod m).
|
static int[] |
modulusInt(java.util.Iterator<java.lang.Integer> itor)
The iterator produces Integer values.
|
static long[] |
modulusLong(java.util.Iterator<java.lang.Long> itor)
The iterator produces Long values.
|
static int[] |
modulusStrict(int[] nums,
boolean nonstrictEnds)
Return an array of two integers (r,m) such that each number in NUMS is equal to r (mod m).
|
static long[] |
modulusStrict(long[] nums,
boolean nonstrictEnds)
Return an array of two integers (r,m) such that each number in NUMS is equal to r (mod m).
|
static int[] |
modulusStrictInt(java.util.Iterator<java.lang.Integer> itor,
boolean nonstrictEnds)
The iterator produces Integer values.
|
static long[] |
modulusStrictLong(java.util.Iterator<java.lang.Long> itor,
boolean nonstrictEnds)
The iterator produces Long values.
|
static double |
mul(double x,
double y)
Multiplies its arguments.
|
static int |
mul(int x,
int y)
Multiplies its arguments.
|
static long |
mul(long x,
long y)
Multiplies its arguments.
|
static double |
negate(double a)
Negates its argument.
|
static int |
negate(int a)
Negates its argument.
|
static long |
negate(long a)
Negates its argument.
|
static int[] |
nonmodulusNonstrict(int[] nums)
Return a tuple of (r,m) where no number in NUMS is equal to r (mod m) but for every number in
NUMS, at least one is equal to every non-r remainder.
|
static long[] |
nonmodulusNonstrict(long[] nums)
Return a tuple of (r,m) where no number in NUMS is equal to r (mod m) but for every number in
NUMS, at least one is equal to every non-r remainder.
|
static int[] |
nonmodulusStrict(int[] nums)
Return a tuple of (r,m) where no number in NUMS is equal to r (mod m) but all missing numbers
in their range are.
|
static long[] |
nonmodulusStrict(long[] nums)
Return a tuple of (r,m) where no number in NUMS is equal to r (mod m) but all missing numbers
in their range are.
|
static int[] |
nonmodulusStrictInt(java.util.Iterator<java.lang.Integer> nums)
Return a tuple of (r,m) where no number in NUMS is equal to r (mod m) but all missing numbers
in their range are.
|
static long[] |
nonmodulusStrictLong(java.util.Iterator<java.lang.Long> nums)
Return a tuple of (r,m) where no number in NUMS is equal to r (mod m) but all missing numbers
in their range are.
|
static int |
pow(int base,
int expt)
Returns of value of the first argument raised to the power of the second argument.
|
static long |
pow(long base,
long expt)
Returns of value of the first argument raised to the power of the second argument.
|
static int |
rshiftSigned(int x,
int y)
Returns x >> y, the signed right-shift operation applied to its arguments.
|
static long |
rshiftSigned(long x,
long y)
Returns x >> y, the signed right-shift operation applied to its arguments.
|
static int |
rshiftUnsigned(int x,
int y)
Returns x >>> y, the unsigned right-shift operation applied to its arguments.
|
static long |
rshiftUnsigned(long x,
long y)
Returns x >>> y, the unsigned right-shift operation applied to its arguments.
|
static int |
sign(int a)
Returns the sign of its argument.
|
@Pure public static int negate(int a)
a - value to negate@Pure public static long negate(long a)
a - value to negate@Pure public static double negate(double a)
a - value to negate@Pure public static int bitwiseComplement(int a)
a - value to bitwise-complement@Pure public static long bitwiseComplement(long a)
a - value to bitwise-complement@Pure
public static int mul(int x,
int y)
x - first multiplicandy - second multiplicand@Pure
public static long mul(long x,
long y)
x - first multiplicandy - second multiplicand@Pure
public static double mul(double x,
double y)
x - first multiplicandy - second multiplicand@Pure
public static int div(int x,
int y)
x - dividendy - divisor@Pure
public static long div(long x,
long y)
x - dividendy - divisor@Pure
public static double div(double x,
double y)
x - dividendy - divisor@Pure
public static int mod(int x,
int y)
x - valued to be moddedy - modulus@Pure
public static long mod(long x,
long y)
x - valued to be moddedy - modulus@Pure
public static int lshift(int x,
int y)
x - valued to be left-shiftedy - magnitude of the left-shift@Pure
public static long lshift(long x,
long y)
x - valued to be left-shiftedy - magnitude of the left-shift@Pure
public static int rshiftSigned(int x,
int y)
x - valued to be right-shiftedy - magnitude of the right-shift@Pure
public static long rshiftSigned(long x,
long y)
x - valued to be right-shiftedy - magnitude of the right-shift@Pure
public static int rshiftUnsigned(int x,
int y)
x - valued to be right-shiftedy - magnitude of the right-shift@Pure
public static long rshiftUnsigned(long x,
long y)
x - valued to be right-shiftedy - magnitude of the right-shift@Pure
public static int bitwiseAnd(int x,
int y)
x - first operandy - second operand@Pure
public static long bitwiseAnd(long x,
long y)
x - first operandy - second operand@Pure
public static int logicalAnd(int x,
int y)
x - first operandy - second operand@Pure
public static long logicalAnd(long x,
long y)
x - first operandy - second operand@Pure
public static int bitwiseXor(int x,
int y)
x - first operandy - second operand@Pure
public static long bitwiseXor(long x,
long y)
x - first operandy - second operand@Pure
public static int logicalXor(int x,
int y)
x - first operandy - second operand@Pure
public static long logicalXor(long x,
long y)
x - first operandy - second operand@Pure
public static int bitwiseOr(int x,
int y)
x - first operandy - second operand@Pure
public static long bitwiseOr(long x,
long y)
x - first operandy - second operand@Pure
public static int logicalOr(int x,
int y)
x - first operandy - second operand@Pure
public static long logicalOr(long x,
long y)
x - first operandy - second operand@Pure public static int sign(int a)
a - value to have its sign taken@Pure
public static int pow(int base,
int expt)
throws java.lang.ArithmeticException
base - the baseexpt - the exponentjava.lang.ArithmeticExceptionMath.pow(double, double)@Pure
public static long pow(long base,
long expt)
throws java.lang.ArithmeticException
base - the baseexpt - the exponentjava.lang.ArithmeticExceptionMath.pow(double, double)@Pure
public static int gcd(int a,
int b)
a - first operandb - second operand@Pure public static int gcd(int[] a)
a - array of operands@Pure public static int gcdDifferences(int[] a)
a - array of operands@Pure
public static long gcd(long a,
long b)
a - first operandb - second operand@Pure public static long gcd(long[] a)
a - array of operands@Pure public static long gcdDifferences(long[] a)
a - array of operands@Pure
public static double gcd(double a,
double b)
a - first operandb - second operand@Pure public static double gcd(double[] a)
a - array of operands@Pure public static double gcdDifferences(double[] a)
a - array of operands@Deprecated
@Pure
public static int modPositive(int x,
int y)
(z == x mod y) && (0 <= z < abs(y)). This should really be named
modNonnegative rather than modPositive.x - value to be moddedy - modulus@Pure
public static int modNonnegative(int x,
int y)
(z == x mod y) && (0 <= z < abs(y)).x - value to be moddedy - modulus@Pure public static int[] modulus(int[] nums)
nums - array of operandspublic static int[] modulusInt(java.util.Iterator<java.lang.Integer> itor)
itor - iterator of operandsmodulus(int[])@Pure
public static int[] modulusStrict(int[] nums,
boolean nonstrictEnds)
This "Strict" version requires its input to be sorted, and no element may be missing.
This "Strict" version differs from the regular modulus by requiring that the argument be dense: that is, every pair of numbers in the argument array is separated by exactly the modulus.
The endpoints can be treated in two different ways: Either exactly like other numbers in the input, or they can merely be checked for the condition without the strict density requirement.
nums - array of operandsnonstrictEnds - whether endpoints are NOT subject to the strict density requirementpublic static int[] modulusStrictInt(java.util.Iterator<java.lang.Integer> itor,
boolean nonstrictEnds)
For documentation, see modulusStrict(int[], boolean).
itor - iterator of operandsnonstrictEnds - whether endpoints are NOT subject to the strict density requirementmodulusStrict(int[], boolean)@Deprecated
@Pure
public static long modPositive(long x,
long y)
(z == x mod y) && (0 <= z < abs(y)). This should really be named
modNonnegative rather than modPositive.x - value to be moddedy - modulus@Pure
public static long modNonnegative(long x,
long y)
(z == x mod y) && (0 <= z < abs(y)).x - value to be moddedy - modulus@Pure public static long[] modulus(long[] nums)
nums - array of operandspublic static long[] modulusLong(java.util.Iterator<java.lang.Long> itor)
itor - iterator of operandsmodulus(long[])@Pure
public static long[] modulusStrict(long[] nums,
boolean nonstrictEnds)
This "Strict" version requires its input to be sorted, and no element may be missing.
This "Strict" version differs from the regular modulus by requiring that the argument be dense: that is, every pair of numbers in the argument array is separated by exactly the modulus.
The endpoints can be treated in two different ways: Either exactly like other numbers in the input, or they can merely be checked for the condition without the strict density requirement.
nums - array of operandsnonstrictEnds - whether endpoints are NOT subject to the strict density requirementpublic static long[] modulusStrictLong(java.util.Iterator<java.lang.Long> itor,
boolean nonstrictEnds)
For documentation, see modulusStrict(long[], boolean).
itor - iterator of operandsnonstrictEnds - whether endpoints are NOT subject to the strict density requirementmodulusStrict(int[], boolean)@Pure public static int[] missingNumbers(int[] nums)
nums - numbers to be excluded; length > 0; may contain duplicates@Pure public static int[] nonmodulusStrict(int[] nums)
nums - the list of operandspublic static int[] nonmodulusStrictInt(java.util.Iterator<java.lang.Integer> nums)
nums - the list of operands@Pure public static int[] nonmodulusNonstrict(int[] nums)
nums - the list of operands@Pure public static long[] missingNumbers(long[] nums)
nums - numbers to be excluded; length > 0; may contain duplicates@Pure public static long[] nonmodulusStrict(long[] nums)
nums - the list of operandspublic static long[] nonmodulusStrictLong(java.util.Iterator<java.lang.Long> nums)
nums - the list of operands@Pure public static long[] nonmodulusNonstrict(long[] nums)
nums - the list of operands