Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template prim sum's return type on eigen matrices (code cleanup #987) #1004

Merged
merged 4 commits into from
Aug 27, 2018

Conversation

cqfd
Copy link
Contributor

@cqfd cqfd commented Aug 25, 2018

Summary

This fixes a little bug that @bbbales2 noted in #987: prim's implementation of sum for Eigen::Matrix was always returning double, rather than its argument's (templated) element type. Per our discussion in the issue, I've also replaced sum's implementation for std::vector with the standard library algorithm std::accumulate.

Tests

One new test that makes sure that sum has the right return type for various argument types. Any other return cases I should check?

Side Effects

None.

Checklist

@cqfd cqfd changed the title Code cleanup 987 Template prim sum's return type on eigen matrices (code cleanup #987) Aug 25, 2018
Copy link
Member

@bbbales2 bbbales2 left a comment

Choose a reason for hiding this comment

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

Looks good to me

@bbbales2 bbbales2 merged commit 4b2d88b into stan-dev:develop Aug 27, 2018
@bbbales2
Copy link
Member

Thanks @cqfd!

@bbbales2
Copy link
Member

Oh whoops, @cqfd, could you add a copyright holder to the pull req.?

@cqfd
Copy link
Contributor Author

cqfd commented Aug 27, 2018

Whoops—just added it (that look right?).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants