Operation between two large N-dimensional arrays

Hello, I am pretty much new to Julia.

I am now trying to do an operation between two large N-dimensional sparse arrays of the same size (typically something like 8-dimensional array with 5 to 10 elements for each dimension). The operation is just like the product of two matrices (i.e., applied to every combination of the elements between those two arrays).

The problem is that the operation cannot be expressed explicitly using the two arrays (e.g., arrayA+arrayB, arrayA*arrayB). So the operation must be performed in an element-wise way using something like for loop.

So far I have implemented the operation by first identifying the indices of non-zero elements of those two arrays by “findall” and then applying the operation to every combination of them. However, this algorithm is very slow in the first identification part (especially if the size of the arrays is large).

I believe that this is a problem that many people encounter. How do people get around this in general in Julia? Is there an efficient way to solve this?

it would be nice if you have an example (i.e. your code), but take a look at GitHub - mcabbott/Tullio.jl: ⅀ anyway

1 Like

Also sounds like you may be able to take advantage of SparseArrays.

1 Like