# Generic API to reconstruct from factorize

**URL:** https://discourse.julialang.org/t/generic-api-to-reconstruct-from-factorize/44748
**Category:** General Usage
**Tags:** question
**Created:** [August 11, 2020, 4:05pm UTC](https://discourse.julialang.org/t/generic-api-to-reconstruct-from-factorize/44748 "2020-08-11T16:05:44Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [August 11, 2020, 4:05pm UTC](https://discourse.julialang.org/t/generic-api-to-reconstruct-from-factorize/44748/1 "2020-08-11T16:05:44Z")

</div>

Is there a generic function/API to recover the original matrix from a factorization? Eg `LinearAlgebra` defines `Matrix` in various places, so

```julia
A = randn(5, 5)
F = factorize(A)
Matrix(F) # <- is there a generic API here?

```

works but this fails for generic `<:AbstractArray`, eg `StaticArrays.SMatrix` which has its own `LU`.

---

<div class="post-metadata">

### Author: ![Zach\_Christensen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zach_christensen/32/7220_2.png) [@Zach\_Christensen](https://discourse.julialang.org/u/Zach_Christensen)
#### Post date: [August 12, 2020, 9:01am UTC](https://discourse.julialang.org/t/generic-api-to-reconstruct-from-factorize/44748/2 "2020-08-12T09:01:04Z")

</div>

Unfortunately, I think it comes down to [this line](https://github.com/JuliaLang/julia/blob/master/stdlib/LinearAlgebra/src/lu.jl#L693) defining a method specifically on `LU`. It would be nice if instead factorizations had a method specific for this like

```julia
parent(F::LU) = (F.L * F.U)[invperm(F.p),:]

```

so that it wasn’t necessary to define a bunch of array specific conversions for each factorization.

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [August 12, 2020, 10:03am UTC](https://discourse.julialang.org/t/generic-api-to-reconstruct-from-factorize/44748/3 "2020-08-12T10:03:26Z")

</div>

I realized that simply documenting that an `AbstractMatrix` method (which currently exists) should be defined for all results of `factorize` would fix this issue for me.

@andreasnoack, what do you think about this?
