MilesCranmer commited on
Commit
ec58b6d
1 Parent(s): 0f6ed91

Increase speed by explicitly allocating arrays

Browse files
Files changed (1) hide show
  1. julia/sr.jl +2 -2
julia/sr.jl CHANGED
@@ -240,9 +240,9 @@ end
240
  function evalTreeArray(tree::Node)::Array{Float32, 1}
241
  if tree.degree == 0
242
  if tree.constant
243
- return ones(Float32, len) .* tree.val
244
  else
245
- return ones(Float32, len) .* X[:, tree.val]
246
  end
247
  elseif tree.degree == 1
248
  return unaops[tree.op].(evalTreeArray(tree.l))
 
240
  function evalTreeArray(tree::Node)::Array{Float32, 1}
241
  if tree.degree == 0
242
  if tree.constant
243
+ return fill(tree.val, len)
244
  else
245
+ return copy(X[:, tree.val])
246
  end
247
  elseif tree.degree == 1
248
  return unaops[tree.op].(evalTreeArray(tree.l))