Hi all. I have a use case where I make a large memory buffer for a matrix, but I will regularly want to take a slightly smaller sub-array of it. Views are great, particularly for version 1.5+, but I’m wondering what happens when I pass my view of a matrix into LAPACK because it isn’t just a simple contiguous chunk of memory anymore. As an example, consider this:
_A = randn(36, 36)
A = _A'_A
B = view(A, 1:24, 1:24)
_C = randn(24, 24)
C = _C'_C
cholesky!(B)
cholesky!(C) # won't this be faster because of the memory layout?
I’m having a little trouble figuring out the smart way to benchmark the in-place Cholesky, so apologies if there’s some easy way to see that the factorizations for B
and C
cost the same. But I would think they don’t, particularly at non-toy sizes.
With this issue in mind, I’m wondering if there’s some way to do the following thing: take the first 24*24 entries of the buffer for A
and then treat that as a native 24x24 matrix, disregarding the structure about A
that the view operation maintains. Something like reinterpret(Matrix{Float64}, (24, 24), view(A, 1:24*24))
or something, which I recognize is not anywhere near a valid function call. Is there some tidy way to do that?
Am I overthinking this? Is this not a problem? I’d appreciate any thoughts you have to share. Thanks in advance for reading.