0% found this document useful (0 votes)
0 views

Sapre Se Matrix

Uploaded by

omsingh300710
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

Sapre Se Matrix

Uploaded by

omsingh300710
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Sparse Matrix

SAMBUDDHA CHAKRABORTY
Sparse Matrix

 Sparse matrix is a matrix in which most of the element are zero.


 By contrast if the most element are non zero then matrix is Dense.
 Sparsity of sparse matrix is the number of zero valued elements
divided by total no. of element.
 The following sparse matrix contains only 16 nonzero elements, with
84 zero elements. Its sparsity is 84%, and its density is 16%. SPARSE
MATRIX
Sparse Matrix

 When a sparse matrix is represented with a 2-dimensional array, we


waste a lot of space to represent that matrix.
 For example, consider a matrix of size 100 X 100 containing only 10 non-
zero elements.
 In this matrix, only 10 spaces are filled with non-zero values and
remaining spaces of the matrix are filled with zero.
 That means, totally we allocate 100 X 100 X 2 = 20000 bytes of space to
store this integer matrix.
 And to access these 10 non-zero elements we have to make scanning for
10000 times. To make it simple we use the following sparse matrix
representation.
Sparse Matrix Representations

A sparse matrix can be represented by using TWO representations, those


are as follows...

 Triplet Representation (Array Representation)


 Linked Representation
Triplet Representation (Array
Representation)

 In this representation, we consider only non-zero values along with their


row and column index values.
 In this representation, the 0th row stores the total number of rows,
total number of columns and the total number of non-zero values in the
sparse matrix.
 For example, consider a matrix of size 5 X 6 containing 6 number of
non-zero values. This matrix can be represented as shown in the
image...
Triplet representation

 In this example, there are only 6 non-zero


elements ( those are 9, 8, 4, 2, 5 & 2) and matrix
size is 5 X 6. We represent this matrix as shown in
the above image. Here the first row in the right
side table is filled with values 5, 6 & 6 which
indicates that it is a sparse matrix with 5 rows, 6
columns & 6 non-zero values. The second row is
filled with 0, 4, & 9 which indicates the non-zero
value 9 is at the 0th-row 4th column in the Sparse
matrix. In the same way, the remaining non-zero
values also follow a similar pattern.
Algorithm
Algorithm(continues…)
Algorithm(continues…)
Thank You

You might also like