How to use the backslash operator in Julia? -


i trying invert huge matrices of order 1 million 1 million , figured backslash operator helpful in doing this. idea how it's implemented?. did not find concrete examples appreciated.

any idea how it's implemented?

it's multialgorithm. shows how use it:

julia> = rand(10,10) 10×10 array{float64,2}:  0.330453  0.294142  0.682869  0.991427   …  0.533443  0.876566   0.157157  0.666233  0.47974   0.172657  0.427015      0.501511  0.0978822  0.634164  0.829653  0.380123  0.589555  0.480963      0.606704  0.642441   0.159564  0.709197  0.570496  0.484826  0.17325       0.699379  0.0281233  0.66744  0.478663  0.87298   0.488389  0.188844      0.38193   0.641309   0.448757  0.471705  0.804767  0.420039  0.0528729  …  0.658368  0.911007   0.705696  0.679734  0.542958  0.22658   0.977581      0.197043  0.717683   0.21933  0.771544  0.326557  0.863982  0.641557      0.969889  0.382148   0.508773  0.932684  0.531116  0.838293  0.031451      0.242338  0.663352   0.784813  0.283031  0.754613  0.938358  0.0408097     0.609105  0.325545   0.671151  julia> b = rand(10) 10-element array{float64,1}:  0.0795157  0.219318  0.965155  0.896807  0.701626  0.741823  0.954437  0.573683  0.493615  0.0821557   julia> a\b 10-element array{float64,1}:   1.47909   2.39816  -0.15789   0.144003  -1.10083  -0.273698  -0.775122   0.590762  -0.0266894  -2.36216 

you can use @which see how it's defined:

julia> @which a\b \(a::abstractarray{t,2} t, b::union{abstractarray{t,1}, abstractarray{t,2}} t) in base.linalg @ linalg\generic.jl:805 

which leads here: https://github.com/julialang/julia/blob/master/base/linalg/generic.jl#l827 (line numbers change because of version differences). can see, few quick function calls determine type of matrix is. istril finds out of lower triangular: https://github.com/julialang/julia/blob/master/base/linalg/generic.jl#l987 , etc. once determines matrix type, specializes matrix as possible can efficient, , calls \. these specialized matrix types either perform factorization \ backsubstitution (which nice way use \ on own btw re-use factorization), or "directly knows" answer, triangular or diagonal matrices.

can't more concrete source.

note \ different inverting. not want invert matrix, let alone large matrix. these factorizations more numerically stable. however, inv inversion, lot lu-factorization (which in julia lufact). may want pinv psudo-inverse in cases matrix singular or close singular, should avoid instead factorize + solve system instead of using inverse.

for large sparse matrices, you'll want use iterative solvers. you'll find lot of implementations in iterativesolvers.jl


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -