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

## Class SparseMatrix

- java.lang.Object
- - org.apache.ignite.ml.math.primitives.matrix.AbstractMatrix
  - - org.apache.ignite.ml.math.primitives.matrix.impl.SparseMatrix

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

      public class SparseMatrix
      extends AbstractMatrix
      implements StorageConstants

  Sparse local onheap matrix with `SparseVector` as rows.
  See Also:
    Serialized Form

- - ### Nested Class Summary

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

      `Matrix.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
    `SparseMatrix()`
    `SparseMatrix(int rows, int cols)` Construct new `SparseMatrix`.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `compute(int row, int col, IgniteTriFunction<Integer,Integer,Double,Double> f)` Replace matrix entry with value oldVal at (row, col) with result of computing f(row, col, oldVal).
    `Matrix` | `copy()` Clones this matrix.
    `it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap<it.unimi.dsi.fastutil.ints.IntSet>` | `indexesMap()`
    `Matrix` | `like(int rows, int cols)` Creates new empty matrix of the same underlying class but of different size.
    `Vector` | `likeVector(int crd)` Creates new empty vector of compatible properties (similar or the same flavor) to this matrix.
    `int` | `nonZeroElements()` Gets number of non-zero elements in this matrix.

    - ### Methods inherited from class org.apache.ignite.ml.math.primitives.matrix.AbstractMatrix

      `allSpliterator, assign, assign, assign, assign, assignColumn, assignRow, columnSize, density, destroy, determinant, divide, equals, foldColumns, foldMap, foldRows, get, getCol, getElement, getMetaStorage, getRow, getStorage, getX, guid, hashCode, inverse, isArrayBased, isDense, likeIdentity, map, map, maxElement, maxValue, minElement, minus, minValue, nonZeroSpliterator, plus, plus, readExternal, rowSize, set, setColumn, setRow, setStorage, setX, storageGet, storageSet, sum, swapColumns, swapRows, times, times, times, toString, transpose, viewColumn, viewDiagonal, viewRow, writeExternal`

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

      `clone, finalize, getClass, notify, notifyAll, 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.matrix.Matrix

      `isNumeric`

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

      `getAttribute, hasAttribute, removeAttribute, setAttribute`

- - ### Constructor Detail

    - #### SparseMatrix

          public SparseMatrix()

    - #### SparseMatrix

          public SparseMatrix(int rows,
                              int cols)

      Construct new `SparseMatrix`. By default storage sets in row optimized mode and in random access mode.

  - ### Method Detail

    - #### like

          public Matrix like(int rows,
                             int cols)

      Creates new empty matrix of the same underlying class but of different size.

      NOTE: new matrix will have the same flavor as the this matrix but a different ID.

      Specified by:
        `like` in interface `Matrix`
      Parameters:
        `rows` - Number of rows for new matrix.
        `cols` - Number of columns for new matrix.
      Returns:
        New matrix of the same underlying class and size.

    - #### likeVector

          public Vector likeVector(int crd)

      Creates new empty vector of compatible properties (similar or the same flavor) to this matrix.
      Specified by:
        `likeVector` in interface `Matrix`
      Parameters:
        `crd` - Cardinality of the vector.
      Returns:
        Newly created empty vector "compatible" to this matrix.

    - #### nonZeroElements

          public int nonZeroElements()

      Gets number of non-zero elements in this matrix.
      Specified by:
        `nonZeroElements` in interface `Matrix`
      Overrides:
        `nonZeroElements` in class `AbstractMatrix`
      Returns:
        Number of non-zero elements in this matrix.

    - #### indexesMap

          public it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap<it.unimi.dsi.fastutil.ints.IntSet> indexesMap()

    - #### copy

          public Matrix copy()

      Clones this matrix.

      NOTE: new matrix will have the same flavor as the this matrix but a different ID.

      Specified by:
        `copy` in interface `Matrix`
      Overrides:
        `copy` in class `AbstractMatrix`
      Returns:
        New matrix of the same underlying class, the same size and the same values.

    - #### compute

          public void compute(int row,
                              int col,
                              IgniteTriFunction<Integer,Integer,Double,Double> f)

      Replace matrix entry with value oldVal at (row, col) with result of computing f(row, col, oldVal).
      Specified by:
        `compute` in interface `Matrix`
      Overrides:
        `compute` in class `AbstractMatrix`
      Parameters:
        `row` - Row.
        `col` - Column.
        `f` - Function used for replacing.

2021 Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.10.0
Release Date | : March 10 2021