Fork me on GitHub
#uncomplicate
<
2024-05-21
>
Nguyen Hoai Nam05:05:35

Does Neanderthal support higher-dimensional arrays? For example, can I create this 2 × 3 × 4 array using Neanderthal?

[[[1 2 3 4]
  [2 3 4 5]
  [3 4 5 6]]
 [[1 3 5 7]
  [2 4 6 8]
  [3 5 7 9]]]
I only need this for storage and convenience, since I want every entry to be indexable by three numbers, i, j and k. I don’t need tensor math, though—my plan is to slice regular matrices out of it (e.g., all entries with k = 2) and then do the math, so regular matrix multiplication is good enough for me.

Carsten Behring15:05:40

Not neanderthal as such. There is deep-diamond which supports tensors of any dimension: https://github.com/uncomplicate/deep-diamond

Carsten Behring15:05:08

So for math, you would indeed need to "slide" off and go back to naenderthal. Documentation is mainly as tests (or in the book): https://github.com/uncomplicate/deep-diamond/blob/master/test/uncomplicate/diamond/tensor_test.clj

Nguyen Hoai Nam05:05:29

Thank you. It seems that deep-diamond doesn’t have any functions for indexing or slicing 3D tensors (e.g., to get a specific entry or a 2D matrix), so it might not suit my use case.

Carsten Behring20:05:21

Have you tried this: https://cnuernber.github.io/dtype-next/tech.v3.tensor.html This has funtiocn mget to (mget tens x y z & args) and select / slicing which looks like slicing

Nguyen Hoai Nam01:05:01

Thank you. I’ve actually tried both dtype-next and core.matrix, and am using the latter. I was hoping to speed up my matrix math and thought neanderthal would be a good way to do it, but if I have to convert between neanderthal matrices and dtype-next tensors then that might negate any performance benefit.