# CUR in LowRankApprox

**URL:** <https://discourse.julialang.org/t/cur-in-lowrankapprox/99867>\
**Category:** New to Julia\
**Created:** [June 5, 2023, 2:44am UTC](https://discourse.julialang.org/t/cur-in-lowrankapprox/99867 "2023-06-05T02:44:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marcelo\_Ferreira](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marcelo_ferreira/32/50495_2.png) [@Marcelo\_Ferreira](https://discourse.julialang.org/u/Marcelo_Ferreira)\
**Post date:** [June 5, 2023, 2:44am UTC](https://discourse.julialang.org/t/cur-in-lowrankapprox/99867/1 "2023-06-05T02:44:46Z")

</div>

I installed the LowRankApprox package and I want to use the Cur decomposition. I read part of the documentation on GitHub, but I still don’t understand how to use it. For example, given a matrix A = rand(5,5), and I want an approximation by a rank-3 matrix, how do I obtain the matrix U and how do I obtain the decomposition using the package?

---

<div class="post-metadata">

**Author:** ![jishnub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jishnub/32/33620_2.png) [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Post date:** [June 5, 2023, 7:56am UTC](https://discourse.julialang.org/t/cur-in-lowrankapprox/99867/2 "2023-06-05T07:56:28Z")

</div>

I think this is what you want:

```julia
julia> A = rand(5,5)
5×5 Matrix{Float64}:
 0.486094 0.75991 0.621441 0.539697 0.575809
 0.0490788 0.705689 0.560474 0.87127 0.514848
 0.357313 0.722965 0.815362 0.805765 0.912823
 0.524595 0.0300627 0.457595 0.654335 0.13646
 0.105278 0.545006 0.0349351 0.73656 0.260524

julia> U = curfact(A, rank=3);

julia> F = CUR(A, U);

julia> F[:C] * F[:U] * F[:R]
5×5 Matrix{Float64}:
 0.11283 0.75991 0.621441 0.539697 0.89334
 0.299764 0.705689 0.560474 0.87127 0.707704
 0.357313 0.722965 0.815362 0.805765 0.912823
 0.524595 0.0300627 0.457595 0.654335 0.13646
 0.105278 0.545006 0.0349351 0.73656 0.260524

julia> Matrix(F[:U])
3×3 Matrix{Float64}:
 -0.828474 1.39819 1.02187
  1.11581 0.311455 -1.49733
  1.04814 -1.90959 0.549796

```
