Search in sources :

Example 6 with Vector

use of org.apache.sis.math.Vector in project sis by apache.

the class ImageFileDirectory method extremum.

/**
 * Computes the minimal or maximal values of the given vector. Those vectors do not need to have the same length.
 * One of those two vector will be modified in-place.
 *
 * @param  a    the first vector, or {@code null} if none.
 * @param  b    the new vector to combine with the existing one. Can not be null.
 * @param  max  {@code true} for computing the maximal values, or {@code false} for the minimal value.
 */
private static Vector extremum(Vector a, Vector b, final boolean max) {
    if (a != null) {
        int s = b.size();
        int i = a.size();
        if (i > s) {
            // If a vector is longer than b, swap a and b.
            i = s;
            final Vector t = a;
            a = b;
            b = t;
        }
        while (--i >= 0) {
            // At this point, 'b' shall be the longest vector.
            final double va = a.doubleValue(i);
            final double vb = b.doubleValue(i);
            if (Double.isNaN(vb) || (max ? va > vb : va < vb)) {
                b.set(i, va);
            }
        }
    }
    return b;
}
Also used : Vector(org.apache.sis.math.Vector)

Aggregations

Vector (org.apache.sis.math.Vector)6 Point (com.esri.core.geometry.Point)1 Polyline (com.esri.core.geometry.Polyline)1 Line2D (java.awt.geom.Line2D)1 Path2D (java.awt.geom.Path2D)1 Instant (java.time.Instant)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 Set (java.util.Set)1 LocalizationGridBuilder (org.apache.sis.referencing.operation.builder.LocalizationGridBuilder)1 LinearTransform (org.apache.sis.referencing.operation.transform.LinearTransform)1 CorruptedObjectException (org.apache.sis.util.CorruptedObjectException)1 Test (org.junit.Test)1 MathTransform (org.opengis.referencing.operation.MathTransform)1 FactoryException (org.opengis.util.FactoryException)1