-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
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
feat: added integral approximation algorithm #1485
Conversation
Maintains functionality but dividing by 2 is easier to read/understand
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Good work.
math/integral_approximation.cpp
Outdated
@@ -0,0 +1,111 @@ | |||
/** | |||
* @file | |||
* @brief Algorithm to compute integral approximation of function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Provide a Wikipedia link in Markdown format (if available/possible).
If there's no Wikipedia link, add another web source for algorithm explanation.
Also, add a detailed/long description of the algorithm (use @details
for this).
math/integral_approximation.cpp
Outdated
#include <cassert> | ||
#include <cmath> | ||
#include <functional> | ||
#include <iostream> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a one-line description of what the library/header is for (see the example below).
#include <cassert> /// for assert
#include <iostream> /// for IO operations
Co-authored-by: David Leal <halfpacho@gmail.com>
Co-authored-by: David Leal <halfpacho@gmail.com>
Co-authored-by: David Leal <halfpacho@gmail.com>
081c080
to
23c9cfc
Compare
Co-authored-by: David Leal <halfpacho@gmail.com>
79dbaff
to
8ed70fc
Compare
Co-authored-by: David Leal <halfpacho@gmail.com>
0d90265
to
3a53020
Compare
c8816aa
to
d6ac9ce
Compare
c2eb8f8
to
7e09f2c
Compare
Co-authored-by: David Leal <halfpacho@gmail.com>
Co-authored-by: David Leal <halfpacho@gmail.com>
Co-authored-by: David Leal <halfpacho@gmail.com>
95219b7
to
6a09e7f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please address all the unresolved conversations above.
Co-authored-by: David Leal <halfpacho@gmail.com>
math/integral_approximation.cpp
Outdated
const std::function<double(double)>& func, | ||
double delta = .0001) { | ||
double result = 0; | ||
int numDeltas = static_cast<int>((ub - lb) / delta); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using uint64_t
for non-negative values (or their appropriate size: uint32_t
, uint16_t
, uint8_t
) or int64_t
for negative values. Check other parts of the code (reference).
Co-authored-by: David Leal <halfpacho@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work; your code is neat. Thank you for your contribution! 👍 🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for your contribution @bwalton24
Description of Change
Algorithm that takes in a lower bound, upper bound, function, and an optional delta value and computes an integral approximation.
Checklist
Notes: