Sparse Matrices are those which have a high ratio of number of zero elements to that of non - zero elements, that is, the matrix is sparsely populated with non- zero elements. Here's a simple program for sparse matrix addition.
The matrices are given in the form of 3-tuple representation.
A 3- tuple representation means that matrices are stored in the form of a 2-dimensional array, with three columns andthe number of rows the same as the no. of non-zero elements in the matrix. The first column describes the row index of an element, the second describes the column index and the third describes the value of the element. Usually, the first row (index 0) is used to describe the total no. of rows, columns and non-zero elements. Sparse Matrices can be provided in both row major and column major order, the program below follows row major order.