ml-sparse-matrix
    Preparing search index...

    Class SparseMatrix

    Index

    Constructors

    Properties

    columns: any
    elements: any
    klass: string
    rows: any
    tensorProduct: (other: SparseMatrix) => SparseMatrix

    Type declaration

    threshold: any
    identity: (rows?: number, columns?: number) => SparseMatrix

    Accessors

    • get cardinality(): number

      Returns number

    Methods

    • Parameters

      • rows: any
      • columns: any
      • elements: any
      • threshold: any

      Returns void

    • Search for the wither band in the main diagonals

      Returns number

    • Parameters

      • row: number
      • column: number

      Returns number

    • Returns the non-zero elements of the matrix in coordinates (COO) or CSR format.

      COO (Coordinate) format: Stores the non-zero elements as three arrays: rows, columns, and values, where each index corresponds to a non-zero entry at (row, column) with the given value.

      CSR (Compressed Sparse Row) format: Stores the matrix using three arrays:

      • rows: Row pointer array of length numRows + 1, where each entry indicates the start of a row in the columns and values arrays.
      • columns: Column indices of non-zero elements.
      • values: Non-zero values. This format is efficient for row slicing and matrix-vector multiplication.

      Parameters

      • Optionaloptions: { csr?: boolean; sort?: boolean } = {}

        Options for output format and sorting.

        • Optionalcsr?: boolean

          If true, returns the result in CSR format. Otherwise, returns COO format.

        • Optionalsort?: boolean

          If true, sorts the non-zero elements by their indices.

      Returns any

      If csr is not specified, returns an object with Float64Array rows, columns, and values (COO format). If csr is true, returns { rows, columns, values } in CSR format.

    • Test if a matrix is consider banded using a threshold

      Parameters

      • width: number

      Returns boolean

    • Returns boolean

    • Returns boolean

    • Matrix multiplication, does not modify the current instance.

      Parameters

      Returns SparseMatrix

      returns a new matrix instance.

      If the number of columns of this matrix does not match the number of rows of the other matrix.

    • Returns number[][]

    • Calls callback for each value in the matrix that is not zero. Unlike forEachNonZero, the callback's return value has no effect.

      Parameters

      Returns void