I have a data set where each samples has a structure similar to this
X=[ [[],[],[],[]], [[],[]] , [[],[],[]] ,[[][]]]
for example:
There's nothing you can do here. You want to get the results of all multiplications, you just have to do them, and that's what your algorithm does. One of the only things you can do is store your results in a hashtable, in case you know that you have a lot of duplicate results, but it's gonna cost a lot of memory if you don't. By the way, multithreading might make your program run faster, but it will never improve it's complexity, which is the number of operations needed.