From 6cdb5ff8c4a8e32cacfe5106ed18a22c89b76196 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Thu, 8 Aug 2024 17:34:31 +0530 Subject: [PATCH 01/24] feat: add BLAS Level 2 routine for sger --- .../blas/base/sger/benchmark/benchmark.js | 105 +++ .../base/sger/benchmark/benchmark.ndarray.js | 105 +++ .../@stdlib/blas/base/sger/docs/repl.txt | 132 +++ .../blas/base/sger/docs/types/index.d.ts | 129 +++ .../@stdlib/blas/base/sger/docs/types/test.ts | 449 ++++++++++ .../@stdlib/blas/base/sger/examples/index.js | 39 + .../@stdlib/blas/base/sger/lib/base.js | 115 +++ .../@stdlib/blas/base/sger/lib/index.js | 72 ++ .../@stdlib/blas/base/sger/lib/main.js | 35 + .../@stdlib/blas/base/sger/lib/ndarray.js | 84 ++ .../@stdlib/blas/base/sger/lib/sger.js | 101 +++ .../@stdlib/blas/base/sger/package.json | 68 ++ .../base/sger/test/fixtures/column_major.json | 18 + .../column_major_complex_access_pattern.json | 16 + .../sger/test/fixtures/column_major_oa.json | 16 + .../test/fixtures/column_major_sa1_sa2.json | 16 + .../test/fixtures/column_major_sa1_sa2n.json | 16 + .../test/fixtures/column_major_sa1n_sa2.json | 16 + .../test/fixtures/column_major_sa1n_sa2n.json | 16 + .../sger/test/fixtures/column_major_xnyn.json | 18 + .../sger/test/fixtures/column_major_xnyp.json | 18 + .../sger/test/fixtures/column_major_xpyn.json | 18 + .../sger/test/fixtures/column_major_xpyp.json | 18 + .../base/sger/test/fixtures/row_major.json | 18 + .../row_major_complex_access_pattern.json | 16 + .../base/sger/test/fixtures/row_major_oa.json | 16 + .../sger/test/fixtures/row_major_sa1_sa2.json | 16 + .../test/fixtures/row_major_sa1_sa2n.json | 16 + .../test/fixtures/row_major_sa1n_sa2.json | 16 + .../test/fixtures/row_major_sa1n_sa2n.json | 16 + .../sger/test/fixtures/row_major_xnyn.json | 18 + .../sger/test/fixtures/row_major_xnyp.json | 18 + .../sger/test/fixtures/row_major_xpyn.json | 18 + .../sger/test/fixtures/row_major_xpyp.json | 18 + .../@stdlib/blas/base/sger/test/test.js | 82 ++ .../blas/base/sger/test/test.ndarray.js | 815 ++++++++++++++++++ .../@stdlib/blas/base/sger/test/test.sger.js | 565 ++++++++++++ 37 files changed, 3268 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/sger/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/base/sger/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/sger/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/base/sger/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/base/sger/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/base/sger/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/sger/lib/base.js create mode 100644 lib/node_modules/@stdlib/blas/base/sger/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/sger/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/base/sger/lib/ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/sger/lib/sger.js create mode 100644 lib/node_modules/@stdlib/blas/base/sger/package.json create mode 100644 lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major.json create mode 100644 lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_complex_access_pattern.json create mode 100644 lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_oa.json create mode 100644 lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1_sa2.json create mode 100644 lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1_sa2n.json create mode 100644 lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1n_sa2.json create mode 100644 lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1n_sa2n.json create mode 100644 lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_xnyn.json create mode 100644 lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_xnyp.json create mode 100644 lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_xpyn.json create mode 100644 lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_xpyp.json create mode 100644 lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major.json create mode 100644 lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_complex_access_pattern.json create mode 100644 lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_oa.json create mode 100644 lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1_sa2.json create mode 100644 lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1_sa2n.json create mode 100644 lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1n_sa2.json create mode 100644 lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1n_sa2n.json create mode 100644 lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_xnyn.json create mode 100644 lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_xnyp.json create mode 100644 lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_xpyn.json create mode 100644 lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_xpyp.json create mode 100644 lib/node_modules/@stdlib/blas/base/sger/test/test.js create mode 100644 lib/node_modules/@stdlib/blas/base/sger/test/test.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/sger/test/test.sger.js diff --git a/lib/node_modules/@stdlib/blas/base/sger/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/sger/benchmark/benchmark.js new file mode 100644 index 000000000000..d051392ada41 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/benchmark/benchmark.js @@ -0,0 +1,105 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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 isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var pkg = require( './../package.json' ).name; +var sger = require( './../lib/sger.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float32' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - array dimension size +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var x = uniform( N, -10.0, 10.0, options ); + var y = uniform( N, -10.0, 10.0, options ); + var A = uniform( N*N, -10.0, 10.0, 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 = sger( 'row-major', N, N, 1, 0, x, 1, y, 1, A, N ); + if ( isnanf( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( z[ i%z.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 = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( len ); + bench( pkg+':size='+(len*len), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/sger/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/sger/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..b2d150a154e7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/benchmark/benchmark.ndarray.js @@ -0,0 +1,105 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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 isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var pkg = require( './../package.json' ).name; +var sger = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float32' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - array dimension size +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var x = uniform( N, -10.0, 10.0, options ); + var y = uniform( N, -10.0, 10.0, options ); + var A = uniform( N*N, -10.0, 10.0, 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 = sger( N, N, 1.0, x, 1, 0, y, 1, 0, A, N, 1, 0 ); + if ( isnanf( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( z[ i%z.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 = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( len ); + bench( pkg+':ndarray:size='+(len*len), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/sger/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/sger/docs/repl.txt new file mode 100644 index 000000000000..00b207e0ebbb --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/docs/repl.txt @@ -0,0 +1,132 @@ + +{{alias}}( ord, M, N, α, x, sx, y, sy, A, lda ) + Performs the rank 1 operation `A = α*x*y^T + A`, where `α` is a scalar, `x` + is an `M` element vector, `y` is an `N` element vector and `A` is an `M` by + `N` matrix. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + If `M` or `N` or `α` is equal to `0`, the function returns `A` unchanged. + + Parameters + ---------- + ord: string + Row-major (C-style) or column-major (Fortran-style) order. + + M: integer + Number of rows in `A`. + + N: integer + Number of columns in `A`. + + α: number + Scalar constant. + + x: Float32Array + First input vector. + + sx: integer + Index increment for `x`. + + y: Float32Array + Second input vector. + + sy: integer + Index increment for `y`. + + A: Float32Array + Input Matrix. + + lda: integer + Stride of the first dimension of `A` (a.k.a., leading dimension of the + matrix `A`). + + Returns + ------- + A: Float32Array + Input Matrix. + + Examples + -------- + // Standard usage: + > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > var y = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > var A = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > var ord = 'row-major'; + > {{alias}}( ord, 2, 2, 1.0, x, 1, y, 1, A, 2 ) + [ 2.0, 3.0, 4.0, 5.0 ] + + // Advanced indexing: + > x = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > y = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > A = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > {{alias}}( ord, 2, 2, 1.0, x, -1, y, -1, A, 2 ) + [ 2.0, 3.0, 4.0, 5.0 ] + + +{{alias}}.ndarray( M, N, α, x, sx, ox, y, sy, oy, A, sa1, sa2, oa ) + Performs the rank 1 operation `A = α*x*y^T + A`, using alternative indexing + semantics and where `α` is a scalar, `x` is an `M` element vector, `y` is an + `N` element vector and `A` is an `M` by `N` matrix. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameters support indexing semantics based on starting + indices. + + Parameters + ---------- + M: integer + Number of rows in `A`. + + N: integer + Number of columns in `A`. + + α: number + Scalar constant. + + x: Float32Array + First input vector. + + sx: integer + Index increment for `x`. + + ox: integer + Starting index for `x`. + + y: Float32Array + Second input vector. + + sy: integer + Index increment for `y`. + + oy: integer + Starting index for `y`. + + A: Float32Array + Input Matrix. + + sa1: integer + Stride of the first dimension of `A`. + + sa2: integer + Stride of the second dimension of `A`. + + oa: integer + Starting index for `A`. + + Returns + ------- + A: Float32Array + Input Matrix. + + Examples + -------- + > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > var y = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > var A = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > {{alias}}.ndarray( 2, 2, 1.0, x, 1, 0, y, 1, 0, A, 2, 1, 0 ) + [ 2.0, 3.0, 4.0, 5.0 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/blas/base/sger/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/sger/docs/types/index.d.ts new file mode 100644 index 000000000000..51a151d49b89 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/docs/types/index.d.ts @@ -0,0 +1,129 @@ +/* +* @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. +*/ + +// TypeScript Version: 4.1 + +/// + +import { Layout } from '@stdlib/types/blas'; + +/** +* Interface describing `sger`. +*/ +interface Routine { + /** + * Performs the rank 1 operation `A = α*x*y^T + A`, where `α` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector and `A` is an `M` by `N` matrix. + * + * @param order - storage layout + * @param trans - specifies whether `A` should be transposed, conjugate-transposed, or not transposed + * @param M - number of rows in the matrix `A` + * @param N - number of columns in the matrix `A` + * @param alpha - scalar constant + * @param x - first input vector + * @param strideX - `x` stride length + * @param y - second input vector + * @param strideY - `y` stride length + * @param A - input matrix + * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) + * @returns `A` + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * + * var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + * var x = new Float32Array( [ 1.0, 1.0 ] ); + * var y = new Float32Array( [ 1.0, 1.0, 1.0 ] ); + * + * sger( 'row-major', 2, 3, 1.0, x, 1, y, 1, A, 3 ); + * // A => [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] + */ + ( order: Layout, M: number, N: number, alpha: number, x: Float32Array, strideX: number, y: Float32Array, strideY: number, A: Float32Array, LDA: number ): Float32Array; + + /** + * Performs the rank 1 operation `A = α*x*y^T + A`, using alternative indexing semantics and where `α` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector and `A` is an `M` by `N` matrix. + * + * @param M - number of rows in the matrix `A` + * @param N - number of columns in the matrix `A` + * @param alpha - scalar constant + * @param x - first input vector + * @param strideX - `x` stride length + * @param offsetX - starting index for `x` + * @param y - second input vector + * @param strideY - `y` stride length + * @param offsetY - starting index for `y` + * @param A - input matrix + * @param strideA1 - stride of the first dimension of `A` + * @param strideA2 - stride of the second dimension of `A` + * @param offsetA - starting index for `A` + * @returns `A` + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * + * var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + * var x = new Float32Array( [ 1.0, 1.0 ] ); + * var y = new Float32Array( [ 1.0, 1.0, 1.0 ] ); + * + * sger.ndarray( 2, 3, 1.0, x, 1, 0, y, 1, 0, A, 3, 1, 0 ); + * // A => [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] + */ + ndarray( M: number, N: number, alpha: number, x: Float32Array, strideX: number, offsetX: number, y: Float32Array, strideY: number, offsetY: number, A: Float32Array, strideA1: number, strideA2: number, offsetA: number ): Float32Array; +} + +/** +* Performs the rank 1 operation `A = α*x*y^T + A`, where `α` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector and `A` is an `M` by `N` matrix. +* +* @param order - storage layout +* @param trans - specifies whether `A` should be transposed, conjugate-transposed, or not transposed +* @param M - number of rows in the matrix `A` +* @param N - number of columns in the matrix `A` +* @param alpha - scalar constant +* @param x - first input vector +* @param strideX - `x` stride length +* @param y - second input vector +* @param strideY - `y` stride length +* @param A - input matrix +* @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @returns `A` +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] ); +* var x = new Float32Array( [ 1.0, 1.0 ] ); +* var y = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +* +* sger( 'column-major', 2, 3, 1.0, x, 1, y, 1, A, 2 ); +* // A => [ 2.0, 5.0, 3.0, 6.0, 4.0, 7.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] ); +* var x = new Float32Array( [ 1.0, 1.0 ] ); +* var y = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +* +* sger.ndarray( 2, 3, 1.0, x, 1, 0, y, 1, 0, A, 1, 2, 0 ); +* // A => [ 2.0, 5.0, 3.0, 6.0, 4.0, 7.0 ] +*/ +declare var sger: Routine; + + +// EXPORTS // + +export = sger; diff --git a/lib/node_modules/@stdlib/blas/base/sger/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/sger/docs/types/test.ts new file mode 100644 index 000000000000..489f798f3dad --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/docs/types/test.ts @@ -0,0 +1,449 @@ +/* +* @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. +*/ + +import sger = require( './index' ); + + +// TESTS // + +// The function returns a Float32Array... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sger( 'row-major', 10, 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectType Float32Array +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sger( 10, 10, 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + sger( true, 10, 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + sger( false, 10, 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + sger( null, 10, 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + sger( undefined, 10, 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + sger( [], 10, 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + sger( {}, 10, 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + sger( ( x: number ): number => x, 10, 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sger( 'row-major', '10', 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + sger( 'row-major', true, 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + sger( 'row-major', false, 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + sger( 'row-major', null, 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + sger( 'row-major', undefined, 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + sger( 'row-major', [], 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + sger( 'row-major', {}, 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + sger( 'row-major', ( x: number ): number => x, 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sger( 'row-major', 10, '10', 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + sger( 'row-major', 10, true, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + sger( 'row-major', 10, false, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + sger( 'row-major', 10, null, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + sger( 'row-major', 10, undefined, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + sger( 'row-major', 10, [], 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + sger( 'row-major', 10, {}, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + sger( 'row-major', 10, ( x: number ): number => x, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sger( 'row-major', 10, 10, '10', x, 1, y, 1, A, 10 ); // $ExpectError + sger( 'row-major', 10, 10, true, x, 1, y, 1, A, 10 ); // $ExpectError + sger( 'row-major', 10, 10, false, x, 1, y, 1, A, 10 ); // $ExpectError + sger( 'row-major', 10, 10, null, x, 1, y, 1, A, 10 ); // $ExpectError + sger( 'row-major', 10, 10, undefined, x, 1, y, 1, A, 10 ); // $ExpectError + sger( 'row-major', 10, 10, [], x, 1, y, 1, A, 10 ); // $ExpectError + sger( 'row-major', 10, 10, {}, x, 1, y, 1, A, 10 ); // $ExpectError + sger( 'row-major', 10, 10, ( x: number ): number => x, x, 1, y, 1, A, 10 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a Float32Array... +{ + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sger( 'row-major', 10, 10, 1.0, 10, 1, y, 1, A, 10 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, '10', 1, y, 1, A, 10 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, true, 1, y, 1, A, 10 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, false, 1, y, 1, A, 10 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, null, 1, y, 1, A, 10 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, undefined, 1, y, 1, A, 10 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, [ '1' ], 1, y, 1, A, 10 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, {}, 1, y, 1, A, 10 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, ( x: number ): number => x, 1, y, 1, A, 10 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sger( 'row-major', 10, 10, 1.0, x, '10', y, 1, A, 10 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, true, y, 1, A, 10 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, false, y, 1, A, 10 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, null, y, 1, A, 10 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, undefined, y, 1, A, 10 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, [], y, 1, A, 10 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, {}, y, 1, A, 10 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, ( x: number ): number => x, y, 1, A, 10 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a Float32Array... +{ + const x = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sger( 'row-major', 10, 10, 1.0, x, 1, 10, 1, A, 10 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, 1, '10', 1, A, 10 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, 1, true, 1, A, 10 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, 1, false, 1, A, 10 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, 1, null, 1, A, 10 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, 1, undefined, 1, A, 10 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, 1, [ '1' ], 1, A, 10 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, 1, {}, 1, A, 10 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, 1, ( x: number ): number => x, 1, A, 10 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sger( 'row-major', 10, 10, 1.0, x, 1, y, '10', A, 10 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, 1, y, true, A, 10 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, 1, y, false, A, 10 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, 1, y, null, A, 10 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, 1, y, undefined, A, 10 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, 1, y, [], A, 10 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, 1, y, {}, A, 10 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, 1, y, ( x: number ): number => x, A, 10 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a ninth argument which is not a Float32Array... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + + sger( 'row-major', 10, 10, 1.0, x, 1, y, 1, 10, 1 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, 1, y, 1, '10', 1 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, 1, y, 1, true, 1 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, 1, y, 1, false, 1 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, 1, y, 1, null, 1 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, 1, y, 1, undefined, 1 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, 1, y, 1, [ '1' ], 1 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, 1, y, 1, {}, 1 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, 1, y, 1, ( x: number ): number => x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a tenth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sger( 'row-major', 10, 10, 1.0, x, 1, y, 1, A, '10' ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, 1, y, 1, A, true ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, 1, y, 1, A, false ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, 1, y, 1, A, null ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, 1, y, 1, A, undefined ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, 1, y, 1, A, [] ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, 1, y, 1, A, {} ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, 1, y, 1, A, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sger(); // $ExpectError + sger( 'row-major' ); // $ExpectError + sger( 'row-major', 10 ); // $ExpectError + sger( 'row-major', 10, 10 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, 1 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, 1, y ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, 1, y, 1 ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, 1, y, 1, A ); // $ExpectError + sger( 'row-major', 10, 10, 1.0, x, 1, y, 1, A, 10, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Float32Array... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectType Float32Array +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sger.ndarray( '10', 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( true, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( false, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( null, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( undefined, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( [], 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( {}, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( ( x: number ): number => x, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sger.ndarray( 10, '10', 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, true, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, false, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, null, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, undefined, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, [], 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, {}, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, ( x: number ): number => x, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sger.ndarray( 10, 10, '10', x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, true, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, false, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, null, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, undefined, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, [], x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, {}, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, ( x: number ): number => x, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a Float32Array... +{ + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sger.ndarray( 10, 10, 1.0, 10, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, '10', 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, true, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, false, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, null, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, undefined, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, [ '1' ], 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, {}, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, ( x: number ): number => x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sger.ndarray( 10, 10, 1.0, x, '10', 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, true, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, false, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, null, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, undefined, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, [], 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, {}, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, ( x: number ): number => x, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sger.ndarray( 10, 10, 1.0, x, 1, '10', y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, true, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, false, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, null, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, undefined, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, [], y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, {}, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, ( x: number ): number => x, y, 1, 0, A, 10, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a Float32Array... +{ + const x = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sger.ndarray( 10, 10, 1.0, x, 1, 0, 10, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, '10', 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, true, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, false, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, null, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, undefined, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, [ '1' ], 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, {}, 1, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, ( x: number ): number => x, 1, 0, A, 10, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, '10', 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, true, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, false, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, null, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, undefined, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, [], 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, {}, 0, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, ( x: number ): number => x, 0, A, 10, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a ninth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, '10', A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, true, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, false, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, null, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, undefined, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, [], A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, {}, A, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, ( x: number ): number => x, A, 10, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a tenth argument which is not a Float32Array... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, 10, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, '10', 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, true, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, false, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, null, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, undefined, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, [ '1' ], 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, {}, 10, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, ( x: number ): number => x, 10, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eleventh argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, '10', 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, true, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, false, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, null, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, undefined, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, [], 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, {}, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a twelfth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, '10', 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, true, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, false, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, null, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, undefined, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, [], 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, {}, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a thirteenth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, '10' ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, true ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, false ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, null ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, undefined ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, [] ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, {} ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 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 Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sger.ndarray(); // $ExpectError + sger.ndarray( 10 ); // $ExpectError + sger.ndarray( 10, 10 ); // $ExpectError + sger.ndarray( 10, 10, 1.0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, 10 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1 ); // $ExpectError + sger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/base/sger/examples/index.js b/lib/node_modules/@stdlib/blas/base/sger/examples/index.js new file mode 100644 index 000000000000..f5f64a13bae4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/examples/index.js @@ -0,0 +1,39 @@ +/** +* @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 discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var sger = require( './../lib' ); + +var opts = { + 'dtype': 'float32' +}; + +var M = 3; +var N = 5; + +var A = discreteUniform( M*N, 0, 255, opts ); +var x = discreteUniform( M, 0, 255, opts ); +var y = discreteUniform( N, 0, 255, opts ); + +sger( 'row-major', M, N, 1.0, x, 1, y, 1, A, N ); +console.log( A ); + +sger.ndarray( M, N, 1.0, x, 1, 0, y, 1, 0, A, 1, M, 0 ); +console.log(A); diff --git a/lib/node_modules/@stdlib/blas/base/sger/lib/base.js b/lib/node_modules/@stdlib/blas/base/sger/lib/base.js new file mode 100644 index 000000000000..d73d541ae5b0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/lib/base.js @@ -0,0 +1,115 @@ +/** +* @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'; + +// MODULES // + +var f32 = require( '@stdlib/number/float64/base/to-float32' ); +var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); + + +// MAIN // + +/** +* Performs the rank 1 operation `A = α*x*y^T + A`, where `α` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector and `A` is an `M` by `N` matrix. +* +* @param {NonNegativeInteger} M - number of rows in the matrix `A` +* @param {NonNegativeInteger} N - number of columns in the matrix `A` +* @param {number} alpha - scalar constant +* @param {Float32Array} x - first input vector +* @param {integer} strideX - `x` stride length +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @param {Float32Array} y - second input vector +* @param {integer} strideY - `y` stride length +* @param {NonNegativeInteger} offsetY - starting index for `y` +* @param {Float32Array} A - input matrix +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` +* @returns {Float32Array} `A` +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var x = new Float32Array( [ 1.0, 1.0 ] ); +* var y = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +* +* sger( 2, 3, 1.0, x, 1, 0, y, 1, 0, A, 3, 1, 0 ); +* // A => [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] +*/ +function sger( M, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, strideA1, strideA2, offsetA ) { // eslint-disable-line max-params, max-len + var isrm; + var tmp; + var ix1; + var iy1; + var sa0; + var sa1; + var i0; + var i1; + var oa; + + // Note on variable naming convention: sa#, ix#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + isrm = isRowMajor( [ strideA1, strideA2 ] ); + if ( isrm ) { + // For row-major matrices, the last dimension has the fastest changing index... + sa0 = strideA2; // stride for innermost loop + sa1 = strideA1; // stride for outermost loop + } else { // isColMajor + // For column-major matrices, the first dimension has the fastest changing index... + sa0 = strideA1; // stride for innermost loop + sa1 = strideA2; // stride for outermost loop + } + if ( !isrm ) { + iy1 = offsetY; + for ( i1 = 0; i1 < N; i1++ ) { + if ( y[ iy1 ] !== 0.0 ) { + tmp = f32( alpha * y[ iy1 ] ); + ix1 = offsetX; + oa = offsetA + (sa1*i1); + for ( i0 = 0; i0 < M; i0++ ) { + A[ oa+(sa0*i0) ] += f32( x[ ix1 ] * tmp ); + ix1 += strideX; + } + } + iy1 += strideY; + } + return A; + } + ix1 = offsetX; + for ( i1 = 0; i1 < M; i1++ ) { + if ( x[ ix1 ] !== 0.0 ) { + tmp = f32( alpha * x[ ix1 ] ); + iy1 = offsetY; + oa = offsetA + (sa1*i1); + for ( i0 = 0; i0 < N; i0++ ) { + A[ oa+(sa0*i0) ] += f32( y[ iy1 ] * tmp ); + iy1 += strideY; + } + } + ix1 += strideX; + } + return A; +} + + +// EXPORTS // + +module.exports = sger; diff --git a/lib/node_modules/@stdlib/blas/base/sger/lib/index.js b/lib/node_modules/@stdlib/blas/base/sger/lib/index.js new file mode 100644 index 000000000000..387e6bd0ff30 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/lib/index.js @@ -0,0 +1,72 @@ +/** +* @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'; + +/** +* BLAS level 2 routine to perform the rank 1 operation `A = α*x*y^T + A`, where `α` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector and `A` is an `M` by `N` matrix. +* +* @module @stdlib/blas/base/sger +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* var sger = require( '@stdlib/blas/base/sger' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var x = new Float32Array( [ 1.0, 1.0 ] ); +* var y = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +* +* sger( 'row-major', 2, 3, 1.0, x, 1, y, 1, A, 3 ); +* // A => [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* var sger = require( '@stdlib/blas/base/sger' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var x = new Float32Array( [ 1.0, 1.0 ] ); +* var y = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +* +* sger.ndarray( 'row-major', 2, 3, 1.0, x, 1, 0, y, 1, 0, A, 3, 1, 0 ); +* // A => [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] +*/ + +// MODULES // + +var join = require( 'path' ).join; +var tryRequire = require( '@stdlib/utils/try-require' ); +var isError = require( '@stdlib/assert/is-error' ); +var main = require( './main.js' ); + + +// MAIN // + +var sger; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + sger = main; +} else { + sger = tmp; +} + + +// EXPORTS // + +module.exports = sger; + +// exports: { "ndarray": "sger.ndarray" } diff --git a/lib/node_modules/@stdlib/blas/base/sger/lib/main.js b/lib/node_modules/@stdlib/blas/base/sger/lib/main.js new file mode 100644 index 000000000000..46c1ea8be863 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/lib/main.js @@ -0,0 +1,35 @@ +/** +* @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'; + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var sger = require( './sger.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( sger, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = sger; diff --git a/lib/node_modules/@stdlib/blas/base/sger/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/sger/lib/ndarray.js new file mode 100644 index 000000000000..de60f84760b6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/lib/ndarray.js @@ -0,0 +1,84 @@ +/** +* @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'; + +// MODULES // + +var format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Performs the rank 1 operation `A = α*x*y^T + A`, where `α` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector and `A` is an `M` by `N` matrix. +* +* @param {NonNegativeInteger} M - number of rows in the matrix `A` +* @param {NonNegativeInteger} N - number of columns in the matrix `A` +* @param {number} alpha - scalar constant +* @param {Float32Array} x - first input vector +* @param {integer} strideX - `x` stride length +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @param {Float32Array} y - second input vector +* @param {integer} strideY - `y` stride length +* @param {NonNegativeInteger} offsetY - starting index for `y` +* @param {Float32Array} A - input matrix +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` +* @throws {RangeError} first argument must be a nonnegative integer +* @throws {RangeError} second argument must be a nonnegative integer +* @throws {RangeError} fifth argument must be non-zero +* @throws {RangeError} eighth argument must be non-zero +* @returns {Float32Array} `A` +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var x = new Float32Array( [ 1.0, 1.0 ] ); +* var y = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +* +* sger( 2, 3, 1.0, x, 1, 0, y, 1, 0, A, 3, 1, 0 ); +* // A => [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] +*/ +function sger( M, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, strideA1, strideA2, offsetA ) { // eslint-disable-line max-params, max-len + if ( M < 0 ) { + throw new RangeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%d`.', M ) ); + } + if ( N < 0 ) { + throw new RangeError( format( 'invalid argument. Second argument must be a nonnegative integer. Value: `%d`.', N ) ); + } + if ( strideX === 0 ) { + throw new RangeError( format( 'invalid argument. Fifth argument must be non-zero.' ) ); + } + if ( strideY === 0 ) { + throw new RangeError( format( 'invalid argument. Eighth argument must be non-zero.' ) ); + } + // Check if we can early return... + if ( M === 0 || N === 0 || alpha === 0.0 ) { + return A; + } + return base( M, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, strideA1, strideA2, offsetA ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = sger; diff --git a/lib/node_modules/@stdlib/blas/base/sger/lib/sger.js b/lib/node_modules/@stdlib/blas/base/sger/lib/sger.js new file mode 100644 index 000000000000..f3c10c1024b9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/lib/sger.js @@ -0,0 +1,101 @@ +/** +* @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'; + +// MODULES // + +var stride2offset = require( '@stdlib/strided/base/stride2offset' ); +var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); +var format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Performs the rank 1 operation `A = α*x*y^T + A`, where `α` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector and `A` is an `M` by `N` matrix. +* +* @param {string} order - storage layout +* @param {NonNegativeInteger} M - number of rows in the matrix `A` +* @param {NonNegativeInteger} N - number of columns in the matrix `A` +* @param {number} alpha - scalar constant +* @param {Float32Array} x - first input vector +* @param {integer} strideX - `x` stride length +* @param {Float32Array} y - second input vector +* @param {integer} strideY - `y` stride length +* @param {Float32Array} A - input matrix +* @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @throws {TypeError} first argument must be a valid order +* @throws {RangeError} second argument must be a nonnegative integer +* @throws {RangeError} third argument must be a nonnegative integer +* @throws {RangeError} sixth argument must be non-zero +* @throws {RangeError} eighth argument must be non-zero +* @returns {Float32Array} `A` +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var x = new Float32Array( [ 1.0, 1.0 ] ); +* var y = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +* +* sger( 'row-major', 2, 3, 1.0, x, 1, y, 1, A, 3 ); +* // A => [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] +*/ +function sger( order, M, N, alpha, x, strideX, y, strideY, A, LDA ) { + var sa1; + var sa2; + var ox; + var oy; + + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + if ( M < 0 ) { + throw new RangeError( format( 'invalid argument. Second argument must be a nonnegative integer. Value: `%d`.', M ) ); + } + if ( N < 0 ) { + throw new RangeError( format( 'invalid argument. Third argument must be a nonnegative integer. Value: `%d`.', N ) ); + } + if ( strideX === 0 ) { + throw new RangeError( format( 'invalid argument. Sixth argument must be non-zero.' ) ); + } + if ( strideY === 0 ) { + throw new RangeError( format( 'invalid argument. Eighth argument must be non-zero.' ) ); + } + // Check if we can early return... + if ( M === 0 || N === 0 || alpha === 0.0 ) { + return A; + } + ox = stride2offset( M, strideX ); + oy = stride2offset( N, strideY ); + if ( order === 'column-major' ) { + sa1 = 1; + sa2 = LDA; + } else { // order === 'row-major' + sa1 = LDA; + sa2 = 1; + } + return base( M, N, alpha, x, strideX, ox, y, strideY, oy, A, sa1, sa2, 0 ); +} + + +// EXPORTS // + +module.exports = sger; diff --git a/lib/node_modules/@stdlib/blas/base/sger/package.json b/lib/node_modules/@stdlib/blas/base/sger/package.json new file mode 100644 index 000000000000..dde66bb6d559 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/package.json @@ -0,0 +1,68 @@ +{ + "name": "@stdlib/blas/base/sger", + "version": "0.0.0", + "description": "Perform the rank 1 operation `A = α*x*y^T + A`.", + "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", + "level 2", + "sger", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "float32", + "float", + "float32array" + ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major.json new file mode 100644 index 000000000000..19adb72ab470 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major.json @@ -0,0 +1,18 @@ +{ + "order": "column-major", + "M": 2, + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 1.0 ], + "strideX": 1, + "offsetX": 0, + "y": [ 1.0, 1.0, 1.0 ], + "strideY": 1, + "offsetY": 0, + "A": [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ], + "lda": 2, + "strideA1": 1, + "strideA2": 2, + "offsetA": 0, + "A_out": [ 2.0, 5.0, 3.0, 6.0, 4.0, 7.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_complex_access_pattern.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_complex_access_pattern.json new file mode 100644 index 000000000000..d52726883a6d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_complex_access_pattern.json @@ -0,0 +1,16 @@ +{ + "M": 2, + "N": 3, + "alpha": 1.0, + "x": [ 2.0, 0.0, 1.0, 0.0 ], + "strideX": -2, + "offsetX": 2, + "y": [ 3.0, 0.0, 2.0, 0.0, 1.0, 0.0 ], + "strideY": -2, + "offsetY": 4, + "A": [ 0.0, 0.0, 0.0, 0.0, 6.0, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0, 0.0, 5.0, 0.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 1.0, 0.0 ], + "strideA1": -2, + "strideA2": -8, + "offsetA": 22, + "A_out": [ 0.0, 0.0, 0.0, 0.0, 12.0, 0.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 9.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 6.0, 0.0, 2.0, 0.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_oa.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_oa.json new file mode 100644 index 000000000000..6bb4f94e3616 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_oa.json @@ -0,0 +1,16 @@ +{ + "M": 2, + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 0.0, 1.0, 0.0 ], + "strideX": 2, + "offsetX": 0, + "y": [ 1.0, 0.0, 1.0, 0.0, 1.0, 0.0 ], + "strideY": 2, + "offsetY": 0, + "A": [ 0.0, 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ], + "strideA1": 1, + "strideA2": 2, + "offsetA": 1, + "A_out": [ 0.0, 2.0, 5.0, 3.0, 6.0, 4.0, 7.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1_sa2.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1_sa2.json new file mode 100644 index 000000000000..20c43b149187 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1_sa2.json @@ -0,0 +1,16 @@ +{ + "M": 2, + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 0.0, 2.0, 0.0 ], + "strideX": 2, + "offsetX": 0, + "y": [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ], + "strideY": 2, + "offsetY": 0, + "A": [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3.0, 0.0, 6.0, 0.0 ], + "strideA1": 2, + "strideA2": 8, + "offsetA": 4, + "A_out": [ 0.0, 0.0, 0.0, 0.0, 2.0, 0.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 9.0, 0.0, 0.0, 0.0, 0.0, 0.0, 6.0, 0.0, 12.0, 0.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1_sa2n.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1_sa2n.json new file mode 100644 index 000000000000..ab7ac9e8897d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1_sa2n.json @@ -0,0 +1,16 @@ +{ + "M": 2, + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 0.0, 2.0, 0.0 ], + "strideX": 2, + "offsetX": 0, + "y": [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ], + "strideY": 2, + "offsetY": 0, + "A": [ 0.0, 0.0, 0.0, 0.0, 3.0, 0.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 4.0, 0.0 ], + "strideA1": 2, + "strideA2": -8, + "offsetA": 20, + "A_out": [ 0.0, 0.0, 0.0, 0.0, 6.0, 0.0, 12.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 9.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0, 0.0, 6.0, 0.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1n_sa2.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1n_sa2.json new file mode 100644 index 000000000000..82884c1c0804 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1n_sa2.json @@ -0,0 +1,16 @@ +{ + "M": 2, + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 0.0, 2.0, 0.0 ], + "strideX": 2, + "offsetX": 0, + "y": [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ], + "strideY": 2, + "offsetY": 0, + "A": [ 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 5.0, 0.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 6.0, 0.0, 3.0, 0.0 ], + "strideA1": -2, + "strideA2": 8, + "offsetA": 6, + "A_out": [ 0.0, 0.0, 0.0, 0.0, 6.0, 0.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 9.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 12.0, 0.0, 6.0, 0.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1n_sa2n.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1n_sa2n.json new file mode 100644 index 000000000000..ba307fda875c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1n_sa2n.json @@ -0,0 +1,16 @@ +{ + "M": 2, + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 0.0, 2.0, 0.0 ], + "strideX": 2, + "offsetX": 0, + "y": [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ], + "strideY": 2, + "offsetY": 0, + "A": [ 0.0, 0.0, 0.0, 0.0, 6.0, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0, 0.0, 5.0, 0.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 1.0, 0.0 ], + "strideA1": -2, + "strideA2": -8, + "offsetA": 22, + "A_out": [ 0.0, 0.0, 0.0, 0.0, 12.0, 0.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 9.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 6.0, 0.0, 2.0, 0.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_xnyn.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_xnyn.json new file mode 100644 index 000000000000..f107aa4eb727 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_xnyn.json @@ -0,0 +1,18 @@ +{ + "order": "column-major", + "M": 2, + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 0.0, 1.0, 0.0 ], + "strideX": -2, + "offsetX": 2, + "y": [ 1.0, 0.0, 1.0, 0.0, 1.0, 0.0 ], + "strideY": -2, + "offsetY": 4, + "A": [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ], + "lda": 2, + "strideA1": 1, + "strideA2": 2, + "offsetA": 0, + "A_out": [ 2.0, 5.0, 3.0, 6.0, 4.0, 7.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_xnyp.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_xnyp.json new file mode 100644 index 000000000000..fcfb609eb3f0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_xnyp.json @@ -0,0 +1,18 @@ +{ + "order": "column-major", + "M": 2, + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 0.0, 1.0, 0.0 ], + "strideX": -2, + "offsetX": 2, + "y": [ 1.0, 0.0, 1.0, 0.0, 1.0, 0.0 ], + "strideY": 2, + "offsetY": 0, + "A": [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ], + "lda": 2, + "strideA1": 1, + "strideA2": 2, + "offsetA": 0, + "A_out": [ 2.0, 5.0, 3.0, 6.0, 4.0, 7.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_xpyn.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_xpyn.json new file mode 100644 index 000000000000..2cc21048ac0d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_xpyn.json @@ -0,0 +1,18 @@ +{ + "order": "column-major", + "M": 2, + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 0.0, 1.0, 0.0 ], + "strideX": 2, + "offsetX": 0, + "y": [ 1.0, 0.0, 1.0, 0.0, 1.0, 0.0 ], + "strideY": -2, + "offsetY": 4, + "A": [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ], + "lda": 2, + "strideA1": 1, + "strideA2": 2, + "offsetA": 0, + "A_out": [ 2.0, 5.0, 3.0, 6.0, 4.0, 7.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_xpyp.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_xpyp.json new file mode 100644 index 000000000000..7ddda6580f6b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_xpyp.json @@ -0,0 +1,18 @@ +{ + "order": "column-major", + "M": 2, + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 0.0, 1.0, 0.0 ], + "strideX": 2, + "offsetX": 0, + "y": [ 1.0, 0.0, 1.0, 0.0, 1.0, 0.0 ], + "strideY": 2, + "offsetY": 0, + "A": [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ], + "lda": 2, + "strideA1": 1, + "strideA2": 2, + "offsetA": 0, + "A_out": [ 2.0, 5.0, 3.0, 6.0, 4.0, 7.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major.json new file mode 100644 index 000000000000..6c5a8c89a176 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major.json @@ -0,0 +1,18 @@ +{ + "order": "row-major", + "M": 2, + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 1.0 ], + "strideX": 1, + "offsetX": 0, + "y": [ 1.0, 1.0, 1.0 ], + "strideY": 1, + "offsetY": 0, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "lda": 3, + "strideA1": 3, + "strideA2": 1, + "offsetA": 0, + "A_out": [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_complex_access_pattern.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_complex_access_pattern.json new file mode 100644 index 000000000000..53f86d6f795d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_complex_access_pattern.json @@ -0,0 +1,16 @@ +{ + "M": 2, + "N": 3, + "alpha": 1.0, + "x": [ 2.0, 0.0, 1.0, 0.0 ], + "strideX": -2, + "offsetX": 2, + "y": [ 3.0, 0.0, 2.0, 0.0, 1.0, 0.0 ], + "strideY": -2, + "offsetY": 4, + "A": [ 0.0, 6.0, 0.0, 5.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3.0, 0.0, 2.0, 0.0, 1.0, 0.0 ], + "strideA1": -14, + "strideA2": -2, + "offsetA": 19, + "A_out": [ 0.0, 12.0, 0.0, 9.0, 0.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 6.0, 0.0, 4.0, 0.0, 2.0, 0.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_oa.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_oa.json new file mode 100644 index 000000000000..dce60e368fb3 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_oa.json @@ -0,0 +1,16 @@ +{ + "M": 2, + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 0.0, 1.0, 0.0 ], + "strideX": 2, + "offsetX": 0, + "y": [ 1.0, 0.0, 1.0, 0.0, 1.0, 0.0 ], + "strideY": 2, + "offsetY": 0, + "A": [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "strideA1": 3, + "strideA2": 1, + "offsetA": 1, + "A_out": [ 0.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1_sa2.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1_sa2.json new file mode 100644 index 000000000000..6fd51996873f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1_sa2.json @@ -0,0 +1,16 @@ +{ + "M": 2, + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 0.0, 2.0, 0.0 ], + "strideX": 2, + "offsetX": 0, + "y": [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ], + "strideY": 2, + "offsetY": 0, + "A": [ 0.0, 1.0, 0.0, 2.0, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 5.0, 0.0, 6.0, 0.0 ], + "strideA1": 14, + "strideA2": 2, + "offsetA": 1, + "A_out": [ 0.0, 2.0, 0.0, 4.0, 0.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 6.0, 0.0, 9.0, 0.0, 12.0, 0.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1_sa2n.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1_sa2n.json new file mode 100644 index 000000000000..24ddd2faca66 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1_sa2n.json @@ -0,0 +1,16 @@ +{ + "M": 2, + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 0.0, 2.0, 0.0 ], + "strideX": 2, + "offsetX": 0, + "y": [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ], + "strideY": 2, + "offsetY": 0, + "A": [ 0.0, 3.0, 0.0, 2.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 6.0, 0.0, 5.0, 0.0, 4.0, 0.0 ], + "strideA1": 14, + "strideA2": -2, + "offsetA": 5, + "A_out": [ 0.0, 6.0, 0.0, 4.0, 0.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 12.0, 0.0, 9.0, 0.0, 6.0, 0.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1n_sa2.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1n_sa2.json new file mode 100644 index 000000000000..3b178508b6c3 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1n_sa2.json @@ -0,0 +1,16 @@ +{ + "M": 2, + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 0.0, 2.0, 0.0 ], + "strideX": 2, + "offsetX": 0, + "y": [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ], + "strideY": 2, + "offsetY": 0, + "A": [ 0.0, 4.0, 0.0, 5.0, 0.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ], + "strideA1": -14, + "strideA2": 2, + "offsetA": 15, + "A_out": [ 0.0, 6.0, 0.0, 9.0, 0.0, 12.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0, 0.0, 4.0, 0.0, 6.0, 0.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1n_sa2n.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1n_sa2n.json new file mode 100644 index 000000000000..c35b155184f1 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1n_sa2n.json @@ -0,0 +1,16 @@ +{ + "M": 2, + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 0.0, 2.0, 0.0 ], + "strideX": 2, + "offsetX": 0, + "y": [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ], + "strideY": 2, + "offsetY": 0, + "A": [ 0.0, 6.0, 0.0, 5.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3.0, 0.0, 2.0, 0.0, 1.0, 0.0 ], + "strideA1": -14, + "strideA2": -2, + "offsetA": 19, + "A_out": [ 0.0, 12.0, 0.0, 9.0, 0.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 6.0, 0.0, 4.0, 0.0, 2.0, 0.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_xnyn.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_xnyn.json new file mode 100644 index 000000000000..7713b84d9d54 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_xnyn.json @@ -0,0 +1,18 @@ +{ + "order": "row-major", + "M": 2, + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 0.0, 1.0, 0.0 ], + "strideX": -2, + "offsetX": 2, + "y": [ 1.0, 0.0, 1.0, 0.0, 1.0, 0.0 ], + "strideY": -2, + "offsetY": 4, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "lda": 3, + "strideA1": 3, + "strideA2": 1, + "offsetA": 0, + "A_out": [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_xnyp.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_xnyp.json new file mode 100644 index 000000000000..fea1b4dbd0a0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_xnyp.json @@ -0,0 +1,18 @@ +{ + "order": "row-major", + "M": 2, + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 0.0, 1.0, 0.0 ], + "strideX": -2, + "offsetX": 2, + "y": [ 1.0, 0.0, 1.0, 0.0, 1.0, 0.0 ], + "strideY": 2, + "offsetY": 0, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "lda": 3, + "strideA1": 3, + "strideA2": 1, + "offsetA": 0, + "A_out": [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_xpyn.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_xpyn.json new file mode 100644 index 000000000000..e89ebada429c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_xpyn.json @@ -0,0 +1,18 @@ +{ + "order": "row-major", + "M": 2, + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 0.0, 1.0, 0.0 ], + "strideX": 2, + "offsetX": 0, + "y": [ 1.0, 0.0, 1.0, 0.0, 1.0, 0.0 ], + "strideY": -2, + "offsetY": 4, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "lda": 3, + "strideA1": 3, + "strideA2": 1, + "offsetA": 0, + "A_out": [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_xpyp.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_xpyp.json new file mode 100644 index 000000000000..4291cb6a8b27 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_xpyp.json @@ -0,0 +1,18 @@ +{ + "order": "row-major", + "M": 2, + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 0.0, 1.0, 0.0 ], + "strideX": 2, + "offsetX": 0, + "y": [ 1.0, 0.0, 1.0, 0.0, 1.0, 0.0 ], + "strideY": 2, + "offsetY": 0, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "lda": 3, + "strideA1": 3, + "strideA2": 1, + "offsetA": 0, + "A_out": [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/test.js b/lib/node_modules/@stdlib/blas/base/sger/test/test.js new file mode 100644 index 000000000000..36f83cedcf0d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/test/test.js @@ -0,0 +1,82 @@ +/** +* @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'; + +// MODULES // + +var tape = require( 'tape' ); +var proxyquire = require( 'proxyquire' ); +var IS_BROWSER = require( '@stdlib/assert/is-browser' ); +var sger = require( './../lib' ); + + +// VARIABLES // + +var opts = { + 'skip': IS_BROWSER +}; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof sger, '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 sger.ndarray, 'function', 'method is a function' ); + t.end(); +}); + +tape( 'if a native implementation is available, the main export is the native implementation', opts, function test( t ) { + var sger = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( sger, mock, 'returns expected value' ); + t.end(); + + function tryRequire() { + return mock; + } + + function mock() { + // Mock... + } +}); + +tape( 'if a native implementation is not available, the main export is a JavaScript implementation', opts, function test( t ) { + var sger; + var main; + + main = require( './../lib/sger.js' ); + + sger = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( sger, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/sger/test/test.ndarray.js new file mode 100644 index 000000000000..1f3c89f2196a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/test/test.ndarray.js @@ -0,0 +1,815 @@ +/** +* @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. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float32Array = require( '@stdlib/array/float32' ); +var EPS = require( '@stdlib/constants/float32/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var sger = require( './../lib/ndarray.js' ); + + +// FIXTURES // + +var cm = require( './fixtures/column_major.json' ); +var coa = require( './fixtures/column_major_oa.json' ); +var cxpyp = require( './fixtures/column_major_xpyp.json' ); +var cxnyp = require( './fixtures/column_major_xnyp.json' ); +var cxpyn = require( './fixtures/column_major_xpyn.json' ); +var cxnyn = require( './fixtures/column_major_xnyn.json' ); +var csa1sa2 = require( './fixtures/column_major_sa1_sa2.json' ); +var csa1nsa2 = require( './fixtures/column_major_sa1n_sa2.json' ); +var csa1sa2n = require( './fixtures/column_major_sa1_sa2n.json' ); +var csa1nsa2n = require( './fixtures/column_major_sa1n_sa2n.json' ); +var ccap = require( './fixtures/column_major_complex_access_pattern.json' ); + +var rm = require( './fixtures/row_major.json' ); +var roa = require( './fixtures/row_major_oa.json' ); +var rxpyp = require( './fixtures/row_major_xpyp.json' ); +var rxnyp = require( './fixtures/row_major_xnyp.json' ); +var rxpyn = require( './fixtures/row_major_xpyn.json' ); +var rxnyn = require( './fixtures/row_major_xnyn.json' ); +var rsa1sa2 = require( './fixtures/row_major_sa1_sa2.json' ); +var rsa1nsa2 = require( './fixtures/row_major_sa1n_sa2.json' ); +var rsa1sa2n = require( './fixtures/row_major_sa1_sa2n.json' ); +var rsa1nsa2n = require( './fixtures/row_major_sa1n_sa2n.json' ); +var rcap = require( './fixtures/row_major_complex_access_pattern.json' ); + + +// FUNCTIONS // + +/** +* Tests for element-wise approximate equality. +* +* @private +* @param {Object} t - test object +* @param {Collection} actual - actual values +* @param {Collection} expected - expected values +* @param {number} rtol - relative tolerance +*/ +function isApprox( t, actual, expected, rtol ) { + var delta; + var tol; + var i; + + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + if ( actual[ i ] === expected[ i ] ) { + t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); + } else { + delta = abs( actual[ i ] - expected[ i ] ); + tol = rtol * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof sger, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 13', function test( t ) { + t.strictEqual( sger.length, 13, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var data; + var i; + + data = rm; + + values = [ + -1, + -2, + -3 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + sger( value, data.N, data.alpha, new Float32Array( data.x ), data.strideX, data.offsetX, new Float32Array( data.y ), data.strideY, data.offsetY, new Float32Array( data.A ), data.strideA1, data.strideA2, data.offsetA ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid second argument', function test( t ) { + var values; + var data; + var i; + + data = rm; + + values = [ + -1, + -2, + -3 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + sger( data.M, value, data.alpha, new Float32Array( data.x ), data.strideX, data.offsetX, new Float32Array( data.y ), data.strideY, data.offsetY, new Float32Array( data.A ), data.strideA1, data.strideA2, data.offsetA ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid fifth argument', function test( t ) { + var values; + var data; + var i; + + data = rm; + + values = [ + 0 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + sger( data.M, data.N, data.alpha, new Float32Array( data.x ), value, data.offsetX, new Float32Array( data.y ), data.strideY, data.offsetY, new Float32Array( data.A ), data.strideA1, data.strideA2, data.offsetA ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid eighth argument', function test( t ) { + var values; + var data; + var i; + + data = rm; + + values = [ + 0 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + sger( data.M, data.N, data.alpha, new Float32Array( data.x ), data.strideX, data.offsetX, new Float32Array( data.y ), value, data.offsetY, new Float32Array( data.A ), data.strideA1, data.strideA2, data.offsetA ); + }; + } +}); + +tape( 'the function the rank 1 operation `A = α*x*y^T + A` (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rm; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + isApprox( t, a, expected, 2.0 ); + t.strictEqual( out, a, 'returns expected value' ); + t.end(); +}); + +tape( 'the function the rank 1 operation `A = α*x*y^T + A` (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cm; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + isApprox( t, a, expected, 2.0 ); + t.strictEqual( out, a, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a reference to the input matrix (row-major)', function test( t ) { + var data; + var out; + var a; + var x; + var y; + + data = rm; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a reference to the input matrix (column-major)', function test( t ) { + var data; + var out; + var a; + var x; + var y; + + data = cm; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.end(); +}); + +tape( 'if either `M` or `N` is `0`, the function returns the input matrix unchanged (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rm; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A ); + + out = sger( 0, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + out = sger( data.M, 0, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if either `M` or `N` is `0`, the function returns the input matrix unchanged (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cm; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A ); + + out = sger( 0, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + out = sger( data.M, 0, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `α` is `0.0`, the function returns the input matrix unchanged (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rm; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A ); + + out = sger( data.M, data.N, 0.0, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `α` is `0.0`, the function returns the input matrix unchanged (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cm; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A ); + + out = sger( data.M, data.N, 0.0, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the strides of the first and second dimensions of `A` (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rsa1sa2; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + isApprox( t, a, expected, 2.0 ); + t.strictEqual( out, a, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying the strides of the first and second dimensions of `A` (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = csa1sa2; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + isApprox( t, a, expected, 2.0 ); + t.strictEqual( out, a, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a negative stride for the first dimension of `A` (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rsa1nsa2; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + isApprox( t, a, expected, 2.0 ); + t.strictEqual( out, a, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a negative stride for the first dimension of `A` (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = csa1nsa2; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + isApprox( t, a, expected, 2.0 ); + t.strictEqual( out, a, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a negative stride for the second dimension of `A` (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rsa1sa2n; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + isApprox( t, a, expected, 2.0 ); + t.strictEqual( out, a, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a negative stride for the second dimension of `A` (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = csa1sa2n; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + isApprox( t, a, expected, 2.0 ); + t.strictEqual( out, a, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports negative strides for `A` (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rsa1nsa2n; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + isApprox( t, a, expected, 2.0 ); + t.strictEqual( out, a, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports negative strides for `A` (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = csa1nsa2n; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + isApprox( t, a, expected, 2.0 ); + t.strictEqual( out, a, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying an offset parameter for `A` (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = roa; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + isApprox( t, a, expected, 2.0 ); + t.strictEqual( out, a, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying an offset parameter for `A` (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = coa; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + isApprox( t, a, expected, 2.0 ); + t.strictEqual( out, a, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying `x` and `y` strides (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxpyp; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + isApprox( t, a, expected, 2.0 ); + t.strictEqual( out, a, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying `x` and `y` strides (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxpyp; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + isApprox( t, a, expected, 2.0 ); + t.strictEqual( out, a, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative `x` stride (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxnyp; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + isApprox( t, a, expected, 2.0 ); + t.strictEqual( out, a, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative `x` stride (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxnyp; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + isApprox( t, a, expected, 2.0 ); + t.strictEqual( out, a, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative `y` stride (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxpyn; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + isApprox( t, a, expected, 2.0 ); + t.strictEqual( out, a, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative `y` stride (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxpyn; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + isApprox( t, a, expected, 2.0 ); + t.strictEqual( out, a, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying negative strides for `x` and `y` (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxnyn; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + isApprox( t, a, expected, 2.0 ); + t.strictEqual( out, a, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying negative strides for `x` and `y` (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxnyn; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + isApprox( t, a, expected, 2.0 ); + t.strictEqual( out, a, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports complex access patterns (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rcap; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + isApprox( t, a, expected, 2.0 ); + t.strictEqual( out, a, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports complex access patterns (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = ccap; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + isApprox( t, a, expected, 2.0 ); + t.strictEqual( out, a, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/test.sger.js b/lib/node_modules/@stdlib/blas/base/sger/test/test.sger.js new file mode 100644 index 000000000000..08e43b5c50e2 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/test/test.sger.js @@ -0,0 +1,565 @@ +/** +* @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. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float32Array = require( '@stdlib/array/float32' ); +var EPS = require( '@stdlib/constants/float32/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var sger = require( './../lib/sger.js' ); + + +// FIXTURES // + +var cm = require( './fixtures/column_major.json' ); +var cxpyp = require( './fixtures/column_major_xpyp.json' ); +var cxnyp = require( './fixtures/column_major_xnyp.json' ); +var cxpyn = require( './fixtures/column_major_xpyn.json' ); +var cxnyn = require( './fixtures/column_major_xnyn.json' ); + +var rm = require( './fixtures/row_major.json' ); +var rxpyp = require( './fixtures/row_major_xpyp.json' ); +var rxnyp = require( './fixtures/row_major_xnyp.json' ); +var rxpyn = require( './fixtures/row_major_xpyn.json' ); +var rxnyn = require( './fixtures/row_major_xnyn.json' ); + + +// FUNCTIONS // + +/** +* Tests for element-wise approximate equality. +* +* @private +* @param {Object} t - test object +* @param {Collection} actual - actual values +* @param {Collection} expected - expected values +* @param {number} rtol - relative tolerance +*/ +function isApprox( t, actual, expected, rtol ) { + var delta; + var tol; + var i; + + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + if ( actual[ i ] === expected[ i ] ) { + t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); + } else { + delta = abs( actual[ i ] - expected[ i ] ); + tol = rtol * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof sger, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 10', function test( t ) { + t.strictEqual( sger.length, 10, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var data; + var i; + + data = rm; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop' + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + sger( value, data.M, data.N, data.alpha, new Float32Array( data.x ), data.strideX, new Float32Array( data.y ), data.strideY, new Float32Array( data.A ), data.LDA ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid second argument', function test( t ) { + var values; + var data; + var i; + + data = rm; + + values = [ + -1, + -2, + -3 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + sger( data.order, value, data.N, data.alpha, new Float32Array( data.x ), data.strideX, new Float32Array( data.y ), data.strideY, new Float32Array( data.A ), data.LDA ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid third argument', function test( t ) { + var values; + var data; + var i; + + data = rm; + + values = [ + -1, + -2, + -3 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + sger( data.order, data.M, value, data.alpha, new Float32Array( data.x ), data.strideX, new Float32Array( data.y ), data.strideY, new Float32Array( data.A ), data.LDA ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid sixth argument', function test( t ) { + var values; + var data; + var i; + + data = rm; + + values = [ + 0 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + sger( data.order, data.M, data.N, data.alpha, new Float32Array( data.x ), value, new Float32Array( data.y ), data.strideY, new Float32Array( data.A ), data.LDA ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid eighth argument', function test( t ) { + var values; + var data; + var i; + + data = rm; + + values = [ + 0 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + sger( data.order, data.M, data.N, data.alpha, new Float32Array( data.x ), data.strideX, new Float32Array( data.y ), value, new Float32Array( data.A ), data.LDA ); + }; + } +}); + +tape( 'the function the rank 1 operation `A = α*x*y^T + A` (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rm; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + isApprox( t, a, expected, 2.0 ); + t.strictEqual( out, a, 'returns expected value' ); + t.end(); +}); + +tape( 'the function the rank 1 operation `A = α*x*y^T + A` (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cm; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + isApprox( t, a, expected, 2.0 ); + t.strictEqual( out, a, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a reference to the input matrix (row-major)', function test( t ) { + var data; + var out; + var a; + var x; + var y; + + data = rm; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a reference to the input matrix (column-major)', function test( t ) { + var data; + var out; + var a; + var x; + var y; + + data = cm; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.end(); +}); + +tape( 'if either `M` or `N` is `0`, the function returns the input matrix unchanged (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rm; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A ); + + out = sger( data.order, 0, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + out = sger( data.order, data.M, 0, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if either `M` or `N` is `0`, the function returns the input matrix unchanged (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cm; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A ); + + out = sger( data.order, 0, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + out = sger( data.order, data.M, 0, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `α` is `0.0`, the function returns the input matrix unchanged (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rm; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A ); + + out = sger( data.order, data.M, data.N, 0.0, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `α` is `0.0`, the function returns the input matrix unchanged (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cm; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A ); + + out = sger( data.order, data.M, data.N, 0.0, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying `x` and `y` strides (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxpyp; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + isApprox( t, a, expected, 2.0 ); + t.strictEqual( out, a, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying `x` and `y` strides (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxpyp; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + isApprox( t, a, expected, 2.0 ); + t.strictEqual( out, a, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative `x` stride (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxnyp; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + isApprox( t, a, expected, 2.0 ); + t.strictEqual( out, a, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative `x` stride (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxnyp; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + isApprox( t, a, expected, 2.0 ); + t.strictEqual( out, a, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative `y` stride (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxpyn; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + isApprox( t, a, expected, 2.0 ); + t.strictEqual( out, a, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative `y` stride (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxpyn; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + isApprox( t, a, expected, 2.0 ); + t.strictEqual( out, a, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports complex access patterns (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxnyn; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + isApprox( t, a, expected, 2.0 ); + t.strictEqual( out, a, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports complex access patterns (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxnyn; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + isApprox( t, a, expected, 2.0 ); + t.strictEqual( out, a, 'returns expected value' ); + t.end(); +}); From 6fc0eafb4507d084a6cd7a426d7db8628e4c3374 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Thu, 8 Aug 2024 17:58:40 +0530 Subject: [PATCH 02/24] docs: add README --- .../@stdlib/blas/base/sger/README.md | 269 ++++++++++++++++++ 1 file changed, 269 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/sger/README.md diff --git a/lib/node_modules/@stdlib/blas/base/sger/README.md b/lib/node_modules/@stdlib/blas/base/sger/README.md new file mode 100644 index 000000000000..bf1482b6fa33 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/README.md @@ -0,0 +1,269 @@ + + +# sger + +> Perform the rank 1 operation `A = α*x*y^T + A`. + +
+ +## Usage + +```javascript +var sger = require( '@stdlib/blas/base/sger' ); +``` + +#### sger( ord, M, N, α, x, sx, y, sy, A, lda ) + +Performs the rank 1 operation `A = α*x*y^T + A`, where `α` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector and `A` is an `M` by `N` matrix. + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var x = new Float32Array( [ 1.0, 1.0 ] ); +var y = new Float32Array( [ 1.0, 1.0, 1.0 ] ); + +sger( 'row-major', 2, 3, 1.0, x, 1, y, 1, A, 3 ); +// A => [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] +``` + +The function has the following parameters: + +- **ord**: storage layout. +- **M**: number of rows in the matrix `A`. +- **N**: number of columns in the matrix `A`. +- **α**: scalar constant. +- **x**: input [`Float32Array`][mdn-float32array]. +- **sx**: index increment for `x`. +- **y**: output [`Float32Array`][mdn-float32array]. +- **sy**: index increment for `y`. +- **A**: input matrix stored in linear memory as a [`Float32Array`][mdn-float32array]. +- **lda**: stride of the first dimension of `A` (leading dimension of `A`). + +The stride parameters determine how operations are performed. For example, to iterate over every other element in `x` and `y`, + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var A = new Float32Array( [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] ); +var x = new Float32Array( [ 1.0, 0.0, 1.0, 0.0 ] ); +var y = new Float32Array( [ 1.0, 0.0, 1.0, 0.0, 1.0, 0.0 ] ); + +sger( 'column-major', 2, 3, 1.0, x, 2, y, 2, A, 2 ); +// A => [ 2.0, 5.0, 3.0, 6.0, 4.0, 7.0 ] +``` + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +// Initial arrays... +var x0 = new Float32Array( [ 0.0, 1.0, 1.0 ] ); +var y0 = new Float32Array( [ 0.0, 1.0, 1.0, 1.0 ] ); +var A = new Float32Array( [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] ); + +// Create offset views... +var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var y1 = new Float32Array( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +sger( 'column-major', 2, 3, 1.0, x1, -1, y1, -1, A, 2 ); +// A => [ 2.0, 5.0, 3.0, 6.0, 4.0, 7.0 ] +``` + +#### sger.ndarray( M, N, α, x, sx, ox, y, sy, oy, A, sa1, sa2, oa ) + +Performs the rank 1 operation `A = α*x*y^T + A`, using alternative indexing semantics and where `α` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector and `A` is an `M` by `N` matrix. + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var x = new Float32Array( [ 1.0, 1.0 ] ); +var y = new Float32Array( [ 1.0, 1.0, 1.0 ] ); + +sger.ndarray( 2, 3, 1.0, x, 1, 0, y, 1, 0, A, 3, 1, 0 ); +// A => [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] +``` + +The function has the following additional parameters: + +- **sa1**: stride of the first dimension of `A`. +- **sa2**: stride of the second dimension of `A`. +- **oa**: starting index for `A`. +- **ox**: starting index for `x`. +- **oy**: 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, + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var A = new Float32Array( [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] ); +var x = new Float32Array( [ 1.0, 0.0, 1.0, 0.0 ] ); +var y = new Float32Array( [ 1.0, 0.0, 1.0, 0.0, 1.0, 0.0 ] ); + +sger.ndarray( 2, 3, 1.0, x, 2, 0, y, 2, 0, A, 1, 2, 0 ); +// A => [ 2.0, 5.0, 3.0, 6.0, 4.0, 7.0 ] +``` + +
+ + + +
+ +## Notes + +- `sger()` corresponds to the [BLAS][blas] level 2 function [`sger`][blas-sger]. + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var sger = require( '@stdlib/blas/base/sger' ); + +var opts = { + 'dtype': 'float32' +}; + +var M = 3; +var N = 5; + +var A = discreteUniform( M*N, 0, 255, opts ); +var x = discreteUniform( M, 0, 255, opts ); +var y = discreteUniform( N, 0, 255, opts ); + +sger( 'row-major', M, N, 1.0, x, 1, y, 1, A, N ); +console.log( A ); + +sger.ndarray( M, N, 1.0, x, 1, 0, y, 1, 0, A, 1, M, 0 ); +console.log(A); + +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/blas/base/sger.h" +``` + +#### TODO + +TODO. + +```c +TODO +``` + +TODO + +```c +TODO +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +TODO +``` + +
+ + + +
+ + + + + + + + + + + + + + From 03a1a640b28411f41dbb9bb65a78e5c402afdc45 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Thu, 8 Aug 2024 18:04:42 +0530 Subject: [PATCH 03/24] bench: resolve error --- lib/node_modules/@stdlib/blas/base/sger/benchmark/benchmark.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/sger/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/sger/benchmark/benchmark.js index d051392ada41..214a1fc34fa2 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/base/sger/benchmark/benchmark.js @@ -63,7 +63,7 @@ function createBenchmark( N ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - z = sger( 'row-major', N, N, 1, 0, x, 1, y, 1, A, N ); + z = sger( 'row-major', N, N, 1.0, x, 1, y, 1, A, N ); if ( isnanf( z[ i%z.length ] ) ) { b.fail( 'should not return NaN' ); } From f82fa077461d01fc9a45e8724e6f78f7568f61f8 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Wed, 21 Aug 2024 11:56:28 +0530 Subject: [PATCH 04/24] test: update isApprox with deepEqual --- .../blas/base/sger/test/test.ndarray.js | 75 ++++++------------- .../@stdlib/blas/base/sger/test/test.sger.js | 51 +++---------- 2 files changed, 32 insertions(+), 94 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/sger/test/test.ndarray.js index 1f3c89f2196a..36380c12874f 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/sger/test/test.ndarray.js @@ -24,8 +24,6 @@ var tape = require( 'tape' ); var Float32Array = require( '@stdlib/array/float32' ); -var EPS = require( '@stdlib/constants/float32/eps' ); -var abs = require( '@stdlib/math/base/special/abs' ); var sger = require( './../lib/ndarray.js' ); @@ -56,35 +54,6 @@ var rsa1nsa2n = require( './fixtures/row_major_sa1n_sa2n.json' ); var rcap = require( './fixtures/row_major_complex_access_pattern.json' ); -// FUNCTIONS // - -/** -* Tests for element-wise approximate equality. -* -* @private -* @param {Object} t - test object -* @param {Collection} actual - actual values -* @param {Collection} expected - expected values -* @param {number} rtol - relative tolerance -*/ -function isApprox( t, actual, expected, rtol ) { - var delta; - var tol; - var i; - - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - if ( actual[ i ] === expected[ i ] ) { - t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); - } else { - delta = abs( actual[ i ] - expected[ i ] ); - tol = rtol * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); - } - } -} - - // TESTS // tape( 'main export is a function', function test( t ) { @@ -211,8 +180,8 @@ tape( 'the function the rank 1 operation `A = α*x*y^T + A` (row-major)', functi expected = new Float32Array( data.A_out ); out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); - isApprox( t, a, expected, 2.0 ); t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -233,8 +202,8 @@ tape( 'the function the rank 1 operation `A = α*x*y^T + A` (column-major)', fun expected = new Float32Array( data.A_out ); out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); - isApprox( t, a, expected, 2.0 ); t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -391,8 +360,8 @@ tape( 'the function supports specifying the strides of the first and second dime expected = new Float32Array( data.A_out ); out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); - isApprox( t, a, expected, 2.0 ); t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -413,8 +382,8 @@ tape( 'the function supports specifying the strides of the first and second dime expected = new Float32Array( data.A_out ); out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); - isApprox( t, a, expected, 2.0 ); t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -435,8 +404,8 @@ tape( 'the function supports a negative stride for the first dimension of `A` (r expected = new Float32Array( data.A_out ); out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); - isApprox( t, a, expected, 2.0 ); t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -457,8 +426,8 @@ tape( 'the function supports a negative stride for the first dimension of `A` (c expected = new Float32Array( data.A_out ); out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); - isApprox( t, a, expected, 2.0 ); t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -479,8 +448,8 @@ tape( 'the function supports a negative stride for the second dimension of `A` ( expected = new Float32Array( data.A_out ); out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); - isApprox( t, a, expected, 2.0 ); t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -501,8 +470,8 @@ tape( 'the function supports a negative stride for the second dimension of `A` ( expected = new Float32Array( data.A_out ); out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); - isApprox( t, a, expected, 2.0 ); t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -523,8 +492,8 @@ tape( 'the function supports negative strides for `A` (row-major)', function tes expected = new Float32Array( data.A_out ); out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); - isApprox( t, a, expected, 2.0 ); t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -545,8 +514,8 @@ tape( 'the function supports negative strides for `A` (column-major)', function expected = new Float32Array( data.A_out ); out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); - isApprox( t, a, expected, 2.0 ); t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -567,8 +536,8 @@ tape( 'the function supports specifying an offset parameter for `A` (row-major)' expected = new Float32Array( data.A_out ); out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); - isApprox( t, a, expected, 2.0 ); t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -589,8 +558,8 @@ tape( 'the function supports specifying an offset parameter for `A` (column-majo expected = new Float32Array( data.A_out ); out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); - isApprox( t, a, expected, 2.0 ); t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -611,8 +580,8 @@ tape( 'the function supports specifying `x` and `y` strides (row-major)', functi expected = new Float32Array( data.A_out ); out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); - isApprox( t, a, expected, 2.0 ); t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -633,8 +602,8 @@ tape( 'the function supports specifying `x` and `y` strides (column-major)', fun expected = new Float32Array( data.A_out ); out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); - isApprox( t, a, expected, 2.0 ); t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -655,8 +624,8 @@ tape( 'the function supports specifying a negative `x` stride (row-major)', func expected = new Float32Array( data.A_out ); out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); - isApprox( t, a, expected, 2.0 ); t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -677,8 +646,8 @@ tape( 'the function supports specifying a negative `x` stride (column-major)', f expected = new Float32Array( data.A_out ); out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); - isApprox( t, a, expected, 2.0 ); t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -699,8 +668,8 @@ tape( 'the function supports specifying a negative `y` stride (row-major)', func expected = new Float32Array( data.A_out ); out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); - isApprox( t, a, expected, 2.0 ); t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -721,8 +690,8 @@ tape( 'the function supports specifying a negative `y` stride (column-major)', f expected = new Float32Array( data.A_out ); out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); - isApprox( t, a, expected, 2.0 ); t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -743,8 +712,8 @@ tape( 'the function supports specifying negative strides for `x` and `y` (row-ma expected = new Float32Array( data.A_out ); out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); - isApprox( t, a, expected, 2.0 ); t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -765,8 +734,8 @@ tape( 'the function supports specifying negative strides for `x` and `y` (column expected = new Float32Array( data.A_out ); out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); - isApprox( t, a, expected, 2.0 ); t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -787,8 +756,8 @@ tape( 'the function supports complex access patterns (row-major)', function test expected = new Float32Array( data.A_out ); out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); - isApprox( t, a, expected, 2.0 ); t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -809,7 +778,7 @@ tape( 'the function supports complex access patterns (column-major)', function t expected = new Float32Array( data.A_out ); out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); - isApprox( t, a, expected, 2.0 ); t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/test.sger.js b/lib/node_modules/@stdlib/blas/base/sger/test/test.sger.js index 08e43b5c50e2..4c243c1994d0 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/test.sger.js +++ b/lib/node_modules/@stdlib/blas/base/sger/test/test.sger.js @@ -24,8 +24,6 @@ var tape = require( 'tape' ); var Float32Array = require( '@stdlib/array/float32' ); -var EPS = require( '@stdlib/constants/float32/eps' ); -var abs = require( '@stdlib/math/base/special/abs' ); var sger = require( './../lib/sger.js' ); @@ -44,35 +42,6 @@ var rxpyn = require( './fixtures/row_major_xpyn.json' ); var rxnyn = require( './fixtures/row_major_xnyn.json' ); -// FUNCTIONS // - -/** -* Tests for element-wise approximate equality. -* -* @private -* @param {Object} t - test object -* @param {Collection} actual - actual values -* @param {Collection} expected - expected values -* @param {number} rtol - relative tolerance -*/ -function isApprox( t, actual, expected, rtol ) { - var delta; - var tol; - var i; - - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - if ( actual[ i ] === expected[ i ] ) { - t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); - } else { - delta = abs( actual[ i ] - expected[ i ] ); - tol = rtol * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); - } - } -} - - // TESTS // tape( 'main export is a function', function test( t ) { @@ -225,8 +194,8 @@ tape( 'the function the rank 1 operation `A = α*x*y^T + A` (row-major)', functi expected = new Float32Array( data.A_out ); out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); - isApprox( t, a, expected, 2.0 ); t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -247,8 +216,8 @@ tape( 'the function the rank 1 operation `A = α*x*y^T + A` (column-major)', fun expected = new Float32Array( data.A_out ); out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); - isApprox( t, a, expected, 2.0 ); t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -405,8 +374,8 @@ tape( 'the function supports specifying `x` and `y` strides (row-major)', functi expected = new Float32Array( data.A_out ); out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); - isApprox( t, a, expected, 2.0 ); t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -427,8 +396,8 @@ tape( 'the function supports specifying `x` and `y` strides (column-major)', fun expected = new Float32Array( data.A_out ); out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); - isApprox( t, a, expected, 2.0 ); t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -449,8 +418,8 @@ tape( 'the function supports specifying a negative `x` stride (row-major)', func expected = new Float32Array( data.A_out ); out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); - isApprox( t, a, expected, 2.0 ); t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -471,8 +440,8 @@ tape( 'the function supports specifying a negative `x` stride (column-major)', f expected = new Float32Array( data.A_out ); out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); - isApprox( t, a, expected, 2.0 ); t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -493,8 +462,8 @@ tape( 'the function supports specifying a negative `y` stride (row-major)', func expected = new Float32Array( data.A_out ); out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); - isApprox( t, a, expected, 2.0 ); t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -515,8 +484,8 @@ tape( 'the function supports specifying a negative `y` stride (column-major)', f expected = new Float32Array( data.A_out ); out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); - isApprox( t, a, expected, 2.0 ); t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -537,8 +506,8 @@ tape( 'the function supports complex access patterns (row-major)', function test expected = new Float32Array( data.A_out ); out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); - isApprox( t, a, expected, 2.0 ); t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -559,7 +528,7 @@ tape( 'the function supports complex access patterns (column-major)', function t expected = new Float32Array( data.A_out ); out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); - isApprox( t, a, expected, 2.0 ); t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); From 3af15cc55e6378ce8703d1d2a2bcaa492767a6ab Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Thu, 12 Jun 2025 22:52:24 +0530 Subject: [PATCH 05/24] chore: remove undeclared parameter Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- lib/node_modules/@stdlib/blas/base/sger/docs/types/index.d.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sger/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/sger/docs/types/index.d.ts index 51a151d49b89..0585d1854926 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/sger/docs/types/index.d.ts @@ -30,7 +30,6 @@ interface Routine { * Performs the rank 1 operation `A = α*x*y^T + A`, where `α` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector and `A` is an `M` by `N` matrix. * * @param order - storage layout - * @param trans - specifies whether `A` should be transposed, conjugate-transposed, or not transposed * @param M - number of rows in the matrix `A` * @param N - number of columns in the matrix `A` * @param alpha - scalar constant @@ -89,7 +88,6 @@ interface Routine { * Performs the rank 1 operation `A = α*x*y^T + A`, where `α` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector and `A` is an `M` by `N` matrix. * * @param order - storage layout -* @param trans - specifies whether `A` should be transposed, conjugate-transposed, or not transposed * @param M - number of rows in the matrix `A` * @param N - number of columns in the matrix `A` * @param alpha - scalar constant From d510cbb2fb54f67ce85dc0da73fe5b9475622153 Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Thu, 12 Jun 2025 22:54:07 +0530 Subject: [PATCH 06/24] chore: add indentation Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- lib/node_modules/@stdlib/blas/base/sger/lib/base.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sger/lib/base.js b/lib/node_modules/@stdlib/blas/base/sger/lib/base.js index d73d541ae5b0..7f91b86f70d6 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/lib/base.js +++ b/lib/node_modules/@stdlib/blas/base/sger/lib/base.js @@ -83,9 +83,9 @@ function sger( M, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, strideA if ( y[ iy1 ] !== 0.0 ) { tmp = f32( alpha * y[ iy1 ] ); ix1 = offsetX; - oa = offsetA + (sa1*i1); + oa = offsetA + ( sa1 * i1 ); for ( i0 = 0; i0 < M; i0++ ) { - A[ oa+(sa0*i0) ] += f32( x[ ix1 ] * tmp ); + A[ oa + ( sa0 * i0 ) ] += f32( x[ ix1 ] * tmp ); ix1 += strideX; } } @@ -98,9 +98,9 @@ function sger( M, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, strideA if ( x[ ix1 ] !== 0.0 ) { tmp = f32( alpha * x[ ix1 ] ); iy1 = offsetY; - oa = offsetA + (sa1*i1); + oa = offsetA + ( sa1 * i1 ); for ( i0 = 0; i0 < N; i0++ ) { - A[ oa+(sa0*i0) ] += f32( y[ iy1 ] * tmp ); + A[ oa + ( sa0 * i0 ) ] += f32( y[ iy1 ] * tmp ); iy1 += strideY; } } From 7dff1feaa644da2782d5150f5c222816cf90ec09 Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Thu, 12 Jun 2025 22:55:42 +0530 Subject: [PATCH 07/24] chore: add lda check Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- lib/node_modules/@stdlib/blas/base/sger/lib/sger.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/node_modules/@stdlib/blas/base/sger/lib/sger.js b/lib/node_modules/@stdlib/blas/base/sger/lib/sger.js index f3c10c1024b9..850ba280daf5 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/lib/sger.js +++ b/lib/node_modules/@stdlib/blas/base/sger/lib/sger.js @@ -22,6 +22,7 @@ var stride2offset = require( '@stdlib/strided/base/stride2offset' ); var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); +var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); var format = require( '@stdlib/string/format' ); var base = require( './base.js' ); @@ -46,6 +47,7 @@ var base = require( './base.js' ); * @throws {RangeError} third argument must be a nonnegative integer * @throws {RangeError} sixth argument must be non-zero * @throws {RangeError} eighth argument must be non-zero +* @throws {RangeError} tenth argument must be greater than or equal to max(1,M) * @returns {Float32Array} `A` * * @example @@ -59,11 +61,14 @@ var base = require( './base.js' ); * // A => [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] */ function sger( order, M, N, alpha, x, strideX, y, strideY, A, LDA ) { + var iscm; + var vala; var sa1; var sa2; var ox; var oy; + iscm = isColumnMajor( order ); if ( !isLayout( order ) ) { throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); } @@ -79,6 +84,14 @@ function sger( order, M, N, alpha, x, strideX, y, strideY, A, LDA ) { if ( strideY === 0 ) { throw new RangeError( format( 'invalid argument. Eighth argument must be non-zero.' ) ); } + if ( iscm ) { + vala = M; + } else { + vala = N; + } + if ( LDA < max( 1, vala ) ) { + throw new RangeError( format( 'invalid argument. Tenth argument must be greater than or equal to max(1,%d). Value: `%d`.', vala, LDA ) ); + } // Check if we can early return... if ( M === 0 || N === 0 || alpha === 0.0 ) { return A; From 613f7897c5d00667453f9141f76afc6f2d6011b6 Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Thu, 12 Jun 2025 22:56:24 +0530 Subject: [PATCH 08/24] chore: minor clean-up Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- lib/node_modules/@stdlib/blas/base/sger/lib/sger.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/node_modules/@stdlib/blas/base/sger/lib/sger.js b/lib/node_modules/@stdlib/blas/base/sger/lib/sger.js index 850ba280daf5..fba8bbcb10c3 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/lib/sger.js +++ b/lib/node_modules/@stdlib/blas/base/sger/lib/sger.js @@ -20,6 +20,7 @@ // MODULES // +var max = require( '@stdlib/math/base/special/fast/max' ); var stride2offset = require( '@stdlib/strided/base/stride2offset' ); var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); From ed5f9a8e4eb90f4babe343d36e9288e3f2c032d3 Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Fri, 13 Jun 2025 04:53:31 +0000 Subject: [PATCH 09/24] chore: update copyright years --- lib/node_modules/@stdlib/blas/base/sger/README.md | 2 +- lib/node_modules/@stdlib/blas/base/sger/benchmark/benchmark.js | 2 +- .../@stdlib/blas/base/sger/benchmark/benchmark.ndarray.js | 2 +- lib/node_modules/@stdlib/blas/base/sger/docs/types/index.d.ts | 2 +- lib/node_modules/@stdlib/blas/base/sger/docs/types/test.ts | 2 +- lib/node_modules/@stdlib/blas/base/sger/examples/index.js | 2 +- lib/node_modules/@stdlib/blas/base/sger/lib/base.js | 2 +- lib/node_modules/@stdlib/blas/base/sger/lib/index.js | 2 +- lib/node_modules/@stdlib/blas/base/sger/lib/main.js | 2 +- lib/node_modules/@stdlib/blas/base/sger/lib/ndarray.js | 2 +- lib/node_modules/@stdlib/blas/base/sger/lib/sger.js | 2 +- lib/node_modules/@stdlib/blas/base/sger/test/test.js | 2 +- lib/node_modules/@stdlib/blas/base/sger/test/test.ndarray.js | 2 +- lib/node_modules/@stdlib/blas/base/sger/test/test.sger.js | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sger/README.md b/lib/node_modules/@stdlib/blas/base/sger/README.md index bf1482b6fa33..c167b1a26b31 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/README.md +++ b/lib/node_modules/@stdlib/blas/base/sger/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2024 The Stdlib Authors. +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. diff --git a/lib/node_modules/@stdlib/blas/base/sger/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/sger/benchmark/benchmark.js index 214a1fc34fa2..20835d780fea 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/base/sger/benchmark/benchmark.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/base/sger/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/sger/benchmark/benchmark.ndarray.js index b2d150a154e7..5c4ec6a545c6 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/sger/benchmark/benchmark.ndarray.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/base/sger/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/sger/docs/types/index.d.ts index 0585d1854926..cd3555a51060 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/sger/docs/types/index.d.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/base/sger/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/sger/docs/types/test.ts index 489f798f3dad..c744803657c9 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/base/sger/docs/types/test.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/base/sger/examples/index.js b/lib/node_modules/@stdlib/blas/base/sger/examples/index.js index f5f64a13bae4..e956d5480a5a 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/examples/index.js +++ b/lib/node_modules/@stdlib/blas/base/sger/examples/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/base/sger/lib/base.js b/lib/node_modules/@stdlib/blas/base/sger/lib/base.js index 7f91b86f70d6..683579345276 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/lib/base.js +++ b/lib/node_modules/@stdlib/blas/base/sger/lib/base.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/base/sger/lib/index.js b/lib/node_modules/@stdlib/blas/base/sger/lib/index.js index 387e6bd0ff30..2cd3e2bcb6ee 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/lib/index.js +++ b/lib/node_modules/@stdlib/blas/base/sger/lib/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/base/sger/lib/main.js b/lib/node_modules/@stdlib/blas/base/sger/lib/main.js index 46c1ea8be863..44f4d1d86b77 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/lib/main.js +++ b/lib/node_modules/@stdlib/blas/base/sger/lib/main.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/base/sger/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/sger/lib/ndarray.js index de60f84760b6..e06e7249e535 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/sger/lib/ndarray.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/base/sger/lib/sger.js b/lib/node_modules/@stdlib/blas/base/sger/lib/sger.js index fba8bbcb10c3..1ee29fb20bf3 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/lib/sger.js +++ b/lib/node_modules/@stdlib/blas/base/sger/lib/sger.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/test.js b/lib/node_modules/@stdlib/blas/base/sger/test/test.js index 36f83cedcf0d..35cd7f5dfebe 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/test.js +++ b/lib/node_modules/@stdlib/blas/base/sger/test/test.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/sger/test/test.ndarray.js index 36380c12874f..03b28854c841 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/sger/test/test.ndarray.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/test.sger.js b/lib/node_modules/@stdlib/blas/base/sger/test/test.sger.js index 4c243c1994d0..ee246733f349 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/test.sger.js +++ b/lib/node_modules/@stdlib/blas/base/sger/test/test.sger.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* 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. From 335d5ca713db71b5c9c96fe5f503e5b827fa0724 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Fri, 13 Jun 2025 11:08:48 +0530 Subject: [PATCH 10/24] chore: add test cases --- 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 status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../base/sger/test/fixtures/column_major.json | 4 ++++ .../column_major_complex_access_pattern.json | 4 ++++ .../sger/test/fixtures/column_major_oa.json | 4 ++++ .../test/fixtures/column_major_sa1_sa2.json | 4 ++++ .../test/fixtures/column_major_sa1_sa2n.json | 4 ++++ .../test/fixtures/column_major_sa1n_sa2.json | 4 ++++ .../test/fixtures/column_major_sa1n_sa2n.json | 4 ++++ .../sger/test/fixtures/column_major_xnyn.json | 4 ++++ .../sger/test/fixtures/column_major_xnyp.json | 4 ++++ .../sger/test/fixtures/column_major_xpyn.json | 4 ++++ .../sger/test/fixtures/column_major_xpyp.json | 4 ++++ .../base/sger/test/fixtures/row_major.json | 4 ++++ .../row_major_complex_access_pattern.json | 4 ++++ .../base/sger/test/fixtures/row_major_oa.json | 4 ++++ .../sger/test/fixtures/row_major_sa1_sa2.json | 4 ++++ .../test/fixtures/row_major_sa1_sa2n.json | 4 ++++ .../test/fixtures/row_major_sa1n_sa2.json | 4 ++++ .../test/fixtures/row_major_sa1n_sa2n.json | 4 ++++ .../sger/test/fixtures/row_major_xnyn.json | 4 ++++ .../sger/test/fixtures/row_major_xnyp.json | 4 ++++ .../sger/test/fixtures/row_major_xpyn.json | 4 ++++ .../sger/test/fixtures/row_major_xpyp.json | 4 ++++ .../@stdlib/blas/base/sger/test/test.sger.js | 23 +++++++++++++++++++ 23 files changed, 111 insertions(+) diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major.json index 19adb72ab470..277c350146f0 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major.json @@ -10,6 +10,10 @@ "strideY": 1, "offsetY": 0, "A": [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ], + "A_mat": [ + [ 1.0, 2.0, 3.0 ], + [ 4.0, 5.0, 6.0 ] + ], "lda": 2, "strideA1": 1, "strideA2": 2, diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_complex_access_pattern.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_complex_access_pattern.json index d52726883a6d..a395d2dd0e44 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_complex_access_pattern.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_complex_access_pattern.json @@ -9,6 +9,10 @@ "strideY": -2, "offsetY": 4, "A": [ 0.0, 0.0, 0.0, 0.0, 6.0, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0, 0.0, 5.0, 0.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 1.0, 0.0 ], + "A_mat": [ + [ 1.0, 2.0, 3.0 ], + [ 4.0, 5.0, 6.0 ] + ], "strideA1": -2, "strideA2": -8, "offsetA": 22, diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_oa.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_oa.json index 6bb4f94e3616..375ff499e318 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_oa.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_oa.json @@ -9,6 +9,10 @@ "strideY": 2, "offsetY": 0, "A": [ 0.0, 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ], + "A_mat": [ + [ 1.0, 2.0, 3.0 ], + [ 4.0, 5.0, 6.0 ] + ], "strideA1": 1, "strideA2": 2, "offsetA": 1, diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1_sa2.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1_sa2.json index 20c43b149187..3bdfd0849d8d 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1_sa2.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1_sa2.json @@ -9,6 +9,10 @@ "strideY": 2, "offsetY": 0, "A": [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3.0, 0.0, 6.0, 0.0 ], + "A_mat": [ + [ 1.0, 2.0, 3.0 ], + [ 4.0, 5.0, 6.0 ] + ], "strideA1": 2, "strideA2": 8, "offsetA": 4, diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1_sa2n.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1_sa2n.json index ab7ac9e8897d..31d8fa03f512 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1_sa2n.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1_sa2n.json @@ -9,6 +9,10 @@ "strideY": 2, "offsetY": 0, "A": [ 0.0, 0.0, 0.0, 0.0, 3.0, 0.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 4.0, 0.0 ], + "A_mat": [ + [ 1.0, 2.0, 3.0 ], + [ 4.0, 5.0, 6.0 ] + ], "strideA1": 2, "strideA2": -8, "offsetA": 20, diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1n_sa2.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1n_sa2.json index 82884c1c0804..38229e4d9f20 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1n_sa2.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1n_sa2.json @@ -9,6 +9,10 @@ "strideY": 2, "offsetY": 0, "A": [ 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 5.0, 0.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 6.0, 0.0, 3.0, 0.0 ], + "A_mat": [ + [ 1.0, 2.0, 3.0 ], + [ 4.0, 5.0, 6.0 ] + ], "strideA1": -2, "strideA2": 8, "offsetA": 6, diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1n_sa2n.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1n_sa2n.json index ba307fda875c..fce200afaa36 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1n_sa2n.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1n_sa2n.json @@ -9,6 +9,10 @@ "strideY": 2, "offsetY": 0, "A": [ 0.0, 0.0, 0.0, 0.0, 6.0, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0, 0.0, 5.0, 0.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 1.0, 0.0 ], + "A_mat": [ + [ 1.0, 2.0, 3.0 ], + [ 4.0, 5.0, 6.0 ] + ], "strideA1": -2, "strideA2": -8, "offsetA": 22, diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_xnyn.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_xnyn.json index f107aa4eb727..df5d1cf78f43 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_xnyn.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_xnyn.json @@ -10,6 +10,10 @@ "strideY": -2, "offsetY": 4, "A": [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ], + "A_mat": [ + [ 1.0, 2.0, 3.0 ], + [ 4.0, 5.0, 6.0 ] + ], "lda": 2, "strideA1": 1, "strideA2": 2, diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_xnyp.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_xnyp.json index fcfb609eb3f0..33979ab2d0af 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_xnyp.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_xnyp.json @@ -10,6 +10,10 @@ "strideY": 2, "offsetY": 0, "A": [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ], + "A_mat": [ + [ 1.0, 2.0, 3.0 ], + [ 4.0, 5.0, 6.0 ] + ], "lda": 2, "strideA1": 1, "strideA2": 2, diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_xpyn.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_xpyn.json index 2cc21048ac0d..96cb5e88b6c9 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_xpyn.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_xpyn.json @@ -10,6 +10,10 @@ "strideY": -2, "offsetY": 4, "A": [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ], + "A_mat": [ + [ 1.0, 2.0, 3.0 ], + [ 4.0, 5.0, 6.0 ] + ], "lda": 2, "strideA1": 1, "strideA2": 2, diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_xpyp.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_xpyp.json index 7ddda6580f6b..33fbd18fdb62 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_xpyp.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_xpyp.json @@ -10,6 +10,10 @@ "strideY": 2, "offsetY": 0, "A": [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ], + "A_mat": [ + [ 1.0, 2.0, 3.0 ], + [ 4.0, 5.0, 6.0 ] + ], "lda": 2, "strideA1": 1, "strideA2": 2, diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major.json index 6c5a8c89a176..2ab84ca7d4d3 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major.json @@ -10,6 +10,10 @@ "strideY": 1, "offsetY": 0, "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "A_mat": [ + [ 1.0, 2.0, 3.0 ], + [ 4.0, 5.0, 6.0 ] + ], "lda": 3, "strideA1": 3, "strideA2": 1, diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_complex_access_pattern.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_complex_access_pattern.json index 53f86d6f795d..055b990e0c7d 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_complex_access_pattern.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_complex_access_pattern.json @@ -9,6 +9,10 @@ "strideY": -2, "offsetY": 4, "A": [ 0.0, 6.0, 0.0, 5.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3.0, 0.0, 2.0, 0.0, 1.0, 0.0 ], + "A_mat": [ + [ 1.0, 2.0, 3.0 ], + [ 4.0, 5.0, 6.0 ] + ], "strideA1": -14, "strideA2": -2, "offsetA": 19, diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_oa.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_oa.json index dce60e368fb3..809dfee2957e 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_oa.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_oa.json @@ -9,6 +9,10 @@ "strideY": 2, "offsetY": 0, "A": [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "A_mat": [ + [ 1.0, 2.0, 3.0 ], + [ 4.0, 5.0, 6.0 ] + ], "strideA1": 3, "strideA2": 1, "offsetA": 1, diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1_sa2.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1_sa2.json index 6fd51996873f..0831d623801a 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1_sa2.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1_sa2.json @@ -9,6 +9,10 @@ "strideY": 2, "offsetY": 0, "A": [ 0.0, 1.0, 0.0, 2.0, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 5.0, 0.0, 6.0, 0.0 ], + "A_mat": [ + [ 1.0, 2.0, 3.0 ], + [ 4.0, 5.0, 6.0 ] + ], "strideA1": 14, "strideA2": 2, "offsetA": 1, diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1_sa2n.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1_sa2n.json index 24ddd2faca66..8b299c6269ec 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1_sa2n.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1_sa2n.json @@ -9,6 +9,10 @@ "strideY": 2, "offsetY": 0, "A": [ 0.0, 3.0, 0.0, 2.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 6.0, 0.0, 5.0, 0.0, 4.0, 0.0 ], + "A_mat": [ + [ 1.0, 2.0, 3.0 ], + [ 4.0, 5.0, 6.0 ] + ], "strideA1": 14, "strideA2": -2, "offsetA": 5, diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1n_sa2.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1n_sa2.json index 3b178508b6c3..e1cc5c252679 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1n_sa2.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1n_sa2.json @@ -9,6 +9,10 @@ "strideY": 2, "offsetY": 0, "A": [ 0.0, 4.0, 0.0, 5.0, 0.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ], + "A_mat": [ + [ 1.0, 2.0, 3.0 ], + [ 4.0, 5.0, 6.0 ] + ], "strideA1": -14, "strideA2": 2, "offsetA": 15, diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1n_sa2n.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1n_sa2n.json index c35b155184f1..cd9014c634bf 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1n_sa2n.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1n_sa2n.json @@ -9,6 +9,10 @@ "strideY": 2, "offsetY": 0, "A": [ 0.0, 6.0, 0.0, 5.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3.0, 0.0, 2.0, 0.0, 1.0, 0.0 ], + "A_mat": [ + [ 1.0, 2.0, 3.0 ], + [ 4.0, 5.0, 6.0 ] + ], "strideA1": -14, "strideA2": -2, "offsetA": 19, diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_xnyn.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_xnyn.json index 7713b84d9d54..f158f9dc7d90 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_xnyn.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_xnyn.json @@ -10,6 +10,10 @@ "strideY": -2, "offsetY": 4, "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "A_mat": [ + [ 1.0, 2.0, 3.0 ], + [ 4.0, 5.0, 6.0 ] + ], "lda": 3, "strideA1": 3, "strideA2": 1, diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_xnyp.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_xnyp.json index fea1b4dbd0a0..7fb10bf73ee5 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_xnyp.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_xnyp.json @@ -10,6 +10,10 @@ "strideY": 2, "offsetY": 0, "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "A_mat": [ + [ 1.0, 2.0, 3.0 ], + [ 4.0, 5.0, 6.0 ] + ], "lda": 3, "strideA1": 3, "strideA2": 1, diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_xpyn.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_xpyn.json index e89ebada429c..66a5aedb4406 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_xpyn.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_xpyn.json @@ -10,6 +10,10 @@ "strideY": -2, "offsetY": 4, "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "A_mat": [ + [ 1.0, 2.0, 3.0 ], + [ 4.0, 5.0, 6.0 ] + ], "lda": 3, "strideA1": 3, "strideA2": 1, diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_xpyp.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_xpyp.json index 4291cb6a8b27..43f67e9fb316 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_xpyp.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_xpyp.json @@ -10,6 +10,10 @@ "strideY": 2, "offsetY": 0, "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "A_mat": [ + [ 1.0, 2.0, 3.0 ], + [ 4.0, 5.0, 6.0 ] + ], "lda": 3, "strideA1": 3, "strideA2": 1, diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/test.sger.js b/lib/node_modules/@stdlib/blas/base/sger/test/test.sger.js index ee246733f349..ad8d60db4730 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/test.sger.js +++ b/lib/node_modules/@stdlib/blas/base/sger/test/test.sger.js @@ -177,6 +177,29 @@ tape( 'the function throws an error if provided an invalid eighth argument', fun } }); +tape( 'the function throws an error if provided an invalid tenth argument', function test( t ) { + var values; + var data; + var i; + + data = rm; + + values = [ + 0 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + sger( data.order, data.M, data.N, data.alpha, new Float32Array( data.x ), data.strideX, new Float32Array( data.y ), data.strideY, new Float32Array( data.A ), value ); + }; + } +}); + tape( 'the function the rank 1 operation `A = α*x*y^T + A` (row-major)', function test( t ) { var expected; var data; From d0639522110d1d40ad073975f4a4dad745577976 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Fri, 27 Jun 2025 11:12:32 +0530 Subject: [PATCH 11/24] chore: update implementation --- 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 status: na - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/blas/base/sger/docs/repl.txt | 2 +- .../@stdlib/blas/base/sger/lib/base.js | 157 +++++++++++---- .../@stdlib/blas/base/sger/lib/ndarray.js | 8 +- .../@stdlib/blas/base/sger/lib/sger.js | 6 +- .../column_major_complex_access_pattern.json | 1 + .../sger/test/fixtures/column_major_oa.json | 1 + .../sger/test/fixtures/column_major_ox.json | 22 +++ .../sger/test/fixtures/column_major_oy.json | 22 +++ .../test/fixtures/column_major_sa1_sa2.json | 1 + .../test/fixtures/column_major_sa1_sa2n.json | 1 + .../test/fixtures/column_major_sa1n_sa2.json | 1 + .../test/fixtures/column_major_sa1n_sa2n.json | 1 + .../test/fixtures/column_major_x_zeros.json | 22 +++ .../test/fixtures/column_major_y_zeros.json | 22 +++ .../row_major_complex_access_pattern.json | 1 + .../base/sger/test/fixtures/row_major_oa.json | 1 + .../base/sger/test/fixtures/row_major_ox.json | 22 +++ .../base/sger/test/fixtures/row_major_oy.json | 22 +++ .../sger/test/fixtures/row_major_sa1_sa2.json | 47 ++++- .../test/fixtures/row_major_sa1_sa2n.json | 45 ++++- .../test/fixtures/row_major_sa1n_sa2.json | 51 ++++- .../test/fixtures/row_major_sa1n_sa2n.json | 45 ++++- .../sger/test/fixtures/row_major_x_zeros.json | 22 +++ .../sger/test/fixtures/row_major_y_zeros.json | 22 +++ .../blas/base/sger/test/test.ndarray.js | 184 ++++++++++++++++++ .../@stdlib/blas/base/sger/test/test.sger.js | 98 +++++++++- 26 files changed, 759 insertions(+), 68 deletions(-) create mode 100644 lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_ox.json create mode 100644 lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_oy.json create mode 100644 lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_x_zeros.json create mode 100644 lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_y_zeros.json create mode 100644 lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_ox.json create mode 100644 lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_oy.json create mode 100644 lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_x_zeros.json create mode 100644 lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_y_zeros.json diff --git a/lib/node_modules/@stdlib/blas/base/sger/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/sger/docs/repl.txt index 00b207e0ebbb..49aef9fdba07 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/sger/docs/repl.txt @@ -7,7 +7,7 @@ Indexing is relative to the first index. To introduce an offset, use typed array views. - If `M` or `N` or `α` is equal to `0`, the function returns `A` unchanged. + If `M`, `N`, or `α` is equal to `0`, the function returns `A` unchanged. Parameters ---------- diff --git a/lib/node_modules/@stdlib/blas/base/sger/lib/base.js b/lib/node_modules/@stdlib/blas/base/sger/lib/base.js index 683579345276..310183ac0f1e 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/lib/base.js +++ b/lib/node_modules/@stdlib/blas/base/sger/lib/base.js @@ -27,8 +27,71 @@ var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); // MAIN // /** -* Performs the rank 1 operation `A = α*x*y^T + A`, where `α` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector and `A` is an `M` by `N` matrix. +* Performs the rank 1 operation `A = α*x*y^T + A`, where `α` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector, and `A` is an `M` by `N` matrix. * +* ## Notes +* +* - To help motivate the use of loop interchange below, we first recognize that a matrix stored in row-major order is equivalent to storing the matrix's transpose in column-major order. For example, consider the following 2-by-3 matrix `A` +* +* ```tex +* A = \begin{bmatrix} +* 1 & 2 & 3 \\ +* 4 & 5 & 6 +* \end{bmatrix} +* ``` +* +* When stored in a linear buffer in column-major order, `A` becomes +* +* ```text +* [ 1 4 2 5 3 6] +* ``` +* +* When stored in a linear buffer in row-major order, `A` becomes +* +* ```text +* [ 1 2 3 4 5 6] +* ``` +* +* Now consider the transpose of `A` +* +* ```tex +* A^T = \begin{bmatrix} +* 1 & 4 \\ +* 2 & 5 \\ +* 3 & 6 +* \end{bmatrix} +* ``` +* +* When the transpose is stored in a linear buffer in column-major order, the transpose becomes +* +* ```text +* [ 1 2 3 4 5 6 ] +* ``` +* +* Similarly, when stored in row-major order, the transpose becomes +* +* ```text +* [ 1 4 2 5 3 6 ] +* ``` +* +* As may be observed, `A` stored in column-major order is equivalent to storing the transpose of `A` in row-major order, and storing `A` in row-major order is equivalent to storing the transpose of `A` in column-major order, and vice versa. +* +* Hence, we can interpret an `M` by `N` row-major matrix `B` as the matrix `A^T` stored in column-major order. In which case, we can derive an update equation for `B` as follows: +* +* ```tex +* \begin{align*} +* B &= A^T \\ +* &= (\alpha \bar{x} \bar{y}^T + A)^T \\ +* &= (\alpha \bar{x} \bar{y}^T)^T + A^T \\ +* &= \alpha (\bar{x} \bar{y}^T)^T + A^T \\ +* &= \alpha \bar{y} \bar{x}^T + A^T \\ +* &= \alpha \bar{y} \bar{x}^T + B +* \end{align*} +* ``` +* +* Accordingly, we can reuse the same loop logic for column-major and row-major `A` by simply swapping `x` and `y` and `M` and `N` when `A` is row-major order. That is the essence of loop interchange. +* +* @private * @param {NonNegativeInteger} M - number of rows in the matrix `A` * @param {NonNegativeInteger} N - number of columns in the matrix `A` * @param {number} alpha - scalar constant @@ -55,56 +118,68 @@ var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); * // A => [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] */ function sger( M, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, strideA1, strideA2, offsetA ) { // eslint-disable-line max-params, max-len - var isrm; var tmp; - var ix1; - var iy1; - var sa0; - var sa1; + var da0; + var da1; + var S0; + var S1; + var sx; + var sy; + var ia; + var ix; + var iy; var i0; var i1; - var oa; - // Note on variable naming convention: sa#, ix#, i# where # corresponds to the loop number, with `0` being the innermost loop... + // Note on variable naming convention: S#, da#, ia#, i# where # corresponds to the loop number, with `0` being the innermost loop... - isrm = isRowMajor( [ strideA1, strideA2 ] ); - if ( isrm ) { + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + if ( isRowMajor( [ strideA1, strideA2 ] ) ) { // For row-major matrices, the last dimension has the fastest changing index... - sa0 = strideA2; // stride for innermost loop - sa1 = strideA1; // stride for outermost loop - } else { // isColMajor + S0 = N; + S1 = M; + da0 = strideA2; // offset increment for innermost loop + da1 = strideA1 - ( S0*strideA2 ); // offset increment for outermost loop + + // Swap the vectors... + tmp = x; + x = y; + y = tmp; + + tmp = strideX; + strideX = strideY; + strideY = tmp; + + tmp = offsetX; + offsetX = offsetY; + offsetY = tmp; + } else { // order === 'column-major' // For column-major matrices, the first dimension has the fastest changing index... - sa0 = strideA1; // stride for innermost loop - sa1 = strideA2; // stride for outermost loop - } - if ( !isrm ) { - iy1 = offsetY; - for ( i1 = 0; i1 < N; i1++ ) { - if ( y[ iy1 ] !== 0.0 ) { - tmp = f32( alpha * y[ iy1 ] ); - ix1 = offsetX; - oa = offsetA + ( sa1 * i1 ); - for ( i0 = 0; i0 < M; i0++ ) { - A[ oa + ( sa0 * i0 ) ] += f32( x[ ix1 ] * tmp ); - ix1 += strideX; - } - } - iy1 += strideY; - } - return A; + S0 = M; + S1 = N; + da0 = strideA1; // offset increment for innermost loop + da1 = strideA2 - ( S0*strideA1 ); // offset increment for outermost loop } - ix1 = offsetX; - for ( i1 = 0; i1 < M; i1++ ) { - if ( x[ ix1 ] !== 0.0 ) { - tmp = f32( alpha * x[ ix1 ] ); - iy1 = offsetY; - oa = offsetA + ( sa1 * i1 ); - for ( i0 = 0; i0 < N; i0++ ) { - A[ oa + ( sa0 * i0 ) ] += f32( y[ iy1 ] * tmp ); - iy1 += strideY; + sx = strideX; + sy = strideY; + ix = offsetX; + iy = offsetY; + ia = offsetA; + for ( i1 = 0; i1 < S1; i1++ ) { + // Check whether we can avoid the inner loop entirely... + if ( y[ iy ] === 0.0 ) { + ia += da0 * S0; + } else { + tmp = f32( alpha * y[ iy ] ); + ix = offsetX; + for ( i0 = 0; i0 < S0; i0++ ) { + A[ ia ] += f32( x[ ix ] * tmp ); + ix += sx; + ia += da0; } } - ix1 += strideX; + iy += sy; + ia += da1; } return A; } diff --git a/lib/node_modules/@stdlib/blas/base/sger/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/sger/lib/ndarray.js index e06e7249e535..5a57f104bba4 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/sger/lib/ndarray.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* 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. @@ -27,7 +27,7 @@ var base = require( './base.js' ); // MAIN // /** -* Performs the rank 1 operation `A = α*x*y^T + A`, where `α` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector and `A` is an `M` by `N` matrix. +* Performs the rank 1 operation `A = α*x*y^T + A`, where `α` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector, and `A` is an `M` by `N` matrix. * * @param {NonNegativeInteger} M - number of rows in the matrix `A` * @param {NonNegativeInteger} N - number of columns in the matrix `A` @@ -66,10 +66,10 @@ function sger( M, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, strideA throw new RangeError( format( 'invalid argument. Second argument must be a nonnegative integer. Value: `%d`.', N ) ); } if ( strideX === 0 ) { - throw new RangeError( format( 'invalid argument. Fifth argument must be non-zero.' ) ); + throw new RangeError( format( 'invalid argument. Fifth argument must be non-zero. Value: `%d`.', strideX ) ); } if ( strideY === 0 ) { - throw new RangeError( format( 'invalid argument. Eighth argument must be non-zero.' ) ); + throw new RangeError( format( 'invalid argument. Eighth argument must be non-zero. Value: `%d`.', strideY ) ); } // Check if we can early return... if ( M === 0 || N === 0 || alpha === 0.0 ) { diff --git a/lib/node_modules/@stdlib/blas/base/sger/lib/sger.js b/lib/node_modules/@stdlib/blas/base/sger/lib/sger.js index 1ee29fb20bf3..87939bb3ab8a 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/lib/sger.js +++ b/lib/node_modules/@stdlib/blas/base/sger/lib/sger.js @@ -20,10 +20,10 @@ // MODULES // -var max = require( '@stdlib/math/base/special/fast/max' ); -var stride2offset = require( '@stdlib/strided/base/stride2offset' ); -var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); +var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); +var stride2offset = require( '@stdlib/strided/base/stride2offset' ); +var max = require( '@stdlib/math/base/special/fast/max' ); var format = require( '@stdlib/string/format' ); var base = require( './base.js' ); diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_complex_access_pattern.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_complex_access_pattern.json index a395d2dd0e44..220746be33c5 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_complex_access_pattern.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_complex_access_pattern.json @@ -1,4 +1,5 @@ { + "order": "column-major", "M": 2, "N": 3, "alpha": 1.0, diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_oa.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_oa.json index 375ff499e318..fd257c7fba48 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_oa.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_oa.json @@ -1,4 +1,5 @@ { + "order": "column-major", "M": 2, "N": 3, "alpha": 1.0, diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_ox.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_ox.json new file mode 100644 index 000000000000..ac3db51d9545 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_ox.json @@ -0,0 +1,22 @@ +{ + "order": "column-major", + "M": 2, + "N": 3, + "alpha": 1.0, + "x": [ 0.0, 0.0, 1.0, 1.0 ], + "strideX": 1, + "offsetX": 2, + "y": [ 1.0, 1.0, 1.0 ], + "strideY": 1, + "offsetY": 0, + "A": [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ], + "A_mat": [ + [ 1.0, 2.0, 3.0 ], + [ 4.0, 5.0, 6.0 ] + ], + "lda": 2, + "strideA1": 1, + "strideA2": 2, + "offsetA": 0, + "A_out": [ 2.0, 5.0, 3.0, 6.0, 4.0, 7.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_oy.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_oy.json new file mode 100644 index 000000000000..d11a7ca06684 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_oy.json @@ -0,0 +1,22 @@ +{ + "order": "column-major", + "M": 2, + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 1.0 ], + "strideX": 1, + "offsetX": 0, + "y": [ 0.0, 0.0, 1.0, 1.0, 1.0 ], + "strideY": 1, + "offsetY": 2, + "A": [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ], + "A_mat": [ + [ 1.0, 2.0, 3.0 ], + [ 4.0, 5.0, 6.0 ] + ], + "lda": 2, + "strideA1": 1, + "strideA2": 2, + "offsetA": 0, + "A_out": [ 2.0, 5.0, 3.0, 6.0, 4.0, 7.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1_sa2.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1_sa2.json index 3bdfd0849d8d..702e051e70b9 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1_sa2.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1_sa2.json @@ -1,4 +1,5 @@ { + "order": "column-major", "M": 2, "N": 3, "alpha": 1.0, diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1_sa2n.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1_sa2n.json index 31d8fa03f512..f6b6b56f07a6 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1_sa2n.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1_sa2n.json @@ -1,4 +1,5 @@ { + "order": "column-major", "M": 2, "N": 3, "alpha": 1.0, diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1n_sa2.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1n_sa2.json index 38229e4d9f20..a4df499c44c5 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1n_sa2.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1n_sa2.json @@ -1,4 +1,5 @@ { + "order": "column-major", "M": 2, "N": 3, "alpha": 1.0, diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1n_sa2n.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1n_sa2n.json index fce200afaa36..9bbdcc5d25ff 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1n_sa2n.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1n_sa2n.json @@ -1,4 +1,5 @@ { + "order": "column-major", "M": 2, "N": 3, "alpha": 1.0, diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_x_zeros.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_x_zeros.json new file mode 100644 index 000000000000..7b48b4908fde --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_x_zeros.json @@ -0,0 +1,22 @@ +{ + "order": "column-major", + "M": 2, + "N": 3, + "alpha": 1.0, + "x": [ 0.0, 0.0 ], + "strideX": 1, + "offsetX": 0, + "y": [ 1.0, 1.0, 1.0 ], + "strideY": 1, + "offsetY": 0, + "A": [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ], + "A_mat": [ + [ 1.0, 2.0, 3.0 ], + [ 4.0, 5.0, 6.0 ] + ], + "lda": 2, + "strideA1": 1, + "strideA2": 2, + "offsetA": 0, + "A_out": [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_y_zeros.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_y_zeros.json new file mode 100644 index 000000000000..3f7881dd3860 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_y_zeros.json @@ -0,0 +1,22 @@ +{ + "order": "column-major", + "M": 2, + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 1.0 ], + "strideX": 1, + "offsetX": 0, + "y": [ 0.0, 0.0, 0.0 ], + "strideY": 1, + "offsetY": 0, + "A": [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ], + "A_mat": [ + [ 1.0, 2.0, 3.0 ], + [ 4.0, 5.0, 6.0 ] + ], + "lda": 2, + "strideA1": 1, + "strideA2": 2, + "offsetA": 0, + "A_out": [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_complex_access_pattern.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_complex_access_pattern.json index 055b990e0c7d..545a9ac46edc 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_complex_access_pattern.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_complex_access_pattern.json @@ -1,4 +1,5 @@ { + "order": "row-major", "M": 2, "N": 3, "alpha": 1.0, diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_oa.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_oa.json index 809dfee2957e..e85a1ca258c6 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_oa.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_oa.json @@ -1,4 +1,5 @@ { + "order": "row-major", "M": 2, "N": 3, "alpha": 1.0, diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_ox.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_ox.json new file mode 100644 index 000000000000..776f9aadfadb --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_ox.json @@ -0,0 +1,22 @@ +{ + "order": "row-major", + "M": 2, + "N": 3, + "alpha": 1.0, + "x": [ 0.0, 0.0, 1.0, 1.0 ], + "strideX": 1, + "offsetX": 2, + "y": [ 1.0, 1.0, 1.0 ], + "strideY": 1, + "offsetY": 0, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "A_mat": [ + [ 1.0, 2.0, 3.0 ], + [ 4.0, 5.0, 6.0 ] + ], + "lda": 3, + "strideA1": 3, + "strideA2": 1, + "offsetA": 0, + "A_out": [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_oy.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_oy.json new file mode 100644 index 000000000000..c95e6b470f60 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_oy.json @@ -0,0 +1,22 @@ +{ + "order": "row-major", + "M": 2, + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 1.0 ], + "strideX": 1, + "offsetX": 0, + "y": [ 0.0, 0.0, 1.0, 1.0, 1.0 ], + "strideY": 1, + "offsetY": 2, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "A_mat": [ + [ 1.0, 2.0, 3.0 ], + [ 4.0, 5.0, 6.0 ] + ], + "lda": 3, + "strideA1": 3, + "strideA2": 1, + "offsetA": 0, + "A_out": [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1_sa2.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1_sa2.json index 0831d623801a..37ad4b28b117 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1_sa2.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1_sa2.json @@ -1,4 +1,5 @@ { + "order": "row-major", "M": 2, "N": 3, "alpha": 1.0, @@ -8,13 +9,49 @@ "y": [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ], "strideY": 2, "offsetY": 0, - "A": [ 0.0, 1.0, 0.0, 2.0, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 5.0, 0.0, 6.0, 0.0 ], + "A": [ + 999.0, + 999.0, + 3.0, + 999.0, + 2.0, + 999.0, + 1.0, + 999.0, + 999.0, + 999.0, + 6.0, + 999.0, + 5.0, + 999.0, + 4.0, + 999.0, + 999.0 + ], "A_mat": [ [ 1.0, 2.0, 3.0 ], [ 4.0, 5.0, 6.0 ] ], - "strideA1": 14, - "strideA2": 2, - "offsetA": 1, - "A_out": [ 0.0, 2.0, 0.0, 4.0, 0.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 6.0, 0.0, 9.0, 0.0, 12.0, 0.0 ] + "strideA1": 8, + "strideA2": -2, + "offsetA": 6, + "A_out": [ + 999.0, + 999.0, + 6.0, + 999.0, + 4.0, + 999.0, + 2.0, + 999.0, + 999.0, + 999.0, + 12.0, + 999.0, + 9.0, + 999.0, + 6.0, + 999.0, + 999.0 + ] } diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1_sa2n.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1_sa2n.json index 8b299c6269ec..37ad4b28b117 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1_sa2n.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1_sa2n.json @@ -1,4 +1,5 @@ { + "order": "row-major", "M": 2, "N": 3, "alpha": 1.0, @@ -8,13 +9,49 @@ "y": [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ], "strideY": 2, "offsetY": 0, - "A": [ 0.0, 3.0, 0.0, 2.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 6.0, 0.0, 5.0, 0.0, 4.0, 0.0 ], + "A": [ + 999.0, + 999.0, + 3.0, + 999.0, + 2.0, + 999.0, + 1.0, + 999.0, + 999.0, + 999.0, + 6.0, + 999.0, + 5.0, + 999.0, + 4.0, + 999.0, + 999.0 + ], "A_mat": [ [ 1.0, 2.0, 3.0 ], [ 4.0, 5.0, 6.0 ] ], - "strideA1": 14, + "strideA1": 8, "strideA2": -2, - "offsetA": 5, - "A_out": [ 0.0, 6.0, 0.0, 4.0, 0.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 12.0, 0.0, 9.0, 0.0, 6.0, 0.0 ] + "offsetA": 6, + "A_out": [ + 999.0, + 999.0, + 6.0, + 999.0, + 4.0, + 999.0, + 2.0, + 999.0, + 999.0, + 999.0, + 12.0, + 999.0, + 9.0, + 999.0, + 6.0, + 999.0, + 999.0 + ] } diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1n_sa2.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1n_sa2.json index e1cc5c252679..5feaa8e8f17b 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1n_sa2.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1n_sa2.json @@ -1,4 +1,5 @@ { + "order": "row-major", "M": 2, "N": 3, "alpha": 1.0, @@ -8,13 +9,53 @@ "y": [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ], "strideY": 2, "offsetY": 0, - "A": [ 0.0, 4.0, 0.0, 5.0, 0.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ], + "A": [ + 999.0, + 999.0, + 4.0, + 999.0, + 999.0, + 5.0, + 999.0, + 999.0, + 6.0, + 999.0, + 1.0, + 999.0, + 999.0, + 2.0, + 999.0, + 999.0, + 3.0, + 999.0, + 999.0 + ], "A_mat": [ [ 1.0, 2.0, 3.0 ], [ 4.0, 5.0, 6.0 ] ], - "strideA1": -14, - "strideA2": 2, - "offsetA": 15, - "A_out": [ 0.0, 6.0, 0.0, 9.0, 0.0, 12.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0, 0.0, 4.0, 0.0, 6.0, 0.0 ] + "strideA1": -8, + "strideA2": 3, + "offsetA": 10, + "A_out": [ + 999.0, + 999.0, + 6.0, + 999.0, + 999.0, + 9.0, + 999.0, + 999.0, + 12.0, + 999.0, + 2.0, + 999.0, + 999.0, + 4.0, + 999.0, + 999.0, + 6.0, + 999.0, + 999.0 + ] } diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1n_sa2n.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1n_sa2n.json index cd9014c634bf..e989a4189495 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1n_sa2n.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1n_sa2n.json @@ -1,4 +1,5 @@ { + "order": "row-major", "M": 2, "N": 3, "alpha": 1.0, @@ -8,13 +9,49 @@ "y": [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ], "strideY": 2, "offsetY": 0, - "A": [ 0.0, 6.0, 0.0, 5.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3.0, 0.0, 2.0, 0.0, 1.0, 0.0 ], + "A": [ + 999.0, + 999.0, + 6.0, + 999.0, + 5.0, + 999.0, + 4.0, + 999.0, + 999.0, + 999.0, + 3.0, + 999.0, + 2.0, + 999.0, + 1.0, + 999.0, + 999.0 + ], "A_mat": [ [ 1.0, 2.0, 3.0 ], [ 4.0, 5.0, 6.0 ] ], - "strideA1": -14, + "strideA1": -8, "strideA2": -2, - "offsetA": 19, - "A_out": [ 0.0, 12.0, 0.0, 9.0, 0.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 6.0, 0.0, 4.0, 0.0, 2.0, 0.0 ] + "offsetA": 14, + "A_out": [ + 999.0, + 999.0, + 12.0, + 999.0, + 9.0, + 999.0, + 6.0, + 999.0, + 999.0, + 999.0, + 6.0, + 999.0, + 4.0, + 999.0, + 2.0, + 999.0, + 999.0 + ] } diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_x_zeros.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_x_zeros.json new file mode 100644 index 000000000000..e677e3e2b655 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_x_zeros.json @@ -0,0 +1,22 @@ +{ + "order": "row-major", + "M": 2, + "N": 3, + "alpha": 1.0, + "x": [ 0.0, 0.0 ], + "strideX": 1, + "offsetX": 0, + "y": [ 1.0, 1.0, 1.0 ], + "strideY": 1, + "offsetY": 0, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "A_mat": [ + [ 1.0, 2.0, 3.0 ], + [ 4.0, 5.0, 6.0 ] + ], + "lda": 3, + "strideA1": 3, + "strideA2": 1, + "offsetA": 0, + "A_out": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_y_zeros.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_y_zeros.json new file mode 100644 index 000000000000..3aadc0dd60ca --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_y_zeros.json @@ -0,0 +1,22 @@ +{ + "order": "row-major", + "M": 2, + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 1.0 ], + "strideX": 1, + "offsetX": 0, + "y": [ 0.0, 0.0, 0.0 ], + "strideY": 1, + "offsetY": 0, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "A_mat": [ + [ 1.0, 2.0, 3.0 ], + [ 4.0, 5.0, 6.0 ] + ], + "lda": 3, + "strideA1": 3, + "strideA2": 1, + "offsetA": 0, + "A_out": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/sger/test/test.ndarray.js index 03b28854c841..9a1e063efa32 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/sger/test/test.ndarray.js @@ -31,6 +31,8 @@ var sger = require( './../lib/ndarray.js' ); var cm = require( './fixtures/column_major.json' ); var coa = require( './fixtures/column_major_oa.json' ); +var cox = require( './fixtures/column_major_ox.json' ); +var coy = require( './fixtures/column_major_oy.json' ); var cxpyp = require( './fixtures/column_major_xpyp.json' ); var cxnyp = require( './fixtures/column_major_xnyp.json' ); var cxpyn = require( './fixtures/column_major_xpyn.json' ); @@ -40,9 +42,13 @@ var csa1nsa2 = require( './fixtures/column_major_sa1n_sa2.json' ); var csa1sa2n = require( './fixtures/column_major_sa1_sa2n.json' ); var csa1nsa2n = require( './fixtures/column_major_sa1n_sa2n.json' ); var ccap = require( './fixtures/column_major_complex_access_pattern.json' ); +var cx0 = require( './fixtures/column_major_x_zeros.json' ); +var cy0 = require( './fixtures/column_major_y_zeros.json' ); var rm = require( './fixtures/row_major.json' ); var roa = require( './fixtures/row_major_oa.json' ); +var rox = require( './fixtures/row_major_ox.json' ); +var roy = require( './fixtures/row_major_oy.json' ); var rxpyp = require( './fixtures/row_major_xpyp.json' ); var rxnyp = require( './fixtures/row_major_xnyp.json' ); var rxpyn = require( './fixtures/row_major_xpyn.json' ); @@ -52,6 +58,8 @@ var rsa1nsa2 = require( './fixtures/row_major_sa1n_sa2.json' ); var rsa1sa2n = require( './fixtures/row_major_sa1_sa2n.json' ); var rsa1nsa2n = require( './fixtures/row_major_sa1n_sa2n.json' ); var rcap = require( './fixtures/row_major_complex_access_pattern.json' ); +var rx0 = require( './fixtures/row_major_x_zeros.json' ); +var ry0 = require( './fixtures/row_major_y_zeros.json' ); // TESTS // @@ -343,6 +351,94 @@ tape( 'if `α` is `0.0`, the function returns the input matrix unchanged (column t.end(); }); +tape( 'if `x` contains only zeros, the function returns the input matrix unchanged (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rx0; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if `x` contains only zeros, the function returns the input matrix unchanged (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cx0; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if `y` contains only zeros, the function returns the input matrix unchanged (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = ry0; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if `y` contains only zeros, the function returns the input matrix unchanged (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cy0; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + tape( 'the function supports specifying the strides of the first and second dimensions of `A` (row-major)', function test( t ) { var expected; var data; @@ -739,6 +835,94 @@ tape( 'the function supports specifying negative strides for `x` and `y` (column t.end(); }); +tape( 'the function supports specifying an offset parameter for `x` (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rox; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying an offset parameter for `x` (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cox; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying an offset parameter for `y` (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = roy; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying an offset parameter for `y` (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = coy; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + tape( 'the function supports complex access patterns (row-major)', function test( t ) { var expected; var data; diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/test.sger.js b/lib/node_modules/@stdlib/blas/base/sger/test/test.sger.js index ad8d60db4730..04b1eba25a47 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/test.sger.js +++ b/lib/node_modules/@stdlib/blas/base/sger/test/test.sger.js @@ -34,12 +34,16 @@ var cxpyp = require( './fixtures/column_major_xpyp.json' ); var cxnyp = require( './fixtures/column_major_xnyp.json' ); var cxpyn = require( './fixtures/column_major_xpyn.json' ); var cxnyn = require( './fixtures/column_major_xnyn.json' ); +var cx0 = require( './fixtures/column_major_x_zeros.json' ); +var cy0 = require( './fixtures/column_major_y_zeros.json' ); var rm = require( './fixtures/row_major.json' ); var rxpyp = require( './fixtures/row_major_xpyp.json' ); var rxnyp = require( './fixtures/row_major_xnyp.json' ); var rxpyn = require( './fixtures/row_major_xpyn.json' ); var rxnyn = require( './fixtures/row_major_xnyn.json' ); +var rx0 = require( './fixtures/row_major_x_zeros.json' ); +var ry0 = require( './fixtures/row_major_y_zeros.json' ); // TESTS // @@ -185,7 +189,11 @@ tape( 'the function throws an error if provided an invalid tenth argument', func data = rm; values = [ - 0 + -3, + -2, + -1, + 0, + 1 ]; for ( i = 0; i < values.length; i++ ) { @@ -380,6 +388,94 @@ tape( 'if `α` is `0.0`, the function returns the input matrix unchanged (column t.end(); }); +tape( 'if `x` contains only zeros, the function returns the input matrix unchanged (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rx0; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if `x` contains only zeros, the function returns the input matrix unchanged (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cx0; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if `y` contains only zeros, the function returns the input matrix unchanged (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = ry0; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if `y` contains only zeros, the function returns the input matrix unchanged (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cy0; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + tape( 'the function supports specifying `x` and `y` strides (row-major)', function test( t ) { var expected; var data; From 97e96e0062a901c4d033d0c0494f46e1d5fbdc8c Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Fri, 27 Jun 2025 11:40:27 +0530 Subject: [PATCH 12/24] chore: clean-up --- 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 status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../sger/test/fixtures/column_major_complex_access_pattern.json | 1 + .../@stdlib/blas/base/sger/test/fixtures/column_major_oa.json | 1 + .../blas/base/sger/test/fixtures/column_major_sa1_sa2.json | 1 + .../blas/base/sger/test/fixtures/column_major_sa1_sa2n.json | 1 + .../blas/base/sger/test/fixtures/column_major_sa1n_sa2.json | 1 + .../blas/base/sger/test/fixtures/column_major_sa1n_sa2n.json | 1 + .../sger/test/fixtures/row_major_complex_access_pattern.json | 1 + .../@stdlib/blas/base/sger/test/fixtures/row_major_oa.json | 1 + .../@stdlib/blas/base/sger/test/fixtures/row_major_sa1_sa2.json | 1 + .../@stdlib/blas/base/sger/test/fixtures/row_major_sa1_sa2n.json | 1 + .../@stdlib/blas/base/sger/test/fixtures/row_major_sa1n_sa2.json | 1 + .../blas/base/sger/test/fixtures/row_major_sa1n_sa2n.json | 1 + 12 files changed, 12 insertions(+) diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_complex_access_pattern.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_complex_access_pattern.json index 220746be33c5..c0b1f7e659f3 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_complex_access_pattern.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_complex_access_pattern.json @@ -14,6 +14,7 @@ [ 1.0, 2.0, 3.0 ], [ 4.0, 5.0, 6.0 ] ], + "lda": 8, "strideA1": -2, "strideA2": -8, "offsetA": 22, diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_oa.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_oa.json index fd257c7fba48..0573891b4f3f 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_oa.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_oa.json @@ -14,6 +14,7 @@ [ 1.0, 2.0, 3.0 ], [ 4.0, 5.0, 6.0 ] ], + "lda": 2, "strideA1": 1, "strideA2": 2, "offsetA": 1, diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1_sa2.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1_sa2.json index 702e051e70b9..fd11aac2b0e8 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1_sa2.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1_sa2.json @@ -14,6 +14,7 @@ [ 1.0, 2.0, 3.0 ], [ 4.0, 5.0, 6.0 ] ], + "lda": 8, "strideA1": 2, "strideA2": 8, "offsetA": 4, diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1_sa2n.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1_sa2n.json index f6b6b56f07a6..badbf19f9653 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1_sa2n.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1_sa2n.json @@ -14,6 +14,7 @@ [ 1.0, 2.0, 3.0 ], [ 4.0, 5.0, 6.0 ] ], + "lda": 8, "strideA1": 2, "strideA2": -8, "offsetA": 20, diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1n_sa2.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1n_sa2.json index a4df499c44c5..ad6e61f2bcd2 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1n_sa2.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1n_sa2.json @@ -14,6 +14,7 @@ [ 1.0, 2.0, 3.0 ], [ 4.0, 5.0, 6.0 ] ], + "lda": 8, "strideA1": -2, "strideA2": 8, "offsetA": 6, diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1n_sa2n.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1n_sa2n.json index 9bbdcc5d25ff..257125bbd7eb 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1n_sa2n.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/column_major_sa1n_sa2n.json @@ -14,6 +14,7 @@ [ 1.0, 2.0, 3.0 ], [ 4.0, 5.0, 6.0 ] ], + "lda": 8, "strideA1": -2, "strideA2": -8, "offsetA": 22, diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_complex_access_pattern.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_complex_access_pattern.json index 545a9ac46edc..ba6c3ccb1a16 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_complex_access_pattern.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_complex_access_pattern.json @@ -14,6 +14,7 @@ [ 1.0, 2.0, 3.0 ], [ 4.0, 5.0, 6.0 ] ], + "lda": 14, "strideA1": -14, "strideA2": -2, "offsetA": 19, diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_oa.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_oa.json index e85a1ca258c6..cbc5b922d87e 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_oa.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_oa.json @@ -14,6 +14,7 @@ [ 1.0, 2.0, 3.0 ], [ 4.0, 5.0, 6.0 ] ], + "lda": 3, "strideA1": 3, "strideA2": 1, "offsetA": 1, diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1_sa2.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1_sa2.json index 37ad4b28b117..5ce43bf277a8 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1_sa2.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1_sa2.json @@ -32,6 +32,7 @@ [ 1.0, 2.0, 3.0 ], [ 4.0, 5.0, 6.0 ] ], + "lda": 8, "strideA1": 8, "strideA2": -2, "offsetA": 6, diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1_sa2n.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1_sa2n.json index 37ad4b28b117..5ce43bf277a8 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1_sa2n.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1_sa2n.json @@ -32,6 +32,7 @@ [ 1.0, 2.0, 3.0 ], [ 4.0, 5.0, 6.0 ] ], + "lda": 8, "strideA1": 8, "strideA2": -2, "offsetA": 6, diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1n_sa2.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1n_sa2.json index 5feaa8e8f17b..2b6d599795cd 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1n_sa2.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1n_sa2.json @@ -34,6 +34,7 @@ [ 1.0, 2.0, 3.0 ], [ 4.0, 5.0, 6.0 ] ], + "lda": 8, "strideA1": -8, "strideA2": 3, "offsetA": 10, diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1n_sa2n.json b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1n_sa2n.json index e989a4189495..f7cb88d30017 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1n_sa2n.json +++ b/lib/node_modules/@stdlib/blas/base/sger/test/fixtures/row_major_sa1n_sa2n.json @@ -32,6 +32,7 @@ [ 1.0, 2.0, 3.0 ], [ 4.0, 5.0, 6.0 ] ], + "lda": 8, "strideA1": -8, "strideA2": -2, "offsetA": 14, From 2a95115e48a0014057fb9bda1209d2393c41cb37 Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Fri, 27 Jun 2025 06:48:10 +0000 Subject: [PATCH 13/24] chore: update copyright years --- lib/node_modules/@stdlib/blas/base/sger/lib/ndarray.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/sger/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/sger/lib/ndarray.js index 5a57f104bba4..f4f1f1fa9b73 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/sger/lib/ndarray.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* 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. From cf7f5a3df2b03ce9ddeb2cda20e1b0c702867b03 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Tue, 1 Jul 2025 13:24:17 +0530 Subject: [PATCH 14/24] chore: add fortran and c implementation --- 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 status: passed - 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: na - 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: missing_dependencies - task: lint_c_examples status: missing_dependencies - task: lint_c_benchmarks status: missing_dependencies - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/blas/base/sger/README.md | 154 ++- .../base/sger/benchmark/benchmark.native.js | 110 ++ .../benchmark/benchmark.ndarray.native.js | 110 ++ .../blas/base/sger/benchmark/c/Makefile | 146 +++ .../base/sger/benchmark/c/benchmark.length.c | 206 ++++ .../blas/base/sger/benchmark/fortran/Makefile | 141 +++ .../sger/benchmark/fortran/benchmark.length.f | 217 ++++ .../@stdlib/blas/base/sger/binding.gyp | 265 +++++ .../@stdlib/blas/base/sger/docs/repl.txt | 31 +- .../blas/base/sger/docs/types/index.d.ts | 6 +- .../blas/base/sger/examples/c/example.c | 61 ++ .../@stdlib/blas/base/sger/include.gypi | 70 ++ .../base/sger/include/stdlib/blas/base/sger.h | 48 + .../include/stdlib/blas/base/sger_cblas.h | 43 + .../include/stdlib/blas/base/sger_fortran.h | 41 + .../@stdlib/blas/base/sger/lib/base.js | 5 +- .../@stdlib/blas/base/sger/lib/index.js | 6 +- .../@stdlib/blas/base/sger/lib/native.js | 35 + .../@stdlib/blas/base/sger/lib/ndarray.js | 2 +- .../blas/base/sger/lib/ndarray.native.js | 85 ++ .../@stdlib/blas/base/sger/lib/sger.js | 14 +- .../@stdlib/blas/base/sger/lib/sger.native.js | 100 ++ .../@stdlib/blas/base/sger/manifest.json | 485 +++++++++ .../@stdlib/blas/base/sger/package.json | 4 + .../@stdlib/blas/base/sger/src/Makefile | 70 ++ .../@stdlib/blas/base/sger/src/addon.c | 97 ++ .../@stdlib/blas/base/sger/src/sger.c | 97 ++ .../@stdlib/blas/base/sger/src/sger.f | 148 +++ .../@stdlib/blas/base/sger/src/sger_cblas.c | 39 + .../@stdlib/blas/base/sger/src/sger_f.c | 55 + .../@stdlib/blas/base/sger/src/sger_ndarray.c | 199 ++++ .../base/sger/test/test.ndarray.native.js | 977 ++++++++++++++++++ .../blas/base/sger/test/test.sger.native.js | 662 ++++++++++++ 33 files changed, 4679 insertions(+), 50 deletions(-) create mode 100644 lib/node_modules/@stdlib/blas/base/sger/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/sger/benchmark/benchmark.ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/sger/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/sger/benchmark/c/benchmark.length.c create mode 100644 lib/node_modules/@stdlib/blas/base/sger/benchmark/fortran/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/sger/benchmark/fortran/benchmark.length.f create mode 100644 lib/node_modules/@stdlib/blas/base/sger/binding.gyp create mode 100644 lib/node_modules/@stdlib/blas/base/sger/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/blas/base/sger/include.gypi create mode 100644 lib/node_modules/@stdlib/blas/base/sger/include/stdlib/blas/base/sger.h create mode 100644 lib/node_modules/@stdlib/blas/base/sger/include/stdlib/blas/base/sger_cblas.h create mode 100644 lib/node_modules/@stdlib/blas/base/sger/include/stdlib/blas/base/sger_fortran.h create mode 100644 lib/node_modules/@stdlib/blas/base/sger/lib/native.js create mode 100644 lib/node_modules/@stdlib/blas/base/sger/lib/ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/sger/lib/sger.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/sger/manifest.json create mode 100644 lib/node_modules/@stdlib/blas/base/sger/src/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/sger/src/addon.c create mode 100644 lib/node_modules/@stdlib/blas/base/sger/src/sger.c create mode 100644 lib/node_modules/@stdlib/blas/base/sger/src/sger.f create mode 100644 lib/node_modules/@stdlib/blas/base/sger/src/sger_cblas.c create mode 100644 lib/node_modules/@stdlib/blas/base/sger/src/sger_f.c create mode 100644 lib/node_modules/@stdlib/blas/base/sger/src/sger_ndarray.c create mode 100644 lib/node_modules/@stdlib/blas/base/sger/test/test.ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/sger/test/test.sger.native.js diff --git a/lib/node_modules/@stdlib/blas/base/sger/README.md b/lib/node_modules/@stdlib/blas/base/sger/README.md index c167b1a26b31..7e61bae4277e 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/README.md +++ b/lib/node_modules/@stdlib/blas/base/sger/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2025 The Stdlib Authors. +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. @@ -22,7 +22,13 @@ limitations under the License. > Perform the rank 1 operation `A = α*x*y^T + A`. -
+
+ +
+ + + +
## Usage @@ -30,9 +36,9 @@ limitations under the License. var sger = require( '@stdlib/blas/base/sger' ); ``` -#### sger( ord, M, N, α, x, sx, y, sy, A, lda ) +#### sger( order, M, N, α, x, sx, y, sy, A, lda ) -Performs the rank 1 operation `A = α*x*y^T + A`, where `α` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector and `A` is an `M` by `N` matrix. +Performs the rank 1 operation `A = α*x*y^T + A`, where `α` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector, and `A` is an `M` by `N` matrix. ```javascript var Float32Array = require( '@stdlib/array/float32' ); @@ -47,18 +53,18 @@ sger( 'row-major', 2, 3, 1.0, x, 1, y, 1, A, 3 ); The function has the following parameters: -- **ord**: storage layout. +- **order**: storage layout. - **M**: number of rows in the matrix `A`. - **N**: number of columns in the matrix `A`. - **α**: scalar constant. - **x**: input [`Float32Array`][mdn-float32array]. -- **sx**: index increment for `x`. +- **sx**: stride length for `x`. - **y**: output [`Float32Array`][mdn-float32array]. -- **sy**: index increment for `y`. +- **sy**: stride length for `y`. - **A**: input matrix stored in linear memory as a [`Float32Array`][mdn-float32array]. - **lda**: stride of the first dimension of `A` (leading dimension of `A`). -The stride parameters determine how operations are performed. For example, to iterate over every other element in `x` and `y`, +The stride parameters determine which elements in the strided arrays are accessed at runtime. For example, to iterate over every other element in `x` and `y`, ```javascript var Float32Array = require( '@stdlib/array/float32' ); @@ -93,7 +99,7 @@ sger( 'column-major', 2, 3, 1.0, x1, -1, y1, -1, A, 2 ); #### sger.ndarray( M, N, α, x, sx, ox, y, sy, oy, A, sa1, sa2, oa ) -Performs the rank 1 operation `A = α*x*y^T + A`, using alternative indexing semantics and where `α` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector and `A` is an `M` by `N` matrix. +Performs the rank 1 operation `A = α*x*y^T + A`, using alternative indexing semantics and where `α` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector, and `A` is an `M` by `N` matrix. ```javascript var Float32Array = require( '@stdlib/array/float32' ); @@ -119,12 +125,12 @@ While [`typed array`][mdn-typed-array] views mandate a view offset based on the ```javascript var Float32Array = require( '@stdlib/array/float32' ); -var A = new Float32Array( [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] ); -var x = new Float32Array( [ 1.0, 0.0, 1.0, 0.0 ] ); -var y = new Float32Array( [ 1.0, 0.0, 1.0, 0.0, 1.0, 0.0 ] ); +var A = new Float32Array( [ 0.0, 0.0, 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] ); +var x = new Float32Array( [ 0.0, 1.0, 0.0, 1.0, 0.0 ] ); +var y = new Float32Array( [ 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0 ] ); -sger.ndarray( 2, 3, 1.0, x, 2, 0, y, 2, 0, A, 1, 2, 0 ); -// A => [ 2.0, 5.0, 3.0, 6.0, 4.0, 7.0 ] +sger.ndarray( 2, 3, 1.0, x, 2, 1, y, 2, 1, A, 1, 2, 2 ); +// A => [ 0.0, 0.0, 2.0, 5.0, 3.0, 6.0, 4.0, 7.0 ] ```
@@ -166,7 +172,7 @@ sger( 'row-major', M, N, 1.0, x, 1, y, 1, A, N ); console.log( A ); sger.ndarray( M, N, 1.0, x, 1, 0, y, 1, 0, A, 1, M, 0 ); -console.log(A); +console.log( A ); ``` @@ -200,18 +206,80 @@ console.log(A); #include "stdlib/blas/base/sger.h" ``` -#### TODO +#### c_sger( layout, M, N, alpha, \*X, strideX, \*Y, strideY, \*A, LDA ) -TODO. +Performs the rank 1 operation `A = alpha*x*y^T + A`, where `alpha` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector, and `A` is an `M`-by-`N` matrix. ```c -TODO +#include "stdlib/blas/base/shared.h" + +float A[ 3*4 ] = { + 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0 +}; + +const float x[ 3 ] = { 1.0, 4.0, 0.0 }; +const float y[ 4 ] = { 0.0, 1.0, 2.0, 3.0 }; + +c_sger( CblasRowMajor, 3, 4, 1.0, x, 1, y, 1, A, 4 ); ``` -TODO +The function accepts the following arguments: + +- **layout**: `[in] CBLAS_LAYOUT` storage layout. +- **M**: `[in] CBLAS_INT` number of rows in the matrix `A`. +- **N**: `[in] CBLAS_INT` number of columns in the matrix `A`. +- **alpha**: `[in] float` scalar constant. +- **X**: `[in] float*` an `M` element vector. +- **strideX**: `[in] CBLAS_INT` stride length for `X`. +- **Y**: `[in] float*` an `N` element vector. +- **strideY**: `[in] CBLAS_INT` stride length for `Y`. +- **A**: `[inout] float*` input matrix. +- **LDA**: `[in] CBLAS_INT` stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). ```c -TODO +void c_sger( const CBLAS_LAYOUT layout, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *X, const CBLAS_INT strideX, const float *Y, const CBLAS_INT strideY, float *A, const CBLAS_INT LDA ); +``` + +#### c_sger_ndarray( M, N, alpha, \*X, sx, ox, \*Y, sy, oy, \*A, sa1, sa2, oa ) + +Performs the rank 1 operation `A = alpha*x*y^T + A`, using alternative indexing semantics and where `alpha` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector, and `A` is an `M`-by-`N` matrix. + +```c +#include "stdlib/blas/base/shared.h" + +float A[ 3*4 ] = { + 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0 +}; + +const float x[ 3 ] = { 1.0, 4.0, 0.0 }; +const float y[ 4 ] = { 0.0, 1.0, 2.0, 3.0 }; + +c_sger_ndarray( 3, 4, 1.0, x, 1, 0, y, 1, 0, A, 4, 1, 0 ); +``` + +The function accepts the following arguments: + +- **layout**: `[in] CBLAS_LAYOUT` storage layout. +- **M**: `[in] CBLAS_INT` number of rows in the matrix `A`. +- **N**: `[in] CBLAS_INT` number of columns in the matrix `A`. +- **alpha**: `[in] float` scalar constant. +- **X**: `[in] float*` an `M` element vector. +- **sx**: `[in] CBLAS_INT` stride length for `X`. +- **ox**: `[in] CBLAS_INT` starting index for `X`. +- **Y**: `[in] float*` an `N` element vector. +- **sy**: `[in] CBLAS_INT` stride length for `Y`. +- **oy**: `[in] CBLAS_INT` starting index for `Y`. +- **A**: `[inout] float*` input matrix. +- **sa1**: `[in] CBLAS_INT` stride of the first dimension of `A`. +- **sa2**: `[in] CBLAS_INT` stride of the second dimension of `A`. +- **oa**: `[in] CBLAS_INT` starting index for `A`. + +```c +void c_sger( onst CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const float *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, float *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA ); ```
@@ -233,7 +301,49 @@ TODO ### Examples ```c -TODO +#include "stdlib/blas/base/sger.h" +#include "stdlib/blas/base/shared.h" +#include + +int main( void ) { + // Define a 3x4 matrix stored in row-major order: + float A[ 3*4 ] = { + 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0 + }; + // Define `x` and `y^T` vectors: + const float x[ 3 ] = { 1.0, 4.0, 0.0 }; // M + const float y[ 4 ] = { 0.0, 1.0, 2.0, 3.0 }; // N + + // Specify the number of rows and columns: + const int M = 3; + const int N = 4; + + // Specify stride lengths: + const int strideX = 1; + const int strideY = 1; + + // Perform operation: + c_sger( CblasRowMajor, M, N, 1.0, x, strideX, y, strideY, A, N ); + + // Print the result: + for ( int i = 0; i < M; i++ ) { + for ( int j = 0; j < N; j++ ) { + printf( "A[%i,%i] = %f\n", i, j, A[ (i*N)+j ] ); + } + } + + // Perform operation using alterntive indexing semantics: + c_sger( CblasRowMajor, M, N, 1.0, x, strideX, 0, y, 0, strideY, A, N, 1, 0 ); + + // Print the result: + for ( int i = 0; i < M; i++ ) { + for ( int j = 0; j < N; j++ ) { + printf( "A[%i,%i] = %f\n", i, j, A[ (i*N)+j ] ); + } + } +} ``` @@ -258,7 +368,7 @@ TODO [blas]: http://www.netlib.org/blas -[blas-sger]: https://www.netlib.org/lapack/explore-html/d8/d75/group__ger_ga95baec6bb0a84393d7bc67212b566ab0.html#ga95baec6bb0a84393d7bc67212b566ab0 +[blas-sger]: https://www.netlib.org/lapack/explore-html/d8/d75/group__ger_ga95baec6bb0a84393d7bc67212b566ab0.html [mdn-float32array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array diff --git a/lib/node_modules/@stdlib/blas/base/sger/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/base/sger/benchmark/benchmark.native.js new file mode 100644 index 000000000000..243b4e5ab863 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/benchmark/benchmark.native.js @@ -0,0 +1,110 @@ +/** +* @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'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var sger = tryRequire( resolve( __dirname, './../lib/sger.native.js' ) ); +var opts = { + 'skip': ( sger instanceof Error ) +}; +var options = { + 'dtype': 'float32' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - array dimension size +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var x = uniform( N, -10.0, 10.0, options ); + var y = uniform( N, -10.0, 10.0, options ); + var A = uniform( N*N, -10.0, 10.0, 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 = sger( 'row-major', N, N, 1.0, x, 1, y, 1, A, N ); + if ( isnanf( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( z[ i%z.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 = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( len ); + bench( pkg+'::native:size='+(len*len), opts, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/sger/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/sger/benchmark/benchmark.ndarray.native.js new file mode 100644 index 000000000000..4ef80279226f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/benchmark/benchmark.ndarray.native.js @@ -0,0 +1,110 @@ +/** +* @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'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var sger = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( sger instanceof Error ) +}; +var options = { + 'dtype': 'float32' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - array dimension size +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var x = uniform( N, -10.0, 10.0, options ); + var y = uniform( N, -10.0, 10.0, options ); + var A = uniform( N*N, -10.0, 10.0, 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 = sger( N, N, 1.0, x, 1, 0, y, 1, 0, A, N, 1, 0 ); + if ( isnanf( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( z[ i%z.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 = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( len ); + bench( pkg+'::native:ndarray:size='+(len*len), opts, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/sger/benchmark/c/Makefile b/lib/node_modules/@stdlib/blas/base/sger/benchmark/c/Makefile new file mode 100644 index 000000000000..cce2c865d7ad --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/benchmark/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := benchmark.length.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/blas/base/sger/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/sger/benchmark/c/benchmark.length.c new file mode 100644 index 000000000000..2a439460f7d4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/benchmark/c/benchmark.length.c @@ -0,0 +1,206 @@ +/** +* @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. +*/ + +#include "stdlib/blas/base/sger.h" +#include "stdlib/blas/base/shared.h" +#include +#include +#include +#include +#include + +#define NAME "sger" +#define ITERATIONS 10000000 +#define REPEATS 3 +#define MIN 1 +#define MAX 6 + +/** +* Prints the TAP version. +*/ +static void print_version( void ) { + printf( "TAP version 13\n" ); +} + +/** +* Prints the TAP summary. +* +* @param total total number of tests +* @param passing total number of passing tests +*/ +static void print_summary( int total, int passing ) { + printf( "#\n" ); + printf( "1..%d\n", total ); // TAP plan + printf( "# total %d\n", total ); + printf( "# pass %d\n", passing ); + printf( "#\n" ); + printf( "# ok\n" ); +} + +/** +* Prints benchmarks results. +* +* @param iterations number of iterations +* @param elapsed elapsed time in seconds +*/ +static void print_results( int iterations, double elapsed ) { + double rate = (double)iterations / elapsed; + printf( " ---\n" ); + printf( " iterations: %d\n", iterations ); + printf( " elapsed: %0.9f\n", elapsed ); + printf( " rate: %0.9f\n", rate ); + printf( " ...\n" ); +} + +/** +* Returns a clock time. +* +* @return clock time +*/ +static double tic( void ) { + struct timeval now; + gettimeofday( &now, NULL ); + return (double)now.tv_sec + (double)now.tv_usec/1.0e6; +} + +/** +* Generates a random number on the interval [0,1). +* +* @return random number +*/ +static float rand_float( void ) { + int r = rand(); + return (float)r / ( (float)RAND_MAX + 1.0f ); +} + +/** +* Runs a benchmark. +* +* @param iterations number of iterations +* @param N array dimension size +* @return elapsed time in seconds +*/ +static double benchmark1( int iterations, int N ) { + double elapsed; + float A[ N*N ]; + float x[ N ]; + float y[ N ]; + double t; + int i; + int j; + + for ( i = 0, j = 0; i < N; i++, j += 2 ) { + x[ i ] = ( rand_float()*20.0f ) - 10.0f; + y[ i ] = ( rand_float()*20.0f ) - 10.0f; + A[ j ] = ( rand_float()*20.0f ) - 10.0f; + A[ j+1 ] = ( rand_float()*20.0f ) - 10.0f; + } + t = tic(); + for ( i = 0; i < iterations; i++ ) { + // cppcheck-suppress uninitvar + c_sger( CblasRowMajor, N, N, 1.0f, x, 1, y, 1, A, N ); + if ( A[ i%(N*2) ] != A[ i%(N*2) ] ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( A[ i%(N*2) ] != A[ i%(N*2) ] ) { + printf( "should not return NaN\n" ); + } + return elapsed; +} + +/** +* Runs a benchmark. +* +* @param iterations number of iterations +* @param N array dimension size +* @return elapsed time in seconds +*/ +static double benchmark2( int iterations, int N ) { + double elapsed; + float A[ N*N ]; + float x[ N ]; + float y[ N ]; + double t; + int i; + int j; + + for ( i = 0, j = 0; i < N; i++, j += 2 ) { + x[ i ] = ( rand_float()*20.0f ) - 10.0f; + y[ i ] = ( rand_float()*20.0f ) - 10.0f; + A[ j ] = ( rand_float()*20.0f ) - 10.0f; + A[ j+1 ] = ( rand_float()*20.0f ) - 10.0f; + } + t = tic(); + for ( i = 0; i < iterations; i++ ) { + // cppcheck-suppress uninitvar + c_sger_ndarray( N, N, 1.0f, x, 1, 0, y, 1, 0, A, N, 1, 0 ); + if ( A[ i%(N*2) ] != A[ i%(N*2) ] ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( A[ i%(N*2) ] != A[ i%(N*2) ] ) { + printf( "should not return NaN\n" ); + } + return elapsed; +} + +/** +* Main execution sequence. +*/ +int main( void ) { + double elapsed; + int count; + int iter; + int N; + int i; + int j; + + // Use the current time to seed the random number generator: + srand( time( NULL ) ); + + print_version(); + count = 0; + for ( i = MIN; i <= MAX; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + iter = ITERATIONS / pow( 10, i-1 ); + for ( j = 0; j < REPEATS; j++ ) { + count += 1; + printf( "# c::%s:size=%d\n", NAME, N*N ); + elapsed = benchmark1( iter, N ); + print_results( iter, elapsed ); + printf( "ok %d benchmark finished\n", count ); + } + } + for ( i = MIN; i <= MAX; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + iter = ITERATIONS / pow( 10, i-1 ); + for ( j = 0; j < REPEATS; j++ ) { + count += 1; + printf( "# c::%s:ndarray:size=%d\n", NAME, N*N ); + elapsed = benchmark2( iter, N ); + print_results( iter, elapsed ); + printf( "ok %d benchmark finished\n", count ); + } + } + print_summary( count, count ); +} diff --git a/lib/node_modules/@stdlib/blas/base/sger/benchmark/fortran/Makefile b/lib/node_modules/@stdlib/blas/base/sger/benchmark/fortran/Makefile new file mode 100644 index 000000000000..e66ba947e450 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/benchmark/fortran/Makefile @@ -0,0 +1,141 @@ +#/ +# @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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling Fortran source files: +ifdef FORTRAN_COMPILER + FC := $(FORTRAN_COMPILER) +else + FC := gfortran +endif + +# Define the command-line options when compiling Fortran files: +FFLAGS ?= \ + -std=f95 \ + -ffree-form \ + -O3 \ + -Wall \ + -Wextra \ + -Wno-compare-reals \ + -Wimplicit-interface \ + -fno-underscoring \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop`): +INCLUDE ?= + +# List of Fortran source files: +SOURCE_FILES ?= ../../src/sger.f + +# List of Fortran targets: +f_targets := benchmark.length.out + + +# RULES # + +#/ +# Compiles Fortran source files. +# +# @param {string} SOURCE_FILES - list of Fortran source files +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) +# @param {string} [FORTRAN_COMPILER] - Fortran compiler +# @param {string} [FFLAGS] - Fortran compiler flags +# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code +# +# @example +# make +# +# @example +# make all +#/ +all: $(f_targets) + +.PHONY: all + +#/ +# Compiles Fortran source files. +# +# @private +# @param {string} SOURCE_FILES - list of Fortran source files +# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) +# @param {string} FC - Fortran compiler +# @param {string} FFLAGS - Fortran compiler flags +# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code +#/ +$(f_targets): %.out: %.f + $(QUIET) $(FC) $(FFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(f_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/blas/base/sger/benchmark/fortran/benchmark.length.f b/lib/node_modules/@stdlib/blas/base/sger/benchmark/fortran/benchmark.length.f new file mode 100644 index 000000000000..6eb0d9bf5b7d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/benchmark/fortran/benchmark.length.f @@ -0,0 +1,217 @@ +!> +! @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. +!< + +program bench + implicit none + ! .. + ! Local constants: + character(4), parameter :: name = 'sger' ! if changed, be sure to adjust length + integer, parameter :: iterations = 1000000 + integer, parameter :: repeats = 3 + integer, parameter :: min = 1 + integer, parameter :: max = 6 + ! .. + ! Run the benchmarks: + call main() + ! .. + ! Functions: +contains + ! .. + ! Prints the TAP version. + ! .. + subroutine print_version() + print '(A)', 'TAP version 13' + end subroutine print_version + ! .. + ! Prints the TAP summary. + ! + ! @param {integer} total - total number of tests + ! @param {integer} passing - total number of passing tests + ! .. + subroutine print_summary( total, passing ) + ! .. + ! Scalar arguments: + integer, intent(in) :: total, passing + ! .. + ! Local variables: + character(len=999) :: str, tmp + ! .. + ! Intrinsic functions: + intrinsic adjustl, trim + ! .. + print '(A)', '#' + ! .. + write (str, '(I15)') total ! TAP plan + tmp = adjustl( str ) + print '(A,A)', '1..', trim( tmp ) + ! .. + print '(A,A)', '# total ', trim( tmp ) + ! .. + write (str, '(I15)') passing + tmp = adjustl( str ) + print '(A,A)', '# pass ', trim( tmp ) + ! .. + print '(A)', '#' + print '(A)', '# ok' + end subroutine print_summary + ! .. + ! Prints benchmarks results. + ! + ! @param {integer} iterations - number of iterations + ! @param {double} elapsed - elapsed time in seconds + ! .. + subroutine print_results( iterations, elapsed ) + ! .. + ! Scalar arguments: + double precision, intent(in) :: elapsed + integer, intent(in) :: iterations + ! .. + ! Local variables: + double precision :: rate + character(len=999) :: str, tmp + ! .. + ! Intrinsic functions: + intrinsic dble, adjustl, trim + ! .. + rate = dble( iterations ) / elapsed + ! .. + print '(A)', ' ---' + ! .. + write (str, '(I15)') iterations + tmp = adjustl( str ) + print '(A,A)', ' iterations: ', trim( tmp ) + ! .. + write (str, '(f100.9)') elapsed + tmp = adjustl( str ) + print '(A,A)', ' elapsed: ', trim( tmp ) + ! .. + write( str, '(f100.9)') rate + tmp = adjustl( str ) + print '(A,A)', ' rate: ', trim( tmp ) + ! .. + print '(A)', ' ...' + end subroutine print_results + ! .. + ! Runs a benchmark. + ! + ! @param {integer} iterations - number of iterations + ! @param {integer} N - array dimension size + ! @return {double} elapsed time in seconds + ! .. + double precision function benchmark( iterations, N ) + ! .. + ! External functions: + interface + subroutine sger( M, N, alpha, X, strideX, Y, strideY, A, LDA ) + integer :: strideX, strideY, LDA, M, N + single precision :: X(*), Y(*), A(LDA, *) + single precision :: alpha + end subroutine sger + end interface + ! .. + ! Scalar arguments: + integer, intent(in) :: iterations, N + ! .. + ! Local scalars: + double precision :: elapsed, r + double precision :: t1, t2 + integer :: i, j + ! .. + ! Local arrays: + single precision, allocatable :: x(:), y(:), A(:,:) + ! .. + ! Intrinsic functions: + intrinsic random_number, cpu_time, mod + ! .. + ! Allocate arrays: + allocate( x(N), y(N), A(N,N) ) + ! .. + do i = 1, N + call random_number( r ) + x( i ) = ( r*20.0 ) - 10.0 + call random_number( r ) + y( i ) = ( r*20.0 ) - 10.0 + do j = 1, N + call random_number( r ) + A(i, j) = ( r*20.0 ) - 10.0 + end do + end do + ! .. + call cpu_time( t1 ) + ! .. + j = 1 + do i = 1, iterations + call sger( N, N, 1.0d0, x, 1, y, 1, A, N ) + j = mod( i, N ) + 1 + if ( A( j, j ) /= A( j, j ) ) then + print '(A)', 'should not return NaN' + exit + end if + end do + ! .. + call cpu_time( t2 ) + ! .. + elapsed = t2 - t1 + ! .. + if ( A( j, j ) /= A( j, j ) ) then + print '(A)', 'should not return NaN' + end if + ! .. + ! Deallocate arrays: + deallocate( x, y, A ) + ! .. + benchmark = elapsed + return + end function benchmark + ! .. + ! Main execution sequence. + ! .. + subroutine main() + ! .. + ! Local variables: + character(len=999) :: str, tmp + double precision :: elapsed + integer :: i, j, N, count, iter + ! .. + ! Intrinsic functions: + intrinsic adjustl, trim, floor, sqrt + ! .. + call print_version() + count = 0 + do i = min, max + N = floor( ( 10**i )**(1.0/2.0) ) + iter = iterations / 10**(i-1) + do j = 1, repeats + count = count + 1 + ! .. + write (str, '(I15)') N*N + tmp = adjustl( str ) + print '(A,A,A,A)', '# fortran::', name, ':size=', trim(tmp) + ! .. + elapsed = benchmark( iter, N ) + ! .. + call print_results( iter, elapsed ) + ! .. + write (str, '(I15)') count + tmp = adjustl( str ) + print '(A,A,A)', 'ok ', trim( tmp ), ' benchmark finished' + end do + end do + call print_summary( count, count ) + end subroutine main +end program bench diff --git a/lib/node_modules/@stdlib/blas/base/sger/binding.gyp b/lib/node_modules/@stdlib/blas/base/sger/binding.gyp new file mode 100644 index 000000000000..02a2799da097 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/binding.gyp @@ -0,0 +1,265 @@ +# @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. + +# A `.gyp` file for building a Node.js native add-on. +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # List of files to include in this file: + 'includes': [ + './include.gypi', + ], + + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Target name should match the add-on export name: + 'addon_target_name%': 'addon', + + # Fortran compiler (to override -Dfortran_compiler=): + 'fortran_compiler%': 'gfortran', + + # Fortran compiler flags: + 'fflags': [ + # Specify the Fortran standard to which a program is expected to conform: + '-std=f95', + + # Indicate that the layout is free-form source code: + '-ffree-form', + + # Aggressive optimization: + '-O3', + + # Enable commonly used warning options: + '-Wall', + + # Warn if source code contains problematic language features: + '-Wextra', + + # Warn if a procedure is called without an explicit interface: + '-Wimplicit-interface', + + # Do not transform names of entities specified in Fortran source files by appending underscores (i.e., don't mangle names, thus allowing easier usage in C wrappers): + '-fno-underscoring', + + # Warn if source code contains Fortran 95 extensions and C-language constructs: + '-pedantic', + + # Compile but do not link (output is an object file): + '-c', + ], + + # Set variables based on the host OS: + 'conditions': [ + [ + 'OS=="win"', + { + # Define the object file suffix: + 'obj': 'obj', + }, + { + # Define the object file suffix: + 'obj': 'o', + } + ], # end condition (OS=="win") + ], # end conditions + }, # end variables + + # Define compile targets: + 'targets': [ + + # Target to generate an add-on: + { + # The target name should match the add-on export name: + 'target_name': '<(addon_target_name)', + + # Define dependencies: + 'dependencies': [], + + # Define directories which contain relevant include headers: + 'include_dirs': [ + # Local include directory: + '<@(include_dirs)', + ], + + # List of source files: + 'sources': [ + '<@(src_files)', + ], + + # Settings which should be applied when a target's object files are used as linker input: + 'link_settings': { + # Define libraries: + 'libraries': [ + '<@(libraries)', + ], + + # Define library directories: + 'library_dirs': [ + '<@(library_dirs)', + ], + }, + + # C/C++ compiler flags: + 'cflags': [ + # Enable commonly used warning options: + '-Wall', + + # Aggressive optimization: + '-O3', + ], + + # C specific compiler flags: + 'cflags_c': [ + # Specify the C standard to which a program is expected to conform: + '-std=c99', + ], + + # C++ specific compiler flags: + 'cflags_cpp': [ + # Specify the C++ standard to which a program is expected to conform: + '-std=c++11', + ], + + # Linker flags: + 'ldflags': [], + + # Apply conditions based on the host OS: + 'conditions': [ + [ + 'OS=="mac"', + { + # Linker flags: + 'ldflags': [ + '-undefined dynamic_lookup', + '-Wl,-no-pie', + '-Wl,-search_paths_first', + ], + }, + ], # end condition (OS=="mac") + [ + 'OS!="win"', + { + # C/C++ flags: + 'cflags': [ + # Generate platform-independent code: + '-fPIC', + ], + }, + ], # end condition (OS!="win") + ], # end conditions + + # Define custom build actions for particular inputs: + 'rules': [ + { + # Define a rule for processing Fortran files: + 'extension': 'f', + + # Define the pathnames to be used as inputs when performing processing: + 'inputs': [ + # Full path of the current input: + '<(RULE_INPUT_PATH)' + ], + + # Define the outputs produced during processing: + 'outputs': [ + # Store an output object file in a directory for placing intermediate results (only accessible within a single target): + '<(INTERMEDIATE_DIR)/<(RULE_INPUT_ROOT).<(obj)' + ], + + # Define the rule for compiling Fortran based on the host OS: + 'conditions': [ + [ + 'OS=="win"', + + # Rule to compile Fortran on Windows: + { + 'rule_name': 'compile_fortran_windows', + 'message': 'Compiling Fortran file <(RULE_INPUT_PATH) on Windows...', + + 'process_outputs_as_sources': 0, + + # Define the command-line invocation: + 'action': [ + '<(fortran_compiler)', + '<@(fflags)', + '<@(_inputs)', + '-o', + '<@(_outputs)', + ], + }, + + # Rule to compile Fortran on non-Windows: + { + 'rule_name': 'compile_fortran_linux', + 'message': 'Compiling Fortran file <(RULE_INPUT_PATH) on Linux...', + + 'process_outputs_as_sources': 1, + + # Define the command-line invocation: + 'action': [ + '<(fortran_compiler)', + '<@(fflags)', + '-fPIC', # generate platform-independent code + '<@(_inputs)', + '-o', + '<@(_outputs)', + ], + } + ], # end condition (OS=="win") + ], # end conditions + }, # end rule (extension=="f") + ], # end rules + }, # end target <(addon_target_name) + + # Target to copy a generated add-on to a standard location: + { + 'target_name': 'copy_addon', + + # Declare that the output of this target is not linked: + 'type': 'none', + + # Define dependencies: + 'dependencies': [ + # Require that the add-on be generated before building this target: + '<(addon_target_name)', + ], + + # Define a list of actions: + 'actions': [ + { + 'action_name': 'copy_addon', + 'message': 'Copying addon...', + + # Explicitly list the inputs in the command-line invocation below: + 'inputs': [], + + # Declare the expected outputs: + 'outputs': [ + '<(addon_output_dir)/<(addon_target_name).node', + ], + + # Define the command-line invocation: + 'action': [ + 'cp', + '<(PRODUCT_DIR)/<(addon_target_name).node', + '<(addon_output_dir)/<(addon_target_name).node', + ], + }, + ], # end actions + }, # end target copy_addon + ], # end targets +} diff --git a/lib/node_modules/@stdlib/blas/base/sger/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/sger/docs/repl.txt index 49aef9fdba07..0a13e0664164 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/sger/docs/repl.txt @@ -1,7 +1,7 @@ -{{alias}}( ord, M, N, α, x, sx, y, sy, A, lda ) +{{alias}}( order, M, N, α, x, sx, y, sy, A, lda ) Performs the rank 1 operation `A = α*x*y^T + A`, where `α` is a scalar, `x` - is an `M` element vector, `y` is an `N` element vector and `A` is an `M` by + is an `M` element vector, `y` is an `N` element vector, and `A` is an `M` by `N` matrix. Indexing is relative to the first index. To introduce an offset, use typed @@ -11,7 +11,7 @@ Parameters ---------- - ord: string + order: string Row-major (C-style) or column-major (Fortran-style) order. M: integer @@ -27,13 +27,13 @@ First input vector. sx: integer - Index increment for `x`. + Stride length for `x`. y: Float32Array Second input vector. sy: integer - Index increment for `y`. + Stride length for `y`. A: Float32Array Input Matrix. @@ -53,22 +53,31 @@ > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); > var y = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); > var A = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var ord = 'row-major'; - > {{alias}}( ord, 2, 2, 1.0, x, 1, y, 1, A, 2 ) + > var order = 'row-major'; + > {{alias}}( order, 2, 2, 1.0, x, 1, y, 1, A, 2 ) [ 2.0, 3.0, 4.0, 5.0 ] // Advanced indexing: > x = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); > y = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); > A = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0 ] ); - > {{alias}}( ord, 2, 2, 1.0, x, -1, y, -1, A, 2 ) + > {{alias}}( order, 2, 2, 1.0, x, -1, y, -1, A, 2 ) + [ 2.0, 3.0, 4.0, 5.0 ] + + // Using typed array views: + > var x0 = new {{alias:@stdlib/array/float32}}( [ 0.0, 1.0, 1.0 ] ); + > var y0 = new {{alias:@stdlib/array/float32}}( [ 0.0, 1.0, 1.0 ] ); + > A = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > var x1 = new {{alias:@stdlib/array/float32}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var y1 = new {{alias:@stdlib/array/float32}}( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); + > {{alias}}( order, 2, 2, 1.0, x1, -1, y1, -1, A, 2 ) [ 2.0, 3.0, 4.0, 5.0 ] {{alias}}.ndarray( M, N, α, x, sx, ox, y, sy, oy, A, sa1, sa2, oa ) Performs the rank 1 operation `A = α*x*y^T + A`, using alternative indexing semantics and where `α` is a scalar, `x` is an `M` element vector, `y` is an - `N` element vector and `A` is an `M` by `N` matrix. + `N` element vector, and `A` is an `M` by `N` matrix. While typed array views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting @@ -89,7 +98,7 @@ First input vector. sx: integer - Index increment for `x`. + Stride length for `x`. ox: integer Starting index for `x`. @@ -98,7 +107,7 @@ Second input vector. sy: integer - Index increment for `y`. + Stride length for `y`. oy: integer Starting index for `y`. diff --git a/lib/node_modules/@stdlib/blas/base/sger/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/sger/docs/types/index.d.ts index cd3555a51060..75e3aa18267c 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/sger/docs/types/index.d.ts @@ -27,7 +27,7 @@ import { Layout } from '@stdlib/types/blas'; */ interface Routine { /** - * Performs the rank 1 operation `A = α*x*y^T + A`, where `α` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector and `A` is an `M` by `N` matrix. + * Performs the rank 1 operation `A = α*x*y^T + A`, where `α` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector, and `A` is an `M` by `N` matrix. * * @param order - storage layout * @param M - number of rows in the matrix `A` @@ -54,7 +54,7 @@ interface Routine { ( order: Layout, M: number, N: number, alpha: number, x: Float32Array, strideX: number, y: Float32Array, strideY: number, A: Float32Array, LDA: number ): Float32Array; /** - * Performs the rank 1 operation `A = α*x*y^T + A`, using alternative indexing semantics and where `α` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector and `A` is an `M` by `N` matrix. + * Performs the rank 1 operation `A = α*x*y^T + A`, using alternative indexing semantics and where `α` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector, and `A` is an `M` by `N` matrix. * * @param M - number of rows in the matrix `A` * @param N - number of columns in the matrix `A` @@ -85,7 +85,7 @@ interface Routine { } /** -* Performs the rank 1 operation `A = α*x*y^T + A`, where `α` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector and `A` is an `M` by `N` matrix. +* Performs the rank 1 operation `A = α*x*y^T + A`, where `α` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector, and `A` is an `M` by `N` matrix. * * @param order - storage layout * @param M - number of rows in the matrix `A` diff --git a/lib/node_modules/@stdlib/blas/base/sger/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/sger/examples/c/example.c new file mode 100644 index 000000000000..dae2cc54c955 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/examples/c/example.c @@ -0,0 +1,61 @@ +/** +* @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. +*/ + +#include "stdlib/blas/base/dger.h" +#include "stdlib/blas/base/shared.h" +#include + +int main( void ) { + // Define a 3x4 matrix stored in row-major order: + float A[ 3*4 ] = { + 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0 + }; + // Define `x` and `y^T` vectors: + const float x[ 3 ] = { 1.0, 4.0, 0.0 }; // M + const float y[ 4 ] = { 0.0, 1.0, 2.0, 3.0 }; // N + + // Specify the number of rows and columns: + const int M = 3; + const int N = 4; + + // Specify stride lengths: + const int strideX = 1; + const int strideY = 1; + + // Perform operation: + c_sger( CblasRowMajor, M, N, 1.0, x, strideX, y, strideY, A, N ); + + // Print the result: + for ( int i = 0; i < M; i++ ) { + for ( int j = 0; j < N; j++ ) { + printf( "A[%i,%i] = %f\n", i, j, A[ (i*N)+j ] ); + } + } + + // Perform operation using alterntive indexing semantics: + c_sger( CblasRowMajor, M, N, 1.0, x, strideX, 0, y, 0, strideY, A, N, 1, 0 ); + + // Print the result: + for ( int i = 0; i < M; i++ ) { + for ( int j = 0; j < N; j++ ) { + printf( "A[%i,%i] = %f\n", i, j, A[ (i*N)+j ] ); + } + } +} diff --git a/lib/node_modules/@stdlib/blas/base/sger/include.gypi b/lib/node_modules/@stdlib/blas/base/sger/include.gypi new file mode 100644 index 000000000000..497aeca15320 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/include.gypi @@ -0,0 +1,70 @@ +# @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. + +# A GYP include file for building a Node.js native add-on. +# +# Note that nesting variables is required due to how GYP processes a configuration. Any variables defined within a nested 'variables' section is defined in the outer scope. Thus, conditions in the outer variable scope are free to use these variables without running into "variable undefined" errors. +# +# Main documentation: +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +# +# Variable nesting hacks: +# +# [3]: https://chromium.googlesource.com/external/skia/gyp/+/master/common_variables.gypi +# [4]: https://src.chromium.org/viewvc/chrome/trunk/src/build/common.gypi?revision=127004 +{ + # Define variables to be used throughout the configuration for all targets: + 'variables': { + 'variables': { + # Host BLAS library (to override -Dblas=): + 'blas%': '', + + # Path to BLAS library (to override -Dblas_dir=): + 'blas_dir%': '', + }, # end variables + + # Source directory: + 'src_dir': './src', + + # Include directories: + 'include_dirs': [ + '<@(blas_dir)', + ' [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] */ diff --git a/lib/node_modules/@stdlib/blas/base/sger/lib/native.js b/lib/node_modules/@stdlib/blas/base/sger/lib/native.js new file mode 100644 index 000000000000..602f926e056d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/lib/native.js @@ -0,0 +1,35 @@ +/** +* @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'; + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var sger = require( './sger.native.js' ); +var ndarray = require( './ndarray.native.js' ); + + +// MAIN // + +setReadOnly( sger, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = sger; diff --git a/lib/node_modules/@stdlib/blas/base/sger/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/sger/lib/ndarray.js index f4f1f1fa9b73..5a57f104bba4 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/sger/lib/ndarray.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/base/sger/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/sger/lib/ndarray.native.js new file mode 100644 index 000000000000..1549a080e20a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/lib/ndarray.native.js @@ -0,0 +1,85 @@ +/** +* @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'; + +// MODULES // + +var format = require( '@stdlib/string/format' ); +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Performs the rank 1 operation `A = α*x*y^T + A`, where `α` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector, and `A` is an `M` by `N` matrix. +* +* @param {NonNegativeInteger} M - number of rows in the matrix `A` +* @param {NonNegativeInteger} N - number of columns in the matrix `A` +* @param {number} alpha - scalar constant +* @param {Float32Array} x - first input vector +* @param {integer} strideX - `x` stride length +* @param {NonNegativeInteger} offsetX - starting `x` index +* @param {Float32Array} y - second input vector +* @param {integer} strideY - `y` stride length +* @param {NonNegativeInteger} offsetY - starting `y` index +* @param {Float32Array} A - input matrix +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - starting index for `A +* @throws {RangeError} first argument must be a nonnegative integer +* @throws {RangeError} second argument must be a nonnegative integer +* @throws {RangeError} fifth argument must be non-zero +* @throws {RangeError} eighth argument must be non-zero +* @returns {Float32Array} `A` +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var x = new Float32Array( [ 1.0, 1.0 ] ); +* var y = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +* +* sger( 2, 3, 1.0, x, 1, 0, y, 1, 0, A, 3, 1, 0 ); +* // A => [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] +*/ +function sger( M, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, strideA1, strideA2, offsetA ) { // eslint-disable-line max-len, max-params + if ( M < 0 ) { + throw new RangeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%d`.', M ) ); + } + if ( N < 0 ) { + throw new RangeError( format( 'invalid argument. Second argument must be a nonnegative integer. Value: `%d`.', N ) ); + } + if ( strideX === 0 ) { + throw new RangeError( format( 'invalid argument. Fifth argument must be non-zero. Value: `%d`.', strideX ) ); + } + if ( strideY === 0 ) { + throw new RangeError( format( 'invalid argument. Eighth argument must be non-zero. Value: `%d`.', strideY ) ); + } + // Check if we can early return... + if ( M === 0 || N === 0 || alpha === 0.0 ) { + return A; + } + addon.ndarray( M, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, strideA1, strideA2, offsetA ); // eslint-disable-line max-len + return A; +} + + +// EXPORTS // + +module.exports = sger; diff --git a/lib/node_modules/@stdlib/blas/base/sger/lib/sger.js b/lib/node_modules/@stdlib/blas/base/sger/lib/sger.js index 87939bb3ab8a..6816c5a7826f 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/lib/sger.js +++ b/lib/node_modules/@stdlib/blas/base/sger/lib/sger.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* 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. @@ -31,7 +31,7 @@ var base = require( './base.js' ); // MAIN // /** -* Performs the rank 1 operation `A = α*x*y^T + A`, where `α` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector and `A` is an `M` by `N` matrix. +* Performs the rank 1 operation `A = α*x*y^T + A`, where `α` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector, and `A` is an `M` by `N` matrix. * * @param {string} order - storage layout * @param {NonNegativeInteger} M - number of rows in the matrix `A` @@ -48,7 +48,7 @@ var base = require( './base.js' ); * @throws {RangeError} third argument must be a nonnegative integer * @throws {RangeError} sixth argument must be non-zero * @throws {RangeError} eighth argument must be non-zero -* @throws {RangeError} tenth argument must be greater than or equal to max(1,M) +* @throws {RangeError} tenth argument must be a valid stride * @returns {Float32Array} `A` * * @example @@ -69,7 +69,6 @@ function sger( order, M, N, alpha, x, strideX, y, strideY, A, LDA ) { var ox; var oy; - iscm = isColumnMajor( order ); if ( !isLayout( order ) ) { throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); } @@ -80,11 +79,12 @@ function sger( order, M, N, alpha, x, strideX, y, strideY, A, LDA ) { throw new RangeError( format( 'invalid argument. Third argument must be a nonnegative integer. Value: `%d`.', N ) ); } if ( strideX === 0 ) { - throw new RangeError( format( 'invalid argument. Sixth argument must be non-zero.' ) ); + throw new RangeError( format( 'invalid argument. Sixth argument must be non-zero. Value: `%d`.', strideX ) ); } if ( strideY === 0 ) { - throw new RangeError( format( 'invalid argument. Eighth argument must be non-zero.' ) ); + throw new RangeError( format( 'invalid argument. Eighth argument must be non-zero. Value: `%d`.', strideY ) ); } + iscm = isColumnMajor( order ); if ( iscm ) { vala = M; } else { @@ -99,7 +99,7 @@ function sger( order, M, N, alpha, x, strideX, y, strideY, A, LDA ) { } ox = stride2offset( M, strideX ); oy = stride2offset( N, strideY ); - if ( order === 'column-major' ) { + if ( iscm ) { sa1 = 1; sa2 = LDA; } else { // order === 'row-major' diff --git a/lib/node_modules/@stdlib/blas/base/sger/lib/sger.native.js b/lib/node_modules/@stdlib/blas/base/sger/lib/sger.native.js new file mode 100644 index 000000000000..1f55da9da30e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/lib/sger.native.js @@ -0,0 +1,100 @@ +/** +* @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'; + +// MODULES // + +var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); +var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); +var resolve = require( '@stdlib/blas/base/layout-resolve-enum' ); +var max = require( '@stdlib/math/base/special/fast/max' ); +var format = require( '@stdlib/string/format' ); +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Performs the rank 1 operation `A = α*x*y^T + A`, where `α` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector, and `A` is an `M` by `N` matrix. +* +* @param {*} order - storage layout +* @param {NonNegativeInteger} M - number of rows in the matrix `A` +* @param {NonNegativeInteger} N - number of columns in the matrix `A` +* @param {number} alpha - scalar constant +* @param {Float32Array} x - first input vector +* @param {integer} strideX - `x` stride length +* @param {Float32Array} y - second input vector +* @param {integer} strideY - `y` stride length +* @param {Float32Array} A - matrix of coefficients +* @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @throws {TypeError} first argument must be a valid order +* @throws {RangeError} second argument must be a nonnegative integer +* @throws {RangeError} third argument must be a nonnegative integer +* @throws {RangeError} sixth argument must be non-zero +* @throws {RangeError} eighth argument must be non-zero +* @throws {RangeError} tenth argument must be a valid stride +* @returns {Float32Array} `A` +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var x = new Float32Array( [ 1.0, 1.0 ] ); +* var y = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +* +* sger( 'row-major', 2, 3, 1.0, x, 1, y, 1, A, 3 ); +* // A => [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] +*/ +function sger( order, M, N, alpha, x, strideX, y, strideY, A, LDA ) { + var vala; + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + if ( M < 0 ) { + throw new RangeError( format( 'invalid argument. Second argument must be a nonnegative integer. Value: `%d`.', M ) ); + } + if ( N < 0 ) { + throw new RangeError( format( 'invalid argument. Third argument must be a nonnegative integer. Value: `%d`.', N ) ); + } + if ( strideX === 0 ) { + throw new RangeError( format( 'invalid argument. Sixth argument must be non-zero. Value: `%d`.', strideX ) ); + } + if ( strideY === 0 ) { + throw new RangeError( format( 'invalid argument. Eighth argument must be non-zero. Value: `%d`.', strideY ) ); + } + if ( isColumnMajor( order ) ) { + vala = M; + } else { + vala = N; + } + if ( LDA < max( 1, vala ) ) { + throw new RangeError( format( 'invalid argument. Tenth argument must be greater than or equal to max(1,%d). Value: `%d`.', vala, LDA ) ); + } + // Check if we can early return... + if ( M === 0 || N === 0 || alpha === 0.0 ) { + return A; + } + addon( resolve( order ), M, N, alpha, x, strideX, y, strideY, A, LDA ); + return A; +} + + +// EXPORTS // + +module.exports = sger; diff --git a/lib/node_modules/@stdlib/blas/base/sger/manifest.json b/lib/node_modules/@stdlib/blas/base/sger/manifest.json new file mode 100644 index 000000000000..ae0ae6c048c2 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/manifest.json @@ -0,0 +1,485 @@ +{ + "options": { + "task": "build", + "os": "linux", + "blas": "", + "wasm": false + }, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "task": "build", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/sger.f", + "./src/sger_f.c", + "./src/sger_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-int32", + "@stdlib/napi/argv-strided-float32array", + "@stdlib/napi/argv-strided-float32array2d", + "@stdlib/napi/argv-float", + "@stdlib/ndarray/base/assert/is-row-major" + ] + }, + { + "task": "benchmark", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/sger.c", + "./src/sger_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/strided/base/stride2offset" + ] + }, + { + "task": "examples", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/sger.c", + "./src/sger_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/strided/base/stride2offset" + ] + }, + + { + "task": "build", + "os": "linux", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/sger_cblas.c", + "./src/sger_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-int32", + "@stdlib/napi/argv-strided-float32array", + "@stdlib/napi/argv-strided-float32array2d", + "@stdlib/napi/argv-float", + "@stdlib/ndarray/base/assert/is-row-major" + ] + }, + { + "task": "benchmark", + "os": "linux", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/sger_cblas.c", + "./src/sger_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/ndarray/base/assert/is-row-major" + ] + }, + { + "task": "examples", + "os": "linux", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/sger_cblas.c", + "./src/sger_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/ndarray/base/assert/is-row-major" + ] + }, + + { + "task": "build", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/sger.f", + "./src/sger_f.c", + "./src/sger_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-int32", + "@stdlib/napi/argv-strided-float32array", + "@stdlib/napi/argv-strided-float32array2d", + "@stdlib/napi/argv-float", + "@stdlib/ndarray/base/assert/is-row-major" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/sger.c", + "./src/sger_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/strided/base/stride2offset" + ] + }, + { + "task": "examples", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/sger.c", + "./src/sger_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/strided/base/stride2offset" + ] + }, + + { + "task": "build", + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/sger_cblas.c", + "./src/sger_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lblas" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-int32", + "@stdlib/napi/argv-strided-float32array", + "@stdlib/napi/argv-strided-float32array2d", + "@stdlib/napi/argv-float", + "@stdlib/ndarray/base/assert/is-row-major" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/sger_cblas.c", + "./src/sger_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lblas" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/ndarray/base/assert/is-row-major" + ] + }, + { + "task": "examples", + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/sger_cblas.c", + "./src/sger_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lblas" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/ndarray/base/assert/is-row-major" + ] + }, + + { + "task": "build", + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/sger_cblas.c", + "./src/sger_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-int32", + "@stdlib/napi/argv-strided-float32array", + "@stdlib/napi/argv-strided-float32array2d", + "@stdlib/napi/argv-float", + "@stdlib/ndarray/base/assert/is-row-major" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/sger_cblas.c", + "./src/sger_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/ndarray/base/assert/is-row-major" + ] + }, + { + "task": "examples", + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/sger_cblas.c", + "./src/sger_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/ndarray/base/assert/is-row-major" + ] + }, + + { + "task": "build", + "os": "win", + "blas": "", + "wasm": false, + "src": [ + "./src/sger.c", + "./src/sger_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-int32", + "@stdlib/napi/argv-strided-float32array", + "@stdlib/napi/argv-strided-float32array2d", + "@stdlib/napi/argv-float", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/strided/base/stride2offset" + ] + }, + { + "task": "benchmark", + "os": "win", + "blas": "", + "wasm": false, + "src": [ + "./src/sger.c", + "./src/sger_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/strided/base/stride2offset" + ] + }, + { + "task": "examples", + "os": "win", + "blas": "", + "wasm": false, + "src": [ + "./src/sger.c", + "./src/sger_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/strided/base/stride2offset" + ] + }, + + { + "task": "build", + "os": "", + "blas": "", + "wasm": true, + "src": [ + "./src/sger.c", + "./src/sger_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/strided/base/stride2offset" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sger/package.json b/lib/node_modules/@stdlib/blas/base/sger/package.json index dde66bb6d559..0a86ad4f539d 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/package.json +++ b/lib/node_modules/@stdlib/blas/base/sger/package.json @@ -14,11 +14,15 @@ } ], "main": "./lib", + "browser": "./lib/main.js", + "gypfile": true, "directories": { "benchmark": "./benchmark", "doc": "./docs", "example": "./examples", + "include": "./include", "lib": "./lib", + "src": "./src", "test": "./test" }, "types": "./docs/types", diff --git a/lib/node_modules/@stdlib/blas/base/sger/src/Makefile b/lib/node_modules/@stdlib/blas/base/sger/src/Makefile new file mode 100644 index 000000000000..bcf18aa46655 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/src/Makefile @@ -0,0 +1,70 @@ +#/ +# @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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + + +# RULES # + +#/ +# Removes generated files for building an add-on. +# +# @example +# make clean-addon +#/ +clean-addon: + $(QUIET) -rm -f *.o *.node + +.PHONY: clean-addon + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: clean-addon + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/blas/base/sger/src/addon.c b/lib/node_modules/@stdlib/blas/base/sger/src/addon.c new file mode 100644 index 000000000000..03d2301e28aa --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/src/addon.c @@ -0,0 +1,97 @@ + +/** +* @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. +*/ + +#include "stdlib/blas/base/sger.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/napi/export.h" +#include "stdlib/napi/argv.h" +#include "stdlib/napi/argv_int64.h" +#include "stdlib/napi/argv_int32.h" +#include "stdlib/napi/argv_float.h" +#include "stdlib/napi/argv_strided_float32array.h" +#include "stdlib/napi/argv_strided_float32array2d.h" +#include + +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +static napi_value addon( napi_env env, napi_callback_info info ) { + STDLIB_NAPI_ARGV( env, info, argv, argc, 10 ); + + STDLIB_NAPI_ARGV_INT32( env, layout, argv, 0 ); + + STDLIB_NAPI_ARGV_INT64( env, M, argv, 1 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 2 ); + STDLIB_NAPI_ARGV_INT64( env, LDA, argv, 9 ); + + STDLIB_NAPI_ARGV_FLOAT( env, alpha, argv, 3 ); + + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 5 ); + STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 7 ); + + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, M, strideX, argv, 4 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, Y, N, strideY, argv, 6 ); + + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY2D( env, A, M, N, LDA, 1, argv, 8 ); + + API_SUFFIX(c_sger)( layout, M, N, alpha, X, strideX, Y, strideY, A, LDA ); + + return NULL; +} + +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +static napi_value addon_method( napi_env env, napi_callback_info info ) { + STDLIB_NAPI_ARGV( env, info, argv, argc, 13 ); + + STDLIB_NAPI_ARGV_INT64( env, M, argv, 0 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 1 ); + + STDLIB_NAPI_ARGV_FLOAT( env, alpha, argv, 2 ); + + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 4 ); + STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 5 ); + + STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 7 ); + STDLIB_NAPI_ARGV_INT64( env, offsetY, argv, 8 ); + + STDLIB_NAPI_ARGV_INT64( env, strideA1, argv, 10 ); + STDLIB_NAPI_ARGV_INT64( env, strideA2, argv, 11 ); + STDLIB_NAPI_ARGV_INT64( env, offsetA, argv, 12 ); + + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, M, strideX, argv, 3 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, Y, N, strideY, argv, 6 ); + + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY2D( env, A, M, N, strideA1, strideA2, argv, 9 ); + + API_SUFFIX(c_sger_ndarray)( M, N, alpha, X, strideX, offsetX, Y, strideY, offsetY, A, strideA1, strideA2, offsetA ); + + return NULL; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method ) diff --git a/lib/node_modules/@stdlib/blas/base/sger/src/sger.c b/lib/node_modules/@stdlib/blas/base/sger/src/sger.c new file mode 100644 index 000000000000..7a1cfe78c3b5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/src/sger.c @@ -0,0 +1,97 @@ +/** +* @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. +*/ + +#include "stdlib/blas/base/sger.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/blas/base/xerbla.h" +#include "stdlib/strided/base/stride2offset.h" + +/** +* Performs the rank 1 operation `A = alpha*x*y^T + A`, where `alpha` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector, and `A` is an `M`-by-`N` matrix. +* +* @param layout storage layout +* @param M number of rows in the matrix `A` +* @param N number of columns in the matrix `A` +* @param alpha scalar constant +* @param X an `M` element vector +* @param strideX stride length for `X` +* @param Y an `N` element vector +* @param strideY stride length for `Y` +* @param A matrix of coefficients +* @param LDA stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +*/ +void API_SUFFIX(c_sger)( const CBLAS_LAYOUT layout, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *X, const CBLAS_INT strideX, const float *Y, const CBLAS_INT strideY, float *A, const CBLAS_INT LDA ) { + CBLAS_INT vala; + CBLAS_INT sa1; + CBLAS_INT sa2; + CBLAS_INT ox; + CBLAS_INT oy; + CBLAS_INT v; + + // Perform input argument validation... + if ( layout != CblasRowMajor && layout != CblasColMajor ) { + c_xerbla( 1, "c_sger", "Error: invalid argument. First argument must be a valid storage layout. Value: `%d`.", layout ); + return; + } + if ( M < 0 ) { + c_xerbla( 2, "c_sger", "Error: invalid argument. Second argument must be a nonnegative integer. Value: `%d`.", M ); + return; + } + if ( N < 0 ) { + c_xerbla( 3, "c_sger", "Error: invalid argument. Third argument must be a nonnegative integer. Value: `%d`.", N ); + return; + } + if ( strideX == 0 ) { + c_xerbla( 6, "c_sger", "Error: invalid argument. Sixth argument must be nonzero. Value: `%d`.", strideX ); + return; + } + if ( strideY == 0 ) { + c_xerbla( 8, "c_sger", "Error: invalid argument. Eighth argument must be nonzero. Value: `%d`.", strideX ); + return; + } + if ( layout == CblasColMajor ) { + v = M; + } else { + v = N; + } + // max(1, v) + if ( v < 1 ) { + vala = 1; + } else { + vala = v; + } + if ( LDA < v ) { + c_xerbla( 10, "c_sger", "Error: invalid argument. Tenth argument must be greater than or equal to max(1,%d). Value: `%d`.", vala, LDA ); + return; + } + // Check whether we can avoid computation altogether... + if ( M == 0 || N == 0 || alpha == 0.0 ) { + return; + } + ox = stdlib_strided_stride2offset( N, strideX ); + oy = stdlib_strided_stride2offset( N, strideY ); + if ( layout == CblasColMajor ) { + sa1 = 1; + sa2 = LDA; + } else { // layout == CblasRowMajor + sa1 = LDA; + sa2 = 1; + } + API_SUFFIX(c_sger_ndarray)( M, N, alpha, X, strideX, ox, Y, strideY, oy, A, sa1, sa2, 0 ); + return; +} diff --git a/lib/node_modules/@stdlib/blas/base/sger/src/sger.f b/lib/node_modules/@stdlib/blas/base/sger/src/sger.f new file mode 100644 index 000000000000..e3fdb7ceab6d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/src/sger.f @@ -0,0 +1,148 @@ +!> +! @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. +!< + +!> Performs the rank 1 operation `A = alpha*x*y^T + A`, where `alpha` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector, and `A` is an `M`-by-`N` matrix. +! +! ## Notes +! +! * Modified version of reference BLAS routine (version 3.12.0). Updated to "free form" Fortran 95. +! +! ## Authors +! +! * Univ. of Tennessee +! * Univ. of California Berkeley +! * Univ. of Colorado Denver +! * NAG Ltd. +! +! ## History +! +! * Written on 22-October-1986. +! +! - Jack Dongarra, Argonne National Lab. +! - Jermey Du Croz, Nag Central Office. +! - Sven Hammarling, Nag Central Office. +! - Richard Hanson, Sandia National Labs. +! +! ## License +! +! From : +! +! > The reference BLAS is a freely-available software package. It is available from netlib via anonymous ftp and the World Wide Web. Thus, it can be included in commercial software packages (and has been). We only ask that proper credit be given to the authors. +! > +! > Like all software, it is copyrighted. It is not trademarked, but we do ask the following: +! > +! > * If you modify the source for these routines we ask that you change the name of the routine and comment the changes made to the original. +! > +! > * We will gladly answer any questions regarding the software. If a modification is done, however, it is the responsibility of the person who modified the routine to provide support. +! +! @param {integer} M - number of rows in the matrix `A` +! @param {integer} N - number of columns in the matrix `A` +! @param {single} alpha - scalar constant +! @param {Array} X - an `M` element vector +! @param {integer} strideX - stride length for `X` +! @param {Array} Y - an `N` element vector +! @param {integer} strideY - stride length for `Y` +! @param {Array} A - matrix of coefficients +! @param {integer} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +!< +subroutine sger( M, N, alpha, X, strideX, Y, strideY, A, LDA ) + implicit none + ! .. + ! Internal parameters: + integer, parameter :: dp=kind(0.0d0) ! single-precision + ! .. + ! Scalar arguments: + real(dp) :: alpha + integer :: strideX, strideY, LDA, M, N + ! .. + ! Array arguments: + real(dp) :: A(LDA,*), X(*), Y(*) + ! .. + ! Local scalars: + real(dp) :: temp + integer :: i, info, ix, j, jy, kx + ! .. + ! External functions: + interface + subroutine xerbla( srname, info ) + character*(*) :: srname + integer :: info + end subroutine xerbla + end interface + ! .. + ! Intrinsic functions: + intrinsic max + ! .. + ! Validate input arguments... + info = 0 + if ( M < 0 ) then + info = 1 + else if ( N < 0 ) then + info = 2 + else if ( strideX == 0 ) then + info = 5 + else if ( strideY == 0 ) then + info = 7 + else if ( LDA < max( 1, M ) ) then + info = 9 + end if + if ( info /= 0 ) then + call xerbla( 'sger ', info ) + return + end if + ! .. + ! Check whether we can avoid computation altogether... + if ( M == 0 .OR. N == 0 .OR. alpha == 0.0d0 ) then + return + end if + ! .. + if ( strideY > 0 ) then + jy = 1 + else + jy = 1 - ( (N-1) * strideY ) + end if + if ( strideX == 1 ) then + do j = 1, N + if ( Y( jy ) /= 0.0d0 ) then + temp = alpha * Y( jy ) + do i = 1, M + A( i, j ) = A( i, j ) + ( X( i ) * temp ) + end do + end if + jy = jy + strideY + end do + else + if ( strideX > 0 ) then + kx = 1 + else + kx = 1 - ( (M-1) * strideX ) + end if + do j = 1, N + if ( Y( jy ) /= 0.0d0 ) then + temp = alpha * Y( jy ) + ix = kx + do i = 1, M + A( i, j ) = A( i, j ) + ( X( ix ) * temp ) + ix = ix + strideX + end do + end if + jy = jy + strideY + end do + end if + return +end subroutine sger diff --git a/lib/node_modules/@stdlib/blas/base/sger/src/sger_cblas.c b/lib/node_modules/@stdlib/blas/base/sger/src/sger_cblas.c new file mode 100644 index 000000000000..72dbef498e45 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/src/sger_cblas.c @@ -0,0 +1,39 @@ +/** +* @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. +*/ + +#include "stdlib/blas/base/sger.h" +#include "stdlib/blas/base/sger_cblas.h" +#include "stdlib/blas/base/shared.h" + +/** +* Performs the rank 1 operation `A = alpha*x*y^T + A`, where `alpha` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector, and `A` is an `M`-by-`N` matrix. +* +* @param layout storage layout +* @param M number of rows in the matrix `A` +* @param N number of columns in the matrix `A` +* @param alpha scalar constant +* @param X an `M` element vector +* @param strideX stride length for `X` +* @param Y an `N` element vector +* @param strideY stride length for `Y` +* @param A matrix of coefficients +* @param LDA index of the first dimension of `A` +*/ +void API_SUFFIX(c_sger)( const CBLAS_LAYOUT layout, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *X, const CBLAS_INT strideX, const float *Y, const CBLAS_INT strideY, float *A, const CBLAS_INT LDA ) { + API_SUFFIX(cblas_sger)( layout, M, N, alpha, X, strideX, Y, strideY, A, LDA ); +} diff --git a/lib/node_modules/@stdlib/blas/base/sger/src/sger_f.c b/lib/node_modules/@stdlib/blas/base/sger/src/sger_f.c new file mode 100644 index 000000000000..71952dcfdcc5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/src/sger_f.c @@ -0,0 +1,55 @@ +/** +* @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. +*/ + +#include "stdlib/blas/base/sger.h" +#include "stdlib/blas/base/sger_fortran.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/blas/base/xerbla.h" + +/** +* Performs the rank 1 operation `A = alpha*x*y^T + A`, where `alpha` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector, and `A` is an `M`-by-`N` matrix. +* +* @param layout storage layout +* @param M number of rows in the matrix `A` +* @param N number of columns in the matrix `A` +* @param alpha scalar constant +* @param X an `M` element vector +* @param strideX stride length for `X` +* @param Y an `N` element vector +* @param strideY stride length for `Y` +* @param A matrix of coefficients +* @param LDA stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +*/ +void API_SUFFIX(c_sger)( const CBLAS_LAYOUT layout, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *X, const CBLAS_INT strideX, const float *Y, const CBLAS_INT strideY, float *A, const CBLAS_INT LDA ) { + extern int RowMajorStrg; // global flag + + RowMajorStrg = 0; + if ( layout == CblasColMajor ) { + sger( &M, &N, &alpha, X, &strideX, Y, &strideY, A, &LDA ); + return; + } + if ( layout == CblasRowMajor ) { + RowMajorStrg = 1; + sger( &N, &M, &alpha, Y, &strideY, X, &strideX, A, &LDA ); + RowMajorStrg = 0; + return; + } + c_xerbla( 1, "c_sger", "Error: invalid argument. First argument must be a valid storage layout. Value: `%d`.", layout ); + RowMajorStrg = 0; + return; +} diff --git a/lib/node_modules/@stdlib/blas/base/sger/src/sger_ndarray.c b/lib/node_modules/@stdlib/blas/base/sger/src/sger_ndarray.c new file mode 100644 index 000000000000..449539ec88b7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/src/sger_ndarray.c @@ -0,0 +1,199 @@ +/** +* @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. +*/ + +#include "stdlib/blas/base/sger.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/blas/base/xerbla.h" +#include "stdlib/ndarray/base/assert/is_row_major.h" +#include + +/** +* Performs the rank 1 operation `A = alpha*x*y^T + A`, using alternative indexing semantics and where `alpha` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector, and `A` is an `M`-by-`N` matrix. +* +* ## Notes +* +* - To help motivate the use of loop interchange below, we first recognize that a matrix stored in row-major order is equivalent to storing the matrix's transpose in column-major order. For example, consider the following 2-by-3 matrix `A` +* +* ```tex +* A = \begin{bmatrix} +* 1 & 2 & 3 \\ +* 4 & 5 & 6 +* \end{bmatrix} +* ``` +* +* When stored in a linear buffer in column-major order, `A` becomes +* +* ```text +* [ 1 4 2 5 3 6] +* ``` +* +* When stored in a linear buffer in row-major order, `A` becomes +* +* ```text +* [ 1 2 3 4 5 6] +* ``` +* +* Now consider the transpose of `A` +* +* ```tex +* A^T = \begin{bmatrix} +* 1 & 4 \\ +* 2 & 5 \\ +* 3 & 6 +* \end{bmatrix} +* ``` +* +* When the transpose is stored in a linear buffer in column-major order, the transpose becomes +* +* ```text +* [ 1 2 3 4 5 6 ] +* ``` +* +* Similarly, when stored in row-major order, the transpose becomes +* +* ```text +* [ 1 4 2 5 3 6 ] +* ``` +* +* As may be observed, `A` stored in column-major order is equivalent to storing the transpose of `A` in row-major order, and storing `A` in row-major order is equivalent to storing the transpose of `A` in column-major order, and vice versa. +* +* Hence, we can interpret an `M` by `N` row-major matrix `B` as the matrix `A^T` stored in column-major order. In which case, we can derive an update equation for `B` as follows: +* +* ```tex +* \begin{align*} +* B &= A^T \\ +* &= (\alpha \bar{x} \bar{y}^T + A)^T \\ +* &= (\alpha \bar{x} \bar{y}^T)^T + A^T \\ +* &= \alpha (\bar{x} \bar{y}^T)^T + A^T \\ +* &= \alpha \bar{y} \bar{x}^T + A^T \\ +* &= \alpha \bar{y} \bar{x}^T + B +* \end{align*} +* ``` +* +* Accordingly, we can reuse the same loop logic for column-major and row-major `A` by simply swapping `x` and `y` and `M` and `N` when `A` is row-major order. That is the essence of loop interchange. +* +* @param layout storage layout +* @param M number of rows in the matrix `A` +* @param N number of columns in the matrix `A` +* @param alpha scalar constant +* @param X an `M` element vector +* @param strideX stride length for `X` +* @param offsetX starting index for `X` +* @param Y an `N` element vector +* @param strideY stride length for `Y` +* @param offsetY starting index for `Y` +* @param A matrix of coefficients +* @param strideA1 stride length of the first dimnension of `A` +* @param strideA2 stride length of the second dimension of `A` +* @param offsetA starting index for `A` +*/ +void API_SUFFIX(c_sger_ndarray)( const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const float *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, float *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA ) { + const float *x; + const float *y; + int64_t sa[ 2 ]; + CBLAS_INT da0; + CBLAS_INT da1; + CBLAS_INT S0; + CBLAS_INT S1; + CBLAS_INT sx; + CBLAS_INT sy; + CBLAS_INT ox; + CBLAS_INT ia; + CBLAS_INT ix; + CBLAS_INT iy; + CBLAS_INT i0; + CBLAS_INT i1; + float tmp; + + // Note on variable naming convention: S#, da#, ia#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Perform input argument validation... + if ( M < 0 ) { + c_xerbla( 1, "c_sger_ndarray", "Error: invalid argument. First argument must be a nonnegative integer. Value: `%d`.", M ); + return; + } + if ( N < 0 ) { + c_xerbla( 2, "c_sger_ndarray", "Error: invalid argument. Second argument must be a nonnegative integer. Value: `%d`.", N ); + return; + } + if ( strideX == 0 ) { + c_xerbla( 5, "c_sger_ndarray", "Error: invalid argument. Fifth argument must be a nonzero. Value: `%d`.", strideX ); + return; + } + if ( strideY == 0 ) { + c_xerbla( 8, "c_sger_ndarray", "Error: invalid argument. Eighth argument must be a nonzero. Value: `%d`.", strideY ); + return; + } + // Check whether we can avoid computation altogether... + if ( M == 0 || N == 0 || alpha == 0.0 ) { + return; + } + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sa[ 0 ] = strideA1; + sa[ 1 ] = strideA2; + if ( stdlib_ndarray_is_row_major( 2, sa ) ) { + // For row-major matrices, the last dimension has the fastest changing index... + S0 = N; + S1 = M; + da0 = strideA2; // offset increment for innermost loop + da1 = strideA1 - ( S0*strideA2 ); // offset increment for outermost loop + + // Swap the vectors... + x = Y; + y = X; + + sx = strideY; + sy = strideX; + + ox = offsetY; + iy = offsetX; + } else { // order === 'column-major' + // For column-major matrices, the first dimension has the fastest changing index... + S0 = M; + S1 = N; + da0 = strideA1; // offset increment for innermost loop + da1 = strideA2 - ( S0*strideA1 ); // offset increment for outermost loop + + x = X; + y = Y; + + sx = strideX; + sy = strideY; + + ox = offsetX; + iy = offsetY; + } + ia = offsetA; + for ( i1 = 0; i1 < S1; i1++ ) { + // Check whether we can avoid the inner loop entirely... + if ( y[ iy ] == 0.0 ) { + ia += da0 * S0; + } else { + tmp = alpha * y[ iy ]; + ix = ox; + for ( i0 = 0; i0 < S0; i0++ ) { + A[ ia ] += x[ ix ] * tmp; + ix += sx; + ia += da0; + } + } + iy += sy; + ia += da1; + } + return; +} diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/sger/test/test.ndarray.native.js new file mode 100644 index 000000000000..d59fb3a31f3a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/test/test.ndarray.native.js @@ -0,0 +1,977 @@ +/** +* @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. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var Float32Array = require( '@stdlib/array/float32' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var sger = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( sger instanceof Error ) +}; + + +// FIXTURES // + +var cm = require( './fixtures/column_major.json' ); +var coa = require( './fixtures/column_major_oa.json' ); +var cox = require( './fixtures/column_major_ox.json' ); +var coy = require( './fixtures/column_major_oy.json' ); +var cxpyp = require( './fixtures/column_major_xpyp.json' ); +var cxnyp = require( './fixtures/column_major_xnyp.json' ); +var cxpyn = require( './fixtures/column_major_xpyn.json' ); +var cxnyn = require( './fixtures/column_major_xnyn.json' ); +var csa1sa2 = require( './fixtures/column_major_sa1_sa2.json' ); +var csa1nsa2 = require( './fixtures/column_major_sa1n_sa2.json' ); +var csa1sa2n = require( './fixtures/column_major_sa1_sa2n.json' ); +var csa1nsa2n = require( './fixtures/column_major_sa1n_sa2n.json' ); +var ccap = require( './fixtures/column_major_complex_access_pattern.json' ); +var cx0 = require( './fixtures/column_major_x_zeros.json' ); +var cy0 = require( './fixtures/column_major_y_zeros.json' ); + +var rm = require( './fixtures/row_major.json' ); +var roa = require( './fixtures/row_major_oa.json' ); +var rox = require( './fixtures/row_major_ox.json' ); +var roy = require( './fixtures/row_major_oy.json' ); +var rxpyp = require( './fixtures/row_major_xpyp.json' ); +var rxnyp = require( './fixtures/row_major_xnyp.json' ); +var rxpyn = require( './fixtures/row_major_xpyn.json' ); +var rxnyn = require( './fixtures/row_major_xnyn.json' ); +var rsa1sa2 = require( './fixtures/row_major_sa1_sa2.json' ); +var rsa1nsa2 = require( './fixtures/row_major_sa1n_sa2.json' ); +var rsa1sa2n = require( './fixtures/row_major_sa1_sa2n.json' ); +var rsa1nsa2n = require( './fixtures/row_major_sa1n_sa2n.json' ); +var rcap = require( './fixtures/row_major_complex_access_pattern.json' ); +var rx0 = require( './fixtures/row_major_x_zeros.json' ); +var ry0 = require( './fixtures/row_major_y_zeros.json' ); + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof sger, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 13', opts, function test( t ) { + t.strictEqual( sger.length, 13, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid first argument', opts, function test( t ) { + var values; + var data; + var i; + + data = rm; + + values = [ + -1, + -2, + -3 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + sger( value, data.N, data.alpha, new Float32Array( data.x ), data.strideX, data.offsetX, new Float32Array( data.y ), data.strideY, data.offsetY, new Float32Array( data.A ), data.strideA1, data.strideA2, data.offsetA ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid second argument', opts, function test( t ) { + var values; + var data; + var i; + + data = rm; + + values = [ + -1, + -2, + -3 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + sger( data.M, value, data.alpha, new Float32Array( data.x ), data.strideX, data.offsetX, new Float32Array( data.y ), data.strideY, data.offsetY, new Float32Array( data.A ), data.strideA1, data.strideA2, data.offsetA ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid fifth argument', opts, function test( t ) { + var values; + var data; + var i; + + data = rm; + + values = [ + 0 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + sger( data.M, data.N, data.alpha, new Float32Array( data.x ), value, data.offsetX, new Float32Array( data.y ), data.strideY, data.offsetY, new Float32Array( data.A ), data.strideA1, data.strideA2, data.offsetA ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid eighth argument', opts, function test( t ) { + var values; + var data; + var i; + + data = rm; + + values = [ + 0 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + sger( data.M, data.N, data.alpha, new Float32Array( data.x ), data.strideX, data.offsetX, new Float32Array( data.y ), value, data.offsetY, new Float32Array( data.A ), data.strideA1, data.strideA2, data.offsetA ); + }; + } +}); + +tape( 'the function the rank 1 operation `A = α*x*y^T + A` (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rm; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function the rank 1 operation `A = α*x*y^T + A` (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cm; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a reference to the input matrix (row-major)', opts, function test( t ) { + var data; + var out; + var a; + var x; + var y; + + data = rm; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a reference to the input matrix (column-major)', opts, function test( t ) { + var data; + var out; + var a; + var x; + var y; + + data = cm; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.end(); +}); + +tape( 'if either `M` or `N` is `0`, the function returns the input matrix unchanged (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rm; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A ); + + out = sger( 0, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + out = sger( data.M, 0, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if either `M` or `N` is `0`, the function returns the input matrix unchanged (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cm; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A ); + + out = sger( 0, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + out = sger( data.M, 0, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `α` is `0.0`, the function returns the input matrix unchanged (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rm; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A ); + + out = sger( data.M, data.N, 0.0, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `α` is `0.0`, the function returns the input matrix unchanged (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cm; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A ); + + out = sger( data.M, data.N, 0.0, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `x` contains only zeros, the function returns the input matrix unchanged (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rx0; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if `x` contains only zeros, the function returns the input matrix unchanged (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cx0; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if `y` contains only zeros, the function returns the input matrix unchanged (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = ry0; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if `y` contains only zeros, the function returns the input matrix unchanged (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cy0; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying the strides of the first and second dimensions of `A` (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rsa1sa2; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying the strides of the first and second dimensions of `A` (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = csa1sa2; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a negative stride for the first dimension of `A` (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rsa1nsa2; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a negative stride for the first dimension of `A` (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = csa1nsa2; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a negative stride for the second dimension of `A` (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rsa1sa2n; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a negative stride for the second dimension of `A` (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = csa1sa2n; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports negative strides for `A` (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rsa1nsa2n; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports negative strides for `A` (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = csa1nsa2n; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying an offset parameter for `A` (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = roa; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying an offset parameter for `A` (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = coa; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying `x` and `y` strides (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxpyp; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying `x` and `y` strides (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxpyp; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative `x` stride (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxnyp; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative `x` stride (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxnyp; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative `y` stride (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxpyn; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative `y` stride (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxpyn; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying negative strides for `x` and `y` (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxnyn; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying negative strides for `x` and `y` (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxnyn; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying an offset parameter for `x` (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rox; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying an offset parameter for `x` (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cox; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying an offset parameter for `y` (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = roy; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying an offset parameter for `y` (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = coy; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports complex access patterns (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rcap; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports complex access patterns (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = ccap; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.M, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/sger/test/test.sger.native.js b/lib/node_modules/@stdlib/blas/base/sger/test/test.sger.native.js new file mode 100644 index 000000000000..2dec635ddbb3 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/test/test.sger.native.js @@ -0,0 +1,662 @@ +/** +* @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. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var Float32Array = require( '@stdlib/array/float32' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var sger = tryRequire( resolve( __dirname, './../lib/sger.native.js' ) ); +var opts = { + 'skip': ( sger instanceof Error ) +}; + + +// FIXTURES // + +var cm = require( './fixtures/column_major.json' ); +var cxpyp = require( './fixtures/column_major_xpyp.json' ); +var cxnyp = require( './fixtures/column_major_xnyp.json' ); +var cxpyn = require( './fixtures/column_major_xpyn.json' ); +var cxnyn = require( './fixtures/column_major_xnyn.json' ); +var cx0 = require( './fixtures/column_major_x_zeros.json' ); +var cy0 = require( './fixtures/column_major_y_zeros.json' ); + +var rm = require( './fixtures/row_major.json' ); +var rxpyp = require( './fixtures/row_major_xpyp.json' ); +var rxnyp = require( './fixtures/row_major_xnyp.json' ); +var rxpyn = require( './fixtures/row_major_xpyn.json' ); +var rxnyn = require( './fixtures/row_major_xnyn.json' ); +var rx0 = require( './fixtures/row_major_x_zeros.json' ); +var ry0 = require( './fixtures/row_major_y_zeros.json' ); + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof sger, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 10', opts, function test( t ) { + t.strictEqual( sger.length, 10, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid first argument', opts, function test( t ) { + var values; + var data; + var i; + + data = rm; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop' + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + sger( value, data.M, data.N, data.alpha, new Float32Array( data.x ), data.strideX, new Float32Array( data.y ), data.strideY, new Float32Array( data.A ), data.LDA ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid second argument', opts, function test( t ) { + var values; + var data; + var i; + + data = rm; + + values = [ + -1, + -2, + -3 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + sger( data.order, value, data.N, data.alpha, new Float32Array( data.x ), data.strideX, new Float32Array( data.y ), data.strideY, new Float32Array( data.A ), data.LDA ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid third argument', opts, function test( t ) { + var values; + var data; + var i; + + data = rm; + + values = [ + -1, + -2, + -3 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + sger( data.order, data.M, value, data.alpha, new Float32Array( data.x ), data.strideX, new Float32Array( data.y ), data.strideY, new Float32Array( data.A ), data.LDA ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid sixth argument', opts, function test( t ) { + var values; + var data; + var i; + + data = rm; + + values = [ + 0 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + sger( data.order, data.M, data.N, data.alpha, new Float32Array( data.x ), value, new Float32Array( data.y ), data.strideY, new Float32Array( data.A ), data.LDA ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid eighth argument', opts, function test( t ) { + var values; + var data; + var i; + + data = rm; + + values = [ + 0 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + sger( data.order, data.M, data.N, data.alpha, new Float32Array( data.x ), data.strideX, new Float32Array( data.y ), value, new Float32Array( data.A ), data.LDA ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid tenth argument', opts, function test( t ) { + var values; + var data; + var i; + + data = rm; + + values = [ + -3, + -2, + -1, + 0, + 1 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + sger( data.order, data.M, data.N, data.alpha, new Float32Array( data.x ), data.strideX, new Float32Array( data.y ), data.strideY, new Float32Array( data.A ), value ); + }; + } +}); + +tape( 'the function the rank 1 operation `A = α*x*y^T + A` (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rm; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function the rank 1 operation `A = α*x*y^T + A` (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cm; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a reference to the input matrix (row-major)', opts, function test( t ) { + var data; + var out; + var a; + var x; + var y; + + data = rm; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a reference to the input matrix (column-major)', opts, function test( t ) { + var data; + var out; + var a; + var x; + var y; + + data = cm; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.end(); +}); + +tape( 'if either `M` or `N` is `0`, the function returns the input matrix unchanged (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rm; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A ); + + out = sger( data.order, 0, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + out = sger( data.order, data.M, 0, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if either `M` or `N` is `0`, the function returns the input matrix unchanged (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cm; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A ); + + out = sger( data.order, 0, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + out = sger( data.order, data.M, 0, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `α` is `0.0`, the function returns the input matrix unchanged (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rm; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A ); + + out = sger( data.order, data.M, data.N, 0.0, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `α` is `0.0`, the function returns the input matrix unchanged (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cm; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A ); + + out = sger( data.order, data.M, data.N, 0.0, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `x` contains only zeros, the function returns the input matrix unchanged (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rx0; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if `x` contains only zeros, the function returns the input matrix unchanged (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cx0; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if `y` contains only zeros, the function returns the input matrix unchanged (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = ry0; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if `y` contains only zeros, the function returns the input matrix unchanged (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cy0; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying `x` and `y` strides (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxpyp; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying `x` and `y` strides (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxpyp; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative `x` stride (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxnyp; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative `x` stride (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxnyp; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative `y` stride (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxpyn; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative `y` stride (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxpyn; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports complex access patterns (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxnyn; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports complex access patterns (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxnyn; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = sger( data.order, data.M, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); From c4523f9b166cf7b7425ea00bea5369c22ad44d02 Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Tue, 1 Jul 2025 08:16:06 +0000 Subject: [PATCH 15/24] chore: update copyright years --- lib/node_modules/@stdlib/blas/base/sger/README.md | 2 +- lib/node_modules/@stdlib/blas/base/sger/binding.gyp | 2 +- lib/node_modules/@stdlib/blas/base/sger/examples/c/example.c | 2 +- lib/node_modules/@stdlib/blas/base/sger/include.gypi | 2 +- .../@stdlib/blas/base/sger/include/stdlib/blas/base/sger.h | 2 +- .../blas/base/sger/include/stdlib/blas/base/sger_cblas.h | 2 +- .../blas/base/sger/include/stdlib/blas/base/sger_fortran.h | 2 +- lib/node_modules/@stdlib/blas/base/sger/lib/index.js | 2 +- lib/node_modules/@stdlib/blas/base/sger/lib/native.js | 2 +- lib/node_modules/@stdlib/blas/base/sger/lib/ndarray.js | 2 +- lib/node_modules/@stdlib/blas/base/sger/lib/ndarray.native.js | 2 +- lib/node_modules/@stdlib/blas/base/sger/lib/sger.js | 2 +- lib/node_modules/@stdlib/blas/base/sger/lib/sger.native.js | 2 +- lib/node_modules/@stdlib/blas/base/sger/src/Makefile | 2 +- lib/node_modules/@stdlib/blas/base/sger/src/addon.c | 2 +- lib/node_modules/@stdlib/blas/base/sger/src/sger.c | 2 +- lib/node_modules/@stdlib/blas/base/sger/src/sger.f | 2 +- lib/node_modules/@stdlib/blas/base/sger/src/sger_cblas.c | 2 +- lib/node_modules/@stdlib/blas/base/sger/src/sger_f.c | 2 +- 19 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sger/README.md b/lib/node_modules/@stdlib/blas/base/sger/README.md index 7e61bae4277e..da5618312e19 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/README.md +++ b/lib/node_modules/@stdlib/blas/base/sger/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2024 The Stdlib Authors. +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. diff --git a/lib/node_modules/@stdlib/blas/base/sger/binding.gyp b/lib/node_modules/@stdlib/blas/base/sger/binding.gyp index 02a2799da097..08de71a2020e 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/binding.gyp +++ b/lib/node_modules/@stdlib/blas/base/sger/binding.gyp @@ -1,6 +1,6 @@ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# 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. diff --git a/lib/node_modules/@stdlib/blas/base/sger/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/sger/examples/c/example.c index dae2cc54c955..8cb3fe7fb989 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/base/sger/examples/c/example.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/base/sger/include.gypi b/lib/node_modules/@stdlib/blas/base/sger/include.gypi index 497aeca15320..4217944b5d20 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/include.gypi +++ b/lib/node_modules/@stdlib/blas/base/sger/include.gypi @@ -1,6 +1,6 @@ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# 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. diff --git a/lib/node_modules/@stdlib/blas/base/sger/include/stdlib/blas/base/sger.h b/lib/node_modules/@stdlib/blas/base/sger/include/stdlib/blas/base/sger.h index 99c3edae2c58..04ecae51aed3 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/include/stdlib/blas/base/sger.h +++ b/lib/node_modules/@stdlib/blas/base/sger/include/stdlib/blas/base/sger.h @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/base/sger/include/stdlib/blas/base/sger_cblas.h b/lib/node_modules/@stdlib/blas/base/sger/include/stdlib/blas/base/sger_cblas.h index 637250babf11..316e4cd4b450 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/include/stdlib/blas/base/sger_cblas.h +++ b/lib/node_modules/@stdlib/blas/base/sger/include/stdlib/blas/base/sger_cblas.h @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/base/sger/include/stdlib/blas/base/sger_fortran.h b/lib/node_modules/@stdlib/blas/base/sger/include/stdlib/blas/base/sger_fortran.h index 6692a6aea1f3..acacac8a66a1 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/include/stdlib/blas/base/sger_fortran.h +++ b/lib/node_modules/@stdlib/blas/base/sger/include/stdlib/blas/base/sger_fortran.h @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/base/sger/lib/index.js b/lib/node_modules/@stdlib/blas/base/sger/lib/index.js index 3f1c1436cb5e..efc6f07de765 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/lib/index.js +++ b/lib/node_modules/@stdlib/blas/base/sger/lib/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/base/sger/lib/native.js b/lib/node_modules/@stdlib/blas/base/sger/lib/native.js index 602f926e056d..c9b61f6f8db9 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/lib/native.js +++ b/lib/node_modules/@stdlib/blas/base/sger/lib/native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/base/sger/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/sger/lib/ndarray.js index 5a57f104bba4..f4f1f1fa9b73 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/sger/lib/ndarray.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/base/sger/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/sger/lib/ndarray.native.js index 1549a080e20a..f264a3f69719 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/sger/lib/ndarray.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/base/sger/lib/sger.js b/lib/node_modules/@stdlib/blas/base/sger/lib/sger.js index 6816c5a7826f..56f3ae6799b3 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/lib/sger.js +++ b/lib/node_modules/@stdlib/blas/base/sger/lib/sger.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/base/sger/lib/sger.native.js b/lib/node_modules/@stdlib/blas/base/sger/lib/sger.native.js index 1f55da9da30e..31e0bc4d0ae1 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/lib/sger.native.js +++ b/lib/node_modules/@stdlib/blas/base/sger/lib/sger.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/base/sger/src/Makefile b/lib/node_modules/@stdlib/blas/base/sger/src/Makefile index bcf18aa46655..7733b6180cb4 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/src/Makefile +++ b/lib/node_modules/@stdlib/blas/base/sger/src/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# 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. diff --git a/lib/node_modules/@stdlib/blas/base/sger/src/addon.c b/lib/node_modules/@stdlib/blas/base/sger/src/addon.c index 03d2301e28aa..923825029c97 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/src/addon.c +++ b/lib/node_modules/@stdlib/blas/base/sger/src/addon.c @@ -2,7 +2,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/base/sger/src/sger.c b/lib/node_modules/@stdlib/blas/base/sger/src/sger.c index 7a1cfe78c3b5..6376a78f683e 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/src/sger.c +++ b/lib/node_modules/@stdlib/blas/base/sger/src/sger.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/base/sger/src/sger.f b/lib/node_modules/@stdlib/blas/base/sger/src/sger.f index e3fdb7ceab6d..3235e6631b6f 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/src/sger.f +++ b/lib/node_modules/@stdlib/blas/base/sger/src/sger.f @@ -1,7 +1,7 @@ !> ! @license Apache-2.0 ! -! Copyright (c) 2024 The Stdlib Authors. +! 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. diff --git a/lib/node_modules/@stdlib/blas/base/sger/src/sger_cblas.c b/lib/node_modules/@stdlib/blas/base/sger/src/sger_cblas.c index 72dbef498e45..c3d5fe7a6f5f 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/src/sger_cblas.c +++ b/lib/node_modules/@stdlib/blas/base/sger/src/sger_cblas.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/base/sger/src/sger_f.c b/lib/node_modules/@stdlib/blas/base/sger/src/sger_f.c index 71952dcfdcc5..d6dc0222dee2 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/src/sger_f.c +++ b/lib/node_modules/@stdlib/blas/base/sger/src/sger_f.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* 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. From e1260f3f04253a639e0d6135c7541771b22a9dcb Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Tue, 1 Jul 2025 13:52:31 +0530 Subject: [PATCH 16/24] chore: add Makefile --- 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 status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../blas/base/sger/examples/c/Makefile | 146 ++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/sger/examples/c/Makefile diff --git a/lib/node_modules/@stdlib/blas/base/sger/examples/c/Makefile b/lib/node_modules/@stdlib/blas/base/sger/examples/c/Makefile new file mode 100644 index 000000000000..ff5293d3059f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sger/examples/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2020 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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := example.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled examples. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean From 26506aae0cd9dced3ef5173b7e009cb5f82c8916 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Tue, 1 Jul 2025 16:11:10 +0530 Subject: [PATCH 17/24] chore: clean-up --- 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 status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/blas/base/sger/src/sger.c | 2 +- lib/node_modules/@stdlib/blas/base/sger/src/sger_ndarray.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sger/src/sger.c b/lib/node_modules/@stdlib/blas/base/sger/src/sger.c index 6376a78f683e..6478a943b699 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/src/sger.c +++ b/lib/node_modules/@stdlib/blas/base/sger/src/sger.c @@ -80,7 +80,7 @@ void API_SUFFIX(c_sger)( const CBLAS_LAYOUT layout, const CBLAS_INT M, const CBL return; } // Check whether we can avoid computation altogether... - if ( M == 0 || N == 0 || alpha == 0.0 ) { + if ( M == 0 || N == 0 || alpha == 0.0f ) { return; } ox = stdlib_strided_stride2offset( N, strideX ); diff --git a/lib/node_modules/@stdlib/blas/base/sger/src/sger_ndarray.c b/lib/node_modules/@stdlib/blas/base/sger/src/sger_ndarray.c index 449539ec88b7..b092222722ce 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/src/sger_ndarray.c +++ b/lib/node_modules/@stdlib/blas/base/sger/src/sger_ndarray.c @@ -140,7 +140,7 @@ void API_SUFFIX(c_sger_ndarray)( const CBLAS_INT M, const CBLAS_INT N, const flo return; } // Check whether we can avoid computation altogether... - if ( M == 0 || N == 0 || alpha == 0.0 ) { + if ( M == 0 || N == 0 || alpha == 0.0f ) { return; } // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... @@ -181,7 +181,7 @@ void API_SUFFIX(c_sger_ndarray)( const CBLAS_INT M, const CBLAS_INT N, const flo ia = offsetA; for ( i1 = 0; i1 < S1; i1++ ) { // Check whether we can avoid the inner loop entirely... - if ( y[ iy ] == 0.0 ) { + if ( y[ iy ] == 0.0f ) { ia += da0 * S0; } else { tmp = alpha * y[ iy ]; From 836f39d174c04b912b93e6159ee5fd610985f075 Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Tue, 1 Jul 2025 10:45:51 +0000 Subject: [PATCH 18/24] chore: update copyright years --- lib/node_modules/@stdlib/blas/base/sger/examples/c/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/sger/examples/c/Makefile b/lib/node_modules/@stdlib/blas/base/sger/examples/c/Makefile index ff5293d3059f..25ced822f96a 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/examples/c/Makefile +++ b/lib/node_modules/@stdlib/blas/base/sger/examples/c/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2020 The Stdlib Authors. +# 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. From 16cb1663ad05c41b4df5a4cd7dcf0aa205df8ce2 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Tue, 1 Jul 2025 16:18:23 +0530 Subject: [PATCH 19/24] chore: update header file --- 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 status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: missing_dependencies - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/blas/base/sger/examples/c/example.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/sger/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/sger/examples/c/example.c index 8cb3fe7fb989..af6649516a82 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/base/sger/examples/c/example.c @@ -16,7 +16,7 @@ * limitations under the License. */ -#include "stdlib/blas/base/dger.h" +#include "stdlib/blas/base/sger.h" #include "stdlib/blas/base/shared.h" #include From 8a4b8547f47b9e77810016a809c35d6f4d1fcab6 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Tue, 1 Jul 2025 16:23:06 +0530 Subject: [PATCH 20/24] chore: update examples --- 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 status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: missing_dependencies - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/blas/base/sger/examples/c/example.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/sger/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/sger/examples/c/example.c index af6649516a82..99536b51f8a1 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/base/sger/examples/c/example.c @@ -50,7 +50,7 @@ int main( void ) { } // Perform operation using alterntive indexing semantics: - c_sger( CblasRowMajor, M, N, 1.0, x, strideX, 0, y, 0, strideY, A, N, 1, 0 ); + c_sger_ndarray( M, N, 1.0, x, strideX, 0, y, 0, strideY, A, N, 1, 0 ); // Print the result: for ( int i = 0; i < M; i++ ) { From afd5fc7890aeee5043e5c1957fe1438fdc48fb12 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Tue, 1 Jul 2025 16:26:54 +0530 Subject: [PATCH 21/24] chore: update examples --- 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 status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: missing_dependencies - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/blas/base/sger/examples/c/example.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/sger/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/sger/examples/c/example.c index 99536b51f8a1..246e6a06d3c0 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/base/sger/examples/c/example.c @@ -50,7 +50,7 @@ int main( void ) { } // Perform operation using alterntive indexing semantics: - c_sger_ndarray( M, N, 1.0, x, strideX, 0, y, 0, strideY, A, N, 1, 0 ); + c_sger_ndarray( M, N, 1.0, x, strideX, 0, y, strideY, 0, A, N, 1, 0 ); // Print the result: for ( int i = 0; i < M; i++ ) { From 3bf56251628cbd32c3e39960755cec969b541a6d Mon Sep 17 00:00:00 2001 From: Athan Date: Tue, 1 Jul 2025 11:17:17 -0700 Subject: [PATCH 22/24] fix: ensure single-precision --- 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 status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/blas/base/sger/src/sger.f | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sger/src/sger.f b/lib/node_modules/@stdlib/blas/base/sger/src/sger.f index 3235e6631b6f..058c4b431004 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/src/sger.f +++ b/lib/node_modules/@stdlib/blas/base/sger/src/sger.f @@ -64,17 +64,17 @@ subroutine sger( M, N, alpha, X, strideX, Y, strideY, A, LDA ) implicit none ! .. ! Internal parameters: - integer, parameter :: dp=kind(0.0d0) ! single-precision + integer, parameter :: sp=kind(0.0) ! single-precision ! .. ! Scalar arguments: - real(dp) :: alpha + real(sp) :: alpha integer :: strideX, strideY, LDA, M, N ! .. ! Array arguments: - real(dp) :: A(LDA,*), X(*), Y(*) + real(sp) :: A(LDA,*), X(*), Y(*) ! .. ! Local scalars: - real(dp) :: temp + real(sp) :: temp integer :: i, info, ix, j, jy, kx ! .. ! External functions: @@ -107,7 +107,7 @@ end subroutine xerbla end if ! .. ! Check whether we can avoid computation altogether... - if ( M == 0 .OR. N == 0 .OR. alpha == 0.0d0 ) then + if ( M == 0 .OR. N == 0 .OR. alpha == 0.0 ) then return end if ! .. @@ -118,7 +118,7 @@ end subroutine xerbla end if if ( strideX == 1 ) then do j = 1, N - if ( Y( jy ) /= 0.0d0 ) then + if ( Y( jy ) /= 0.0 ) then temp = alpha * Y( jy ) do i = 1, M A( i, j ) = A( i, j ) + ( X( i ) * temp ) @@ -133,7 +133,7 @@ end subroutine xerbla kx = 1 - ( (M-1) * strideX ) end if do j = 1, N - if ( Y( jy ) /= 0.0d0 ) then + if ( Y( jy ) /= 0.0 ) then temp = alpha * Y( jy ) ix = kx do i = 1, M From b8edf11469751a9237ec1a0a5e4661d74646a27c Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Tue, 1 Jul 2025 23:55:34 +0530 Subject: [PATCH 23/24] chore: clean-up --- 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 status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/blas/base/sger/benchmark/fortran/benchmark.length.f | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/sger/benchmark/fortran/benchmark.length.f b/lib/node_modules/@stdlib/blas/base/sger/benchmark/fortran/benchmark.length.f index 6eb0d9bf5b7d..b768b93b2bef 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/benchmark/fortran/benchmark.length.f +++ b/lib/node_modules/@stdlib/blas/base/sger/benchmark/fortran/benchmark.length.f @@ -156,7 +156,7 @@ end subroutine sger ! .. j = 1 do i = 1, iterations - call sger( N, N, 1.0d0, x, 1, y, 1, A, N ) + call sger( N, N, 1.0, x, 1, y, 1, A, N ) j = mod( i, N ) + 1 if ( A( j, j ) /= A( j, j ) ) then print '(A)', 'should not return NaN' From abb8d95c28d860c55bf008693a3b092abb6153b1 Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 2 Jul 2025 02:55:28 -0700 Subject: [PATCH 24/24] chore: clean-up --- 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 status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: passed - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/blas/base/sger/README.md | 46 +++++++++---------- .../blas/base/sger/examples/c/example.c | 14 +++--- .../@stdlib/blas/base/sger/examples/index.js | 2 +- .../@stdlib/blas/base/sger/lib/sger.native.js | 2 +- .../@stdlib/blas/base/sger/src/sger.f | 8 ++-- .../@stdlib/blas/base/sger/src/sger_ndarray.c | 2 +- 6 files changed, 37 insertions(+), 37 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sger/README.md b/lib/node_modules/@stdlib/blas/base/sger/README.md index da5618312e19..a442ef9f5014 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/README.md +++ b/lib/node_modules/@stdlib/blas/base/sger/README.md @@ -57,9 +57,9 @@ The function has the following parameters: - **M**: number of rows in the matrix `A`. - **N**: number of columns in the matrix `A`. - **α**: scalar constant. -- **x**: input [`Float32Array`][mdn-float32array]. +- **x**: an `M` element [`Float32Array`][mdn-float32array]. - **sx**: stride length for `x`. -- **y**: output [`Float32Array`][mdn-float32array]. +- **y**: an `N` element [`Float32Array`][mdn-float32array]. - **sy**: stride length for `y`. - **A**: input matrix stored in linear memory as a [`Float32Array`][mdn-float32array]. - **lda**: stride of the first dimension of `A` (leading dimension of `A`). @@ -208,21 +208,21 @@ console.log( A ); #### c_sger( layout, M, N, alpha, \*X, strideX, \*Y, strideY, \*A, LDA ) -Performs the rank 1 operation `A = alpha*x*y^T + A`, where `alpha` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector, and `A` is an `M`-by-`N` matrix. +Performs the rank 1 operation `A = alpha*x*y^T + A`, where `alpha` is a scalar, `X` is an `M` element vector, `Y` is an `N` element vector, and `A` is an `M`-by-`N` matrix. ```c #include "stdlib/blas/base/shared.h" float A[ 3*4 ] = { - 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0 + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f }; -const float x[ 3 ] = { 1.0, 4.0, 0.0 }; -const float y[ 4 ] = { 0.0, 1.0, 2.0, 3.0 }; +const float x[ 3 ] = { 1.0f, 4.0f, 0.0f }; +const float y[ 4 ] = { 0.0f, 1.0f, 2.0f, 3.0f }; -c_sger( CblasRowMajor, 3, 4, 1.0, x, 1, y, 1, A, 4 ); +c_sger( CblasRowMajor, 3, 4, 1.0f, x, 1, y, 1, A, 4 ); ``` The function accepts the following arguments: @@ -244,21 +244,21 @@ void c_sger( const CBLAS_LAYOUT layout, const CBLAS_INT M, const CBLAS_INT N, co #### c_sger_ndarray( M, N, alpha, \*X, sx, ox, \*Y, sy, oy, \*A, sa1, sa2, oa ) -Performs the rank 1 operation `A = alpha*x*y^T + A`, using alternative indexing semantics and where `alpha` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector, and `A` is an `M`-by-`N` matrix. +Performs the rank 1 operation `A = alpha*x*y^T + A`, using alternative indexing semantics and where `alpha` is a scalar, `X` is an `M` element vector, `Y` is an `N` element vector, and `A` is an `M`-by-`N` matrix. ```c #include "stdlib/blas/base/shared.h" float A[ 3*4 ] = { - 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0 + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f }; -const float x[ 3 ] = { 1.0, 4.0, 0.0 }; -const float y[ 4 ] = { 0.0, 1.0, 2.0, 3.0 }; +const float x[ 3 ] = { 1.0f, 4.0f, 0.0f }; +const float y[ 4 ] = { 0.0f, 1.0f, 2.0f, 3.0f }; -c_sger_ndarray( 3, 4, 1.0, x, 1, 0, y, 1, 0, A, 4, 1, 0 ); +c_sger_ndarray( 3, 4, 1.0f, x, 1, 0, y, 1, 0, A, 4, 1, 0 ); ``` The function accepts the following arguments: @@ -308,13 +308,13 @@ void c_sger( onst CBLAS_INT M, const CBLAS_INT N, const float alpha, const float int main( void ) { // Define a 3x4 matrix stored in row-major order: float A[ 3*4 ] = { - 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0 + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f }; // Define `x` and `y^T` vectors: - const float x[ 3 ] = { 1.0, 4.0, 0.0 }; // M - const float y[ 4 ] = { 0.0, 1.0, 2.0, 3.0 }; // N + const float x[ 3 ] = { 1.0f, 4.0f, 0.0f }; // M + const float y[ 4 ] = { 0.0f, 1.0f, 2.0f, 3.0f }; // N // Specify the number of rows and columns: const int M = 3; @@ -325,7 +325,7 @@ int main( void ) { const int strideY = 1; // Perform operation: - c_sger( CblasRowMajor, M, N, 1.0, x, strideX, y, strideY, A, N ); + c_sger( CblasRowMajor, M, N, 1.0f, x, strideX, y, strideY, A, N ); // Print the result: for ( int i = 0; i < M; i++ ) { @@ -335,7 +335,7 @@ int main( void ) { } // Perform operation using alterntive indexing semantics: - c_sger( CblasRowMajor, M, N, 1.0, x, strideX, 0, y, 0, strideY, A, N, 1, 0 ); + c_sger( CblasRowMajor, M, N, 1.0f, x, strideX, 0, y, 0, strideY, A, N, 1, 0 ); // Print the result: for ( int i = 0; i < M; i++ ) { diff --git a/lib/node_modules/@stdlib/blas/base/sger/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/sger/examples/c/example.c index 246e6a06d3c0..b06f929d795b 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/base/sger/examples/c/example.c @@ -23,13 +23,13 @@ int main( void ) { // Define a 3x4 matrix stored in row-major order: float A[ 3*4 ] = { - 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0 + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f }; // Define `x` and `y^T` vectors: - const float x[ 3 ] = { 1.0, 4.0, 0.0 }; // M - const float y[ 4 ] = { 0.0, 1.0, 2.0, 3.0 }; // N + const float x[ 3 ] = { 1.0f, 4.0f, 0.0f }; // M + const float y[ 4 ] = { 0.0f, 1.0f, 2.0f, 3.0f }; // N // Specify the number of rows and columns: const int M = 3; @@ -40,7 +40,7 @@ int main( void ) { const int strideY = 1; // Perform operation: - c_sger( CblasRowMajor, M, N, 1.0, x, strideX, y, strideY, A, N ); + c_sger( CblasRowMajor, M, N, 1.0f, x, strideX, y, strideY, A, N ); // Print the result: for ( int i = 0; i < M; i++ ) { @@ -50,7 +50,7 @@ int main( void ) { } // Perform operation using alterntive indexing semantics: - c_sger_ndarray( M, N, 1.0, x, strideX, 0, y, strideY, 0, A, N, 1, 0 ); + c_sger_ndarray( M, N, 1.0f, x, strideX, 0, y, strideY, 0, A, N, 1, 0 ); // Print the result: for ( int i = 0; i < M; i++ ) { diff --git a/lib/node_modules/@stdlib/blas/base/sger/examples/index.js b/lib/node_modules/@stdlib/blas/base/sger/examples/index.js index e956d5480a5a..e658dba12ee2 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/examples/index.js +++ b/lib/node_modules/@stdlib/blas/base/sger/examples/index.js @@ -36,4 +36,4 @@ sger( 'row-major', M, N, 1.0, x, 1, y, 1, A, N ); console.log( A ); sger.ndarray( M, N, 1.0, x, 1, 0, y, 1, 0, A, 1, M, 0 ); -console.log(A); +console.log( A ); diff --git a/lib/node_modules/@stdlib/blas/base/sger/lib/sger.native.js b/lib/node_modules/@stdlib/blas/base/sger/lib/sger.native.js index 31e0bc4d0ae1..e1235b6a1714 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/lib/sger.native.js +++ b/lib/node_modules/@stdlib/blas/base/sger/lib/sger.native.js @@ -33,7 +33,7 @@ var addon = require( './../src/addon.node' ); /** * Performs the rank 1 operation `A = α*x*y^T + A`, where `α` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector, and `A` is an `M` by `N` matrix. * -* @param {*} order - storage layout +* @param {string} order - storage layout * @param {NonNegativeInteger} M - number of rows in the matrix `A` * @param {NonNegativeInteger} N - number of columns in the matrix `A` * @param {number} alpha - scalar constant diff --git a/lib/node_modules/@stdlib/blas/base/sger/src/sger.f b/lib/node_modules/@stdlib/blas/base/sger/src/sger.f index 058c4b431004..afe6c2553a91 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/src/sger.f +++ b/lib/node_modules/@stdlib/blas/base/sger/src/sger.f @@ -52,12 +52,12 @@ ! ! @param {integer} M - number of rows in the matrix `A` ! @param {integer} N - number of columns in the matrix `A` -! @param {single} alpha - scalar constant -! @param {Array} X - an `M` element vector +! @param {real} alpha - scalar constant +! @param {Array} X - an `M` element vector ! @param {integer} strideX - stride length for `X` -! @param {Array} Y - an `N` element vector +! @param {Array} Y - an `N` element vector ! @param {integer} strideY - stride length for `Y` -! @param {Array} A - matrix of coefficients +! @param {Array} A - matrix of coefficients ! @param {integer} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) !< subroutine sger( M, N, alpha, X, strideX, Y, strideY, A, LDA ) diff --git a/lib/node_modules/@stdlib/blas/base/sger/src/sger_ndarray.c b/lib/node_modules/@stdlib/blas/base/sger/src/sger_ndarray.c index b092222722ce..1d0c189f8ee4 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/src/sger_ndarray.c +++ b/lib/node_modules/@stdlib/blas/base/sger/src/sger_ndarray.c @@ -98,7 +98,7 @@ * @param strideY stride length for `Y` * @param offsetY starting index for `Y` * @param A matrix of coefficients -* @param strideA1 stride length of the first dimnension of `A` +* @param strideA1 stride length of the first dimension of `A` * @param strideA2 stride length of the second dimension of `A` * @param offsetA starting index for `A` */