Repository navigation
Commit 80fca19
authored
perf: compute Twist3.Ad() directly instead of via a throwaway SE3 (#211)
## Summary
- `Twist3.Ad()` was `return self.SE3().Ad()` -- builds a full, validated
`SE3` object purely to immediately extract its array inside `.Ad()` and
discard the object.
- Computes the same result directly: `smb.tr2adjoint(smb.trexp(self.S,
check=False))`. Same underlying math (`trexp` then `tr2adjoint`), just
without the intermediate pose-object construction.
- No behavior change: bit-identical output for the general case, only
the computation path is different.
- No existing test covered `Ad()` at all. Added one first, with
hand-verified ground truth (not derived from `Ad()` itself) for
pure-rotation (block-diagonal `[[R,0],[0,R]]`) and pure-translation
(`skew(t)` coupling) cases, plus a cross-check against `SE3.Ad()` over
20 random transforms -- confirmed it passes unchanged against both the
old and new implementation.
## Test plan
- [x] New `test_Ad` passes against the old implementation
(`self.SE3().Ad()`) -- establishes the correctness baseline
- [x] Passes unchanged after the optimization -- confirms
behavior-preserving
- [x] `pytest tests/` -- full suite, 343 passed, no regressions
- [x] Benchmarked old vs new in the same process: 35.7us vs 25.6us per
call, 1.40x faster, results bit-identical
(`np.testing.assert_almost_equal`)1 parent 9295833 commit 80fca19
2 files changed
Lines changed: 30 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
903 | 903 | | |
904 | 904 | | |
905 | 905 | | |
906 | | - | |
907 | | - | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
908 | 909 | | |
909 | 910 | | |
910 | 911 | | |
911 | | - | |
| 912 | + | |
912 | 913 | | |
913 | 914 | | |
914 | 915 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
193 | 219 | | |
194 | 220 | | |
195 | 221 | | |
| |||
0 commit comments