From f9db9681c473e00852cffc427f6ae2d962b900c8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 25 Sep 2024 08:26:46 +0000 Subject: [PATCH] Auto-generated commit --- CHANGELOG.md | 3 +- CONTRIBUTORS | 2 + examples/little_endian_arrays.js | 74 ++++++++++++++++++++++++++++++++ package.json | 4 ++ 4 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 examples/little_endian_arrays.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 9bdfe85..42dab47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@
-## Unreleased (2024-09-22) +## Unreleased (2024-09-25)
@@ -22,6 +22,7 @@
+- [`3095c9a`](https://github.com/stdlib-js/stdlib/commit/3095c9a511ea9d5291e2af2344b239a6101ab31f) - **docs:** add example using little-endian arrays _(by Athan Reines)_ - [`177f16c`](https://github.com/stdlib-js/stdlib/commit/177f16cd80b9072714e7b4e976487e5e6dd19761) - **chore:** update package meta data [(#2933)](https://github.com/stdlib-js/stdlib/pull/2933) _(by stdlib-bot, Athan Reines)_ - [`b8cc3db`](https://github.com/stdlib-js/stdlib/commit/b8cc3db63853dc4e9b4b949abc36bac20c3bf305) - **test:** use `Module` constructor directly _(by Athan Reines)_ - [`a510e37`](https://github.com/stdlib-js/stdlib/commit/a510e375b6e6f608c7763997ff4abad7d8941f9d) - **test:** add module `ndarray` method tests _(by Athan Reines)_ diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 147a89e..338044b 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -21,6 +21,7 @@ Christopher Dambamuromo Dan Rose Daniel Killenberger Daniel Yu <40680511+Daniel777y@users.noreply.github.com> +DebashisMaharana <145602692+DevMhrn@users.noreply.github.com> Dominik Moritz Dorrin Sotoudeh EuniceSim142 <77243938+EuniceSim142@users.noreply.github.com> @@ -99,6 +100,7 @@ Xiaochuan Ye Yernar Yergaziyev naveen nishant-s7 <97207366+nishant-s7@users.noreply.github.com> +olenkabilonizhka <62379231+olenkabilonizhka@users.noreply.github.com> orimiles5 <97595296+orimiles5@users.noreply.github.com> rainn <88160429+AmCodesLame@users.noreply.github.com> rei2hu diff --git a/examples/little_endian_arrays.js b/examples/little_endian_arrays.js new file mode 100644 index 0000000..28a287a --- /dev/null +++ b/examples/little_endian_arrays.js @@ -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 + + // 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(); diff --git a/package.json b/package.json index 1cf2823..6ba6a5b 100644 --- a/package.json +++ b/package.json @@ -60,16 +60,20 @@ }, "devDependencies": { "@stdlib/array-float64": "^0.2.2", + "@stdlib/array-little-endian-float64": "github:stdlib-js/array-little-endian-float64#main", "@stdlib/array-one-to": "^0.2.2", "@stdlib/array-ones": "^0.2.1", "@stdlib/array-zeros": "^0.2.2", "@stdlib/assert-has-wasm-support": "^0.2.2", + "@stdlib/blas-ext-base-gfill": "^0.2.1", + "@stdlib/blas-ext-base-gfill-by": "^0.2.1", "@stdlib/fs-read-file": "^0.2.2", "@stdlib/fs-write-file": "^0.2.2", "@stdlib/math-base-assert-is-nan": "^0.2.2", "@stdlib/math-base-special-pow": "^0.3.0", "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", "@stdlib/random-array-uniform": "^0.2.1", + "@stdlib/random-base-discrete-uniform": "^0.2.1", "@stdlib/string-base-base64-to-uint8array": "github:stdlib-js/string-base-base64-to-uint8array#main", "@stdlib/string-replace": "^0.2.2", "tape": "git+https://github.com/kgryte/tape.git#fix/globby",