I have 16 NxN matrices, where N can be anywhere between 1000-64000.. Some of them are real and some of them are complex. I want to Reshape then to form a 4Nx4N matrix. When I try to accomplish this using ArrayFlatten or Flatten[,{{1,3},{2,4}}], this results in a huge spike in memory utilization. For N=2000, that is around 6GB RAM. So for larger N it is going to be astronomically large. However, when I checked the space required to store a RandomComplex[] matrix of the same size was around 2GB, which is still a bit high but understandable with 128bit complex numbers.
I understand that this is probably due to Mathematica unpacking the array while flattening, which is what I get when I check with PackedArrayQ[] which returns false for the final array.
My question is is there any way to keep the array packed during flattening? My idea was the unpacking occurs probably because of different data types, is that the case? If so, then how do I ensure all of them are complex and the resulting matrix remains packed.
I need the matrix in that specific format because I need to calculate inverse and eigenvalues later. Any suggestions which involve not using Flatten but get the inverse of the matrix and eigenvalues are also appreciated.