proj_nonneg!

Fri, 08 May 2020 14:46:41 -0500

author
Tuomo Valkonen <tuomov@iki.fi>
date
Fri, 08 May 2020 14:46:41 -0500
changeset 18
0253c5881812
parent 17
c4c2ab568324
child 19
63849571a046

proj_nonneg!

src/Util.jl file | annotate | diff | comparison | revisions
--- a/src/Util.jl	Mon Apr 20 18:47:09 2020 -0500
+++ b/src/Util.jl	Fri May 08 14:46:41 2020 -0500
@@ -22,6 +22,7 @@
        dot,
        mean,
        proj_norm₂₁ball!,
+       proj_nonneg!,
        curry,
        ⬿,
        @threadsif,
@@ -191,5 +192,14 @@
     end
 end
 
+@inline function proj_nonneg!(y)
+    @inbounds @simd for i=1:length(y)
+        if y[i] < 0
+            y[i] = 0
+        end
+    end
+    return y
+end
+
 end # Module
 

mercurial