From 58b8cfe04cc2d3c77b131391b020b324d6697b78 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Thu, 25 Jun 2026 00:04:12 -0700 Subject: [PATCH 1/4] feat: add `blas/ext/base/gxmy` --- 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_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - 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: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - 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/blas/ext/base/gxmy/README.md | 190 ++++++++ .../blas/ext/base/gxmy/benchmark/benchmark.js | 104 ++++ .../base/gxmy/benchmark/benchmark.ndarray.js | 104 ++++ .../@stdlib/blas/ext/base/gxmy/docs/repl.txt | 118 +++++ .../blas/ext/base/gxmy/docs/types/index.d.ts | 104 ++++ .../blas/ext/base/gxmy/docs/types/test.ts | 249 ++++++++++ .../blas/ext/base/gxmy/examples/index.js | 35 ++ .../blas/ext/base/gxmy/lib/accessors.js | 82 ++++ .../@stdlib/blas/ext/base/gxmy/lib/index.js | 59 +++ .../@stdlib/blas/ext/base/gxmy/lib/main.js | 53 +++ .../@stdlib/blas/ext/base/gxmy/lib/ndarray.js | 110 +++++ .../@stdlib/blas/ext/base/gxmy/package.json | 71 +++ .../@stdlib/blas/ext/base/gxmy/test/test.js | 38 ++ .../blas/ext/base/gxmy/test/test.main.js | 352 ++++++++++++++ .../blas/ext/base/gxmy/test/test.ndarray.js | 447 ++++++++++++++++++ 15 files changed, 2116 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gxmy/README.md create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gxmy/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gxmy/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gxmy/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gxmy/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gxmy/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gxmy/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gxmy/lib/accessors.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gxmy/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gxmy/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gxmy/lib/ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gxmy/package.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gxmy/test/test.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gxmy/test/test.main.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gxmy/test/test.ndarray.js diff --git a/lib/node_modules/@stdlib/blas/ext/base/gxmy/README.md b/lib/node_modules/@stdlib/blas/ext/base/gxmy/README.md new file mode 100644 index 000000000000..87cf5cba3329 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gxmy/README.md @@ -0,0 +1,190 @@ + + +# gxmy + +> Multiply elements of a strided array `x` by the corresponding elements of a strided array `y` and assign the results to `y`. + +
+ +This BLAS extension implements the operation + + + +```math +\mathbf{y} = \mathbf{x} \odot \mathbf{y} +``` + + + +
+ + + +
+ +## Usage + +```javascript +var gxmy = require( '@stdlib/blas/ext/base/gxmy' ); +``` + +#### gxmy( N, x, strideX, y, strideY ) + +Multiplies elements of a strided array `x` by the corresponding elements of a strided array `y` and assigns the results to `y`. + +```javascript +var x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; +var y = [ 2.0, 3.0, 4.0, 5.0, 6.0 ]; + +gxmy( x.length, x, 1, y, 1 ); +// y => [ 2.0, 6.0, 12.0, 20.0, 30.0 ] +``` + +The function has the following parameters: + +- **N**: number of indexed elements. +- **x**: input [`Array`][mdn-array] or [`typed array`][mdn-typed-array]. +- **strideX**: stride length for `x`. +- **y**: output [`Array`][mdn-array] or [`typed array`][mdn-typed-array]. +- **strideY**: stride length for `y`. + +The `N` and stride parameters determine which elements in the strided arrays are accessed at runtime. For example, to multiply every other element of `x` by every other element of `y`: + +```javascript +var x = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; +var y = [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ]; + +gxmy( 3, x, 2, y, 2 ); +// y => [ 7.0, 8.0, 27.0, 10.0, 55.0, 12.0 ] +``` + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +// Initial arrays... +var x0 = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var y0 = new Float64Array( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); + +// Create offset views... +var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var y1 = new Float64Array( y0.buffer, y0.BYTES_PER_ELEMENT*2 ); // start at 3rd element + +gxmy( 3, x1, 1, y1, 1 ); +// y0 => [ 7.0, 8.0, 18.0, 30.0, 44.0, 12.0 ] +``` + +#### gxmy.ndarray( N, x, strideX, offsetX, y, strideY, offsetY ) + +Multiplies elements of a strided array `x` by the corresponding elements of a strided array `y` and assigns the results to `y` using alternative indexing semantics. + +```javascript +var x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; +var y = [ 2.0, 3.0, 4.0, 5.0, 6.0 ]; + +gxmy.ndarray( x.length, x, 1, 0, y, 1, 0 ); +// y => [ 2.0, 6.0, 12.0, 20.0, 30.0 ] +``` + +The function has the following additional parameters: + +- **offsetX**: starting index for `x`. +- **offsetY**: starting index for `y`. + +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, to multiply the last three elements of `x` by the last three elements of `y`: + +```javascript +var x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; +var y = [ 6.0, 7.0, 8.0, 9.0, 10.0 ]; + +gxmy.ndarray( 3, x, 1, x.length-3, y, 1, y.length-3 ); +// y => [ 6.0, 7.0, 24.0, 36.0, 50.0 ] +``` + +
+ + + +
+ +## Notes + +- If `N <= 0`, both functions return `y` unchanged. +- Both functions support array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array/base/accessor`][@stdlib/array/base/accessor]). + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var gxmy = require( '@stdlib/blas/ext/base/gxmy' ); + +var x = discreteUniform( 10, -100, 100, { + 'dtype': 'float64' +}); +console.log( x ); + +var y = discreteUniform( 10, -100, 100, { + 'dtype': 'float64' +}); +console.log( y ); + +gxmy( x.length, x, 1, y, 1 ); +console.log( y ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/ext/base/gxmy/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/gxmy/benchmark/benchmark.js new file mode 100644 index 000000000000..bb86ec9f2ffa --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gxmy/benchmark/benchmark.js @@ -0,0 +1,104 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var gxmy = require( './../lib/main.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'generic' +}; + + +// FUNCTIONS // + +/** +* Create a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var x = uniform( len, -100, 100, options ); + var y = uniform( len, -100, 100, options ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = gxmy( x.length, x, 1, y, 1 ); + if ( isnan( z[ i%x.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z[ i%x.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( format( '%s:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gxmy/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gxmy/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..991bf053b271 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gxmy/benchmark/benchmark.ndarray.js @@ -0,0 +1,104 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var gxmy = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'generic' +}; + + +// FUNCTIONS // + +/** +* Create a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var x = uniform( len, -100, 100, options ); + var y = uniform( len, -100, 100, options ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = gxmy( x.length, x, 1, 0, y, 1, 0 ); + if ( isnan( z[ i%x.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z[ i%x.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( format( '%s:ndarray:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gxmy/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/gxmy/docs/repl.txt new file mode 100644 index 000000000000..76bc1faa2e26 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gxmy/docs/repl.txt @@ -0,0 +1,118 @@ + +{{alias}}( N, x, strideX, y, strideY ) + Multiplies elements of a strided array `x` by the corresponding elements of + a strided array `y` and assigns the results to `y`. + + The `N` and stride parameters determine which elements in the strided arrays + are accessed at runtime. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + If `N <= 0`, the function returns `y` unchanged. + + Parameters + ---------- + N: integer + Number of indexed elements. + + x: Array|TypedArray + Input array. + + strideX: integer + Stride length for `x`. + + y: Array|TypedArray + Output array. + + strideY: integer + Stride length for `y`. + + Returns + ------- + y: Array|TypedArray + Output array. + + Examples + -------- + // Standard Usage: + > var x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + > var y = [ 2.0, 3.0, 4.0, 5.0, 6.0 ]; + > {{alias}}( x.length, x, 1, y, 1 ) + [ 2.0, 6.0, 12.0, 20.0, 30.0 ] + + // Using `N` and stride parameters: + > x = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; + > y = [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ]; + > {{alias}}( 3, x, 2, y, 2 ) + [ 7.0, 8.0, 27.0, 10.0, 55.0, 12.0 ] + + // Using view offsets: + > var bufX = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; + > var bufY = [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ]; + > var x0 = new {{alias:@stdlib/array/float64}}( bufX ); + > var y0 = new {{alias:@stdlib/array/float64}}( bufY ); + > var offsetX = x0.BYTES_PER_ELEMENT * 1; + > var offsetY = y0.BYTES_PER_ELEMENT * 2; + > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, offsetX ); + > var y1 = new {{alias:@stdlib/array/float64}}( y0.buffer, offsetY ); + > {{alias}}( 3, x1, 1, y1, 1 ) + [ 18.0, 30.0, 44.0, 12.0 ] + > y0 + [ 7.0, 8.0, 18.0, 30.0, 44.0, 12.0 ] + + +{{alias}}.ndarray( N, x, strideX, offsetX, y, strideY, offsetY ) + Multiplies elements of a strided array `x` by the corresponding elements of + a strided array `y` and assigns the results to `y` using alternative + indexing semantics. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameters support indexing semantics based on starting + indices. + + Parameters + ---------- + N: integer + Number of indexed elements. + + x: Array|TypedArray + Input array. + + strideX: integer + Stride length for `x`. + + offsetX: integer + Starting index for `x`. + + y: Array|TypedArray + Output array. + + strideY: integer + Stride length for `y`. + + offsetY: integer + Starting index for `y`. + + Returns + ------- + y: Array|TypedArray + Output array. + + Examples + -------- + // Standard Usage: + > var x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + > var y = [ 2.0, 3.0, 4.0, 5.0, 6.0 ]; + > {{alias}}.ndarray( x.length, x, 1, 0, y, 1, 0 ) + [ 2.0, 6.0, 12.0, 20.0, 30.0 ] + + // Using index offsets: + > x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + > y = [ 6.0, 7.0, 8.0, 9.0, 10.0 ]; + > {{alias}}.ndarray( 3, x, 1, x.length-3, y, 1, y.length-3 ) + [ 6.0, 7.0, 24.0, 36.0, 50.0 ] + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/blas/ext/base/gxmy/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/gxmy/docs/types/index.d.ts new file mode 100644 index 000000000000..a4b067cb7a36 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gxmy/docs/types/index.d.ts @@ -0,0 +1,104 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 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. +*/ + +// TypeScript Version: 4.1 + +/// + +import { NumericArray, Collection, AccessorArrayLike } from '@stdlib/types/array'; + +/** +* Input array. +*/ +type InputArray = NumericArray | Collection | AccessorArrayLike; + +/** +* Interface describing `gxmy`. +*/ +interface Routine { + /** + * Multiplies elements of a strided array `x` by the corresponding elements of a strided array `y` and assigns the results to `y`. + * + * @param N - number of indexed elements + * @param x - input array + * @param strideX - `x` stride length + * @param y - output array + * @param strideY - `y` stride length + * @returns `y` + * + * @example + * var x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + * var y = [ 2.0, 3.0, 4.0, 5.0, 6.0 ]; + * + * gxmy( x.length, x, 1, y, 1 ); + * // y => [ 2.0, 6.0, 12.0, 20.0, 30.0 ] + */ + ( N: number, x: T, strideX: number, y: U, strideY: number ): U; + + /** + * Multiplies elements of a strided array `x` by the corresponding elements of a strided array `y` and assigns the results to `y` using alternative indexing semantics. + * + * @param N - number of indexed elements + * @param x - input array + * @param strideX - `x` stride length + * @param offsetX - starting index for `x` + * @param y - output array + * @param strideY - `y` stride length + * @param offsetY - starting index for `y` + * @returns `y` + * + * @example + * var x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + * var y = [ 2.0, 3.0, 4.0, 5.0, 6.0 ]; + * + * gxmy.ndarray( x.length, x, 1, 0, y, 1, 0 ); + * // y => [ 2.0, 6.0, 12.0, 20.0, 30.0 ] + */ + ndarray( N: number, x: T, strideX: number, offsetX: number, y: U, strideY: number, offsetY: number ): U; +} + +/** +* Multiplies elements of a strided array `x` by the corresponding elements of a strided array `y` and assigns the results to `y`. +* +* @param N - number of indexed elements +* @param x - input array +* @param strideX - `x` stride length +* @param y - output array +* @param strideY - `y` stride length +* @returns `y` +* +* @example +* var x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; +* var y = [ 2.0, 3.0, 4.0, 5.0, 6.0 ]; +* +* gxmy( x.length, x, 1, y, 1 ); +* // y => [ 2.0, 6.0, 12.0, 20.0, 30.0 ] +* +* @example +* var x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; +* var y = [ 2.0, 3.0, 4.0, 5.0, 6.0 ]; +* +* gxmy.ndarray( x.length, x, 1, 0, y, 1, 0 ); +* // y => [ 2.0, 6.0, 12.0, 20.0, 30.0 ] +*/ +declare var gxmy: Routine; + + +// EXPORTS // + +export = gxmy; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gxmy/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/gxmy/docs/types/test.ts new file mode 100644 index 000000000000..15f8edefd9b5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gxmy/docs/types/test.ts @@ -0,0 +1,249 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 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. +*/ + +import AccessorArray = require( '@stdlib/array/base/accessor' ); +import gxmy = require( './index' ); + + +// TESTS // + +// The function returns a numeric array... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + gxmy( x.length, x, 1, y, 1 ); // $ExpectType Float64Array + gxmy( x.length, new AccessorArray( x ), 1, new AccessorArray( y ), 1 ); // $ExpectType AccessorArray +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + gxmy( '10', x, 1, y, 1 ); // $ExpectError + gxmy( true, x, 1, y, 1 ); // $ExpectError + gxmy( false, x, 1, y, 1 ); // $ExpectError + gxmy( null, x, 1, y, 1 ); // $ExpectError + gxmy( undefined, x, 1, y, 1 ); // $ExpectError + gxmy( [], x, 1, y, 1 ); // $ExpectError + gxmy( {}, x, 1, y, 1 ); // $ExpectError + gxmy( ( x: number ): number => x, x, 1, y, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a numeric array... +{ + const y = new Float64Array( 10 ); + + gxmy( 10, 10, 1, y, 1 ); // $ExpectError + gxmy( 10, '10', 1, y, 1 ); // $ExpectError + gxmy( 10, true, 1, y, 1 ); // $ExpectError + gxmy( 10, false, 1, y, 1 ); // $ExpectError + gxmy( 10, null, 1, y, 1 ); // $ExpectError + gxmy( 10, undefined, 1, y, 1 ); // $ExpectError + gxmy( 10, [ '1' ], 1, y, 1 ); // $ExpectError + gxmy( 10, {}, 1, y, 1 ); // $ExpectError + gxmy( 10, ( x: number ): number => x, 1, y, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + gxmy( x.length, x, '10', y, 1 ); // $ExpectError + gxmy( x.length, x, true, y, 1 ); // $ExpectError + gxmy( x.length, x, false, y, 1 ); // $ExpectError + gxmy( x.length, x, null, y, 1 ); // $ExpectError + gxmy( x.length, x, undefined, y, 1 ); // $ExpectError + gxmy( x.length, x, [], y, 1 ); // $ExpectError + gxmy( x.length, x, {}, y, 1 ); // $ExpectError + gxmy( x.length, x, ( x: number ): number => x, y, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a numeric array... +{ + const x = new Float64Array( 10 ); + + gxmy( 10, x, 1, 10, 1 ); // $ExpectError + gxmy( 10, x, 1, '10', 1 ); // $ExpectError + gxmy( 10, x, 1, true, 1 ); // $ExpectError + gxmy( 10, x, 1, false, 1 ); // $ExpectError + gxmy( 10, x, 1, null, 1 ); // $ExpectError + gxmy( 10, x, 1, undefined, 1 ); // $ExpectError + gxmy( 10, x, 1, [ '1' ], 1 ); // $ExpectError + gxmy( 10, x, 1, {}, 1 ); // $ExpectError + gxmy( 10, x, 1, ( x: number ): number => x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + gxmy( x.length, x, 1, y, '10' ); // $ExpectError + gxmy( x.length, x, 1, y, true ); // $ExpectError + gxmy( x.length, x, 1, y, false ); // $ExpectError + gxmy( x.length, x, 1, y, null ); // $ExpectError + gxmy( x.length, x, 1, y, undefined ); // $ExpectError + gxmy( x.length, x, 1, y, [] ); // $ExpectError + gxmy( x.length, x, 1, y, {} ); // $ExpectError + gxmy( x.length, x, 1, y, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + gxmy(); // $ExpectError + gxmy( x.length ); // $ExpectError + gxmy( x.length, x ); // $ExpectError + gxmy( x.length, x, 1 ); // $ExpectError + gxmy( x.length, x, 1, y ); // $ExpectError + gxmy( x.length, x, 1, y, 1, 10 ); // $ExpectError +} + +// Attached to the main export is an `ndarray` method which returns a numeric array... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + gxmy.ndarray( x.length, x, 1, 0, y, 1, 0 ); // $ExpectType Float64Array + gxmy.ndarray( x.length, new AccessorArray( x ), 1, 0, new AccessorArray( y ), 1, 0 ); // $ExpectType AccessorArray +} + +// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + gxmy.ndarray( '10', x, 1, 0, y, 1, 0 ); // $ExpectError + gxmy.ndarray( true, x, 1, 0, y, 1, 0 ); // $ExpectError + gxmy.ndarray( false, x, 1, 0, y, 1, 0 ); // $ExpectError + gxmy.ndarray( null, x, 1, 0, y, 1, 0 ); // $ExpectError + gxmy.ndarray( undefined, x, 1, 0, y, 1, 0 ); // $ExpectError + gxmy.ndarray( [], x, 1, 0, y, 1, 0 ); // $ExpectError + gxmy.ndarray( {}, x, 1, 0, y, 1, 0 ); // $ExpectError + gxmy.ndarray( ( x: number ): number => x, x, 1, 0, y, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a second argument which is not a numeric array... +{ + const y = new Float64Array( 10 ); + + gxmy.ndarray( 10, 10, 1, 0, y, 1, 0 ); // $ExpectError + gxmy.ndarray( 10, '10', 1, 0, y, 1, 0 ); // $ExpectError + gxmy.ndarray( 10, true, 1, 0, y, 1, 0 ); // $ExpectError + gxmy.ndarray( 10, false, 1, 0, y, 1, 0 ); // $ExpectError + gxmy.ndarray( 10, null, 1, 0, y, 1, 0 ); // $ExpectError + gxmy.ndarray( 10, undefined, 1, 0, y, 1, 0 ); // $ExpectError + gxmy.ndarray( 10, [ '1' ], 1, 0, y, 1, 0 ); // $ExpectError + gxmy.ndarray( 10, {}, 1, 0, y, 1, 0 ); // $ExpectError + gxmy.ndarray( 10, ( x: number ): number => x, 1, 0, y, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + gxmy.ndarray( x.length, x, '10', 0, y, 1, 0 ); // $ExpectError + gxmy.ndarray( x.length, x, true, 0, y, 1, 0 ); // $ExpectError + gxmy.ndarray( x.length, x, false, 0, y, 1, 0 ); // $ExpectError + gxmy.ndarray( x.length, x, null, 0, y, 1, 0 ); // $ExpectError + gxmy.ndarray( x.length, x, undefined, 0, y, 1, 0 ); // $ExpectError + gxmy.ndarray( x.length, x, [], 0, y, 1, 0 ); // $ExpectError + gxmy.ndarray( x.length, x, {}, 0, y, 1, 0 ); // $ExpectError + gxmy.ndarray( x.length, x, ( x: number ): number => x, 0, y, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + gxmy.ndarray( x.length, x, 1, '10', y, 1, 0 ); // $ExpectError + gxmy.ndarray( x.length, x, 1, true, y, 1, 0 ); // $ExpectError + gxmy.ndarray( x.length, x, 1, false, y, 1, 0 ); // $ExpectError + gxmy.ndarray( x.length, x, 1, null, y, 1, 0 ); // $ExpectError + gxmy.ndarray( x.length, x, 1, undefined, y, 1, 0 ); // $ExpectError + gxmy.ndarray( x.length, x, 1, [], y, 1, 0 ); // $ExpectError + gxmy.ndarray( x.length, x, 1, {}, y, 1, 0 ); // $ExpectError + gxmy.ndarray( x.length, x, 1, ( x: number ): number => x, y, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a numeric array... +{ + const x = new Float64Array( 10 ); + + gxmy.ndarray( 10, x, 1, 0, 10, 1, 0 ); // $ExpectError + gxmy.ndarray( 10, x, 1, 0, '10', 1, 0 ); // $ExpectError + gxmy.ndarray( 10, x, 1, 0, true, 1, 0 ); // $ExpectError + gxmy.ndarray( 10, x, 1, 0, false, 1, 0 ); // $ExpectError + gxmy.ndarray( 10, x, 1, 0, null, 1, 0 ); // $ExpectError + gxmy.ndarray( 10, x, 1, 0, undefined, 1, 0 ); // $ExpectError + gxmy.ndarray( 10, x, 1, 0, [ '1' ], 1, 0 ); // $ExpectError + gxmy.ndarray( 10, x, 1, 0, {}, 1, 0 ); // $ExpectError + gxmy.ndarray( 10, x, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a sixth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + gxmy.ndarray( x.length, x, 1, 0, y, '10', 0 ); // $ExpectError + gxmy.ndarray( x.length, x, 1, 0, y, true, 0 ); // $ExpectError + gxmy.ndarray( x.length, x, 1, 0, y, false, 0 ); // $ExpectError + gxmy.ndarray( x.length, x, 1, 0, y, null, 0 ); // $ExpectError + gxmy.ndarray( x.length, x, 1, 0, y, undefined, 0 ); // $ExpectError + gxmy.ndarray( x.length, x, 1, 0, y, [], 0 ); // $ExpectError + gxmy.ndarray( x.length, x, 1, 0, y, {}, 0 ); // $ExpectError + gxmy.ndarray( x.length, x, 1, 0, y, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a seventh argument which is not a number... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + gxmy.ndarray( x.length, x, 1, 0, y, 1, '10' ); // $ExpectError + gxmy.ndarray( x.length, x, 1, 0, y, 1, true ); // $ExpectError + gxmy.ndarray( x.length, x, 1, 0, y, 1, false ); // $ExpectError + gxmy.ndarray( x.length, x, 1, 0, y, 1, null ); // $ExpectError + gxmy.ndarray( x.length, x, 1, 0, y, 1, undefined ); // $ExpectError + gxmy.ndarray( x.length, x, 1, 0, y, 1, [] ); // $ExpectError + gxmy.ndarray( x.length, x, 1, 0, y, 1, {} ); // $ExpectError + gxmy.ndarray( x.length, x, 1, 0, y, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + gxmy.ndarray(); // $ExpectError + gxmy.ndarray( x.length ); // $ExpectError + gxmy.ndarray( x.length, x ); // $ExpectError + gxmy.ndarray( x.length, x, 1 ); // $ExpectError + gxmy.ndarray( x.length, x, 1, 0 ); // $ExpectError + gxmy.ndarray( x.length, x, 1, 0, y ); // $ExpectError + gxmy.ndarray( x.length, x, 1, 0, y, 1 ); // $ExpectError + gxmy.ndarray( x.length, x, 1, 0, y, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/gxmy/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/gxmy/examples/index.js new file mode 100644 index 000000000000..12828a0c357a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gxmy/examples/index.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var gxmy = require( './../lib' ); + +var x = discreteUniform( 10, -100, 100, { + 'dtype': 'float64' +}); +console.log( x ); + +var y = discreteUniform( 10, -100, 100, { + 'dtype': 'float64' +}); +console.log( y ); + +gxmy( x.length, x, 1, y, 1 ); +console.log( y ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gxmy/lib/accessors.js b/lib/node_modules/@stdlib/blas/ext/base/gxmy/lib/accessors.js new file mode 100644 index 000000000000..9f2924002bb9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gxmy/lib/accessors.js @@ -0,0 +1,82 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 elements of a strided array `x` by the corresponding elements of a strided array `y` and assigns the results to `y`. +* +* @private +* @param {PositiveInteger} N - number of indexed elements +* @param {Object} x - input array object +* @param {Collection} x.data - input array data +* @param {Array} 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} 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 x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; +* var y = [ 2.0, 3.0, 4.0, 5.0, 6.0 ]; +* +* gxmy( x.length, arraylike2object( toAccessorArray( x ) ), 1, 0, arraylike2object( toAccessorArray( y ) ), 1, 0 ); +* // y => [ 2.0, 6.0, 12.0, 20.0, 30.0 ] +*/ +function gxmy( N, x, strideX, offsetX, y, strideY, offsetY ) { + var xbuf; + var ybuf; + var xget; + var yset; + var yget; + var ix; + var iy; + var i; + + // Cache references to array data: + xbuf = x.data; + ybuf = y.data; + + // Cache references to element accessors: + xget = x.accessors[ 0 ]; + yget = y.accessors[ 0 ]; + yset = y.accessors[ 1 ]; + + ix = offsetX; + iy = offsetY; + for ( i = 0; i < N; i++ ) { + yset( ybuf, iy, xget( xbuf, ix ) * yget( ybuf, iy ) ); + ix += strideX; + iy += strideY; + } + return y; +} + + +// EXPORTS // + +module.exports = gxmy; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gxmy/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/gxmy/lib/index.js new file mode 100644 index 000000000000..327d43caa58e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gxmy/lib/index.js @@ -0,0 +1,59 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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'; + +/** +* Multiply elements of a strided array `x` by the corresponding elements of a strided array `y` and assign the results to `y`. +* +* @module @stdlib/blas/ext/base/gxmy +* +* @example +* var gxmy = require( '@stdlib/blas/ext/base/gxmy' ); +* +* var x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; +* var y = [ 2.0, 3.0, 4.0, 5.0, 6.0 ]; +* +* gxmy( x.length, x, 1, y, 1 ); +* // y => [ 2.0, 6.0, 12.0, 20.0, 30.0 ] +* +* @example +* var gxmy = require( '@stdlib/blas/ext/base/gxmy' ); +* +* var x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; +* var y = [ 2.0, 3.0, 4.0, 5.0, 6.0 ]; +* +* gxmy.ndarray( x.length, x, 1, 0, y, 1, 0 ); +* // y => [ 2.0, 6.0, 12.0, 20.0, 30.0 ] +*/ + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var main = require( './main.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( main, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gxmy/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/gxmy/lib/main.js new file mode 100644 index 000000000000..33c6a1a00fcb --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gxmy/lib/main.js @@ -0,0 +1,53 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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'; + +// MODULES // + +var stride2offset = require( '@stdlib/strided/base/stride2offset' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +/** +* Multiplies elements of a strided array `x` by the corresponding elements of a strided array `y` and assigns the results to `y`. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {NumericArray} x - input array +* @param {integer} strideX - `x` stride length +* @param {NumericArray} y - output array +* @param {integer} strideY - `y` stride length +* @returns {NumericArray} output array +* +* @example +* var x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; +* var y = [ 2.0, 3.0, 4.0, 5.0, 6.0 ]; +* +* gxmy( x.length, x, 1, y, 1 ); +* // y => [ 2.0, 6.0, 12.0, 20.0, 30.0 ] +*/ +function gxmy( N, x, strideX, y, strideY ) { + return ndarray( N, x, strideX, stride2offset( N, strideX ), y, strideY, stride2offset( N, strideY ) ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = gxmy; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gxmy/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gxmy/lib/ndarray.js new file mode 100644 index 000000000000..9834f849becc --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gxmy/lib/ndarray.js @@ -0,0 +1,110 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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'; + +// MODULES // + +var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +var accessors = require( './accessors.js' ); + + +// VARIABLES // + +var M = 5; + + +// MAIN // + +/** +* Multiplies elements of a strided array `x` by the corresponding elements of a strided array `y` and assigns the results to `y` using alternative indexing semantics. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {NumericArray} x - input array +* @param {integer} strideX - `x` stride length +* @param {NonNegativeInteger} offsetX - starting `x` index +* @param {NumericArray} y - output array +* @param {integer} strideY - `y` stride length +* @param {NonNegativeInteger} offsetY - starting `y` index +* @returns {NumericArray} output array +* +* @example +* var x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; +* var y = [ 2.0, 3.0, 4.0, 5.0, 6.0 ]; +* +* gxmy( x.length, x, 1, 0, y, 1, 0 ); +* // y => [ 2.0, 6.0, 12.0, 20.0, 30.0 ] +*/ +function gxmy( N, x, strideX, offsetX, y, strideY, offsetY ) { + var ix; + var iy; + var ox; + var oy; + var m; + var i; + + if ( N <= 0 ) { + return y; + } + ox = arraylike2object( x ); + oy = arraylike2object( y ); + if ( ox.accessorProtocol || oy.accessorProtocol ) { + accessors( N, ox, strideX, offsetX, oy, strideY, offsetY ); + return y; + } + ix = offsetX; + iy = offsetY; + + // Use loop unrolling if both strides are equal to `1`... + if ( strideX === 1 && strideY === 1 ) { + m = N % M; + + // If we have a remainder, run a clean-up loop... + if ( m > 0 ) { + for ( i = 0; i < m; i++ ) { + y[ iy ] *= x[ ix ]; + ix += strideX; + iy += strideY; + } + } + if ( N < M ) { + return y; + } + for ( i = m; i < N; i += M ) { + y[ iy ] *= x[ ix ]; + y[ iy+1 ] *= x[ ix+1 ]; + y[ iy+2 ] *= x[ ix+2 ]; + y[ iy+3 ] *= x[ ix+3 ]; + y[ iy+4 ] *= x[ ix+4 ]; + ix += M; + iy += M; + } + return y; + } + for ( i = 0; i < N; i++ ) { + y[ iy ] *= x[ ix ]; + ix += strideX; + iy += strideY; + } + return y; +} + + +// EXPORTS // + +module.exports = gxmy; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gxmy/package.json b/lib/node_modules/@stdlib/blas/ext/base/gxmy/package.json new file mode 100644 index 000000000000..391455613f7d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gxmy/package.json @@ -0,0 +1,71 @@ +{ + "name": "@stdlib/blas/ext/base/gxmy", + "version": "0.0.0", + "description": "Multiply elements of a strided array `x` by the corresponding elements of a strided array `y` and assign the results to `y`.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "blas", + "extended", + "linear", + "algebra", + "subroutines", + "multiply", + "product", + "strided", + "array", + "ndarray", + "vector", + "xmy", + "gxmy" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/gxmy/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/gxmy/test/test.js new file mode 100644 index 000000000000..a28147c2adc5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gxmy/test/test.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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'; + +// MODULES // + +var tape = require( 'tape' ); +var gxmy = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof gxmy, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the main export is a method providing an ndarray interface', function test( t ) { + t.strictEqual( typeof gxmy.ndarray, 'function', 'method is a function' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gxmy/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/gxmy/test/test.main.js new file mode 100644 index 000000000000..b9ca500faf85 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gxmy/test/test.main.js @@ -0,0 +1,352 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +var gxmy = require( './../lib/main.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof gxmy, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 5', function test( t ) { + t.strictEqual( gxmy.length, 5, 'has expected arity' ); + t.end(); +}); + +tape( 'the function multiplies elements of `x` by the corresponding elements of `y` and assigns the results to `y`', function test( t ) { + var expected; + var x; + var y; + + x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + y = [ 2.0, 3.0, 4.0, 5.0, 6.0 ]; + expected = [ + 2.0, // 1.0 * 2.0 + 6.0, // 2.0 * 3.0 + 12.0, // 3.0 * 4.0 + 20.0, // 4.0 * 5.0 + 30.0 // 5.0 * 6.0 + ]; + + gxmy( x.length, x, 1, y, 1 ); + t.deepEqual( y, expected, 'returns expected value' ); + + x = [ 1.0, 2.0 ]; + y = [ 5.0, 6.0 ]; + expected = [ 5.0, 12.0 ]; + + gxmy( x.length, x, 1, y, 1 ); + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function multiplies elements of `x` by the corresponding elements of `y` and assigns the results to `y` (accessors)', function test( t ) { + var expected; + var x; + var y; + + x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + y = [ 2.0, 3.0, 4.0, 5.0, 6.0 ]; + expected = [ + 2.0, // 1.0 * 2.0 + 6.0, // 2.0 * 3.0 + 12.0, // 3.0 * 4.0 + 20.0, // 4.0 * 5.0 + 30.0 // 5.0 * 6.0 + ]; + + gxmy( x.length, toAccessorArray( x ), 1, toAccessorArray( y ), 1 ); + t.deepEqual( y, expected, 'returns expected value' ); + + x = [ 1.0, 2.0 ]; + y = [ 5.0, 6.0 ]; + expected = [ 5.0, 12.0 ]; + + gxmy( x.length, toAccessorArray( x ), 1, toAccessorArray( y ), 1 ); + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a reference to the output array', function test( t ) { + var out; + var x; + var y; + + x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + y = [ 5.0, 6.0, 7.0, 8.0, 9.0 ]; + out = gxmy( x.length, x, 1, y, 1 ); + + t.strictEqual( out, y, 'same reference' ); + t.end(); +}); + +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `y` unchanged', function test( t ) { + var expected; + var x; + var y; + + x = [ 1.0, 2.0, 3.0 ]; + y = [ 4.0, 5.0, 6.0 ]; + expected = [ 4.0, 5.0, 6.0 ]; + + gxmy( 0, x, 1, y, 1 ); + t.deepEqual( y, expected, 'returns expected value' ); + + gxmy( -4, x, 1, y, 1 ); + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` stride', function test( t ) { + var expected; + var x; + var y; + + x = [ + 1.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]; + y = [ 2.0, 3.0, 4.0 ]; + expected = [ + 2.0, // 1.0 * 2.0 + 9.0, // 3.0 * 3.0 + 20.0 // 5.0 * 4.0 + ]; + + gxmy( 3, x, 2, y, 1 ); + t.deepEqual( y, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `x` stride (accessors)', function test( t ) { + var expected; + var x; + var y; + + x = [ + 1.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]; + y = [ 2.0, 3.0, 4.0 ]; + expected = [ + 2.0, // 1.0 * 2.0 + 9.0, // 3.0 * 3.0 + 20.0 // 5.0 * 4.0 + ]; + + gxmy( 3, toAccessorArray( x ), 2, toAccessorArray( y ), 1 ); + t.deepEqual( y, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `y` stride', function test( t ) { + var expected; + var x; + var y; + + x = [ 1.0, 2.0, 3.0 ]; + y = [ + 2.0, // 0 + 30.0, + 3.0, // 1 + 10.0, + 4.0 // 2 + ]; + expected = [ + 2.0, // 1.0 * 2.0 + 30.0, + 6.0, // 2.0 * 3.0 + 10.0, + 12.0 // 3.0 * 4.0 + ]; + + gxmy( 3, x, 1, y, 2 ); + t.deepEqual( y, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `y` stride (accessors)', function test( t ) { + var expected; + var x; + var y; + + x = [ 1.0, 2.0, 3.0 ]; + y = [ + 2.0, // 0 + 30.0, + 3.0, // 1 + 10.0, + 4.0 // 2 + ]; + expected = [ + 2.0, // 1.0 * 2.0 + 30.0, + 6.0, // 2.0 * 3.0 + 10.0, + 12.0 // 3.0 * 4.0 + ]; + + gxmy( 3, toAccessorArray( x ), 1, toAccessorArray( y ), 2 ); + t.deepEqual( y, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports negative strides', function test( t ) { + var expected; + var x; + var y; + + x = new Float64Array([ + 1.0, // 2 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 0 + ]); + y = new Float64Array([ + 4.0, // 2 + 3.0, // 1 + 2.0 // 0 + ]); + expected = new Float64Array([ + 4.0, // 1.0 * 4.0 + 9.0, // 3.0 * 3.0 + 10.0 // 5.0 * 2.0 + ]); + + gxmy( 3, x, -2, y, -1 ); + t.deepEqual( y, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports negative strides (accessors)', function test( t ) { + var expected; + var x; + var y; + + x = [ + 1.0, // 2 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 0 + ]; + y = new Float64Array([ + 4.0, // 2 + 3.0, // 1 + 2.0 // 0 + ]); + expected = new Float64Array([ + 4.0, // 1.0 * 4.0 + 9.0, // 3.0 * 3.0 + 10.0 // 5.0 * 2.0 + ]); + + gxmy( 3, toAccessorArray( x ), -2, toAccessorArray( y ), -1 ); + t.deepEqual( y, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var expected; + var x0; + var y0; + var x1; + var y1; + + x0 = new Float64Array([ + 10.0, + 1.0, // 0 + 2.0, // 1 + 3.0, // 2 + 4.0 + ]); + y0 = new Float64Array([ + 10.0, + 10.0, + 2.0, // 0 + 3.0, // 1 + 4.0 // 2 + ]); + + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + y1 = new Float64Array( y0.buffer, y0.BYTES_PER_ELEMENT*2 ); + + expected = new Float64Array([ + 10.0, + 10.0, + 2.0, // 1.0 * 2.0 + 6.0, // 2.0 * 3.0 + 12.0 // 3.0 * 4.0 + ]); + + gxmy( 3, x1, 1, y1, 1 ); + t.deepEqual( y0, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if both strides are equal to `1`, the function efficiently multiplies elements of `x` by the corresponding elements of `y` and assigns the results to `y`', function test( t ) { + var expected; + var x; + var y; + var i; + + x = new Float64Array( 100 ); + y = new Float64Array( 100 ); + expected = new Float64Array( x.length ); + for ( i = 0; i < x.length; i++ ) { + x[ i ] = i; + y[ i ] = x.length - i; + expected[ i ] = x[ i ] * y[ i ]; + } + gxmy( x.length, x, 1, y, 1 ); + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Float64Array( 240 ); + y = new Float64Array( 240 ); + expected = new Float64Array( x.length ); + for ( i = 0; i < x.length; i++ ) { + x[ i ] = i; + y[ i ] = x.length - i; + expected[ i ] = x[ i ] * y[ i ]; + } + gxmy( x.length, x, 1, y, 1 ); + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gxmy/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gxmy/test/test.ndarray.js new file mode 100644 index 000000000000..3fb2da614871 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gxmy/test/test.ndarray.js @@ -0,0 +1,447 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +var gxmy = require( './../lib/ndarray.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof gxmy, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 7', function test( t ) { + t.strictEqual( gxmy.length, 7, 'has expected arity' ); + t.end(); +}); + +tape( 'the function multiplies elements of `x` by the corresponding elements of `y` and assigns the results to `y`', function test( t ) { + var expected; + var x; + var y; + + x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + y = [ 2.0, 3.0, 4.0, 5.0, 6.0 ]; + expected = [ + 2.0, // 1.0 * 2.0 + 6.0, // 2.0 * 3.0 + 12.0, // 3.0 * 4.0 + 20.0, // 4.0 * 5.0 + 30.0 // 5.0 * 6.0 + ]; + + gxmy( x.length, x, 1, 0, y, 1, 0 ); + t.deepEqual( y, expected, 'returns expected value' ); + + x = [ 1.0, 2.0 ]; + y = [ 5.0, 6.0 ]; + expected = [ 5.0, 12.0 ]; + + gxmy( x.length, x, 1, 0, y, 1, 0 ); + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function multiplies elements of `x` by the corresponding elements of `y` and assigns the results to `y` (accessors)', function test( t ) { + var expected; + var x; + var y; + + x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + y = [ 2.0, 3.0, 4.0, 5.0, 6.0 ]; + expected = [ + 2.0, // 1.0 * 2.0 + 6.0, // 2.0 * 3.0 + 12.0, // 3.0 * 4.0 + 20.0, // 4.0 * 5.0 + 30.0 // 5.0 * 6.0 + ]; + + gxmy( x.length, toAccessorArray( x ), 1, 0, toAccessorArray( y ), 1, 0 ); + t.deepEqual( y, expected, 'returns expected value' ); + + x = [ 1.0, 2.0 ]; + y = [ 5.0, 6.0 ]; + expected = [ 5.0, 12.0 ]; + + gxmy( x.length, toAccessorArray( x ), 1, 0, toAccessorArray( y ), 1, 0 ); + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a reference to the output array', function test( t ) { + var out; + var x; + var y; + + x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + y = [ 5.0, 6.0, 7.0, 8.0, 9.0 ]; + out = gxmy( x.length, x, 1, 0, y, 1, 0 ); + + t.strictEqual( out, y, 'same reference' ); + t.end(); +}); + +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `y` unchanged', function test( t ) { + var expected; + var x; + var y; + + x = [ 1.0, 2.0, 3.0 ]; + y = [ 4.0, 5.0, 6.0 ]; + expected = [ 4.0, 5.0, 6.0 ]; + + gxmy( 0, x, 1, 0, y, 1, 0 ); + t.deepEqual( y, expected, 'returns expected value' ); + + gxmy( -4, x, 1, 0, y, 1, 0 ); + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` stride', function test( t ) { + var expected; + var x; + var y; + + x = [ + 1.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]; + y = [ 2.0, 3.0, 4.0 ]; + expected = [ + 2.0, // 1.0 * 2.0 + 9.0, // 3.0 * 3.0 + 20.0 // 5.0 * 4.0 + ]; + + gxmy( 3, x, 2, 0, y, 1, 0 ); + t.deepEqual( y, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `x` stride (accessors)', function test( t ) { + var expected; + var x; + var y; + + x = [ + 1.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]; + y = [ 2.0, 3.0, 4.0 ]; + expected = [ + 2.0, // 1.0 * 2.0 + 9.0, // 3.0 * 3.0 + 20.0 // 5.0 * 4.0 + ]; + + gxmy( 3, toAccessorArray( x ), 2, 0, toAccessorArray( y ), 1, 0 ); + t.deepEqual( y, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `y` stride', function test( t ) { + var expected; + var x; + var y; + + x = [ 1.0, 2.0, 3.0 ]; + y = [ + 2.0, // 0 + 30.0, + 3.0, // 1 + 10.0, + 4.0 // 2 + ]; + expected = [ + 2.0, // 1.0 * 2.0 + 30.0, + 6.0, // 2.0 * 3.0 + 10.0, + 12.0 // 3.0 * 4.0 + ]; + + gxmy( 3, x, 1, 0, y, 2, 0 ); + t.deepEqual( y, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `y` stride (accessors)', function test( t ) { + var expected; + var x; + var y; + + x = [ 1.0, 2.0, 3.0 ]; + y = [ + 2.0, // 0 + 30.0, + 3.0, // 1 + 10.0, + 4.0 // 2 + ]; + expected = [ + 2.0, // 1.0 * 2.0 + 30.0, + 6.0, // 2.0 * 3.0 + 10.0, + 12.0 // 3.0 * 4.0 + ]; + + gxmy( 3, toAccessorArray( x ), 1, 0, toAccessorArray( y ), 2, 0 ); + t.deepEqual( y, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports negative strides', function test( t ) { + var expected; + var x; + var y; + + x = new Float64Array([ + 1.0, // 2 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 0 + ]); + y = new Float64Array([ + 4.0, // 2 + 3.0, // 1 + 2.0 // 0 + ]); + expected = new Float64Array([ + 4.0, // 1.0 * 4.0 + 9.0, // 3.0 * 3.0 + 10.0 // 5.0 * 2.0 + ]); + + gxmy( 3, x, -2, x.length-1, y, -1, y.length-1 ); + t.deepEqual( y, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports negative strides (accessors)', function test( t ) { + var expected; + var x; + var y; + + x = [ + 1.0, // 2 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 0 + ]; + y = new Float64Array([ + 4.0, // 2 + 3.0, // 1 + 2.0 // 0 + ]); + expected = new Float64Array([ + 4.0, // 1.0 * 4.0 + 9.0, // 3.0 * 3.0 + 10.0 // 5.0 * 2.0 + ]); + + gxmy( 3, toAccessorArray( x ), -2, x.length-1, toAccessorArray( y ), -1, y.length-1 ); // eslint-disable-line max-len + t.deepEqual( y, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `x` offset', function test( t ) { + var expected; + var x; + var y; + + x = [ + 0.0, + 1.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]; + y = [ 2.0, 3.0, 4.0 ]; + expected = [ + 2.0, // 1.0 * 2.0 + 9.0, // 3.0 * 3.0 + 20.0 // 5.0 * 4.0 + ]; + + gxmy( 3, x, 2, 1, y, 1, 0 ); + t.deepEqual( y, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `x` offset (accessors)', function test( t ) { + var expected; + var x; + var y; + + x = [ + 0.0, + 1.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]; + y = [ 2.0, 3.0, 4.0 ]; + expected = [ + 2.0, // 1.0 * 2.0 + 9.0, // 3.0 * 3.0 + 20.0 // 5.0 * 4.0 + ]; + + gxmy( 3, toAccessorArray( x ), 2, 1, toAccessorArray( y ), 1, 0 ); + t.deepEqual( y, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `y` offset', function test( t ) { + var expected; + var x; + var y; + + x = [ 1.0, 2.0, 3.0 ]; + y = [ + 0.0, + 2.0, // 0 + 3.0, // 1 + 4.0 // 2 + ]; + expected = [ + 0.0, + 2.0, // 1.0 * 2.0 + 6.0, // 2.0 * 3.0 + 12.0 // 3.0 * 4.0 + ]; + + gxmy( 3, x, 1, 0, y, 1, 1 ); + t.deepEqual( y, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `y` offset (accessors)', function test( t ) { + var expected; + var x; + var y; + + x = [ 1.0, 2.0, 3.0 ]; + y = [ + 0.0, + 2.0, // 0 + 3.0, // 1 + 4.0 // 2 + ]; + expected = [ + 0.0, + 2.0, // 1.0 * 2.0 + 6.0, // 2.0 * 3.0 + 12.0 // 3.0 * 4.0 + ]; + + gxmy( 3, toAccessorArray( x ), 1, 0, toAccessorArray( y ), 1, 1 ); + t.deepEqual( y, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports complex access patterns', function test( t ) { + var expected; + var x; + var y; + + x = [ + 0.0, + 1.0, // 0 + 0.0, + 2.0, // 1 + 0.0, + 3.0 // 2 + ]; + y = [ + 0.0, + 0.0, + 2.0, // 0 + 3.0, // 1 + 4.0, // 2 + 0.0 + ]; + expected = [ + 0.0, + 0.0, + 2.0, // 1.0 * 2.0 + 6.0, // 2.0 * 3.0 + 12.0, // 3.0 * 4.0 + 0.0 + ]; + + gxmy( 3, x, 2, 1, y, 1, 2 ); + t.deepEqual( y, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if both strides are equal to `1`, the function efficiently multiplies elements of `x` by the corresponding elements of `y` and assigns the results to `y`', function test( t ) { + var expected; + var x; + var y; + var i; + + x = new Float64Array( 100 ); + y = new Float64Array( 100 ); + expected = new Float64Array( x.length ); + for ( i = 0; i < x.length; i++ ) { + x[ i ] = i; + y[ i ] = x.length - i; + expected[ i ] = x[ i ] * y[ i ]; + } + gxmy( x.length, x, 1, 0, y, 1, 0 ); + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Float64Array( 240 ); + y = new Float64Array( 240 ); + expected = new Float64Array( x.length ); + for ( i = 0; i < x.length; i++ ) { + x[ i ] = i; + y[ i ] = x.length - i; + expected[ i ] = x[ i ] * y[ i ]; + } + gxmy( x.length, x, 1, 0, y, 1, 0 ); + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); From ef458b1779f78c877c562f77632201e04a8680b1 Mon Sep 17 00:00:00 2001 From: Karan Anand <119553199+anandkaranubc@users.noreply.github.com> Date: Thu, 25 Jun 2026 01:27:46 -0700 Subject: [PATCH 2/4] Apply suggestions from code review Co-authored-by: Karan Anand <119553199+anandkaranubc@users.noreply.github.com> Signed-off-by: Karan Anand <119553199+anandkaranubc@users.noreply.github.com> --- .../@stdlib/blas/ext/base/gxmy/docs/types/index.d.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gxmy/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/gxmy/docs/types/index.d.ts index a4b067cb7a36..2f5c5a9667f9 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gxmy/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/gxmy/docs/types/index.d.ts @@ -48,7 +48,8 @@ interface Routine { * gxmy( x.length, x, 1, y, 1 ); * // y => [ 2.0, 6.0, 12.0, 20.0, 30.0 ] */ - ( N: number, x: T, strideX: number, y: U, strideY: number ): U; + ( N: number, x: InputArray, strideX: number, y: T, strideY: number ): T; + /** * Multiplies elements of a strided array `x` by the corresponding elements of a strided array `y` and assigns the results to `y` using alternative indexing semantics. @@ -69,7 +70,8 @@ interface Routine { * gxmy.ndarray( x.length, x, 1, 0, y, 1, 0 ); * // y => [ 2.0, 6.0, 12.0, 20.0, 30.0 ] */ - ndarray( N: number, x: T, strideX: number, offsetX: number, y: U, strideY: number, offsetY: number ): U; + ndarray( N: number, x: InputArray, strideX: number, offsetX: number, y: T, strideY: number, offsetY: number ): T; + } /** From 286fb7e4a1be9a3325a7a52fa37ceea0b85a4c6a Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 25 Jun 2026 02:39:21 -0700 Subject: [PATCH 3/4] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../@stdlib/blas/ext/base/gxmy/docs/types/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gxmy/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/gxmy/docs/types/index.d.ts index 2f5c5a9667f9..63643d1b480d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gxmy/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/gxmy/docs/types/index.d.ts @@ -50,7 +50,6 @@ interface Routine { */ ( N: number, x: InputArray, strideX: number, y: T, strideY: number ): T; - /** * Multiplies elements of a strided array `x` by the corresponding elements of a strided array `y` and assigns the results to `y` using alternative indexing semantics. * From a00b9a391d7fc4bca74e4b012ed6090c7bc3d77c Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 25 Jun 2026 02:39:49 -0700 Subject: [PATCH 4/4] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../@stdlib/blas/ext/base/gxmy/docs/types/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gxmy/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/gxmy/docs/types/index.d.ts index 63643d1b480d..f6f9b43cf5be 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gxmy/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/gxmy/docs/types/index.d.ts @@ -70,7 +70,6 @@ interface Routine { * // y => [ 2.0, 6.0, 12.0, 20.0, 30.0 ] */ ndarray( N: number, x: InputArray, strideX: number, offsetX: number, y: T, strideY: number, offsetY: number ): T; - } /**