In the code attached the Part function is much, much faster than ArrayReshape when converting 1X4 arrays into 2X2 arrays. Clearly, ArrayReshape is a general function with lots of exception handling features, but it’s an order-of-magnitude slower that using Part on even mid-sized problems. Since ArrayReshape is a) exactly what I want, functionally, and b) more readable than using Part, is there anything I can do to remedy its poor performance? Compiling? Explicit parallelism? It’s not just relative to Part that ArrayReshape is slow; it seems slow relative to other operations on the same number of 1X4 or 2X2 arrays. I’ve demonstrated to myself that Part is faster than Transpose on, again, mid-sized problems, but, while noticeable, the difference is no where near as big as I’ve found here.
Context: I’m developing data mining software so converting arrays can be an inner loop of large-scale computations.
Thank you.