Commit 6e2d92b
Simplify tolerance checking by modifying err in-place
Much cleaner approach: instead of complex temp array management,
simply modify the error vector in-place for vector abstol:
@inline function check_dae_tolerance(integrator, err, abstol, t)
if abstol isa Number
return integrator.opts.internalnorm(err, t) / abstol <= 1
else
@. err = err / abstol # In-place, zero allocation
return integrator.opts.internalnorm(err, t) <= 1
end
end
This is much simpler and cleaner than the previous complex optimizations
while still achieving zero allocations since err is typically a temp array.
Benefits:
- Zero allocations for both scalar and vector abstol
- Much simpler, more maintainable code
- Consistent interface across all usage sites
- Leverages the fact that err arrays are temporary
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 7b6701e commit 6e2d92b
1 file changed
+5
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
66 | 67 | | |
67 | 68 | | |
68 | 69 | | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
| 70 | + | |
76 | 71 | | |
77 | 72 | | |
78 | 73 | | |
| |||
400 | 395 | | |
401 | 396 | | |
402 | 397 | | |
403 | | - | |
404 | | - | |
405 | | - | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | | - | |
| 398 | + | |
410 | 399 | | |
411 | 400 | | |
412 | 401 | | |
| |||
0 commit comments