Java Utililty Methods Double Number mod

List of utility methods to do Double Number mod

Description

The list of methods to do Double Number mod are organized into topic(s).

Method

doublemod(double x, double y)
mod
if (0. == y)
    return x;
double m = x - y * Math.floor(x / y);
if (y > 0) { 
    if (m >= y) 
        return 0;
    if (m < 0) {
        if (y + m == y)
...
doublemod(double x, double y)
Returns the given number modulo the second number (mod for floats).
return x - y * Math.floor(x / y);
doublemod(double x, double y)
Performs 'x modulo y' (not to be confused with the remainder operator '%', which behaves differently when x is negative).
if (x >= 0) {
    return x % y;
} else {
    double tmp = -x % y; 
    return (tmp == 0) ? tmp : (y - tmp);
doublemod(final double a, final double b)
mod
double val = a;
while (val >= b) {
    val -= b;
while (val < 0.0) {
    val += b;
return val;
...
doublemod2pi(double vin)
Ensure that v is [-PI, PI]
double v;
if (vin < 0)
    v = -mod2pi_pos(-vin);
else
    v = mod2pi_pos(vin);
return v;
doublemod2pi_pos(double vin)
modppos
double q = vin * twopi_inv + 0.5;
int qi = (int) q;
return vin - qi * twopi;
long[]modArray(double value, int mod, int div)
Return an array of long values.
final long[] result = new long[mod];
if (result.length > 0) {
    result[0] = 100;
    if (result.length > 1) {
        final long base = ((long) (value / (mod * div))) * div;
        final long last = (long) (value - base * (mod - 1));
        for (int i = 0; i < result.length; i++) {
            if (i == result.length - 1) {
...
double[][]modifiedGramSchmidt(double[][] s)
Orthonormalizes a set of vectors.
double[][] u = new double[s.length][s[0].length];
for (int i = 0; i < s.length; i++) {
    u[i] = s[i];
    for (int j = 0; j < i; j++) {
        u[i] = sumArrays(u[i], scalarProduct(-1, project(u[j], u[i])));
for (int i = 0; i < u.length; i++) {
...
doublemodifiedJulianToJulian(double modifiedJulian)
_more_
return modifiedJulian + 2400000.5;
double[]modifySize(double[] x, int newLen)
modify Size
double[] y = null;
if (newLen < 1)
    return y;
if (x.length == newLen || newLen == 1) {
    y = new double[x.length];
    System.arraycopy(x, 0, y, 0, x.length);
    return y;
} else {
...