in Linear Algebra
779 views
1 vote
1 vote

An $n \times n$ matrix is said to be tridiagonal if its entries $a_{ij}$ are zero except when $|i−j| \leq 1$ for $1 \leq i, \: j \leq n$. Note that only $3n − 2$ entries of a tridiagonal matrix are non-zero. Thus, an array $L$ of size $3n − 2$ is sufficient to store a tridiagonal matrix. Given $i, j$, write pseudo-code to

  1. store $a_{ij}$ in $L$, and
  2. get the value of $a_{ij}$ stored earlier in $L$.
in Linear Algebra
779 views

2 Answers

0 votes
0 votes

L is the array aij  is the given element

1 comment

not correct
0
0
0 votes
0 votes

Question (ii)

Since the indexing starts with 1, 1st row has only 2 elements {A[1,1] ,A[1,2]}

And 2nd row onwards each row has 3 elements.{A[i,j-1], A[i.j], A[i,j+1]}

A[i,j] = [2+(i-1)*3 + f(i,j)]

where f(i,j) = 0        (j=i-1)

                      1        (j=i)

                      2        (j=i+1)

Note: A[i,j] where |i-j|>1    ---not valid

edited by

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true