## LU Factorizations in Julia.
A = randn(1000, 1000)
b = randn(1000)
println("First time: ")
@time x = A\b
println("Second time: ")
@time x = A\b ; # don't display
First time: 0.823344 seconds (3.17 M allocations: 168.208 MiB, 3.97% gc time, 98.06% compilation time) Second time: 0.027692 seconds (9 allocations: 7.645 MiB, 49.21% gc time)
## If we want to save the factorization, we can do this with lufact
println("Factorization time: ")
@time F = lu(A)
println("Solve time: ")
@time x = F\b
println("Solve time again: ")
@time x = F\b ; # don't display
Factorization time:
UndefVarError: `lu` not defined in `Main` Suggestion: check for spelling errors or missing imports. Hint: a global variable of this name may be made accessible by importing LinearAlgebra in the current active module Main Stacktrace: [1] macro expansion @ ./timing.jl:581 [inlined] [2] top-level scope @ ./In[2]:3
##
F.L
F.U
F.p
UndefVarError: `F` not defined in `Main` Suggestion: check for spelling errors or missing imports. Stacktrace: [1] top-level scope @ In[3]:2
##
size(F)
UndefVarError: `F` not defined in `Main` Suggestion: check for spelling errors or missing imports. Stacktrace: [1] top-level scope @ In[4]:2
##
# This still fails...
F = qr(randn(1000000,1)) # take the QR of a tall skinny matrix
UndefVarError: `qr` not defined in `Main` Suggestion: check for spelling errors or missing imports. Hint: a global variable of this name may be made accessible by importing LinearAlgebra in the current active module Main Stacktrace: [1] top-level scope @ In[5]:3