feat: add blas/ext/base/dsortnans#9445
feat: add blas/ext/base/dsortnans#9445anandkaranubc wants to merge 2 commits intostdlib-js:developfrom
blas/ext/base/dsortnans#9445Conversation
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: passed
- task: lint_package_json
status: passed
- task: lint_repl_help
status: passed
- task: lint_javascript_src
status: passed
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: passed
- task: lint_javascript_tests
status: passed
- task: lint_javascript_benchmarks
status: na
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: passed
- task: lint_c_examples
status: passed
- task: lint_c_benchmarks
status: na
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: passed
- task: lint_license_headers
status: passed
---
| * - The algorithm is not stable, meaning that the relative order of non-NaN elements is not guaranteed to be preserved. | ||
| * | ||
| * @param {PositiveInteger} N - number of indexed elements | ||
| * @param {number} order - NaN placement order |
There was a problem hiding this comment.
| * @param {number} order - NaN placement order | |
| * @param {number} order - NaN placement order |
Is the naming convention acceptable here?
Coverage Report
The above coverage report was generated for the changes in this PR. |
| * | ||
| * ## Notes | ||
| * | ||
| * - The algorithm is not stable, meaning that the relative order of non-NaN elements is not guaranteed to be preserved. |
There was a problem hiding this comment.
| * - The algorithm is not stable, meaning that the relative order of non-NaN elements is not guaranteed to be preserved. | |
| * - The algorithm is not stable, meaning that the relative order of non-NaN elements is not guaranteed to be preserved. |
If we are using this for dquicksort, the "instability" doesn't cause an issue. We can also add something like dsortnans2 (if needed) later which would preserve the relative order of non-NaN elements.
|
|
||
| If `N <= 0` or `order == 0`, the function returns `x` unchanged. | ||
|
|
||
| A positive order places `NaN` values at the end of the array, while a |
There was a problem hiding this comment.
In this whole PR, I changed the wording from “increasing order” to “positive order.” The main reason is that we are not actually performing a sort here, and “increasing” or “decreasing” implies that some kind of sorting is taking place.
Same applies for “decreasing order” to “negative order”.
| ## Notes | ||
|
|
||
| - If `N <= 0` or `order == 0.0`, both functions return `x` unchanged. | ||
| - A positive order places `NaN` values at the end of the array, while a negative order places `NaN` values at the beginning. |
There was a problem hiding this comment.
Any explicit need to mention that (the point regarding positive/negative order)?
| x = new Float64Array( 10 ); | ||
| for ( i = 0; i < x.length; i++ ) { | ||
| if ( randu() < 0.3 ) { | ||
| x[ i ] = NaN; | ||
| } else { | ||
| x[ i ] = (randu()*20.0) - 10.0; | ||
| } | ||
| } | ||
| console.log( x ); |
There was a problem hiding this comment.
Is this kind of array generation and population okay? I wanted to inject NaNs into the array, and I couldn’t find a better way to do it.
|
I have not yet added the C/JS benchmarks because I need some suggestions here. Since no actual “sorting” is being done, I was thinking that we would only need cc: @kgryte |
| // MAIN // | ||
|
|
||
| /** | ||
| * Partitions a double-precision floating-point strided array by moving all NaNs either to the beginning or the end of the array. |
There was a problem hiding this comment.
Function description ok?
|
@kgryte Sorry for the ping, but whenever you get some time, could you please take a look at this PR? Thank you! |
Resolves None.
Description
This pull request:
dsortnanswhich partitions a double-precision floating-point strided array by moving all NaNs either to the beginning or the end of the array.Related Issues
This pull request has the following related issues:
Questions
No.
Other
No.
Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
@stdlib-js/reviewers