-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7d12522
commit f9db968
Showing
4 changed files
with
82 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
|
@@ -21,6 +21,7 @@ Christopher Dambamuromo <[email protected]> | |
Dan Rose <[email protected]> | ||
Daniel Killenberger <[email protected]> | ||
Daniel Yu <[email protected]> | ||
DebashisMaharana <[email protected]> | ||
Dominik Moritz <[email protected]> | ||
Dorrin Sotoudeh <[email protected]> | ||
EuniceSim142 <[email protected]> | ||
|
@@ -99,6 +100,7 @@ Xiaochuan Ye <[email protected]> | |
Yernar Yergaziyev <[email protected]> | ||
naveen <[email protected]> | ||
nishant-s7 <[email protected]> | ||
olenkabilonizhka <[email protected]> | ||
orimiles5 <[email protected]> | ||
rainn <[email protected]> | ||
rei2hu <[email protected]> | ||
|
This file contains 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,74 @@ | ||
/** | ||
* @license Apache-2.0 | ||
* | ||
* Copyright (c) 2024 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'; | ||
|
||
var hasWebAssemblySupport = require( '@stdlib/assert-has-wasm-support' ); | ||
var Memory = require( '@stdlib/wasm-memory' ); | ||
var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; | ||
var gfill = require( '@stdlib/blas-ext-base-gfill' ); | ||
var gfillBy = require( '@stdlib/blas-ext-base-gfill-by' ); | ||
var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); | ||
var Float64ArrayLE = require( '@stdlib/array-little-endian-float64' ); | ||
var daxpy = require( './../lib' ); | ||
|
||
function main() { | ||
if ( !hasWebAssemblySupport() ) { | ||
console.error( 'Environment does not support WebAssembly.' ); | ||
return; | ||
} | ||
// Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB): | ||
var mem = new Memory({ | ||
'initial': 10, | ||
'maximum': 100 | ||
}); | ||
|
||
// Create a BLAS routine: | ||
var mod = new daxpy.Module( mem ); | ||
// returns <Module> | ||
|
||
// Initialize the routine: | ||
mod.initializeSync(); // eslint-disable-line node/no-sync | ||
|
||
// Define a vector data type: | ||
var dtype = 'float64'; | ||
|
||
// Specify a vector length: | ||
var N = 5; | ||
|
||
// Define pointers (i.e., byte offsets) for storing two vectors: | ||
var xptr = 0; | ||
var yptr = N * bytesPerElement( dtype ); | ||
|
||
// Create typed array views over module memory: | ||
var x = new Float64ArrayLE( mod.memory.buffer, xptr, N ); | ||
var y = new Float64ArrayLE( mod.memory.buffer, yptr, N ); | ||
|
||
// Write values to module memory: | ||
gfillBy( N, x, 1, discreteUniform( -10.0, 10.0 ) ); | ||
gfill( N, 1.0, y, 1 ); | ||
|
||
// Perform computation: | ||
mod.ndarray( N, 5.0, xptr, 1, 0, yptr, 1, 0 ); | ||
|
||
// Print the results: | ||
console.log( 'x[:] = [%s]', x.toString() ); | ||
console.log( 'y[:] = [%s]', y.toString() ); | ||
} | ||
|
||
main(); |
This file contains 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