Documentation of 'mikera.vectorz.Vectorz' Java class
Vectorz
mikera.vectorz

Class Vectorz



  • public class Vectorz
    extends java.lang.Object
    • Field Detail

      • TEST_EPSILON

        public static final double TEST_EPSILON
        Constant tolerance used for testing double values
        See Also:
        Constant Field Values
      • MIN_SPARSE_LENGTH

        public static final int MIN_SPARSE_LENGTH
        Specified the minimum length at which it is worthwhile creating sparse vectors rather than dense vectors. This acts as a hint to modify the behaviour of sparse vector construction functions.
        See Also:
        Constant Field Values
    • Method Detail

      • create

        public static AVector create(double... data)
        Creates a vector using the given double data, using the most efficient dense representation.
        Parameters:
        data -
        Returns:
      • join

        public static AVector join(AVector first,
                                   AVector second)
        Creates a joined vector that refers to the two underlying vectors
        Parameters:
        first -
        second -
        Returns:
      • join

        public static AVector join(AVector... vectors)
        Join one or more vectors into a single concatenated vector
        Parameters:
        vectors -
        Returns:
      • join

        public static AVector join(java.util.List<AVector> vectors)
        Join a list of vectors into a single concatenated vector
        Parameters:
        vectors -
        Returns:
      • createZeroVector

        public static AVector createZeroVector(long l)
        Creates an immutable zero vector of the specified length.
        Parameters:
        l -
        Returns:
      • wrap

        public static Vector wrap(double... data)
        Wraps a double array as a Vector instance. Changes to the double array will be reflected in the Vector
        Parameters:
        data -
        Returns:
      • wrap

        public static AVector wrap(double[][] data)
      • wrap

        public static ADenseArrayVector wrap(double[] data,
                                             int offset,
                                             int length)
      • wrapStrided

        public static AStridedVector wrapStrided(double[] data,
                                                 int offset,
                                                 int length,
                                                 int stride)
      • newVector

        public static AVector newVector(int length)
        Returns a new mutable vector filled with zeros of the specified length. Attempts to select the most efficient dense mutable concrete Vector type for any given length.
        Parameters:
        length -
        Returns:
      • createSparse

        public static AVector createSparse(AVector v)
        Creates a sparse vector from the data in the given vector. Selects the appropriate sparse vector type based on analysis of the element values. The sparse vector may or may not be mutable.
        Parameters:
        v - Vector containing sparse element data
        Returns:
      • createSparse

        public static AVector createSparse(java.lang.Object... values)
        Creates a sparse vector from an array of Object values
        Parameters:
        values -
        Returns:
      • createSparse

        public static AVector createSparse(java.lang.Object data)
        Creates a sparse vector from an array of Object values
        Parameters:
        values -
        Returns:
      • createSparseMutable

        public static AVector createSparseMutable(int length)
        Creates a mutable sparse vector from the data in the given vector. Selects the appropriate sparse vector type based on analysis of the element values.
        Parameters:
        v - Vector containing sparse element data
        Returns:
      • createSparseMutable

        public static AVector createSparseMutable(AVector v)
      • createSameSize

        public static AVector createSameSize(AVector v)
        Creates a new zero-filled vector of the same size as the given Vector.
        Parameters:
        v -
        Returns:
      • create

        public static AVector create(AVector vector)
        Creates a mutable clone of a given vector
        Parameters:
        vector -
        Returns:
      • create

        public static AVector create(IVector vector)
        Creates a mutable clone of a given vector
        Parameters:
        vector -
        Returns:
      • create

        public static AVector create(AIndex index)
        Creates a new vector containing the values in the specified index
        Parameters:
        index -
        Returns:
      • createScalar

        public static Scalar createScalar(double value)
      • createUniformRandomVector

        public static AVector createUniformRandomVector(int dimensions)
        Creates a random vector containing the specified number of elements. Each element will be randomly distributed in the range [0,1)
        Parameters:
        dimensions -
        Returns:
      • createMutableVector

        @Deprecated
        public static AVector createMutableVector(AVector v)
        Deprecated. 
      • immutableZeroVector

        public static AVector immutableZeroVector(int dimensions)
        Returns an immutable vector of zeros
        Parameters:
        dimensions -
        Returns:
      • parse

        public static AVector parse(java.lang.String ednString)
        Parse a vector in edn format
        Parameters:
        ednString -
        Returns:
      • create

        public static AVector create(java.util.List<java.lang.Object> d)
        Create a vector from a list of numerical values (objects should be java.lang.Number instances)
      • create

        public static AVector create(java.nio.DoubleBuffer d)
        Create a vector from a DoubleBuffer Note: consumes all doubles from the buffer
      • create

        public static AVector create(java.lang.Iterable<java.lang.Object> d)
        Create a vector from an arbitrary iterable object
        Parameters:
        d -
        Returns:
      • minValue

        @Deprecated
        public static double minValue(AVector v)
        Deprecated. 
        Returns the minimum-valued component in a vector
        Parameters:
        v -
        Returns:
      • indexOfMinValue

        @Deprecated
        public static int indexOfMinValue(AVector v)
        Deprecated. 
        Returns the index of the minimum-valued component in a vector
        Parameters:
        v -
        Returns:
      • maxValue

        @Deprecated
        public static double maxValue(AVector v)
        Deprecated. 
      • indexOfMaxValue

        @Deprecated
        public static int indexOfMaxValue(AVector v)
        Deprecated. 
      • invSqrt

        public static void invSqrt(AVector v)
      • swap

        public static void swap(AVector a,
                                AVector b)
        Swaps two vectors, mutating both.
        Parameters:
        a -
        b -
      • invSqrt

        public static void invSqrt(Vector v)
      • totalValue

        @Deprecated
        public static double totalValue(AVector v)
        Deprecated. 
      • averageValue

        @Deprecated
        public static double averageValue(AVector v)
        Deprecated. 
      • averageSquaredDifference

        @Deprecated
        public static double averageSquaredDifference(AVector a,
                                                                  AVector b)
        Deprecated. 
      • rmsDifference

        public static double rmsDifference(AVector a,
                                           AVector b)
      • fillRandom

        public static void fillRandom(AVector v)
        Fills a vector with uniform random numbers in the range [0..1)
        Parameters:
        v -
      • fillIndexes

        public static void fillIndexes(AVector v)
        Fills a vector with index values
        Parameters:
        v -
      • fillGaussian

        public static void fillGaussian(AVector v)
      • fillGaussian

        public static void fillGaussian(AVector v,
                                        java.util.Random r)
      • fillGaussian

        public static void fillGaussian(AVector v,
                                        double mean,
                                        double sd)
      • fillGaussian

        public static void fillGaussian(AVector v,
                                        double mean,
                                        double sd,
                                        java.util.Random r)
      • fillBinaryRandom

        public static void fillBinaryRandom(AVector v)
      • axisVector

        public static AVector axisVector(int axisIndex,
                                         int dimensions)
      • fillBinaryRandom

        public static void fillBinaryRandom(AVector v,
                                            double prob)
      • toVector

        public static AVector toVector(java.lang.Object o)
        Coerce to AVector. Avoids copying if possible.
        Parameters:
        o -
        Returns:
      • create

        public static AVector create(java.lang.Object o)
        Creates a vector from the given source data. Copies undelying data as needed.
        Parameters:
        o -
        Returns:
      • createMutableRange

        public static AVector createMutableRange(int length)
        Create a mutable vector contain the sequence of integers from 0 to length-1
        Parameters:
        length - The length of vector to create
        Returns:
      • createRange

        public static AVector createRange(int length)
        Create an immutable vector contain the sequence of integers from 0 to length-1
        Parameters:
        length - The length of vector to create
        Returns:
      • createRepeatedElement

        public static AVector createRepeatedElement(int length,
                                                    double value)
        Create an immutable vector containing a single repeated value. Guaranteed to be O(1).
        Parameters:
        length -
        value -
        Returns:
      • safeLongToInt

        public static int safeLongToInt(long value)
        Cast a long to an int value, and throws an exception if the result does not fit in an int
        Parameters:
        value - A long value
        Returns:
        An int equal to the long value argument
        Throws:
        java.lang.IllegalArgumentException - if the long value is out of range for an int
      • fillRandom

        public static void fillRandom(AVector v,
                                      long seed)
        Fills a mutable vector with random double values in the range [0..1)
      • fillRandom

        public static void fillRandom(AVector v,
                                      java.util.Random random)
        Fills a mutable vector with random double values in the range [0..1)
      • fillNormal

        public static void fillNormal(AVector v,
                                      long seed)
        Fills a mutable vector with random normally distributed values
      • fillNormal

        public static void fillNormal(AVector v,
                                      java.util.Random random)
        Fills a mutable vector with random normally distributed values
      • isUncountable

        public static boolean isUncountable(double value)
        Utility function to test whether a double value is uncountable Uncountable values are NaN and infinity
        Parameters:
        value -
        Returns:

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.