-
-
Notifications
You must be signed in to change notification settings - Fork 836
feat: add support for accessor arrays blas/base/gaxpy
#7244
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
1e7f5ba
feat: add support for accessor arrays blas/base/gaxpy
ShabiShett07 f2a05e6
update: update implementation
ShabiShett07 35dd8ec
update: update implementation
ShabiShett07 4a5478a
chore: minor clean-up
ShabiShett07 7873e6b
chore: minor clean-up
ShabiShett07 f66263c
chore: update implementation
ShabiShett07 b07940e
chore: update implementation
ShabiShett07 ad41647
chore: remove duplicates
ShabiShett07 9bf24ea
chore: minor clean-up
ShabiShett07 b4c62a1
Discard changes to lib/node_modules/@stdlib/blas/base/gaxpy/examples/…
kgryte 3d85f32
chore: update implementation
ShabiShett07 34f0db8
chore: clean-up
kgryte File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/** | ||
* @license Apache-2.0 | ||
* | ||
* Copyright (c) 2025 The Stdlib Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
// MAIN // | ||
|
||
/** | ||
* Multiplies a vector `x` by a constant and adds the result to `y`. | ||
* | ||
* @param {PositiveInteger} N - number of indexed elements | ||
* @param {number} alpha - scalar | ||
* @param {Object} x - input array object | ||
* @param {Collection} x.data - input array data | ||
* @param {Array<Function>} x.accessors - array element accessors | ||
* @param {integer} strideX - `x` stride length | ||
* @param {NonNegativeInteger} offsetX - starting `x` index | ||
* @param {Object} y - output array object | ||
* @param {Collection} y.data - output array data | ||
* @param {Array<Function>} y.accessors - array element accessors | ||
* @param {integer} strideY - `y` stride length | ||
* @param {NonNegativeInteger} offsetY - starting `y` index | ||
* @returns {Object} output array object | ||
* | ||
* @example | ||
* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); | ||
* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); | ||
* var Float32Array = require( '@stdlib/array/float32' ); | ||
* var Complex64 = require( '@stdlib/complex/float32/ctor' ); | ||
* var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); | ||
* | ||
* var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); | ||
* var y = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); | ||
* | ||
* var z = gaxpy( x.length, 5.0, arraylike2object( toAccessorArray( x ) ), 1, 0, arraylike2object( toAccessorArray( y ) ), 1, 0 ); | ||
* | ||
* // y => <Float32Array>[ 6.0, 11.0, 16.0, 21.0, 26.0. 31.0 ] | ||
*/ | ||
function gaxpy( N, alpha, x, strideX, offsetX, y, strideY, offsetY ) { | ||
var xbuf; | ||
var ybuf; | ||
var set; | ||
var get; | ||
var tmp; | ||
var ix; | ||
var iy; | ||
var y0; | ||
var i; | ||
|
||
// Cache references to array data: | ||
xbuf = x.data; | ||
ybuf = y.data; | ||
|
||
// Cache a reference to the element accessors: | ||
get = x.accessors[ 0 ]; | ||
set = y.accessors[ 1 ]; | ||
|
||
ix = offsetX; | ||
iy = offsetY; | ||
for ( i = 0; i < N; i++ ) { | ||
y0 = ybuf[ iy ]; | ||
tmp = alpha * ( get( xbuf, ix ) + y0 ); | ||
ShabiShett07 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
set( ybuf, iy, tmp ); | ||
ix += strideX; | ||
iy += strideY; | ||
} | ||
return y; | ||
} | ||
|
||
|
||
// EXPORTS // | ||
|
||
module.exports = gaxpy; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.