Let’s follow what inv does.
https://github.com/JuliaLang/julia/blob/master/stdlib/LinearAlgebra/src/lu.jl#L142
https://github.com/JuliaLang/julia/blob/master/stdlib/LinearAlgebra/src/lu.jl#L40
Ok, so first we create a copy of A
and then compute the lu factorization via a call to LAPACK.getrf!(A)
And then:
we call LAPACK.getri!
to get the inverse of an LU-factorization.
There is “no” julia code running here, it all get shelled out to lapack. If we profile:
julia> Profile.print()
813 ./task.jl:259; (::getfield(REPL, Symbol("##26#27")){REPL.REPLBackend})()
813 ...build/usr/share/julia/stdlib/v1.1/REPL/src/REPL.jl:117; macro expansion
813 ...build/usr/share/julia/stdlib/v1.1/REPL/src/REPL.jl:85; eval_user_input(::Any, ::REPL.REPLBackend)
813 ./boot.jl:328; eval(::Module, ::Any)
813 ...hare/julia/stdlib/v1.1/LinearAlgebra/src/dense.jl:732; inv(::Array{Float64,2})
646 .../share/julia/stdlib/v1.1/LinearAlgebra/src/lu.jl:410; inv!
646 ...re/julia/stdlib/v1.1/LinearAlgebra/src/lapack.jl:978; getri!(::Array{Float64,2}, ::Array{Int64,1})
167 .../share/julia/stdlib/v1.1/LinearAlgebra/src/lu.jl:142; lu
167 .../share/julia/stdlib/v1.1/LinearAlgebra/src/lu.jl:142; lu
167 ...share/julia/stdlib/v1.1/LinearAlgebra/src/lu.jl:142; #lu#107
89 ./array.jl:308; copy
78 ./none:0; #lu!
78 ...e/julia/stdlib/v1.1/LinearAlgebra/src/lapack.jl:550; #lu!#103(::Bool, ::Function, ::Array{Float64,2}, ::Val{true})
we can see that we are inside getri!
(lapack) the majority of the time.