Example usage for java.lang Math log10

List of usage examples for java.lang Math log10

Introduction

In this page you can find the example usage for java.lang Math log10.

Prototype

@HotSpotIntrinsicCandidate
public static double log10(double a) 

Source Link

Document

Returns the base 10 logarithm of a double value.

Usage

From source file:grafix.telas.MolduraAreaDados.java

private Point2D converterPontoNaMolduraParaPlot_EixoLog(final Point2D pontoMoldura) {
    XYPlot plot = getPlot();//from   w  ww  . j a  va 2s  .co  m
    ValueAxis vAxis = plot.getRangeAxis();
    ValueAxis dAxis = plot.getDomainAxis();
    double fracaoX = pontoMoldura.getX() / this.getWidth();
    double fracaoYlog = 1 - (pontoMoldura.getY() / this.getHeight());
    double dX = dAxis.getUpperBound() - dAxis.getLowerBound();
    double dYlog = Math.log10(vAxis.getUpperBound()) - Math.log10(vAxis.getLowerBound());
    double ylog = Math.log10(vAxis.getLowerBound()) + fracaoYlog * dYlog;
    return new Point2D.Double(dAxis.getLowerBound() + dX * fracaoX, Math.pow(10, ylog));
}

From source file:org.whitesource.agent.hash.HashCalculator.java

/**
 * Calculates 3 hashes for the given bytes:
 *
 * 1. Hash of the file without new lines and whitespaces
 * 2. Hash of the most significant bits of the file without new lines and whitespaces
 * 3. Hash of the least significant bits of the file without new lines and whitespaces
 *
 * @param bytes to calculate/*from   w w  w .ja  va 2 s .c  o m*/
 * @return HashCalculationResult with all three hashes
 * @throws IOException exception2
 */
public HashCalculationResult calculateSuperHash(byte[] bytes) throws IOException {
    HashCalculationResult result = null;

    // Remove white spaces
    byte[] bytesWithoutSpaces = stripWhiteSpaces(bytes);

    long fileSize = bytesWithoutSpaces.length;
    if (fileSize < FILE_MIN_SIZE_THRESHOLD) {
        // Ignore files smaller 1/2 kb
        logger.debug("Ignoring file with size " + FileUtils.byteCountToDisplaySize(fileSize)
                + ": minimum file size is 512B");
    } else if (fileSize <= FILE_PARTIAL_HASH_MIN_SIZE) {
        // Don't calculate msb and lsb hashes for files smaller than 2kb
        String fullFileHash = calculateByteArrayHash(bytesWithoutSpaces, HashAlgorithm.SHA1);
        result = new HashCalculationResult(fullFileHash);
    } else if (fileSize <= FILE_SMALL_SIZE) {
        // Handle 2kb->3kb files
        result = hashBuckets(bytesWithoutSpaces, FILE_SMALL_BUCKET_SIZE);
    } else {
        int baseLowNumber = 1;
        int digits = (int) Math.log10(fileSize);
        int i = 0;
        while (i < digits) {
            baseLowNumber = baseLowNumber * 10;
            i++;
        }
        double highNumber = Math.ceil((fileSize + 1) / (float) baseLowNumber) * baseLowNumber;
        double lowNumber = highNumber - baseLowNumber;
        double bucketSize = (highNumber + lowNumber) / 4;
        result = hashBuckets(bytesWithoutSpaces, bucketSize);
    }
    return result;
}

From source file:org.apache.drill.exec.fn.impl.TestNewMathFunctions.java

@Test
public void testExtendedMathFunc() throws Throwable {
    final BigDecimal d = new BigDecimal(
            "100111111111111111111111111111111111.00000000000000000000000000000000000000000000000000001");
    final Object[] expected = new Object[] { Math.cbrt(1000), Math.log(10), Math.log10(5),
            (Math.log(64.0) / Math.log(2.0)), Math.exp(10), Math.toDegrees(0.5), Math.toRadians(45.0), Math.PI,
            Math.cbrt(d.doubleValue()), Math.log(d.doubleValue()), (Math.log(d.doubleValue()) / Math.log(2)),
            Math.exp(d.doubleValue()), Math.toDegrees(d.doubleValue()), Math.toRadians(d.doubleValue()) };
    runTest(expected, "functions/testExtendedMathFunctions.json");
}

From source file:org.lightjason.agentspeak.action.builtin.TestCActionMath.java

/**
 * data provider generator for single-value tests
 * @return data//from w  w w . j a v a 2s  . c om
 */
@DataProvider
public static Object[] singlevaluegenerate() {
    return Stream.concat(

            singlevaluetestcase(

                    Stream.of(2.5, 9.1, 111.7, 889.9),

                    Stream.of(CNextPrime.class),

                    (i) -> (double) Primes.nextPrime(i.intValue())),

            singlevaluetestcase(

                    Stream.of(-2, -6, 4, -1, -5, 3, 49, 30, 6, 5, 1.3, 2.8, 9.7, 1, 8, 180, Math.PI),

                    Stream.of(CAbs.class, CACos.class, CASin.class, CATan.class, CCeil.class, CCos.class,
                            CCosh.class, CDegrees.class, CExp.class, CIsPrime.class, CLog.class, CLog10.class,
                            CFloor.class, CRadians.class, CRound.class, CSignum.class, CSin.class, CSinh.class,
                            CSqrt.class, CTan.class, CTanh.class),

                    (i) -> Math.abs(i.doubleValue()), (i) -> Math.acos(i.doubleValue()),
                    (i) -> Math.asin(i.doubleValue()), (i) -> Math.atan(i.doubleValue()),
                    (i) -> Math.ceil(i.doubleValue()), (i) -> Math.cos(i.doubleValue()),
                    (i) -> Math.cosh(i.doubleValue()), (i) -> Math.toDegrees(i.doubleValue()),
                    (i) -> Math.exp(i.doubleValue()), (i) -> Primes.isPrime(i.intValue()),
                    (i) -> Math.log(i.doubleValue()), (i) -> Math.log10(i.doubleValue()),
                    (i) -> Math.floor(i.doubleValue()), (i) -> Math.toRadians(i.doubleValue()),
                    (i) -> Math.round(i.doubleValue()), (i) -> Math.signum(i.doubleValue()),
                    (i) -> Math.sin(i.doubleValue()), (i) -> Math.sinh(i.doubleValue()),
                    (i) -> Math.sqrt(i.doubleValue()), (i) -> Math.tan(i.doubleValue()),
                    (i) -> Math.tanh(i.doubleValue()))

    ).toArray();
}

From source file:org.orbisgis.sos.LeqStats.java

public double getLeqMean() {
    if (rmsSumCount > 0) {
        return 10 * Math.log10(rmsSum / rmsSumCount);
    } else {/*from  ww w.  j  a  v a2s  .c o m*/
        return 0;
    }
}

From source file:cn.edu.hfut.dmic.contentextractor.ContentExtractor.java

private double computeScore(Element tag) {
    CountInfo countInfo = infoMap.get(tag);
    double var = Math.sqrt(computeVar(countInfo.leafList) + 1);
    double score = Math.log(var) * countInfo.densitySum
            * Math.log(countInfo.textCount - countInfo.linkTextCount + 1) * Math.log10(countInfo.pCount + 10);
    return score;
}

From source file:com.lfv.lanzius.application.SoundClip.java

public synchronized void setVolume(float volume) {
    if (stream != null && clip != null) {
        volume *= volumeAdjustment;//from   w  ww . ja  v  a2 s .com
        if (volume < 0.0001f)
            volume = 0.0001f;
        float gain_dB = (float) (20.0 * Math.log10(volume));
        FloatControl ctrl = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);
        gain_dB = Math.max(gain_dB, ctrl.getMinimum());
        gain_dB = Math.min(gain_dB, ctrl.getMaximum());
        ctrl.setValue(gain_dB);
    }
}

From source file:org.apache.flink.table.runtime.functions.SqlFunctionUtils.java

public static double log10(double x) {
    return Math.log10(x);
}

From source file:com.zhihu.android.app.mirror.widget.ArtboardView.java

private void onActionMove(MotionEvent event) {
    mDragDistance = event.getY() - mActionDownY;
    mIsDragDown = mDragDistance > 0.0F;

    float dragFraction = (float) Math.log10(1.0F + (Math.abs(mDragDistance) / mDragDismissDistance));
    float dragTo = dragFraction * mDragDismissDistance * mDragElacticity;
    setTranslationY(mIsDragDown ? dragTo : -dragTo);
    if (mCallback != null) {
        mCallback.onDrag(this, mDragDismissDistance, dragTo);
    }//from ww  w .  jav  a 2 s  .c o  m
}

From source file:interpolation.InteractiveRegression.java

protected static double computeValueFromDoubleExpScrollbarPosition(final int scrollbarPosition,
        final int scrollbarMax, final double maxValue) {
    final int maxScrollHalf = scrollbarMax / 2;
    final int scrollPos = scrollbarPosition - maxScrollHalf;

    final double logMax = Math.log10(maxScrollHalf + 1);

    final double value = Math.min(maxValue,
            ((logMax - Math.log10(maxScrollHalf + 1 - Math.abs(scrollPos))) / logMax) * maxValue);

    if (scrollPos < 0)
        return -value;
    else/*w  ww  .j a  v a2 s.  c  o  m*/
        return value;
}