Class: Triplet

LinearAlgebra. Triplet


new Triplet(m, n)

This class represents a small structure to hold nonzero entries in a SparseMatrix.
Each entry is a triplet of a value and the (i, j)th indices, i.e., (x, i, j).

Parameters:
Name Type Description
m number

The number of rows in the sparse matrix that will be initialized
from this triplet.

n number

The number of columns in the sparse matrix that will be initialized
from this triplet.

Example
let T = new Triplet(100, 100);
T.addEntry(3.4, 11, 43);
T.addEntry(6.4, 99, 99);

let A = SparseMatrix.fromTriplet(T);

Methods


addEntry(x, i, j)

A(i, j) += x

Parameters:
Name Type Description
x number

The value of the nonzero entry being inserted into this triplet.

i number

The ith row of the sparse matrix that will be initialized
from this triplet.

j number

The jth column of the sparse matrix that will be initialized
from this triplet.