Skip to content

feat: add blas/ext/base/sindex-of #7318

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

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

headlessNode
Copy link
Member


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: passed
  • task: lint_python status: na
  • task: lint_r status: na
  • task: lint_c_src status: na
  • task: lint_c_examples status: na
  • 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 ---

Progresses #2656 .

Description

What is the purpose of this pull request?

This pull request:

  • add blas/ext/base/sindexof

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

---
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: passed
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - 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
---
@stdlib-bot stdlib-bot added the BLAS Issue or pull request related to Basic Linear Algebra Subprograms (BLAS). label Jun 11, 2025
@headlessNode headlessNode added Feature Issue or pull request for adding a new feature. GSoC Google Summer of Code. gsoc: 2025 Google Summer of Code (2025). labels Jun 11, 2025
@stdlib-bot
Copy link
Contributor

stdlib-bot commented Jun 11, 2025

Coverage Report

Package Statements Branches Functions Lines
blas/ext/base/sindex-of $\color{red}118/119$
$\color{green}+99.16\%$
$\color{red}16/17$
$\color{green}+94.12\%$
$\color{green}1/1$
$\color{green}+100.00\%$
$\color{red}118/119$
$\color{green}+99.16\%$

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

---
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: na
  - task: lint_repl_help
    status: na
  - 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: passed
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - 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
---
@kgryte kgryte changed the title feat: add blas/ext/base/sindexof feat: add blas/ext/base/sindex-of Jun 12, 2025
var sindexOf = require( '@stdlib/blas/ext/base/sindex-of' );
```

#### sindexOf( N, searchElement, x, strideX\[, offsetX ] )
Copy link
Member

Choose a reason for hiding this comment

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

@headlessNode This is not correct. Our practice is to always have separate APIs. One for providing an offset and another in which the offset is computed. This follows BLAS conventions. I am not sure why you decided to make the API variadic.

- **searchElement**: element to search the index of.
- **x**: input [`Float32Array`][@stdlib/array/float32].
- **strideX**: index increment.
- **offsetX**: starting index (_optional_).
Copy link
Member

Choose a reason for hiding this comment

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

Incorrect. Please follow existing practice.

@@ -0,0 +1,40 @@

{{alias}}( N, searchElement, x, strideX[, offsetX ] )
Copy link
Member

Choose a reason for hiding this comment

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

Incorrect.

* var idx = sindexOf( x.length, 2.0, x, 1 );
* // returns 1
*/
declare function sindexOf( N: number, searchElement: number, x: Float32Array, strideX: number, offsetX?: number ): number;
Copy link
Member

Choose a reason for hiding this comment

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

In correct.

* ## Notes
*
* - If unable to find an element which equals a provided search element, the function returns `-1`.
* - If `offsetX` is less than zero, the starting index is resolved relative to the last array element, with the last array element corresponding to `offsetX = -1`.
Copy link
Member

Choose a reason for hiding this comment

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

Offsets are never negative. Why are you designing the API this way? Please show me what BLAS package supports this behavior.

* @param {Number} searchElement - number to search index of
* @param {Float32Array} x - input array
* @param {integer} strideX - index increment
* @param {NonNegativeInteger} [offsetX] - starting index
Copy link
Member

Choose a reason for hiding this comment

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

NonNegativeInteger directly contradicts what you stated in the index.d.ts file.

return -1;
}

if ( offsetX === void 0 ) {
Copy link
Member

Choose a reason for hiding this comment

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

Incorrect.


if ( offsetX === void 0 ) {
if ( strideX < 0 ) {
ix = x.length - 1;
Copy link
Member

Choose a reason for hiding this comment

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

We should NOT be assuming or inquiring anything about x length. Plus, this doesn't make sense at all. N and stride completely specify the array view defining what values are indexed.

@kgryte kgryte added the Needs Changes Pull request which needs changes before being merged. label Jun 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BLAS Issue or pull request related to Basic Linear Algebra Subprograms (BLAS). Feature Issue or pull request for adding a new feature. GSoC Google Summer of Code. gsoc: 2025 Google Summer of Code (2025). Needs Changes Pull request which needs changes before being merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants