org.apache.ignite.ml.math.primitives.vector

## Class VectorUtils

- java.lang.Object
- - org.apache.ignite.ml.math.primitives.vector.VectorUtils

-     public class VectorUtils
      extends Object

  Some utils for `Vector`.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `VectorUtils()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static Vector` | `concat(Vector... vs)` Concatenates given vectors.
    `static Vector` | `concat(Vector v1, Vector... vs)` Concatenates given vectors.
    `static Vector` | `concat(Vector v1, Vector v2)` Concatenates two given vectors.
    `static Vector` | `copyPart(Vector v, int off, int len)` Get copy of part of given length of given vector starting from given offset.
    `static Vector` | `elementWiseMinus(Vector vec1, Vector vec2)` Performs in-place vector subtraction.
    `static Vector` | `elementWiseTimes(Vector vec1, Vector vec2)` Performs in-place vector multiplication.
    `static DenseVector` | `fill(double val, int n)` Create new vector of specified size n with specified value.
    `static IgniteFunction<Vector,Vector>` | `getProjector(int[] mapping)` Get projector from index mapping.
    `static double[]` | `num2Arr(double val)` Turn number to 1-sized array.
    `static Vector` | `num2Vec(double val)` Wrap specified value into vector.
    `static Vector` | `of(double... values)` Creates dense local on heap vector based on array of doubles.
    `static Vector` | `of(Double[] values)` Creates vector based on array of Doubles.
    `static NamedVector` | `of(Map<String,Double> values)` Creates named vector based on map of keys and values.
    `static double` | `vec2Num(Vector vec)` Turn Vector into number by looking at index of maximal element in vector.
    `static DenseVector` | `zeroes(int n)` Create new
    `static Vector` | `zeroesLike(Vector v)` Create new vector like given vector initialized by zeroes.
    `static Vector` | `zipWith(Vector v1, Vector v2, IgniteBiFunction<Double,Double,Double> f)` Zip two vectors with given binary function (i.e. apply binary function to both vector elementwise and construct vector from results).

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### VectorUtils

          public VectorUtils()

  - ### Method Detail

    - #### zeroesLike

          public static Vector zeroesLike(Vector v)

      Create new vector like given vector initialized by zeroes.

    - #### zeroes

          public static DenseVector zeroes(int n)

      Create new

    - #### fill

          public static DenseVector fill(double val,
                                         int n)

      Create new vector of specified size n with specified value.
      Parameters:
        `val` - Value.
        `n` - Size;
      Returns:
        New vector of specified size n with specified value.

    - #### num2Vec

          public static Vector num2Vec(double val)

      Wrap specified value into vector.
      Parameters:
        `val` - Value to wrap.
      Returns:
        Specified value wrapped into vector.

    - #### num2Arr

          public static double[] num2Arr(double val)

      Turn number to 1-sized array.
      Parameters:
        `val` - Value to wrap in array.
      Returns:
        Number wrapped in 1-sized array.

    - #### vec2Num

          public static double vec2Num(Vector vec)

      Turn Vector into number by looking at index of maximal element in vector.
      Parameters:
        `vec` - Vector to be turned into number.
      Returns:
        Number.

    - #### elementWiseTimes

          public static Vector elementWiseTimes(Vector vec1,
                                                Vector vec2)

      Performs in-place vector multiplication.
      Parameters:
        `vec1` - Operand to be changed and first multiplication operand.
        `vec2` - Second multiplication operand.
      Returns:
        Updated first operand.

    - #### elementWiseMinus

          public static Vector elementWiseMinus(Vector vec1,
                                                Vector vec2)

      Performs in-place vector subtraction.
      Parameters:
        `vec1` - Operand to be changed and subtracted from.
        `vec2` - Operand to subtract.
      Returns:
        Updated first operand.

    - #### zipWith

          public static Vector zipWith(Vector v1,
                                       Vector v2,
                                       IgniteBiFunction<Double,Double,Double> f)

      Zip two vectors with given binary function (i.e. apply binary function to both vector elementwise and construct vector from results). Example zipWith({0, 2, 4}, {1, 3, 5}, plus) = {0 + 1, 2 + 3, 4 + 5}. Length of result is length of shortest of vectors.
      Parameters:
        `v1` - First vector.
        `v2` - Second vector.
        `f` - Function to zip with.
      Returns:
        Result of zipping.

    - #### copyPart

          public static Vector copyPart(Vector v,
                                        int off,
                                        int len)

      Get copy of part of given length of given vector starting from given offset.
      Parameters:
        `v` - Vector to copy part from.
        `off` - Offset.
        `len` - Length.
      Returns:
        Copy of part of given length of given vector starting from given offset.

    - #### of

          public static Vector of(double... values)

      Creates dense local on heap vector based on array of doubles.
      Parameters:
        `values` - Values.

    - #### of

          public static Vector of(Double[] values)

      Creates vector based on array of Doubles. If array contains null-elements then method returns sparse local on head vector. In other case method returns dense local on heap vector.
      Parameters:
        `values` - Values.

    - #### of

          public static NamedVector of(Map<String,Double> values)

      Creates named vector based on map of keys and values.
      Parameters:
        `values` - Values.
      Returns:
        Named vector.

    - #### concat

          public static Vector concat(Vector v1,
                                      Vector v2)

      Concatenates two given vectors.
      Parameters:
        `v1` - First vector.
        `v2` - Second vector.
      Returns:
        Concatenation result.

    - #### concat

          public static Vector concat(Vector v1,
                                      Vector... vs)

      Concatenates given vectors.
      Parameters:
        `v1` - First vector.
        `vs` - Other vectors.
      Returns:
        Concatenation result.

    - #### concat

          public static Vector concat(Vector... vs)

      Concatenates given vectors.
      Parameters:
        `vs` - Other vectors.
      Returns:
        Concatenation result.

    - #### getProjector

          public static IgniteFunction<Vector,Vector> getProjector(int[] mapping)

      Get projector from index mapping.
      Parameters:
        `mapping` - Index mapping.
      Returns:
        Projector.

2022 Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.12.0
Release Date | : January 10 2022