Skip to content

added Linear Interpolation by Timothy Kandiado #500

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

Merged
merged 6 commits into from
May 23, 2023

Conversation

TimothyKandiado
Copy link
Contributor

@TimothyKandiado TimothyKandiado commented May 23, 2023

Description

added linear interpolation and lagrange polynomial interpolation algorithms in the math directory

Type of change

  • [ x ] New feature (non-breaking change which adds functionality)

Checklist:

  • [ x ] I ran bellow commands using the latest version of rust nightly.
  • [ x ] I ran cargo clippy --all -- -D warnings just before my last commit and fixed any issue that was found.
  • [ x ] I ran cargo fmt just before my last commit.
  • [ x ] I ran cargo test just before my last commit and all tests passed.
  • [ x ] I checked COUNTRIBUTING.md and my code follows its guidelines.

siriak
siriak previously approved these changes May 23, 2023
Copy link
Member

@siriak siriak 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, thanks!

@siriak
Copy link
Member

siriak commented May 23, 2023

Please run cargo fmt. Now it fails with

Diff in /home/runner/work/Rust/Rust/src/math/interpolation.rs at line 73:
         let defined_points = vec![(0.0, 0.0), (1.0, 1.0), (2.0, 4.0), (3.0, 9.0)];
 
         // check for equality
-        assert_eq!(
-            lagrange_polynomial_interpolation(1.0, &defined_points),
-            1.0
-        );
-        assert_eq!(
-            lagrange_polynomial_interpolation(2.0, &defined_points),
-            4.0
-        );
-        assert_eq!(
-            lagrange_polynomial_interpolation(3.0, &defined_points),
-            [9](https://github.com/TheAlgorithms/Rust/actions/runs/5058758579/jobs/9079526049?pr=500#step:3:10).0
-        );
+        assert_eq!(lagrange_polynomial_interpolation(1.0, &defined_points), 1.0);
+        assert_eq!(lagrange_polynomial_interpolation(2.0, &defined_points), 4.0);
+        assert_eq!(lagrange_polynomial_interpolation(3.0, &defined_points), 9.0);

@TimothyKandiado
Copy link
Contributor Author

I have run cargo fix again, please check if it works now.

Copy link
Member

@siriak siriak 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, thanks!

@siriak siriak merged commit 0d40c84 into TheAlgorithms:master May 23, 2023
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.

2 participants