Page 89 - DCAP201_FUNDAMENTALS_OF_DATA_STRUCTURES
P. 89
Fundamentals of Data Structures
Notes printf(“%d %d %d\n”, (i+1),(j+1),a[i][j]);
}
}
}
Output:
enter the order of the matrix. The order should be less than 5 × 5:
3 3
Enter the elements of the matrix:
1 2 3
0 1 0
0 0 4
The 3-tuple representation of the matrix is:
1 1 1
1 2 2
1 3 3
2 2 1
3 3 4
The program initially prompted for the order of the input matrix with a warning that the order
should not be greater than 5 × 5. After accepting the order, it prompts for the elements of the
matrix. After accepting the matrix, it checks each element of the matrix for a non-zero. If the
element is non-zero, then it prints the row number and column number of that element along
with its value.
Task Compare and contrast triangular matrix and tridiagonal matrix.
6.2.1 Sparse Matrix Storage Formats
The efficiency of most of the iterative methods is determined primarily by the performance of
the matrix-vector product and therefore on the storage scheme used for the matrix.
Did u know? Often, the storage scheme used arises naturally from the specific application
problem.
There are many methods for storing the data such as compressed row and column storage, block
compressed row storage, diagonal storage, jagged diagonal storage, and skyline storage. These
are discussed as below.
Compressed Row Storage
The compressed row and column storage formats are the most general: they make absolutely no
assumptions about the sparsity structure of the matrix, and they don’t store any unnecessary
82 LOVELY PROFESSIONAL UNIVERSITY