Ask Your Question
0

Hypermatrices?

asked 4 years ago

Boston gravatar image

Hi all,

I want to store and manipulate arrays of n×n×n numbers xijkwhere0i,j,kn1

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(abcd)ijk

and loop over such lists, e.g. for a ..., for b ..., for c ..., do ... with the 3-hypermatrix X(abcd).

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
0

answered 4 years ago

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.

Preview: (hide)
link

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: 4 years ago

Seen: 293 times

Last updated: May 27 '20