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 number/float32/base/signbit #623

Open
wants to merge 14 commits into
base: develop
Choose a base branch
from

Conversation

Planeshifter
Copy link
Member

@Planeshifter Planeshifter commented Nov 15, 2022

Description

What is the purpose of this pull request?

This pull request:

  • adds a C implementation for @stdlib/number/float32/base/signbit

Related Issues

Does this pull request have any related issues?

This pull request:

  • resolves #
  • fixes #

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.

Opening this PR to test out and incrementally improve our AI workflow for scaffolding packages, which includes addition of C implementations. I expect to delete and re-run the respective scaffolding workflows multiple times as I continue improving the scaffolding outputs.

Checklist

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


@stdlib-js/reviewers

@Planeshifter Planeshifter changed the title Add C implementation Add C implementation for @stdlib/number/float32/base/signbit Nov 15, 2022
@stdlib-js stdlib-js deleted a comment from github-actions bot Nov 15, 2022
@stdlib-js stdlib-js deleted a comment from github-actions bot Nov 15, 2022
@stdlib-js stdlib-js deleted a comment from github-actions bot Nov 15, 2022
@stdlib-js stdlib-js deleted a comment from github-actions bot Nov 15, 2022
@stdlib-js stdlib-js deleted a comment from github-actions bot Nov 15, 2022
@stdlib-js stdlib-js deleted a comment from github-actions bot Nov 15, 2022
@github-actions
Copy link
Contributor

Based off the README.md file, the stdlib-bot has generated contents for the signbitf package and pushed them to the pull request branch.

Notes

  • ⚠️ The stdlib-bot uses AI to generate package content. The generated content is not guaranteed to be correct, and will require manual review and editing. ⚠️

Copy link
Member Author

@Planeshifter Planeshifter left a comment

Choose a reason for hiding this comment

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

@kgryte Would appreciate a look at the scaffolded files to catch any further issues that need to be resolved with our bot.

#include "stdlib/math/base/special/signbitf.h"
#include "stdlib/math/base/napi/unary.h"

STDLIB_MATH_BASE_NAPI_MODULE_D_B( stdlib_base_signbitf )
Copy link
Member Author

Choose a reason for hiding this comment

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

@kgryte So STDLIB_MATH_BASE_NAPI_MODULE_D_B doesn't exist in stdlib/math/base/napi/unary.h. What should this file look like?

Copy link
Member

@kgryte kgryte Nov 15, 2022

Choose a reason for hiding this comment

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

There won't be this macro, as it is not common enough. See https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/%40stdlib/number/float64/base/signbit/src/addon.c. Unless this pattern happens over and over, not likely to add. As mentioned elsewhere, cannot really predict what should go in addon.c as it will vary from package to package, even if for some types of packages, such as math/base/special/*, we predominantly use macros, this won't be true elsewhere (e.g., in number/base/* or blas/* or strided/*).

In short, in terms of scaffolding, I'd template the addon.c file with a TODO.


#### stdlib_base_float32_signbit( x )

Returns a `boolean` indicating if the sign bit for a [single-precision floating-point number][ieee754] is on (`true`) or off (`false`).
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

We cannot rely on JS and C APIs being the same in terms of API signatures.

#include <time.h>
#include <sys/time.h>

#define NAME "{{alias}}"
Copy link
Member

Choose a reason for hiding this comment

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

Missing {{alias}}.

double elapsed;
bool out;
float x;
double t;
Copy link
Member

Choose a reason for hiding this comment

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

Incorrect order.

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = ( rand_double()*1000.0f ) - 500.0f;
out = x < 0.0f;
Copy link
Member

Choose a reason for hiding this comment

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

Not sure what happened here.

Personally, I'd just insert a TODO here, as benchmarks can be fairly bespoke.

/**
* Returns a `boolean` indicating if the sign bit for a single-precision floating-point number is on (`true`) or off (`false`).
*/
bool stdlib_base_float32_signbit( const float x );
Copy link
Member

Choose a reason for hiding this comment

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

Needs to be updated. And even if returning a bool, L22 would not be correct.

* // returns true
*/
function signbitf( x ) {
return addon( x );
Copy link
Member

Choose a reason for hiding this comment

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

As the native add-on will be return an int32, need to wrap with the Boolean constructor.

"libraries": [],
"libpath": [],
"dependencies": [
"@stdlib/math/base/special/signbitf",
Copy link
Member

Choose a reason for hiding this comment

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

This is incorrect and should not be included.

@Planeshifter Planeshifter added the Ready To Merge A pull request which is ready to be merged. label Sep 14, 2024
@Planeshifter Planeshifter added Ready To Merge A pull request which is ready to be merged. and removed Ready To Merge A pull request which is ready to be merged. labels Sep 14, 2024
@stdlib-js stdlib-js deleted a comment from github-actions bot Sep 14, 2024
@Planeshifter Planeshifter added Ready To Merge A pull request which is ready to be merged. and removed Ready To Merge A pull request which is ready to be merged. labels Sep 14, 2024
@stdlib-bot
Copy link
Contributor

PR Commit Message

feat: add C implementation for `number/float32/base/signbit`

PR-URL: https://github.com/stdlib-js/stdlib/pull/623
Signed-off-by: Philipp Burckhardt <pburckhardt@outlook.com>

Please review the above commit message and make any necessary adjustments.

@Planeshifter Planeshifter removed the Ready To Merge A pull request which is ready to be merged. label Sep 14, 2024
@kgryte kgryte added the Do Not Merge Pull request which should not be merged. label Sep 16, 2024
@Planeshifter Planeshifter added the Ready To Merge A pull request which is ready to be merged. label Sep 21, 2024
@stdlib-bot
Copy link
Contributor

PR Commit Message

feat: add C implementation for `number/float32/base/signbit`

PR-URL: https://github.com/stdlib-js/stdlib/pull/623

Please review the above commit message and make any necessary adjustments.

@Planeshifter Planeshifter removed the Ready To Merge A pull request which is ready to be merged. label Sep 21, 2024
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. Do Not Merge Pull request which should not be merged. Math Issue or pull request specific to math functionality. Native Addons Issue involves or relates to Node.js native add-ons. Needs Changes Pull request which needs changes before being merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants