1
$\begingroup$

I am struggling with a problem from this textbook. The question is as follows:

Determine a formula h = f(i,j) to store location MATRIX[i][j] in h. Ensure to only store nonzero elements.

Then it asks how they can be stored in a single dimensional array.

I'm unsure of how to go about solving this. Can someone help me better understand this?

2 Answers 2

1

Lets consider the matrix:

\begin{pmatrix} a & b \\ c & d \\ \end{pmatrix}

You can memorize it as

\begin{pmatrix} a & b & c & d \end{pmatrix}

You can do it with every matrix, and in fact the computer do it every time.

If you have a $m\times n$ matrix you can access to the entry $a_{ij}$ with the formulae $(i-1)\times n + j$ (I start the array with $1$).

Let's consider a lower triangular matrix. You can ignore the upper part of the matrix.

You can actually use three major methods:

  1. store it by row,
  2. store it by column,
  3. proceed by diagonal entry.

I will show you the first and the third method by you have to find the formulae (because it is an homework).

Let's consider the matrix:

\begin{pmatrix} a_{11} & 0 \\ a_{21} & a_{22} \\ \end{pmatrix}

You save it as \begin{pmatrix} a_{11} & a_{21} & a_{22} \end{pmatrix}.

In the third method you memorize it as \begin{pmatrix} a_{11} & a_{22} & a_{21} \end{pmatrix}

  • 0
    Ok, things are making sense. Thank you.2012-06-05
0

This is triangular Length with Formulas &colculation

  • 0
    Perhaps you could give some more explanation. It is unclear what you are trying to say here.2013-03-16