-
-
Notifications
You must be signed in to change notification settings - Fork 903
feat: add blas/ext/base/dcopy-within
#8234
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
base: develop
Are you sure you want to change the base?
Conversation
--- 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 ---
/stdlib help |
@headlessNode, available slash commands include:
|
/stdlib update-copyright-years |
Coverage Report
The above coverage report was generated for the changes in this PR. |
var dcopyWithin = require( '@stdlib/blas/ext/base/dcopy-within' ); | ||
``` | ||
|
||
#### dcopyWithin( N, target, x, strideX, start, end ) |
There was a problem hiding this comment.
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 ); |
There was a problem hiding this comment.
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 ] ); |
There was a problem hiding this comment.
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 ); |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 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
* Sets an array element.
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.
- 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 ofdcopy
.ndarray. And if you usedcopy
, 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.
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes. report:
Resolves stdlib-js/metr-issue-tracker#97
Description
This pull request:
blas/ext/base/dcopy-within
Related Issues
This pull request:
blas/ext/base/dcopy-within
metr-issue-tracker#97Questions
No.
Other
No.
Checklist
@stdlib-js/reviewers