Skip to content

feat: add C implementation for stats/base/ndarray/smediansorted#10252

Open
LoayAhmed304 wants to merge 22 commits intostdlib-js:developfrom
LoayAhmed304:feat/c-smediansorted
Open

feat: add C implementation for stats/base/ndarray/smediansorted#10252
LoayAhmed304 wants to merge 22 commits intostdlib-js:developfrom
LoayAhmed304:feat/c-smediansorted

Conversation

@LoayAhmed304
Copy link
Contributor

Resolves #{{TODO: add issue number}}.

Description

What is the purpose of this pull request?

This pull request:

  • Adds C implementation for stats/base/ndarray/smediansorted package.

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

  • #{{TODO: add related issue number}}

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.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

If you answered "yes" to using AI assistance, please provide a short disclosure indicating how you used AI assistance. This helps reviewers determine how much scrutiny to apply when reviewing your contribution. Example disclosures: "This PR was written primarily by Claude Code." or "I consulted ChatGPT to understand the codebase, but the proposed changes were fully authored manually by myself.".

{{TODO: add disclosure if applicable}}


@stdlib-js/reviewers

@stdlib-bot stdlib-bot added Statistics Issue or pull request related to statistical functionality. Needs Review A pull request which needs code review. labels Feb 13, 2026
@stdlib-bot
Copy link
Contributor

stdlib-bot commented Feb 13, 2026

Coverage Report

Package Statements Branches Functions Lines
stats/base/ndarray/smediansorted $\color{green}170/170$
$\color{green}+0.00%$
$\color{green}7/7$
$\color{green}+0.00%$
$\color{green}2/2$
$\color{green}+0.00%$
$\color{green}170/170$
$\color{green}+0.00%$

The above coverage report was generated for the changes in this PR.

@Sachinn-64 Sachinn-64 changed the title feat: add C impl for stats/base/ndarray/smediansorted feat: add C implementation for stats/base/ndarray/smediansorted Feb 13, 2026
@Sachinn-64 Sachinn-64 self-requested a review February 15, 2026 07:15
Copy link
Member

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

Thanks for your PR! Left an initial round of comments.

@Planeshifter Planeshifter added Needs Changes Pull request which needs changes before being merged. and removed Needs Review A pull request which needs code review. labels Feb 15, 2026
Signed-off-by: Sachin Pangal <151670745+Sachinn-64@users.noreply.github.com>
Comment on lines 130 to 132
for ( i = 0; i < len; i++ ) {
data[ i ] = ( rand_float() * 20000.0f ) - 10000.0f;
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
for ( i = 0; i < len; i++ ) {
data[ i ] = ( rand_float() * 20000.0f ) - 10000.0f;
}
for ( i = 0; i < len; i++ ) {
data[ i ] = (float)i;
}

This implementation does not generate sorted data. Since values are assigned using a random generator, the resulting array is not guaranteed to be sorted. This PR is meant to benchmark or handle sorted input.

Copy link
Contributor Author

@LoayAhmed304 LoayAhmed304 Feb 16, 2026

Choose a reason for hiding this comment

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

I've implemented the suggested ndarray generation and hence removed the time.h header and the rand_double() function since we don't deal with random values anymore (check 2c9fb40 ). However, should we really implement this as you suggested or mimic benchmark.js which creates a linear space of ordered values for a given interval? I haven't found a reference C length benchmark of a sorted-input package.

Signed-off-by: Sachin Pangal <151670745+Sachinn-64@users.noreply.github.com>
Signed-off-by: Sachin Pangal <151670745+Sachinn-64@users.noreply.github.com>
Signed-off-by: Sachin Pangal <151670745+Sachinn-64@users.noreply.github.com>
Sachinn-64 and others added 4 commits February 17, 2026 02:19
Signed-off-by: Sachin Pangal <151670745+Sachinn-64@users.noreply.github.com>
Update copyright year in test file.

Signed-off-by: Sachin Pangal <151670745+Sachinn-64@users.noreply.github.com>
@LoayAhmed304
Copy link
Contributor Author

I've adjusted the requested changes and responded with comments with my questions. Thank you for the review 🙏 @Sachinn-64 @Planeshifter

@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Feb 16, 2026
Signed-off-by: Sachin Pangal <151670745+Sachinn-64@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Changes Pull request which needs changes before being merged. Needs Review A pull request which needs code review. Statistics Issue or pull request related to statistical functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Comments