feat: add `blas/base/csscal`
If applied, this commit will add the package blas/base/csscal which effectively scales a complex single-precision floating-point vector by a real single-precision floating-point constant.
Description
This pull request:
- includes the support for C and Fortran and obtains Fortran reference from this page
Related Issues
Does this pull request have any related issues?
This pull request:
- resolves a part of #2039
- resolves #2173
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.
- [x] Read, understood, and followed the contributing guidelines.
@stdlib-js/reviewers
Hello, I have to do some styling changes in the package like spaces before any kind of brackets in the JS implementations and write README.md but since I got some issues while running, just thought I should open up a draft PR. So, I request you to ignore those for the time being.
Some notes:
- The test data is taken from PR for
cscal. - For representing the input array, we have used
x/X(andx0,x1) for JS and C while usingcxsince in packages likeccopythat same convention is followed. If we're requiring the use of namescx/CX, please do let me know so that I can make the changes on them before code review (since there are a lot of those instances).
- For
test.ndarray.native.js, I am getting this error for both Fortran and C:
return new Float32Array( x.buffer, x.byteOffset+(x.BYTES_PER_ELEMENT*offset), 2*(x.length-offset) ); // eslint-disable-line max-len
^
RangeError: Start offset -24 is outside the bounds of the buffer
at new Float32Array (<anonymous>)
at reinterpret (d:\stdlib\lib\node_modules\@stdlib\strided\base\reinterpret-complex64\lib\main.js:47:9)
at csscal (d:\stdlib\lib\node_modules\@stdlib\blas\base\csscal\lib\ndarray.native.js:63:10)
at Test.test (d:\stdlib\lib\node_modules\@stdlib\blas\base\csscal\test\test.ndarray.native.js:254:2)
at Test.bound [as _cb] (d:\stdlib\node_modules\tape\lib\test.js:58:32)
at Test.run (d:\stdlib\node_modules\tape\lib\test.js:77:10)
at Test.bound [as run] (d:\stdlib\node_modules\tape\lib\test.js:58:32)
at Immediate.next (d:\stdlib\node_modules\tape\lib\results.js:70:15)
at process.processImmediate (node:internal/timers:476:21)
when i keep stride less than 0 like csscal( 4, alpha, x, -1, 0 );. I'm not sure how to approach this since it this means that in reinterpret, a negative offset value is invalid (maybe we could directly return x without any run in ndarray.native.js like:
function csscal( N, alpha, x, strideX, offsetX ) {
var viewX;
offsetX = minViewBufferIndex( N, strideX, offsetX );
if (offsetX < 0) {
return x;
}
viewX = reinterpret( x, offsetX );
addon( N, new Float32Array([alpha]), viewX, strideX );
return x;
}
- Also, I'm hilariously getting an error related to modules not found while running C implementation which is also found in the PR for
cscal. I double-checked the.jsonfiles and the filepaths but the error seems persistent.
Edit: For the C lint error, I tried defining alpha_len inside the function scope, directly typecasting to int64_t, and passing alpha_len's address but still gives errors to build the add-ons.
⭐ Since the PR for cscal itself is under review and there was no corresponding z* implementation, I expect this PR to be fairly involved but yeah, it would be really helpful too in terms of understanding how c* and in general, how blas routines using complex numbers are implemented. So, thank you so much in advance!
@performant23 Sorry for the long turnaround. PRs for cscal and zscal have now been merged. It is likely worth checking out the final implementations as currently in the develop branch. Updating based on those implementations may help resolve some of the errors you're seeing.