/** * fc(0, y) = f(g(0), h(y)) = f(0, h(y)) = 0 if g(0) = 0 and f isLikeLeftMult * @return true iff f(0, y) = 0 for any y */ @Override public boolean isLikeLeftMult() { return g.apply(0) == 0 && f.isLikeLeftMult(); }
/** * g(h(0, y)) = g(0) = 0 for any y iff g(0) = 0 and h isLikeLeftMult * @return true iff f(0, y) = 0 for any y */ @Override public boolean isLikeLeftMult() { return !g.isDensifying() && h.isLikeLeftMult(); }
/** * fc(x, 0) = f(g(x), h(0)) = f(g(x), 0) = 0 if h(0) = 0 and f isLikeRightMult * @return true iff f(x, 0) = 0 for any x */ @Override public boolean isLikeRightMult() { return h.apply(0) == 0 && f.isLikeRightMult(); }
/** Constructs a function that returns <tt>a / b</tt>. <tt>a</tt> is a variable, <tt>b</tt> is fixed. */ public static DoubleFunction div(double b) { return mult(1 / b); }
@Override public double apply(double var) { return function.apply(c, var); } };
/** * @return true iff f(x, y) = f(y, x) for any x, y AND f(x, f(y, z)) = f(f(x, y), z) for any x, y, z */ public boolean isAssociativeAndCommutative() { return isAssociative() && isCommutative(); }
/** * @return true iff f(x, 0) = f(0, y) = 0 for any x, y */ public boolean isLikeMult() { return isLikeLeftMult() && isLikeRightMult(); }
/** * g(h(x, 0)) = g(0) = 0 for any x iff g(0) = 0 and h isLikeRightMult * @return true iff f(x, 0) = 0 for any x */ @Override public boolean isLikeRightMult() { return !g.isDensifying() && h.isLikeRightMult(); }
private static int med3(double[] array, int a, int b, int c, DoubleComparator comp) { double x = array[a]; double y = array[b]; double z = array[c]; int comparisonxy = comp.compare(x, y); int comparisonxz = comp.compare(x, z); int comparisonyz = comp.compare(y, z); return comparisonxy < 0 ? (comparisonyz < 0 ? b : (comparisonxz < 0 ? c : a)) : (comparisonyz > 0 ? b : (comparisonxz > 0 ? c : a)); }
private static int med3(short[] array, int a, int b, int c, ShortComparator comp) { short x = array[a]; short y = array[b]; short z = array[c]; int comparisonxy = comp.compare(x, y); int comparisonxz = comp.compare(x, z); int comparisonyz = comp.compare(y, z); return comparisonxy < 0 ? (comparisonyz < 0 ? b : (comparisonxz < 0 ? c : a)) : (comparisonyz > 0 ? b : (comparisonxz > 0 ? c : a)); }
private static int med3(long[] array, int a, int b, int c, LongComparator comp) { long x = array[a]; long y = array[b]; long z = array[c]; int comparisonxy = comp.compare(x, y); int comparisonxz = comp.compare(x, z); int comparisonyz = comp.compare(y, z); return comparisonxy < 0 ? (comparisonyz < 0 ? b : (comparisonxz < 0 ? c : a)) : (comparisonyz > 0 ? b : (comparisonxz > 0 ? c : a)); }
@Override public boolean isValid(Vector x, Vector y, DoubleDoubleFunction f) { return f.isLikeLeftMult(); }
@Override public boolean isValid(Vector x, Vector y, DoubleDoubleFunction f) { return f.isLikeRightPlus(); }
/** <tt>a - b*constant</tt>. */ public static PlusMult minusMult(double constant) { return new PlusMult(-constant); }
@Override public double apply(double var) { return function.apply(var, c); } };
@Override public double apply(double a, double b) { return function.apply(b, a); } };
/** * @return true iff f(0, 0) != 0 */ public boolean isDensifying() { return apply(0.0, 0.0) != 0.0; } }