Spaces:
Running
Running
Commit
·
40270bf
1
Parent(s):
ec58b6d
Recycle arrays more; gets speedup
Browse files- julia/sr.jl +13 -2
julia/sr.jl
CHANGED
|
@@ -245,9 +245,20 @@ function evalTreeArray(tree::Node)::Array{Float32, 1}
|
|
| 245 |
return copy(X[:, tree.val])
|
| 246 |
end
|
| 247 |
elseif tree.degree == 1
|
| 248 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 249 |
else
|
| 250 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 251 |
end
|
| 252 |
end
|
| 253 |
|
|
|
|
| 245 |
return copy(X[:, tree.val])
|
| 246 |
end
|
| 247 |
elseif tree.degree == 1
|
| 248 |
+
cumulator = evalTreeArray(tree.l)
|
| 249 |
+
op = unaops[tree.op]
|
| 250 |
+
@inbounds for i=1:len
|
| 251 |
+
cumulator[i] = op(cumulator[i])
|
| 252 |
+
end
|
| 253 |
+
return cumulator
|
| 254 |
else
|
| 255 |
+
op = binops[tree.op]
|
| 256 |
+
cumulator = evalTreeArray(tree.l)
|
| 257 |
+
array2 = evalTreeArray(tree.r)
|
| 258 |
+
@inbounds for i=1:len
|
| 259 |
+
cumulator[i] = op(cumulator[i], array2[i])
|
| 260 |
+
end
|
| 261 |
+
return cumulator
|
| 262 |
end
|
| 263 |
end
|
| 264 |
|