in Programming in C
1,002 views
0 votes
0 votes
Assume that Tridiagonal Matrix of order (4 x 4) is mapped into a one-dimensional array by diagonals, starting with the lowest diagonal.

 

(1) The location of an element A(4.3) is (a) t[1] (b) t[3] (c) t[4] (d) t2

 

Answer is given as d. Can someone please help me visualize it? Im not sure I understand how they arrange the matrix into array.
in Programming in C
1.0k views

3 Comments

The array indexing starts from 0?
0
0

$\begin{bmatrix} {\color{Magenta} e1} & {\color{Blue} e2} & 0 &0 \\ {\color{Red} e3} & {\color{Magenta} e4} & {\color{Blue} e5} &0 \\ 0 & {\color{Red} e6} &{\color{Magenta} e7} & {\color{Blue} e8}\\ 0 & 0 & {\color{Red} e9} &{\color{Magenta} e10} \end{bmatrix}$

Tridiagonal matrix of order 4x4 looks like this. Tri-diagonal means there are 3 diagonals including the main diagnonal. See that the elements {e3,e6,e9} fall in the same diagonal line(lower diagonal) and I have colored them with red. Similarly {e1,e4,e7,e10} are colored in magenta to indicate they belong to the same diagonal line(main diagonal) and {e2,e5,e8} are colored with blue because they also belong to same diagonal(upper diagonal).

Now question says that the elements in this matrix are stored starting with the elements of lower diagonal and we store them diagonal wise.

That is first we cover all the elements of lower diagonal then main diagonal and then upper. The array if indexed from 0 will look like :

0 1 2 3 4 5 6 7 8 9
e3 e6 e9 e1 e4 e7 e10 e2 e5 e8

 

Now from the matrix, element at (4,3) is e9. It is indexed at 2.

2
2

@MiNiPanda

That could be answered from the matrix itself then why you draw all of those elements in linear dimension??

Was there any need to do that?

I know that elements are stored in linear dimensions only in the physical representation.

0
0

Please log in or register to answer this question.

Related questions