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

Sparse Matrices: Dr. Manmath N. Sahoo Department of CSE, NIT Rourkela

The document discusses sparse matrices, which have many zero elements. It provides examples of structured sparse matrices like diagonal, tridiagonal, lower triangular, and upper triangular matrices. It also describes various representations of unstructured sparse matrices using a triplet array, single chain, array of row chains, array of column chains, and orthogonal lists. It compares the storage requirements of different representations for a sample sparse matrix.

Uploaded by

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

Sparse Matrices: Dr. Manmath N. Sahoo Department of CSE, NIT Rourkela

The document discusses sparse matrices, which have many zero elements. It provides examples of structured sparse matrices like diagonal, tridiagonal, lower triangular, and upper triangular matrices. It also describes various representations of unstructured sparse matrices using a triplet array, single chain, array of row chains, array of column chains, and orthogonal lists. It compares the storage requirements of different representations for a sample sparse matrix.

Uploaded by

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

Sparse Matrices

Dr. Manmath N. Sahoo


Department of CSE, NIT Rourkela
Sparse Matrices

sparse … many elements are zero


dense … few elements are zero
Example Of Sparse Matrices
 diagonal
 tridiagonal
 lower triangular
 upper triangular

These are structured sparse matrices.


9 0 0 0 9 5 0 0
0 7 0 0  4 7 2 0 
A B
0 0 5 0 0 3 5 2
   
0 0 0 13 0 0 1 13

Diagonal matrix Tri-diagonal matrix

9 0 0 0 9 5 9 1
4 0 1 
7 0 0  D
7 2
C 0 0 5 2
5 3 5 0
   
2 6 1 13 0 0 0 13
Lower triangular matrix Upper triangular matrix
Representation Of Unstructured
Sparse Matrices using triplet array
4 5 6
1 3 3
0 0 3 0 4 1 5 4
0 0 5 7 0 2 3 5
A
0 0 0 0 0 2 4 7
 
0 2 6 0 0 4 2 2
4 3 6

(row, column, value) --- triplet 5


Chain Representation

Node structure.

row col

value next
Single Chain

0 0 3 0 4
0 0 5 7 0
A
0 0 0 0 0
 
0 2 6 0 0

4 5 1 3 1 5 2 3 2 4 4 2 4 3

3 4 5 7 2 6 null
6

Head
One Linear List Per Row

0 0 3 0 4 row1 = [(3, 3), (5,4)]


0 0 5 7 0 row2 = [(3,5), (4,7)]
A
0 0 0 0 0 row3 = []
 
0 2 6 0 0 row4 = [(2,2), (3,6)]
Array Of Row Chains

Node structure.

next

col value
Array Of Row Chains

nul
6 2 3 3 5 l 4

00304 nul
6 2 3 5 4 l 7

00570 6 0

00000 nul
6 2
02600 2 2 3 l 6

*row[]
One Linear List Per Column

0 0 3 0 4 col1 = []
0 0 5 7 0 col2 = [(4,2)]
A
0 0 0 0 0 col3 = [(1, 3), (2,5), (4,6)]
 
0 2 6 0 0 col4 = [(2,7)]
col5 = [(1,4)]
Array Of Column Chains
Node structure.

next

row value

down
Array Of Column Chains
*col[]

4 0 4 1 4 3 4 1 4 1
00304
1 3 1 4
n
00570
00000 2 5 2 7
n
02600

4 2 4 6
n n
Orthogonal List Representation

Both row and column lists.

Node structure.
row col value

down next
Row Lists

3 3 5 4
00304 n

3 5 4 7
n

00570
00000 null

02600 2 2 3 6
n
Column Lists

null

1 3 1 4
00304 n

2 5 2 7
00570
00000
02600
4 2 4 6
n n
Orthogonal Lists

null

1 3 3 1 5 4
00304 n n

2 3 5 2 4 7
n

00570
00000 null

02600 4 2 2 4 3 6
n n n

row[]
Storage Requirements
500 x 500 integer matrix with 1994 nonzero elements

2D array 500 x 500 x 2 = 0.5million bytes


Triplet array 3 x (1995) x 2 = 11,9770 bytes
Linked list 1995 x 8 (node size) + 2 (head)
= 15962 bytes //1995 because of header node
One Chain Per Row (1994+500) x 6 (node size) + 2 x
500
= 15,964 bytes
Orthogonal List---- how many bytes?

You might also like