# Choleski Factorization transpose

**URL:** <https://discourse.julialang.org/t/choleski-factorization-transpose/9483>\
**Category:** New to Julia\
**Tags:** question, linearalgebra\
**Created:** [March 4, 2018, 3:55am UTC](https://discourse.julialang.org/t/choleski-factorization-transpose/9483 "2018-03-04T03:55:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yifan\_Liu](https://avatars.discourse-cdn.com/v4/letter/y/4da419/32.png) [@Yifan\_Liu](https://discourse.julialang.org/u/Yifan_Liu)\
**Post date:** [March 4, 2018, 3:55am UTC](https://discourse.julialang.org/t/choleski-factorization-transpose/9483/1 "2018-03-04T03:55:59Z")

</div>

I have a Matlab code like this:

```julia

    T = 0.5;
    NbPas=100;
    DeltaT=T/NbPas;
    rho=-0.2;
    
L = chol([DeltaT,rho*DeltaT;rho*DeltaT,DeltaT])’;

```

I tried to translate it into Julia code:

```julia

    T = 0.5
    NbPas=100
    DeltaT=T/NbPas
    rho=-0.2
    
L = cholfact([DeltaT rho*DeltaT;rho*DeltaT DeltaT])’

```

but got an error message

```julia

ctranspose not implemented for Base.LinAlg.Cholesky{Float64,Array{Float64,2}}

```

---

<div class="post-metadata">

**Author:** ![Elrod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elrod/32/22461_2.png) [@Elrod](https://discourse.julialang.org/u/Elrod)\
**Post date:** [March 4, 2018, 4:13am UTC](https://discourse.julialang.org/t/choleski-factorization-transpose/9483/2 "2018-03-04T04:13:38Z")

</div>

Either:

```julia
L = chol([DeltaT rho*DeltaT;rho*DeltaT DeltaT])’
L = cholfact([DeltaT rho*DeltaT;rho*DeltaT DeltaT], :L)

```

---

<div class="post-metadata">

**Author:** ![Yifan\_Liu](https://avatars.discourse-cdn.com/v4/letter/y/4da419/32.png) [@Yifan\_Liu](https://discourse.julialang.org/u/Yifan_Liu)\
**Post date:** [March 4, 2018, 4:15am UTC](https://discourse.julialang.org/t/choleski-factorization-transpose/9483/3 "2018-03-04T04:15:17Z")

</div>

Thanks so much!

---

<div class="post-metadata">

**Author:** ![Elrod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elrod/32/22461_2.png) [@Elrod](https://discourse.julialang.org/u/Elrod)\
**Post date:** [March 4, 2018, 4:18am UTC](https://discourse.julialang.org/t/choleski-factorization-transpose/9483/4 "2018-03-04T04:18:26Z")

</div>

The latter returns a cholesky factor object (which is not a subtype of abstract array), instead of a lower triangular matrix. You can extract it with

```julia
L = cholfact([DeltaT rho*DeltaT;rho*DeltaT DeltaT], :L)
Lmatrix = L[:L]

```

Alternatively, these work:

```julia
L = cholfact([DeltaT rho*DeltaT;rho*DeltaT DeltaT])[:L]
L = cholfact([DeltaT rho*DeltaT;rho*DeltaT DeltaT], :L)[:L]

```

If performance matters, go with the latter of these two. The former computes the upper triangular, and then transposes it while the latter gets the lower triangular directly.

For a 4000x4000 matrix, this makes the difference between 262/315 and 185/187 ms minimum/median on my computer.  
Extra allocations of non-lazy tranpose on 0.6.2 is why the minimum/median gap is so big for calculating the upper triangle and transposing.

On 0.7 it was 270/271 and 203/204, respectively.  
Syntax was updated to `cholfact(Hermitian(X, :L)).L`.  
Memory requirements did not go down because `.L` still transposed the data when using `cholfact(Hermitian(X)).L`.

---

<div class="post-metadata">

**Author:** ![compleat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/compleat/32/8958_2.png) [@compleat](https://discourse.julialang.org/u/compleat)\
**Post date:** [June 9, 2021, 7:55pm UTC](https://discourse.julialang.org/t/choleski-factorization-transpose/9483/5 "2021-06-09T19:55:25Z")

</div>

Hi Maybe cholfact has been deprecated, but I keep getting cholfact not found. What package is it in? Has it been subsumed into cholesky()? If not, what are the differences?

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [June 9, 2021, 8:00pm UTC](https://discourse.julialang.org/t/choleski-factorization-transpose/9483/6 "2021-06-09T20:00:14Z")

</div>

You can search through History.md to find these sorts of deprecations. Looks like it was a .7 / 1.0 breaking change [here](https://github.com/JuliaLang/julia/blob/1fd46e6251b7e8fd60559ed513144efdbb69cb7c/HISTORY.md#deprecated-or-removed-6).

---

<div class="post-metadata">

**Author:** ![compleat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/compleat/32/8958_2.png) [@compleat](https://discourse.julialang.org/u/compleat)\
**Post date:** [June 9, 2021, 8:12pm UTC](https://discourse.julialang.org/t/choleski-factorization-transpose/9483/7 "2021-06-09T20:12:11Z")

</div>

Thanks! Exactly what I needed 🙂
