Java Code Examples for org.apache.commons.math3.util.FastMath#scalb()

The following examples show how to use org.apache.commons.math3.util.FastMath#scalb() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Vector3DTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testCrossProductCancellation() {
    Vector3D v1 = new Vector3D(9070467121.0, 4535233560.0, 1);
    Vector3D v2 = new Vector3D(9070467123.0, 4535233561.0, 1);
    checkVector(Vector3D.crossProduct(v1, v2), -1, 2, 1);

    double scale    = FastMath.scalb(1.0, 100);
    Vector3D big1   = new Vector3D(scale, v1);
    Vector3D small2 = new Vector3D(1 / scale, v2);
    checkVector(Vector3D.crossProduct(big1, small2), -1, 2, 1);

}
 
Example 2
Source File: Vector3DTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testCrossProductCancellation() {
    Vector3D v1 = new Vector3D(9070467121.0, 4535233560.0, 1);
    Vector3D v2 = new Vector3D(9070467123.0, 4535233561.0, 1);
    checkVector(Vector3D.crossProduct(v1, v2), -1, 2, 1);

    double scale    = FastMath.scalb(1.0, 100);
    Vector3D big1   = new Vector3D(scale, v1);
    Vector3D small2 = new Vector3D(1 / scale, v2);
    checkVector(Vector3D.crossProduct(big1, small2), -1, 2, 1);

}
 
Example 3
Source File: FieldVector3DTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testCrossProductCancellation() {
    FieldVector3D<DerivativeStructure> v1 = createVector(9070467121.0, 4535233560.0, 1, 3);
    FieldVector3D<DerivativeStructure> v2 = createVector(9070467123.0, 4535233561.0, 1, 3);
    checkVector(FieldVector3D.crossProduct(v1, v2), -1, 2, 1);

    double scale    = FastMath.scalb(1.0, 100);
    FieldVector3D<DerivativeStructure> big1   = new FieldVector3D<DerivativeStructure>(scale, v1);
    FieldVector3D<DerivativeStructure> small2 = new FieldVector3D<DerivativeStructure>(1 / scale, v2);
    checkVector(FieldVector3D.crossProduct(big1, small2), -1, 2, 1);

}
 
Example 4
Source File: SparseGradient.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
public SparseGradient scalb(final int n) {
    final SparseGradient out = new SparseGradient(FastMath.scalb(value, n), Collections.<Integer, Double> emptyMap());
    for (Map.Entry<Integer, Double> entry : derivatives.entrySet()) {
        out.derivatives.put(entry.getKey(), FastMath.scalb(entry.getValue(), n));
    }
    return out;
}
 
Example 5
Source File: FieldVector3DTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testCrossProductCancellation() {
    FieldVector3D<DerivativeStructure> v1 = createVector(9070467121.0, 4535233560.0, 1, 3);
    FieldVector3D<DerivativeStructure> v2 = createVector(9070467123.0, 4535233561.0, 1, 3);
    checkVector(FieldVector3D.crossProduct(v1, v2), -1, 2, 1);

    double scale    = FastMath.scalb(1.0, 100);
    FieldVector3D<DerivativeStructure> big1   = new FieldVector3D<DerivativeStructure>(scale, v1);
    FieldVector3D<DerivativeStructure> small2 = new FieldVector3D<DerivativeStructure>(1 / scale, v2);
    checkVector(FieldVector3D.crossProduct(big1, small2), -1, 2, 1);

}
 
Example 6
Source File: Vector3DTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testCrossProductCancellation() {
    Vector3D v1 = new Vector3D(9070467121.0, 4535233560.0, 1);
    Vector3D v2 = new Vector3D(9070467123.0, 4535233561.0, 1);
    checkVector(Vector3D.crossProduct(v1, v2), -1, 2, 1);

    double scale    = FastMath.scalb(1.0, 100);
    Vector3D big1   = new Vector3D(scale, v1);
    Vector3D small2 = new Vector3D(1 / scale, v2);
    checkVector(Vector3D.crossProduct(big1, small2), -1, 2, 1);

}
 
Example 7
Source File: DerivativeStructure.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc}
 * @since 3.2
 */
public DerivativeStructure scalb(final int n) {
    final DerivativeStructure ds = new DerivativeStructure(compiler);
    for (int i = 0; i < ds.data.length; ++i) {
        ds.data[i] = FastMath.scalb(data[i], n);
    }
    return ds;
}
 
Example 8
Source File: FieldVector3DTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testCrossProductCancellation() {
    FieldVector3D<DerivativeStructure> v1 = createVector(9070467121.0, 4535233560.0, 1, 3);
    FieldVector3D<DerivativeStructure> v2 = createVector(9070467123.0, 4535233561.0, 1, 3);
    checkVector(FieldVector3D.crossProduct(v1, v2), -1, 2, 1);

    double scale    = FastMath.scalb(1.0, 100);
    FieldVector3D<DerivativeStructure> big1   = new FieldVector3D<DerivativeStructure>(scale, v1);
    FieldVector3D<DerivativeStructure> small2 = new FieldVector3D<DerivativeStructure>(1 / scale, v2);
    checkVector(FieldVector3D.crossProduct(big1, small2), -1, 2, 1);

}
 
Example 9
Source File: Vector3DTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testCrossProductCancellation() {
    Vector3D v1 = new Vector3D(9070467121.0, 4535233560.0, 1);
    Vector3D v2 = new Vector3D(9070467123.0, 4535233561.0, 1);
    checkVector(Vector3D.crossProduct(v1, v2), -1, 2, 1);

    double scale    = FastMath.scalb(1.0, 100);
    Vector3D big1   = new Vector3D(scale, v1);
    Vector3D small2 = new Vector3D(1 / scale, v2);
    checkVector(Vector3D.crossProduct(big1, small2), -1, 2, 1);

}
 
Example 10
Source File: DerivativeStructure.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
public DerivativeStructure scalb(final int n) {
    final DerivativeStructure ds = new DerivativeStructure(compiler);
    for (int i = 0; i < ds.data.length; ++i) {
        ds.data[i] = FastMath.scalb(data[i], n);
    }
    return ds;
}
 
Example 11
Source File: SparseGradient.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
public SparseGradient scalb(final int n) {
    final SparseGradient out = new SparseGradient(FastMath.scalb(value, n), Collections.<Integer, Double> emptyMap());
    for (Map.Entry<Integer, Double> entry : derivatives.entrySet()) {
        out.derivatives.put(entry.getKey(), FastMath.scalb(entry.getValue(), n));
    }
    return out;
}
 
Example 12
Source File: FieldVector3DTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testCrossProductCancellation() {
    FieldVector3D<DerivativeStructure> v1 = createVector(9070467121.0, 4535233560.0, 1, 3);
    FieldVector3D<DerivativeStructure> v2 = createVector(9070467123.0, 4535233561.0, 1, 3);
    checkVector(FieldVector3D.crossProduct(v1, v2), -1, 2, 1);

    double scale    = FastMath.scalb(1.0, 100);
    FieldVector3D<DerivativeStructure> big1   = new FieldVector3D<DerivativeStructure>(scale, v1);
    FieldVector3D<DerivativeStructure> small2 = new FieldVector3D<DerivativeStructure>(1 / scale, v2);
    checkVector(FieldVector3D.crossProduct(big1, small2), -1, 2, 1);

}
 
Example 13
Source File: Vector3DTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testCrossProductCancellation() {
    Vector3D v1 = new Vector3D(9070467121.0, 4535233560.0, 1);
    Vector3D v2 = new Vector3D(9070467123.0, 4535233561.0, 1);
    checkVector(Vector3D.crossProduct(v1, v2), -1, 2, 1);

    double scale    = FastMath.scalb(1.0, 100);
    Vector3D big1   = new Vector3D(scale, v1);
    Vector3D small2 = new Vector3D(1 / scale, v2);
    checkVector(Vector3D.crossProduct(big1, small2), -1, 2, 1);

}
 
Example 14
Source File: DerivativeStructure.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc}
 * @since 3.2
 */
public DerivativeStructure scalb(final int n) {
    final DerivativeStructure ds = new DerivativeStructure(compiler);
    for (int i = 0; i < ds.data.length; ++i) {
        ds.data[i] = FastMath.scalb(data[i], n);
    }
    return ds;
}
 
Example 15
Source File: Vector3DTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testCrossProductCancellation() {
    Vector3D v1 = new Vector3D(9070467121.0, 4535233560.0, 1);
    Vector3D v2 = new Vector3D(9070467123.0, 4535233561.0, 1);
    checkVector(Vector3D.crossProduct(v1, v2), -1, 2, 1);

    double scale    = FastMath.scalb(1.0, 100);
    Vector3D big1   = new Vector3D(scale, v1);
    Vector3D small2 = new Vector3D(1 / scale, v2);
    checkVector(Vector3D.crossProduct(big1, small2), -1, 2, 1);

}
 
Example 16
Source File: Vector3DTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testCrossProductCancellation() {
    Vector3D v1 = new Vector3D(9070467121.0, 4535233560.0, 1);
    Vector3D v2 = new Vector3D(9070467123.0, 4535233561.0, 1);
    checkVector(Vector3D.crossProduct(v1, v2), -1, 2, 1);

    double scale    = FastMath.scalb(1.0, 100);
    Vector3D big1   = new Vector3D(scale, v1);
    Vector3D small2 = new Vector3D(1 / scale, v2);
    checkVector(Vector3D.crossProduct(big1, small2), -1, 2, 1);

}
 
Example 17
Source File: DerivativeStructure.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Multiply the instance by a power of 2.
 * @param n power of 2
 * @return this &times; 2<sup>n</sup>
 */
public DerivativeStructure scalb(final int n) {
    final DerivativeStructure ds = new DerivativeStructure(compiler);
    for (int i = 0; i < ds.data.length; ++i) {
        ds.data[i] = FastMath.scalb(data[i], n);
    }
    return ds;
}
 
Example 18
Source File: FieldVector3DTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testCrossProductCancellation() {
    FieldVector3D<DerivativeStructure> v1 = createVector(9070467121.0, 4535233560.0, 1, 3);
    FieldVector3D<DerivativeStructure> v2 = createVector(9070467123.0, 4535233561.0, 1, 3);
    checkVector(FieldVector3D.crossProduct(v1, v2), -1, 2, 1);

    double scale    = FastMath.scalb(1.0, 100);
    FieldVector3D<DerivativeStructure> big1   = new FieldVector3D<DerivativeStructure>(scale, v1);
    FieldVector3D<DerivativeStructure> small2 = new FieldVector3D<DerivativeStructure>(1 / scale, v2);
    checkVector(FieldVector3D.crossProduct(big1, small2), -1, 2, 1);

}
 
Example 19
Source File: Vector3DTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testCrossProductCancellation() {
    Vector3D v1 = new Vector3D(9070467121.0, 4535233560.0, 1);
    Vector3D v2 = new Vector3D(9070467123.0, 4535233561.0, 1);
    checkVector(Vector3D.crossProduct(v1, v2), -1, 2, 1);

    double scale    = FastMath.scalb(1.0, 100);
    Vector3D big1   = new Vector3D(scale, v1);
    Vector3D small2 = new Vector3D(1 / scale, v2);
    checkVector(Vector3D.crossProduct(big1, small2), -1, 2, 1);

}
 
Example 20
Source File: DerivativeStructure.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc}
 * @since 3.2
 */
public DerivativeStructure scalb(final int n) {
    final DerivativeStructure ds = new DerivativeStructure(compiler);
    for (int i = 0; i < ds.data.length; ++i) {
        ds.data[i] = FastMath.scalb(data[i], n);
    }
    return ds;
}