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/special/fast/uint32-log2 #1946

Conversation

performant23
Copy link
Contributor

This commit if applied adds the native C implementation to @stdlib/math/base/special/fast/uint32-log2

Description

What is the purpose of this pull request?
Add the native C implementation to @stdlib/math/base/special/fast/uint32-log2 package

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 native C implementation to @stdlib/math/base/special/fast/uint32-log2
@stdlib-bot stdlib-bot added the Math Issue or pull request specific to math functionality. label Mar 18, 2024
Signed-off-by: Rutam <[email protected]>
@performant23
Copy link
Contributor Author

performant23 commented Mar 18, 2024

Would we need to disable the cppcheck equivalent of no-unused-vars rule here? Cause we'll need to modify the value of x at intermediate stages but we never have to formally return it. If so, where can I find the instruction to disable the rule?

Edit: cc @kgryte and @Planeshifter. Hello, I'd be really grateful to receive your feedback for the query above and also, that will speed up the process since by the time the PR gets reviewed, I can keep the required changes ready!

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.

Tests fail, please check if something is off in your implementation. Thanks for your work!

  total:     5034
  passing:   2
  failing:   5032
  duration:  482ms

@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. Needs Changes Pull request which needs changes before being merged. labels Mar 19, 2024
@performant23
Copy link
Contributor Author

performant23 commented Mar 19, 2024

Hi @Pranavchiku, I was mistakenly typecasting the return value - fixed.

Edit: So about the linting error, at the last conditional, we're assigning xc but as soon as the conditional ends, we're returning out and so, since the function doesn't involve loops/recursion, the modified xc remains dormant (also it's a temporary variable inside a function and not an pointer). So, the compiler considers that assignment unnecessary and removing that fixes the error. Request you to take a look!

@kgryte kgryte self-requested a review March 22, 2024 23:32
Copy link
Member

@kgryte kgryte left a comment

Choose a reason for hiding this comment

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

Thanks for working on this, @performant23. I left a few comments and suggestions for improvement.

Copy link
Member

@kgryte kgryte left a comment

Choose a reason for hiding this comment

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

@performant23 This PR is almost there. We can simplify the addon.c file just a touch more by using another macro.

Copy link
Member

@kgryte kgryte 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, @performant23!

@kgryte kgryte removed the Needs Changes Pull request which needs changes before being merged. label Mar 23, 2024
@kgryte kgryte merged commit c17484a into stdlib-js:develop Mar 23, 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RFC]: add C implementation for @stdlib/math/base/special/fast/uint32-log2
4 participants