Ask Your Question
0

Hypermatrices?

asked 2020-05-27 08:54:24 -0600

Boston gravatar image

Hi all,

I want to store and manipulate arrays of $n\times n\times n$ numbers $$x_{ijk}\quad\text{where}\quad 0\leq i, j, k\leq n-1$$ with Sage.

Here is what I have been doing so far:

import numpy as np

n = 7

X = np.zeros((n, n, n))

X[2][4][1] = 17

etc...

Remark: So $X$ is a so called 3-hypermatrix.

Question: Are NumPy arrays my best option when handling hypermatrices with Sage?

Precision: I will need to manipulate lists of such hypermatrices, and even hypermatrices whose elements will be hypermatrices, e.g. $$X_{ijk}^{(abcd)}$$ and loop over such lists, e.g. for a ..., for b ..., for c ..., do ... with the 3-hypermatrix $X^{(abcd)}$.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2020-05-27 11:40:44 -0600

tmonteil gravatar image

It depends on your use, but if you want to build complex constructions out of them on the long term, i would suggest to define your own Hypermatrix/Hypermatrices element and parent classes, so that changing base ring, product, etc will be less painful, see the folliwing links:

Now i am not sure about having numpy arrays as a backend. Those are fast, but since the dtype will be any object, i am not sure about the benefit.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-05-27 08:54:24 -0600

Seen: 90 times

Last updated: May 27