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

Use built-in sum instead of writing our own ad-hoc version #738

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

matthiasgoergens
Copy link
Collaborator

@matthiasgoergens matthiasgoergens commented Dec 12, 2024

Extracted from #736 for ease of review.

self[1..]
.iter()
.fold(self[0].double(), |acc, coeff| acc + coeff)
self[0] + self[..].iter().sum::<E>()
Copy link
Collaborator Author

@matthiasgoergens matthiasgoergens Dec 12, 2024

Choose a reason for hiding this comment

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

Doubling the first element is a bit weird. But the tests seem to expect it. What's the reason for it?

@yczhangsjtu I think you wrote that code? Could you please enlighten me? (I'll probably make a documenting comment out of your answer later.) Thanks!

@matthiasgoergens matthiasgoergens changed the title Use sum instead of writing our own Use built-in sum instead of writing our own ad-hoc version Dec 12, 2024
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.

1 participant