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: add C implementation for math/base/assert/is-composite #1918

Conversation

performant23
Copy link
Contributor

This commit if applied adds the C implementation to @stdlib/math/base/assert/is-composite package

This pull request:

  • adds native C implementation to @stdlib/math/base/assert/is-composite

Related Issues

Does this pull request have any related issues?

This pull request:

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

No.

Checklist

Please ensure the following tasks are completed before submitting this pull request.


@stdlib-js/reviewers

This commit if applied adds the C implementation to @stdlib/math/base/assert/is-composite package
@stdlib-bot stdlib-bot added the Math Issue or pull request specific to math functionality. label Mar 16, 2024
@performant23
Copy link
Contributor Author

performant23 commented Mar 16, 2024

working on the C examples and benchmarks!

Edit: have fixed the .c file! Requesting you to review the PR. Thanks!

Note: The current function checks if a number is composite using:

return ( stdlib_base_is_integer( x ) && ( x > 1 ) && ( x != STDLIB_CONSTANT_FLOAT64_PINF )  && ( !stdlib_base_is_prime( x ) ) );

This is written according to the function written in lib/main.js. Please do let me know if we are to prefer something like:

...
if(condition1){
   return false;
}
...

(using multiple if statements for filtering instead of performing AND on the checks in one go).
cc @Pranavchiku

Signed-off-by: Rutam <138517416+performant23@users.noreply.github.com>
Signed-off-by: Rutam <138517416+performant23@users.noreply.github.com>
Signed-off-by: Rutam <138517416+performant23@users.noreply.github.com>
Signed-off-by: Pranav <85227306+Pranavchiku@users.noreply.github.com>
Copy link
Member

@Pranavchiku Pranavchiku 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 @performant23 !

@Pranavchiku Pranavchiku added Feature Issue or pull request for adding a new feature. Native Addons Issue involves or relates to Node.js native add-ons. C Issue involves or relates to C. Ready To Merge A pull request which is ready to be merged. labels Mar 17, 2024
Signed-off-by: Philipp Burckhardt <pburckhardt@outlook.com>
@Planeshifter Planeshifter merged commit 8dffd8f into stdlib-js:develop Mar 17, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C Issue involves or relates to C. Feature Issue or pull request for adding a new feature. Math Issue or pull request specific to math functionality. Native Addons Issue involves or relates to Node.js native add-ons. Ready To Merge A pull request which is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RFC]: add C implementation for @stdlib/math/base/assert/is-composite
4 participants