Package org.apache.sis.internal.util

Examples of org.apache.sis.internal.util.DoubleDouble

{@code DoubleDouble} is used as an alternative to {@link java.math.BigDecimal} when we do not need arbitraryprecision, we do not want to convert from base 2 to base 10, we need support for NaN and infinities, we want more compact storage and better performance. {@code DoubleDouble} can be converted to {@code BigDecimal} asbelow: {@preformat javaBigDecimal decimal = new BigDecimal(dd.value).add(new BigDecimal(dd.error));}We do not provide convenience method for the above in order to avoid dependency to {@code BigDecimal}. {@section Impact of availability of FMA instructions}If fused multiply-add (FMA) instruction are available in a future Java version (see SIS-136 on Apache SIS JIRA), then the following methods should be revisited: @author Martin Desruisseaux (Geomatys) @since 0.4 @version 0.4 @module @see Wikipedia: Double-double arithmetic

        double v3;
        do if (i == 0) return Math.hypot(v1, v2);
        while ((v3 = vector[--i]) == 0);

        // Usual magnitude computation, but using double-double arithmetic.
        final DoubleDouble sum = new DoubleDouble();
        final DoubleDouble dot = new DoubleDouble();
        sum.setToProduct(v1, v1);
        dot.setToProduct(v2, v2); sum.add(dot);
        dot.setToProduct(v3, v3); sum.add(dot);
        while (i != 0) {
            v1 = vector[--i];
            dot.setToProduct(v1, v1);
            sum.add(dot);
        }
        sum.sqrt();
        return sum.value;
    }
View Full Code Here

TOP

Related Classes of org.apache.sis.internal.util.DoubleDouble

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.