Skip to content

Commit

Permalink
chunk getcoeff
Browse files Browse the repository at this point in the history
  • Loading branch information
chriselrod committed Dec 21, 2023
1 parent cb4c04a commit e089c9e
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions src/systems/alias_elimination.jl
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,31 @@ end
swap!(v, i, j) = v[i], v[j] = v[j], v[i]

function getcoeff(vars, coeffs, var)
for (vj, v) in enumerate(vars)
v == var && return coeffs[vj]
Nvars = length(vars)
i = 0
chunk_size = 8
@inbounds while i < Nvars - chunk_size + 1
btup = let vars = vars, var = var, i = i
ntuple(Val(chunk_size)) do j
@inbounds vars[i + j] == var

Check warning on line 392 in src/systems/alias_elimination.jl

View check run for this annotation

Codecov / codecov/patch

src/systems/alias_elimination.jl#L390-L392

Added lines #L390 - L392 were not covered by tests
end
end
inds = ntuple(Base.Fix2(-, 1), Val(8))
eights = ntuple(Returns(8), Val(8))
inds = map(ifelse, btup, inds, eights)
inds4 = (min(inds[1], inds[5]),

Check warning on line 398 in src/systems/alias_elimination.jl

View check run for this annotation

Codecov / codecov/patch

src/systems/alias_elimination.jl#L395-L398

Added lines #L395 - L398 were not covered by tests
min(inds[2], inds[6]),
min(inds[3], inds[7]),
min(inds[4], inds[8]))
inds2 = (min(inds4[1], inds4[3]), min(inds4[2], inds4[4]))
ind = min(inds2[1], inds2[2])
if ind != 8
return coeffs[i + ind + 1]

Check warning on line 405 in src/systems/alias_elimination.jl

View check run for this annotation

Codecov / codecov/patch

src/systems/alias_elimination.jl#L402-L405

Added lines #L402 - L405 were not covered by tests
end
i += chunk_size
end

Check warning on line 408 in src/systems/alias_elimination.jl

View check run for this annotation

Codecov / codecov/patch

src/systems/alias_elimination.jl#L407-L408

Added lines #L407 - L408 were not covered by tests
@inbounds for vj in (i + 1):Nvars
vars[vj] == var && return coeffs[vj]
end
return 0
end
Expand Down

0 comments on commit e089c9e

Please sign in to comment.