Skip to content

Instantly share code, notes, and snippets.

Avatar

Oliver Lylloff 1oly

  • Copenhagen, Denmark
View GitHub Profile
@1oly
1oly / gp.jl
Created July 14, 2014 07:40
subgradient projection for nnls
View gp.jl
function gp(nnls::Function,A::AbstractMatrix,b::AbstractVector,x0::AbstractVector,maxit::Integer)
obj = zeros(maxit)
x = x0
for i = 1:maxit
f,g,r = nnls(A,b,x)
g[(x.==0.0) & (g.>0.0)] = 0.0
alpha = dot(A*g,r)/dot(A*g,A*g)
x = x-alpha*g
x[x.<0.0] = 0.0
obj[i] = f
@1oly
1oly / func.jl
Last active August 29, 2015 14:02
Matlab vs. Julia
View func.jl
function func(b,x,Fps)
r = fftshift(ifft(fft(x).*Fps)) - b;
return r
end