Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
|
|
Re: matrices as vectors
Posted:
Feb 20, 2013 1:04 PM
|
|
In article <496eaca6-79de-4d35-bd4b-190428fb2af2@googlegroups.com>, leonard14279@gmail.com writes:
>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> "Writing about jazz is like dancing about architecture" - Thelonious Monk
|
|
|
|