A sparse matrix is a two-dimensional list of m rows and n columns. The shape of a matrix is m x n if it consists of m rows and n columns. Sparse matrices are used for solving large-scale problems that do not require dense matrices. For example, partial differential equations are solved by using the finite element method (FEM). Tuples of a sparse matrix are non-zero elements of the matrix.
In the following code, a sparse matrix is modeled as a list of lists. A sparse matrix consists of cells that are a list of lists. Each cell has properties such as Row, Column, and Value:
///main package has examples shown
// in Go Data Structures and algorithms book
package main
// importing fmt package
import (
"fmt"
)
//List of List
type LOL struct {
Row int
Column int
Value float64
}
The next section talks about the SparseMatrix class...