# SVD on a matrix that does not fit into memory

**URL:** <https://discourse.julialang.org/t/svd-on-a-matrix-that-does-not-fit-into-memory/92802>\
**Category:** Numerics\
**Tags:** memory, svd\
**Created:** [January 11, 2023, 11:37am UTC](https://discourse.julialang.org/t/svd-on-a-matrix-that-does-not-fit-into-memory/92802 "2023-01-11T11:37:14Z")\
**Posts on this page:** 1\
**Page:** 2

<div class="post-metadata">

**Author:** ![aasdelat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aasdelat/32/45268_2.png) [@aasdelat](https://discourse.julialang.org/u/aasdelat)\
**Post date:** [January 16, 2023, 3:44pm UTC](https://discourse.julialang.org/t/svd-on-a-matrix-that-does-not-fit-into-memory/92802/21 "2023-01-16T15:44:17Z")

</div>

Who knows …  
So, as conclusion, I think that your first answer (without the implementation of the `mul_by_cols ` function) is the best one.

And the whole and definitive code (if you accept it) is the one I posted above:

> [@aasdelat](#):
>
> ```julia
> using HDF5, KrylovKit
> 
> fid = h5open("nc_file.nc", "r")
> array = HDF5.readmmap(fid["nc_var_name"])
> # Make lons and lats a single dimension
> array = reshape(array, (size(array)[1] * size(array)[2], size(array)[3]))
> array = transpose(array) # (time x space). It was (space x time)
> vals, lvecs, rvecs, info = KrylovKit.svdsolve(array, 100, krylovdim=200)
> 
> ```

[Previous page](https://discourse.julialang.org/t/svd-on-a-matrix-that-does-not-fit-into-memory/92802.md?page=1)
