[Tutor] cannonical matrix representation?

Andre Roberge andre.roberge at gmail.com
Fri Feb 10 23:05:15 CET 2006


On 2/10/06, Mike Cheponis <mac at wireless.com> wrote:
> What's the best way to represent a matrix M with 4 dimensions, such as M[x][y][z][t] where each element in the sparse matrix could be a simple number, or could be an executable Python function snipped that returns a value when that cell is evaluated?
>
> The user of the program will type in Python functions to be inserted into particular cells in the 4-D matrix.
>
> I did't see any package that exactly does this; do I write my own Matrix class and base it on lists?
>
> Thanks!  -Mike

If it is a truly sparse matrix, I would use a dictionary with tuples
as keys; i.e.,
m{(x, y, z, t) = "element"}

André

>
> p.s. This seems to me like it ought to be built into the base language - multidimensional object arrays. (Indeed, maybe it is, and I'm just too dense to notice!)
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list