Skip to content

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: missing_dependencies
  • task: lint_c_examples status: missing_dependencies
  • task: lint_c_benchmarks status: missing_dependencies
  • 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 ---

Resolves stdlib-js/metr-issue-tracker#97

Description

What is the purpose of this pull request?

This pull request:

  • add blas/ext/base/dcopy-within

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: missing_dependencies
  - task: lint_c_examples
    status: missing_dependencies
  - task: lint_c_benchmarks
    status: missing_dependencies
  - 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
---
@headlessNode headlessNode added the Feature Issue or pull request for adding a new feature. label Oct 13, 2025
@stdlib-bot stdlib-bot added BLAS Issue or pull request related to Basic Linear Algebra Subprograms (BLAS). Needs Review A pull request which needs code review. and removed Feature Issue or pull request for adding a new feature. labels Oct 13, 2025
@headlessNode
Copy link
Member Author

/stdlib help

@stdlib-bot stdlib-bot added the bot: In Progress Pull request is currently awaiting automation. label Oct 13, 2025
@stdlib-bot
Copy link
Contributor

@headlessNode, available slash commands include:

  • /stdlib check-files - Check for required files.
  • /stdlib make-commands - Print make commands for package changed in PR.
  • /stdlib update-copyright-years - Update copyright header years.
  • /stdlib lint-autofix - Auto-fix lint errors.
  • /stdlib merge - Merge changes from develop branch into this PR.
  • /stdlib rebase - Rebase this PR on top of develop branch.

@stdlib-bot stdlib-bot removed the bot: In Progress Pull request is currently awaiting automation. label Oct 13, 2025
@headlessNode
Copy link
Member Author

/stdlib update-copyright-years

@headlessNode headlessNode marked this pull request as draft October 13, 2025 19:07
@stdlib-bot stdlib-bot added bot: In Progress Pull request is currently awaiting automation. and removed Needs Review A pull request which needs code review. labels Oct 13, 2025
@stdlib-bot stdlib-bot removed the bot: In Progress Pull request is currently awaiting automation. label Oct 13, 2025
@stdlib-bot
Copy link
Contributor

Coverage Report

Package Statements Branches Functions Lines
blas/ext/base/dcopy-within $\color{green}404/404$
$\color{green}+100.00\%$
$\color{green}27/27$
$\color{green}+100.00\%$
$\color{green}4/4$
$\color{green}+100.00\%$
$\color{green}404/404$
$\color{green}+100.00\%$

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

@kgryte kgryte added the Feature Issue or pull request for adding a new feature. label Oct 14, 2025
var dcopyWithin = require( '@stdlib/blas/ext/base/dcopy-within' );
```

#### dcopyWithin( N, target, x, strideX, start, end )
Copy link
Member

Choose a reason for hiding this comment

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

Splitting the target, start, and end parameters is a bit awkward. Instead, how about

dcopyWithin( N, target, start, end, x, strideX )


var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );

dcopyWithin( 3, 2, x, 1, 1, 2 );
Copy link
Member

Choose a reason for hiding this comment

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

A single value copy example isn't super informative. Set N = x.length and copy additional elements.

```javascript
var Float64Array = require( '@stdlib/array/float64' );

var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
Copy link
Member

Choose a reason for hiding this comment

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

I'd make this a tad more obvious by zeroing the non-indexed values.

var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element

// Copy within the view...
dcopyWithin( 2, 0, x1, 1, 2, 5 );
Copy link
Member

Choose a reason for hiding this comment

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

A 2-element array is not super-informative.

// Resolve copy length:
cl = min( abs( end - start ), N );

// Create a temporary copy of source elements:
Copy link
Member

@kgryte kgryte Oct 14, 2025

Choose a reason for hiding this comment

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

  1. While always copying to a temporary array is "safe", it is not the most performant. Ideally, we'd determine whether we actually need to copy. E.g., see .

We only need to copy when writing into the target region would overwrite the values we are wanting to copy. It should be possible to determine this.

  1. It's not clear why you are needing to use manual for loops once you actually perform the copy. This is exactly the use case of dcopy.ndarray. And if you use dcopy, you can get perf benefits due to hardware acceleration. In short, ensure you are appropriately leveraging what we already have rather than reinventing the wheel.

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RFC]: add blas/ext/base/dcopy-within

3 participants