Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: matrices as vectors
Replies: 4   Last Post: Feb 22, 2013 12:43 PM

 Messages: [ Previous | Next ]
 Michael Stemper Posts: 671 Registered: 6/26/08
Re: matrices as vectors
Posted: Feb 20, 2013 1:04 PM

>Had the idea to represent a 2d-matrix as a 1d-vector.

That's how most (if not all) programming languages do it.

>Need a function to map [ row, col ] indices to an index [ n ], and vice-versa.
>
>Then the rest should be straightforward.
>
>So we have two functions ...

>Then the rest of the code can be refactored to use the 1d-vector representation of a 2d-matrix.
>
>The question is, are there already existing formulas for matrix operations, where the matrix is represented as a 1d-vector?

Yes, and this approach can be generalized to p-dimensional arrays, as well.
See any book on data structures, or possibly Section 8.9 of:
<http://people.cis.ksu.edu/~schmidt/PPJv12pdf/ch8V12.pdf>

--
Michael F. Stemper
#include <Standard_Disclaimer>