Skip to content

[primitives] Spell ternary operator compatibly with new AutoDiff#17533

Merged
RussTedrake merged 1 commit into
RobotLocomotion:masterfrom
jwnimmer-tri:primitives-test-ternary
Jul 9, 2022
Merged

[primitives] Spell ternary operator compatibly with new AutoDiff#17533
RussTedrake merged 1 commit into
RobotLocomotion:masterfrom
jwnimmer-tri:primitives-test-ternary

Conversation

@jwnimmer-tri

@jwnimmer-tri jwnimmer-tri commented Jul 8, 2022

Copy link
Copy Markdown
Collaborator

The new AutoDiff will have a breaking change: its derivatives() mutable accessor will no longer guide the conditional ternary operator to construct a temporary Eigen::VectorXd. There is no longer a "common type" between a constant-expression eigen xpr vector and a mutable AutoDiff derivatives vector (both a will be eigen xprs, of different types).

We plan to add sugar to make this easier down the road (i.e., without a ternary operator), but in any case forcing the constant vector to materialize in test code is not any great loss, and it's easier for the commit train to land this now and get it out of the way.

(We can't merge the sugar until we merge the new derivatives() first, so it's a bit of a Catch-22.)

Towards #17492.


This change is Reviewable

@jwnimmer-tri
jwnimmer-tri force-pushed the primitives-test-ternary branch from 36765d7 to 6566454 Compare July 8, 2022 16:31
The new AutoDiff will have a breaking change: its derivatives()
mutable accessor will no longer guide the conditional ternary
operator to construct a temporary VectorXd. There is no longer
a "common type" between a constant-expression eigen xpr vector
and an AutoDiff derivatives vector (both a will be eigen xprs,
of different types).

We plan to add sugar to make this easier down the road, but in
any case forcing the constant vector to materialize in test code
is not any great loss, and it's easier for the commit train to
land this now and get it out of the way.
@jwnimmer-tri
jwnimmer-tri force-pushed the primitives-test-ternary branch from 6566454 to 7d7da6a Compare July 8, 2022 16:33
@jwnimmer-tri jwnimmer-tri added priority: low release notes: none This pull request should not be mentioned in the release notes status: single reviewer ok https://drake.mit.edu/reviewable.html labels Jul 8, 2022
@jwnimmer-tri

Copy link
Copy Markdown
Collaborator Author

+@RussTedrake for both reviews, please?

@RussTedrake RussTedrake left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm: x2.

Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: :shipit: complete! all discussions resolved, LGTM from assignee RussTedrake(platform) (waiting on @jwnimmer-tri)

@RussTedrake
RussTedrake merged commit f65cd91 into RobotLocomotion:master Jul 9, 2022
@jwnimmer-tri
jwnimmer-tri deleted the primitives-test-ternary branch July 9, 2022 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: low release notes: none This pull request should not be mentioned in the release notes status: single reviewer ok https://drake.mit.edu/reviewable.html

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants