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

feat: added integral approximation algorithm #1485

Merged
merged 36 commits into from
Apr 22, 2021

Conversation

bwalton24
Copy link
Contributor

Description of Change

Algorithm that takes in a lower bound, upper bound, function, and an optional delta value and computes an integral approximation.

Checklist

  • Added description of change
  • Added file name matches File name guidelines
  • Added tests and example, test must pass
  • Added documentation so that the program is self-explanatory and educational - Doxygen guidelines
  • Relevant documentation/comments is changed or added
  • PR title follows semantic commit guidelines
  • Search previous suggestions before making a new one, as yours may be a duplicate.
  • I acknowledge that all my contributions will be made under the project's license.

Notes:

@Panquesito7 Panquesito7 added the enhancement New feature or request label Apr 21, 2021
Copy link
Member

@Panquesito7 Panquesito7 left a comment

Choose a reason for hiding this comment

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

👍 Good work.

@@ -0,0 +1,111 @@
/**
* @file
* @brief Algorithm to compute integral approximation of function
Copy link
Member

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).

Comment on lines 8 to 11
#include <cassert>
#include <cmath>
#include <functional>
#include <iostream>
Copy link
Member

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

math/integral_approximation.cpp Outdated Show resolved Hide resolved
math/integral_approximation.cpp Outdated Show resolved Hide resolved
math/integral_approximation.cpp Outdated Show resolved Hide resolved
math/integral_approximation.cpp Outdated Show resolved Hide resolved
math/integral_approximation.cpp Outdated Show resolved Hide resolved
math/integral_approximation.cpp Outdated Show resolved Hide resolved
math/integral_approximation.cpp Outdated Show resolved Hide resolved
math/integral_approximation.cpp Outdated Show resolved Hide resolved
@Panquesito7 Panquesito7 added the requested changes changes required label Apr 21, 2021
@github-actions github-actions bot force-pushed the master branch 2 times, most recently from 081c080 to 23c9cfc Compare April 21, 2021 19:33
@github-actions github-actions bot force-pushed the master branch 2 times, most recently from 0d90265 to 3a53020 Compare April 21, 2021 19:43
@github-actions github-actions bot force-pushed the master branch 2 times, most recently from c8816aa to d6ac9ce Compare April 21, 2021 19:45
shiqisheng2036
shiqisheng2036 previously approved these changes Apr 21, 2021
math/integral_approximation.cpp Outdated Show resolved Hide resolved
math/integral_approximation.cpp Outdated Show resolved Hide resolved
math/integral_approximation.cpp Outdated Show resolved Hide resolved
@github-actions github-actions bot force-pushed the master branch 2 times, most recently from 95219b7 to 6a09e7f Compare April 21, 2021 20:18
Copy link
Member

@Panquesito7 Panquesito7 left a 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.

const std::function<double(double)>& func,
double delta = .0001) {
double result = 0;
int numDeltas = static_cast<int>((ub - lb) / delta);
Copy link
Member

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).

Copy link
Member

@Panquesito7 Panquesito7 left a 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! 👍 🎉

@Panquesito7 Panquesito7 added approved Approved; waiting for merge and removed requested changes changes required labels Apr 22, 2021
Copy link
Member

@ayaankhan98 ayaankhan98 left a 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

@ayaankhan98 ayaankhan98 merged commit a41b707 into TheAlgorithms:master Apr 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Approved; waiting for merge enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants