Commit 1f15677
Fix repeated evaluation of fx0 in forward gradient computation
- Moved fx0 computation outside the loop in finite_difference_gradient!
- Optimizes function evaluations from 2N to N+1 for forward differences
- Maintains compatibility with both cached and uncached function values
- Simplifies logic by eliminating conditional branches in the main loop
Fixes #202
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 83ff37e commit 1f15677
1 file changed
Lines changed: 6 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
372 | 372 | | |
373 | 373 | | |
374 | 374 | | |
| 375 | + | |
375 | 376 | | |
376 | 377 | | |
377 | 378 | | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | | - | |
387 | | - | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
388 | 382 | | |
389 | 383 | | |
390 | 384 | | |
391 | 385 | | |
392 | 386 | | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
| 387 | + | |
398 | 388 | | |
399 | 389 | | |
400 | 390 | | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | | - | |
405 | | - | |
| 391 | + | |
406 | 392 | | |
407 | 393 | | |
408 | 394 | | |
| |||
0 commit comments