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 3:31 AM


On Tue, 19 Feb 2013, leonard14279@gmail.com wrote: > Had the idea to represent a 2dmatrix as a 1dvector. > Have an existing program to perform matrix operations, where a matrix is > represented as an array of arrays. > Seems like the code would be more straightforward if a matrix were > represented as a 1dvector. > Need a function to map [ row, col ] indices to an index [ n ], and > viceversa. Does that mean anything? Are you wanting to map n by m matrices to 1 by n matrices? That can't be done without loosing lots of information.
> Then the rest should be straightforward. > So we have two functions ... > > ijton( row, col ) { > n = row * numrows + col; > } > > ntoij( n ) { > row = ( n  col ) / numrows; > col = n  ( row * numrows ); > }
Those aren't well defined functions, they're snippits of some alian code.
> Then the rest of the code can be refactored to use the 1dvector > representation of a 2dmatrix. I don't know what you're talking about. Do you? You can represent a n by m matrice by a colume of m ndimensional vectors.
> The question is, are there already existing formulas for matrix > operations, where the matrix is represented as a 1dvector? Depends upon what you mean.



