/** {@inheritDoc} */ public double value(double x) { return FastMath.log10(x); }
/** Base 10 logarithm. * @return base 10 logarithm of the instance * @since 3.2 */ public Decimal64 log10() { return new Decimal64(FastMath.log10(value)); }
/** Base 10 logarithm. * @return base 10 logarithm of the instance */ public SparseGradient log10() { return new SparseGradient(FastMath.log10(value), 1.0 / (FastMath.log(10.0) * value), derivatives); }
/** Computes base 10 logarithm of a derivative structure. * @param operand array holding the operand * @param operandOffset offset of the operand in its array * @param result array where result must be stored (for * base 10 logarithm the result array <em>cannot</em> be the input array) * @param resultOffset offset of the result in its array */ public void log10(final double[] operand, final int operandOffset, final double[] result, final int resultOffset) { // create the function value and derivatives double[] function = new double[1 + order]; function[0] = FastMath.log10(operand[operandOffset]); if (order > 0) { double inv = 1.0 / operand[operandOffset]; double xk = inv / FastMath.log(10.0); for (int i = 1; i <= order; ++i) { function[i] = xk; xk *= -i * inv; } } // apply function composition compose(operand, operandOffset, function, result, resultOffset); }
final double log10R = FastMath.log10(FastMath.max(1.0e-10, tol)); int targetIter = FastMath.max(1, FastMath.min(sequence.length - 2,
public static double toSpecialType(final double value, Type type) { return (type == Type.LINEAR) ? value : FastMath.log10(value); }
/** {@inheritDoc} */ public double value(double x) { return FastMath.log10(x); }
/** Base 10 logarithm. * @return base 10 logarithm of the instance * @since 3.2 */ public Decimal64 log10() { return new Decimal64(FastMath.log10(value)); }
/** Base 10 logarithm. * @return base 10 logarithm of the instance */ public SparseGradient log10() { return new SparseGradient(FastMath.log10(value), 1.0 / (FastMath.log(10.0) * value), derivatives); }
@Override public void run() { for (long k = firstIdx; k < lastIdx; k++) { res.setDouble(k, FastMath.log10(a.getDouble(k))); } } });
/** Computes base 10 logarithm of a derivative structure. * @param operand array holding the operand * @param operandOffset offset of the operand in its array * @param result array where result must be stored (for * base 10 logarithm the result array <em>cannot</em> be the input array) * @param resultOffset offset of the result in its array */ public void log10(final double[] operand, final int operandOffset, final double[] result, final int resultOffset) { // create the function value and derivatives double[] function = new double[1 + order]; function[0] = FastMath.log10(operand[operandOffset]); if (order > 0) { double inv = 1.0 / operand[operandOffset]; double xk = inv / FastMath.log(10.0); for (int i = 1; i <= order; ++i) { function[i] = xk; xk *= -i * inv; } } // apply function composition compose(operand, operandOffset, function, result, resultOffset); }
@Test public void testMathLog10Fast() { for (double i = 0; i < numItr; ++i) { double val = FastMath.log10(i); } }
public void testLog10() { System.gc(); double x = 0; long time = System.nanoTime(); for (int i = 0; i < RUNS; i++) x += StrictMath.log10(Math.PI + i/* 1.0 + i/1e9 */); long strictMath = System.nanoTime() - time; System.gc(); double y = 0; time = System.nanoTime(); for (int i = 0; i < RUNS; i++) y += FastMath.log10(Math.PI + i/* 1.0 + i/1e9 */); long fastTime = System.nanoTime() - time; System.gc(); double z = 0; time = System.nanoTime(); for (int i = 0; i < RUNS; i++) z += Math.log10(Math.PI + i/* 1.0 + i/1e9 */); long mathTime = System.nanoTime() - time; report("log10", x + y + z, strictMath, fastTime, mathTime); }
/** * Rounds the value to the significant figures. * <p> * Algorithm takes from <a href= * "http://stackoverflow.com/questions/202302/rounding-to-an-arbitrary-number-of-significant-digits" * >rounding to an arbitrary number of significant digits * [stackoverflow.com]</a> * * @param value * the value. * * @param significant * the significant figures. * * @return the rounded value. */ public static double roundToSignificant(double value, int significant) { if (value == 0) { return 0; } double d = ceil(log10(abs(value))); int power = significant - (int) d; double magnitude = pow(10, power); long shifted = round(value * magnitude); return shifted / magnitude; }
public ValueType log10(CalculatedValue g) { if (g.isComplex() || g.real <= 0.0) { return setComplexValue(g.getComplex().log().divide(FastMath.log(10.0))); } else { return setValue(FastMath.log10(g.real)); } }
if (a.isConstant()) { if (out_type.isIntegerNumericType() || out_type.isRealNumericType()) { return LargeArrayUtils.createConstant(out_type, length, FastMath.log10(a.getDouble(0))); } else if (out_type == LargeArrayType.COMPLEX_FLOAT) { float[] elem_a = ((ComplexFloatLargeArray) a).getComplexFloat(0); if (nthreads < 2 || length < ConcurrencyUtils.getConcurrentThreshold()) { for (long i = 0; i < length; i++) { res.setDouble(i, FastMath.log10(a.getDouble(i))); } catch (InterruptedException | ExecutionException ex) { for (long i = 0; i < length; i++) { res.setDouble(i, FastMath.log10(a.getDouble(i)));
final double log10R = FastMath.log10(FastMath.max(1.0e-10, tol)); int targetIter = FastMath.max(1, FastMath.min(sequence.length - 2,