Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

julia, linear algebra, is there a function finding all vectors orthogonal to the given one?

For a given vector I would like to find the orthogonal basis around it, i.e. the given vector normalized and randomly chosen basis of orthogonal sub-space. Is there a convenient function for this in Julia?

like image 323
xealits Avatar asked Sep 19 '16 17:09

xealits


2 Answers

The function you are looking for is called nullspace.

julia> x = randn(5);

julia> x⊥ = nullspace(x');

julia> x'x⊥
1×4 Array{Float64,2}:
 7.69373e-16  -5.45785e-16  -4.27252e-17  1.26778e-16
like image 108
Andreas Noack Avatar answered Oct 20 '22 00:10

Andreas Noack


You could define a function orth (if someonehasn't already done this)

orth(M) = qr(M)[1]

See here: https://groups.google.com/forum/#!topic/julia-users/eG6a4tj7LGg and http://docs.julialang.org/en/release-0.4/stdlib/linalg/

Or from IterativeSolvers.jl:

orthogonalize{T}(v::Vector{T}, K::KrylovSubspace{T})

See: https://github.com/JuliaMath/IterativeSolvers.jl

like image 40
Alexander Morley Avatar answered Oct 19 '22 22:10

Alexander Morley