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

## Class SparseVector

- java.lang.Object
- - org.apache.ignite.ml.math.primitives.vector.AbstractVector
  - - org.apache.ignite.ml.math.primitives.vector.impl.SparseVector

- All Implemented Interfaces:
    Externalizable, Serializable, Destroyable, MetaAttributes, Vector, StorageConstants, StorageOpsMetrics

      public class SparseVector
      extends AbstractVector
      implements StorageConstants

  Local on-heap sparse vector based on hash map storage.
  See Also:
    Serialized Form

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.apache.ignite.ml.math.primitives.vector.Vector

      `Vector.Element`

  - ### Field Summary

    - ### Fields inherited from interface org.apache.ignite.ml.math.StorageConstants

      `COLUMN_STORAGE_MODE, RANDOM_ACCESS_MODE, ROW_STORAGE_MODE, SEQUENTIAL_ACCESS_MODE, UNKNOWN_STORAGE_MODE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SparseVector()`
    `SparseVector(int size)`
    `SparseVector(Map<Integer,Double> map, boolean cp)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `it.unimi.dsi.fastutil.ints.IntSet` | `indexes()` Indexes of non-default elements.
    `Vector` | `like(int crd)` Creates new empty vector of the same underlying class but of different cardinality.
    `Matrix` | `likeMatrix(int rows, int cols)` Creates new matrix of compatible flavor with given size.
    `Spliterator<Double>` | `nonZeroSpliterator()` Gets spliterator for all non-zero values in this vector.
    `Vector` | `times(double x)` Gets a new vector that contains product of each element and the argument.

    - ### Methods inherited from class org.apache.ignite.ml.math.primitives.vector.AbstractVector

      `all, allSpliterator, assign, assign, assign, assign, checkCardinality, checkCardinality, checkCardinality, checkIndex, compute, copy, copyOfRange, cross, destroy, divide, dot, dotSelf, equals, foldMap, foldMap, get, getDistanceSquared, getElement, getLengthSquared, getMetaStorage, getRaw, getRawX, getStorage, getX, guid, hashCode, increment, incrementX, isArrayBased, isDense, isNumeric, isZero, kNorm, logNormalize, logNormalize, makeElement, map, map, map, maxElement, maxValue, minElement, minus, minValue, nonZeroElements, nonZeroes, normalize, normalize, plus, plus, readExternal, set, setRaw, setRawX, setStorage, setX, size, sort, storageGet, storageGetRaw, storageSet, storageSetRaw, sum, times, toMatrix, toMatrixPlusOne, viewPart, writeExternal`

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

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

    - ### Methods inherited from interface org.apache.ignite.ml.math.StorageConstants

      `assertAccessMode, assertStorageMode`

    - ### Methods inherited from interface org.apache.ignite.ml.math.primitives.vector.Vector

      `asArray, labeled`

    - ### Methods inherited from interface org.apache.ignite.ml.math.MetaAttributes

      `getAttribute, hasAttribute, removeAttribute, setAttribute`

- - ### Constructor Detail

    - #### SparseVector

          public SparseVector()

    - #### SparseVector

          public SparseVector(Map<Integer,Double> map,
                              boolean cp)

      Parameters:
        `map` - Underlying map.
        `cp` - Should given map be copied.

    - #### SparseVector

          public SparseVector(int size)

      Parameters:
        `size` - Vector size.

  - ### Method Detail

    - #### like

          public Vector like(int crd)

      Creates new empty vector of the same underlying class but of different cardinality.
      Specified by:
        `like` in interface `Vector`
      Parameters:
        `crd` - Cardinality for new vector.
      Returns:
        New vector.

    - #### likeMatrix

          public Matrix likeMatrix(int rows,
                                   int cols)

      Creates new matrix of compatible flavor with given size.
      Specified by:
        `likeMatrix` in interface `Vector`
      Parameters:
        `rows` - Number of rows.
        `cols` - Number of columns.
      Returns:
        New matrix.

    - #### times

          public Vector times(double x)

      Gets a new vector that contains product of each element and the argument.
      Specified by:
        `times` in interface `Vector`
      Overrides:
        `times` in class `AbstractVector`
      Parameters:
        `x` - Multiply argument.
      Returns:
        New vector.

    - #### indexes

          public it.unimi.dsi.fastutil.ints.IntSet indexes()

      Indexes of non-default elements.

    - #### nonZeroSpliterator

          public Spliterator<Double> nonZeroSpliterator()

      Gets spliterator for all non-zero values in this vector.
      Specified by:
        `nonZeroSpliterator` in interface `Vector`
      Overrides:
        `nonZeroSpliterator` in class `AbstractVector`
      Returns:
        Spliterator for all non-zero values.

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