From 37909ad31b89b7404a570dab9c7cf1b46d5bed5b Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Wed, 26 Mar 2025 18:17:34 +0530 Subject: [PATCH 01/38] fix: add javascript implementation for /blas/base/dger --- 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: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: 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: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../@stdlib/blas/base/dger/README.md | 132 ++- .../blas/base/dger/benchmark/benchmark.js | 105 +++ .../base/dger/benchmark/benchmark.ndarray.js | 105 +++ .../@stdlib/blas/base/dger/binding.gyp | 265 ------ .../@stdlib/blas/base/dger/docs/repl.txt | 132 +++ .../blas/base/dger/docs/types/index.d.ts | 129 +++ .../@stdlib/blas/base/dger/docs/types/test.ts | 449 ++++++++++ .../blas/base/dger/examples/c/Makefile | 0 .../blas/base/dger/examples/c/example.c | 0 .../@stdlib/blas/base/dger/examples/index.js | 41 +- .../@stdlib/blas/base/dger/include.gypi | 70 -- .../base/dger/include/stdlib/blas/base/dger.h | 43 - .../include/stdlib/blas/base/dger_cblas.h | 43 - .../include/stdlib/blas/base/dger_fortran.h | 41 - .../@stdlib/blas/base/dger/lib/base.js | 114 +++ .../@stdlib/blas/base/dger/lib/dger.js | 74 +- .../@stdlib/blas/base/dger/lib/dger.native.js | 72 -- .../@stdlib/blas/base/dger/lib/index.js | 30 +- .../@stdlib/blas/base/dger/lib/main.js | 0 .../@stdlib/blas/base/dger/lib/native.js | 35 - .../@stdlib/blas/base/dger/lib/ndarray.js | 66 +- .../blas/base/dger/lib/ndarray.native.js | 86 -- .../@stdlib/blas/base/dger/manifest.json | 433 ---------- .../@stdlib/blas/base/dger/package.json | 4 +- .../@stdlib/blas/base/dger/src/Makefile | 70 -- .../@stdlib/blas/base/dger/src/addon.c | 61 -- .../@stdlib/blas/base/dger/src/dger.c | 158 ---- .../@stdlib/blas/base/dger/src/dger.f | 148 ---- .../@stdlib/blas/base/dger/src/dger_cblas.c | 39 - .../@stdlib/blas/base/dger/src/dger_f.c | 55 -- .../base/dger/test/fixtures/column_major.json | 18 + .../column_major_complex_access_pattern.json | 16 + .../dger/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 + .../dger/test/fixtures/column_major_xnyn.json | 18 + .../dger/test/fixtures/column_major_xnyp.json | 18 + .../dger/test/fixtures/column_major_xpyn.json | 18 + .../dger/test/fixtures/column_major_xpyp.json | 18 + .../base/dger/test/fixtures/row_major.json | 18 + .../row_major_complex_access_pattern.json | 16 + .../base/dger/test/fixtures/row_major_oa.json | 16 + .../dger/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 + .../dger/test/fixtures/row_major_xnyn.json | 18 + .../dger/test/fixtures/row_major_xnyp.json | 18 + .../dger/test/fixtures/row_major_xpyn.json | 18 + .../dger/test/fixtures/row_major_xpyp.json | 18 + .../@stdlib/blas/base/dger/test/test.dger.js | 534 ++++++++++++ .../@stdlib/blas/base/dger/test/test.js | 4 +- .../blas/base/dger/test/test.ndarray.js | 784 ++++++++++++++++++ 55 files changed, 2965 insertions(+), 1729 deletions(-) mode change 100644 => 100755 lib/node_modules/@stdlib/blas/base/dger/README.md create mode 100755 lib/node_modules/@stdlib/blas/base/dger/benchmark/benchmark.js create mode 100755 lib/node_modules/@stdlib/blas/base/dger/benchmark/benchmark.ndarray.js delete mode 100644 lib/node_modules/@stdlib/blas/base/dger/binding.gyp create mode 100644 lib/node_modules/@stdlib/blas/base/dger/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/base/dger/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/base/dger/docs/types/test.ts mode change 100644 => 100755 lib/node_modules/@stdlib/blas/base/dger/examples/c/Makefile mode change 100644 => 100755 lib/node_modules/@stdlib/blas/base/dger/examples/c/example.c mode change 100644 => 100755 lib/node_modules/@stdlib/blas/base/dger/examples/index.js delete mode 100644 lib/node_modules/@stdlib/blas/base/dger/include.gypi delete mode 100644 lib/node_modules/@stdlib/blas/base/dger/include/stdlib/blas/base/dger.h delete mode 100644 lib/node_modules/@stdlib/blas/base/dger/include/stdlib/blas/base/dger_cblas.h delete mode 100644 lib/node_modules/@stdlib/blas/base/dger/include/stdlib/blas/base/dger_fortran.h create mode 100755 lib/node_modules/@stdlib/blas/base/dger/lib/base.js mode change 100644 => 100755 lib/node_modules/@stdlib/blas/base/dger/lib/dger.js delete mode 100644 lib/node_modules/@stdlib/blas/base/dger/lib/dger.native.js mode change 100644 => 100755 lib/node_modules/@stdlib/blas/base/dger/lib/index.js mode change 100644 => 100755 lib/node_modules/@stdlib/blas/base/dger/lib/main.js delete mode 100644 lib/node_modules/@stdlib/blas/base/dger/lib/native.js mode change 100644 => 100755 lib/node_modules/@stdlib/blas/base/dger/lib/ndarray.js delete mode 100644 lib/node_modules/@stdlib/blas/base/dger/lib/ndarray.native.js delete mode 100644 lib/node_modules/@stdlib/blas/base/dger/manifest.json mode change 100644 => 100755 lib/node_modules/@stdlib/blas/base/dger/package.json delete mode 100644 lib/node_modules/@stdlib/blas/base/dger/src/Makefile delete mode 100644 lib/node_modules/@stdlib/blas/base/dger/src/addon.c delete mode 100644 lib/node_modules/@stdlib/blas/base/dger/src/dger.c delete mode 100644 lib/node_modules/@stdlib/blas/base/dger/src/dger.f delete mode 100644 lib/node_modules/@stdlib/blas/base/dger/src/dger_cblas.c delete mode 100644 lib/node_modules/@stdlib/blas/base/dger/src/dger_f.c create mode 100755 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major.json create mode 100755 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_complex_access_pattern.json create mode 100755 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_oa.json create mode 100755 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_sa1_sa2.json create mode 100755 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_sa1_sa2n.json create mode 100755 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_sa1n_sa2.json create mode 100755 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_sa1n_sa2n.json create mode 100755 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_xnyn.json create mode 100755 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_xnyp.json create mode 100755 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_xpyn.json create mode 100755 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_xpyp.json create mode 100755 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major.json create mode 100755 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_complex_access_pattern.json create mode 100755 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_oa.json create mode 100755 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_sa1_sa2.json create mode 100755 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_sa1_sa2n.json create mode 100755 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_sa1n_sa2.json create mode 100755 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_sa1n_sa2n.json create mode 100755 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_xnyn.json create mode 100755 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_xnyp.json create mode 100755 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_xpyn.json create mode 100755 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_xpyp.json create mode 100755 lib/node_modules/@stdlib/blas/base/dger/test/test.dger.js mode change 100644 => 100755 lib/node_modules/@stdlib/blas/base/dger/test/test.js create mode 100755 lib/node_modules/@stdlib/blas/base/dger/test/test.ndarray.js diff --git a/lib/node_modules/@stdlib/blas/base/dger/README.md b/lib/node_modules/@stdlib/blas/base/dger/README.md old mode 100644 new mode 100755 index 679b9ef2fb63..e6663f4db5a6 --- a/lib/node_modules/@stdlib/blas/base/dger/README.md +++ b/lib/node_modules/@stdlib/blas/base/dger/README.md @@ -20,33 +20,112 @@ limitations under the License. # dger -> TODO. +> Perform the rank 1 operation `A = α*x*y^T + A`. -
+
-TODO +## Usage -
+```javascript +var dger = require( '@stdlib/blas/base/dger' ); +``` - +#### dger( 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. -## Usage +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var x = new Float64Array( [ 1.0, 1.0 ] ); +var y = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + +dger( '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 [`Float64Array`][mdn-float64array]. +- **sx**: index increment for `x`. +- **y**: output [`Float64Array`][mdn-float64array]. +- **sy**: index increment for `y`. +- **A**: input matrix stored in linear memory as a [`Float64Array`][mdn-float64array]. +- **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 dger = require( '@stdlib/blas/base/dger' ); +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] ); +var x = new Float64Array( [ 1.0, 0.0, 1.0, 0.0 ] ); +var y = new Float64Array( [ 1.0, 0.0, 1.0, 0.0, 1.0, 0.0 ] ); + +dger( '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 ] ``` -#### TODO +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. -TODO + ```javascript -/* to-do */ +var Float64Array = require( '@stdlib/array/float64' ); + +// Initial arrays... +var x0 = new Float64Array( [ 0.0, 1.0, 1.0 ] ); +var y0 = new Float64Array( [ 0.0, 1.0, 1.0, 1.0 ] ); +var A = new Float64Array( [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] ); + +// Create offset views... +var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var y1 = new Float64Array( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +dger( '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 ] ``` -TODO +#### dger.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 Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var x = new Float64Array( [ 1.0, 1.0 ] ); +var y = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + +dger.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 Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] ); +var x = new Float64Array( [ 1.0, 0.0, 1.0, 0.0 ] ); +var y = new Float64Array( [ 1.0, 0.0, 1.0, 0.0, 1.0, 0.0 ] ); + +dger.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 ] +```
@@ -56,7 +135,7 @@ TODO ## Notes -- `dger()` corresponds to the [BLAS][blas] level 2 function [`dger`][dger]. +- `dger()` corresponds to the [BLAS][blas] level 2 function [`dger`][blas-dger].
@@ -69,7 +148,26 @@ TODO ```javascript -/* to-do */ +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var dger = require( '@stdlib/blas/base/dger' ); + +var opts = { + 'dtype': 'float64' +}; + +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 ); + +dger( 'row-major', M, N, 1.0, x, 1, y, 1, A, N ); +console.log( A ); + +dger.ndarray( M, N, 1.0, x, 1, 0, y, 1, 0, A, 1, M, 0 ); +console.log(A); + ``` @@ -160,7 +258,11 @@ TODO [blas]: http://www.netlib.org/blas -[dger]: https://www.netlib.org/lapack/explore-html/dc/da8/dger_8f_source.html +[blas-dger]: https://www.netlib.org/lapack/explore-html-3.6.1/d7/d15/group__double__blas__level2_ga458222e01b4d348e9b52b9343d52f828.html + +[mdn-float64array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array + +[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray diff --git a/lib/node_modules/@stdlib/blas/base/dger/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/dger/benchmark/benchmark.js new file mode 100755 index 000000000000..3d20265c4ee4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var pkg = require( './../package.json' ).name; +var dger = require( './../lib/dger.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// 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 = dger( 'row-major', N, N, 1.0, x, 1, y, 1, A, N ); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( 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/dger/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/dger/benchmark/benchmark.ndarray.js new file mode 100755 index 000000000000..9c26e795904b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var pkg = require( './../package.json' ).name; +var dger = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// 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 = dger( N, N, 1.0, x, 1, 0, y, 1, 0, A, N, 1, 0 ); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( 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/dger/binding.gyp b/lib/node_modules/@stdlib/blas/base/dger/binding.gyp deleted file mode 100644 index 02a2799da097..000000000000 --- a/lib/node_modules/@stdlib/blas/base/dger/binding.gyp +++ /dev/null @@ -1,265 +0,0 @@ -# @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/dger/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/dger/docs/repl.txt new file mode 100644 index 000000000000..ffd73eded85e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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: Float64Array + First input vector. + + sx: integer + Index increment for `x`. + + y: Float64Array + Second input vector. + + sy: integer + Index increment for `y`. + + A: Float64Array + Input Matrix. + + lda: integer + Stride of the first dimension of `A` (a.k.a., leading dimension of the + matrix `A`). + + Returns + ------- + A: Float64Array + Input Matrix. + + Examples + -------- + // Standard usage: + > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] ); + > var y = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] ); + > var A = new {{alias:@stdlib/array/float64}}( [ 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/float64}}( [ 1.0, 1.0 ] ); + > y = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] ); + > A = new {{alias:@stdlib/array/float64}}( [ 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: Float64Array + First input vector. + + sx: integer + Index increment for `x`. + + ox: integer + Starting index for `x`. + + y: Float64Array + Second input vector. + + sy: integer + Index increment for `y`. + + oy: integer + Starting index for `y`. + + A: Float64Array + 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: Float64Array + Input Matrix. + + Examples + -------- + > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] ); + > var y = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] ); + > var A = new {{alias:@stdlib/array/float64}}( [ 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/dger/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/dger/docs/types/index.d.ts new file mode 100644 index 000000000000..f3ff52bbbb05 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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 `dger`. +*/ +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 Float64Array = require( '@stdlib/array/float64' ); + * + * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + * var x = new Float64Array( [ 1.0, 1.0 ] ); + * var y = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + * + * dger( '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: Float64Array, strideX: number, y: Float64Array, strideY: number, A: Float64Array, LDA: number ): Float64Array; + + /** + * 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 Float64Array = require( '@stdlib/array/float64' ); + * + * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + * var x = new Float64Array( [ 1.0, 1.0 ] ); + * var y = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + * + * dger.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: Float64Array, strideX: number, offsetX: number, y: Float64Array, strideY: number, offsetY: number, A: Float64Array, strideA1: number, strideA2: number, offsetA: number ): Float64Array; +} + +/** +* 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 Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] ); +* var x = new Float64Array( [ 1.0, 1.0 ] ); +* var y = new Float64Array( [ 1.0, 1.0, 1.0 ] ); +* +* dger( '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 Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] ); +* var x = new Float64Array( [ 1.0, 1.0 ] ); +* var y = new Float64Array( [ 1.0, 1.0, 1.0 ] ); +* +* dger.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 dger: Routine; + + +// EXPORTS // + +export = dger; diff --git a/lib/node_modules/@stdlib/blas/base/dger/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/dger/docs/types/test.ts new file mode 100644 index 000000000000..cd12e125011a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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 dger = require( './index' ); + + +// TESTS // + +// The function returns a Float64Array... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dger( 'row-major', 10, 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectType Float64Array +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dger( 10, 10, 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + dger( true, 10, 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + dger( false, 10, 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + dger( null, 10, 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + dger( undefined, 10, 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + dger( [], 10, 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + dger( {}, 10, 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + dger( ( 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 Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dger( 'row-major', '10', 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + dger( 'row-major', true, 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + dger( 'row-major', false, 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + dger( 'row-major', null, 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + dger( 'row-major', undefined, 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + dger( 'row-major', [], 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + dger( 'row-major', {}, 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + dger( '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 Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dger( 'row-major', 10, '10', 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + dger( 'row-major', 10, true, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + dger( 'row-major', 10, false, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + dger( 'row-major', 10, null, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + dger( 'row-major', 10, undefined, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + dger( 'row-major', 10, [], 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + dger( 'row-major', 10, {}, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + dger( '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 Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dger( 'row-major', 10, 10, '10', x, 1, y, 1, A, 10 ); // $ExpectError + dger( 'row-major', 10, 10, true, x, 1, y, 1, A, 10 ); // $ExpectError + dger( 'row-major', 10, 10, false, x, 1, y, 1, A, 10 ); // $ExpectError + dger( 'row-major', 10, 10, null, x, 1, y, 1, A, 10 ); // $ExpectError + dger( 'row-major', 10, 10, undefined, x, 1, y, 1, A, 10 ); // $ExpectError + dger( 'row-major', 10, 10, [], x, 1, y, 1, A, 10 ); // $ExpectError + dger( 'row-major', 10, 10, {}, x, 1, y, 1, A, 10 ); // $ExpectError + dger( '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 Float64Array... +{ + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dger( 'row-major', 10, 10, 1.0, 10, 1, y, 1, A, 10 ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, '10', 1, y, 1, A, 10 ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, true, 1, y, 1, A, 10 ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, false, 1, y, 1, A, 10 ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, null, 1, y, 1, A, 10 ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, undefined, 1, y, 1, A, 10 ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, [ '1' ], 1, y, 1, A, 10 ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, {}, 1, y, 1, A, 10 ); // $ExpectError + dger( '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 Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dger( 'row-major', 10, 10, 1.0, x, '10', y, 1, A, 10 ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, x, true, y, 1, A, 10 ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, x, false, y, 1, A, 10 ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, x, null, y, 1, A, 10 ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, x, undefined, y, 1, A, 10 ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, x, [], y, 1, A, 10 ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, x, {}, y, 1, A, 10 ); // $ExpectError + dger( '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 Float64Array... +{ + const x = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dger( 'row-major', 10, 10, 1.0, x, 1, 10, 1, A, 10 ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, x, 1, '10', 1, A, 10 ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, x, 1, true, 1, A, 10 ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, x, 1, false, 1, A, 10 ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, x, 1, null, 1, A, 10 ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, x, 1, undefined, 1, A, 10 ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, x, 1, [ '1' ], 1, A, 10 ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, x, 1, {}, 1, A, 10 ); // $ExpectError + dger( '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 Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dger( 'row-major', 10, 10, 1.0, x, 1, y, '10', A, 10 ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, x, 1, y, true, A, 10 ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, x, 1, y, false, A, 10 ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, x, 1, y, null, A, 10 ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, x, 1, y, undefined, A, 10 ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, x, 1, y, [], A, 10 ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, x, 1, y, {}, A, 10 ); // $ExpectError + dger( '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 Float64Array... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + dger( 'row-major', 10, 10, 1.0, x, 1, y, 1, 10, 1 ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, x, 1, y, 1, '10', 1 ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, x, 1, y, 1, true, 1 ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, x, 1, y, 1, false, 1 ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, x, 1, y, 1, null, 1 ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, x, 1, y, 1, undefined, 1 ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, x, 1, y, 1, [ '1' ], 1 ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, x, 1, y, 1, {}, 1 ); // $ExpectError + dger( '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 Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dger( 'row-major', 10, 10, 1.0, x, 1, y, 1, A, '10' ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, x, 1, y, 1, A, true ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, x, 1, y, 1, A, false ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, x, 1, y, 1, A, null ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, x, 1, y, 1, A, undefined ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, x, 1, y, 1, A, [] ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, x, 1, y, 1, A, {} ); // $ExpectError + dger( '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 Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dger(); // $ExpectError + dger( 'row-major' ); // $ExpectError + dger( 'row-major', 10 ); // $ExpectError + dger( 'row-major', 10, 10 ); // $ExpectError + dger( 'row-major', 10, 10, 1.0 ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, x ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, x, 1 ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, x, 1, y ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, x, 1, y, 1 ); // $ExpectError + dger( 'row-major', 10, 10, 1.0, x, 1, y, 1, A ); // $ExpectError + dger( '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 Float64Array... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectType Float64Array +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dger.ndarray( '10', 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( true, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( false, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( null, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( undefined, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( [], 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( {}, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.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 Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dger.ndarray( 10, '10', 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, true, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, false, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, null, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, undefined, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, [], 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, {}, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.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 Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dger.ndarray( 10, 10, '10', x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, true, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, false, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, null, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, undefined, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, [], x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, {}, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.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 Float64Array... +{ + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dger.ndarray( 10, 10, 1.0, 10, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, '10', 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, true, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, false, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, null, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, undefined, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, [ '1' ], 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, {}, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.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 Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dger.ndarray( 10, 10, 1.0, x, '10', 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, true, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, false, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, null, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, undefined, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, [], 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, {}, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.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 Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dger.ndarray( 10, 10, 1.0, x, 1, '10', y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, true, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, false, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, null, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, undefined, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, [], y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, {}, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.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 Float64Array... +{ + const x = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dger.ndarray( 10, 10, 1.0, x, 1, 0, 10, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, '10', 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, true, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, false, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, null, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, undefined, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, [ '1' ], 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, {}, 1, 0, A, 10, 1, 0 ); // $ExpectError + dger.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 Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, '10', 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, true, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, false, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, null, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, undefined, 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, [], 0, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, {}, 0, A, 10, 1, 0 ); // $ExpectError + dger.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 Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, '10', A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, true, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, false, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, null, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, undefined, A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, [], A, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, {}, A, 10, 1, 0 ); // $ExpectError + dger.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 Float64Array... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, 10, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, '10', 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, true, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, false, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, null, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, undefined, 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, [ '1' ], 10, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, {}, 10, 1, 0 ); // $ExpectError + dger.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 Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, '10', 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, true, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, false, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, null, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, undefined, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, [], 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, {}, 1, 0 ); // $ExpectError + dger.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 Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, '10', 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, true, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, false, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, null, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, undefined, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, [], 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, {}, 0 ); // $ExpectError + dger.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 Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, '10' ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, true ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, false ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, null ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, undefined ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, [] ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, {} ); // $ExpectError + dger.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 Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dger.ndarray(); // $ExpectError + dger.ndarray( 10 ); // $ExpectError + dger.ndarray( 10, 10 ); // $ExpectError + dger.ndarray( 10, 10, 1.0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, 10 ); // $ExpectError + dger.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1 ); // $ExpectError + dger.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/dger/examples/c/Makefile b/lib/node_modules/@stdlib/blas/base/dger/examples/c/Makefile old mode 100644 new mode 100755 diff --git a/lib/node_modules/@stdlib/blas/base/dger/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/dger/examples/c/example.c old mode 100644 new mode 100755 diff --git a/lib/node_modules/@stdlib/blas/base/dger/examples/index.js b/lib/node_modules/@stdlib/blas/base/dger/examples/index.js old mode 100644 new mode 100755 index 9e6f484ac7b4..00bd66217fb6 --- a/lib/node_modules/@stdlib/blas/base/dger/examples/index.js +++ b/lib/node_modules/@stdlib/blas/base/dger/examples/index.js @@ -16,41 +16,24 @@ * limitations under the License. */ -/* eslint-disable */ // FIXME - 'use strict'; var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var zeros = require( '@stdlib/array/zeros' ); var dger = require( './../lib' ); -// var M = 4; -// var N = 3; -// var B = zeros( M*N, 'float64' ); - -// var opts = { -// 'dtype': 'float64' -// }; -// var x = discreteUniform( M, 0, 500, opts ); -// console.log( x ); - -// var y = discreteUniform( N, 0, 255, opts ); -// console.log( y ); - -// dger( 'row-major', N, M, 1.0, y, 1, x, 1, B, N ); -// console.log( B ); - -var Float64Array = require( '@stdlib/array/float64' ); +var opts = { + 'dtype': 'float32' +}; -var M = 4; -var N = 3; -var B = zeros( M*N, 'float64' ); +var M = 3; +var N = 5; -var x = new Float64Array( [ 0.0, 1.0, 2.0, 3.0 ] ); -console.log( x ); +var A = discreteUniform( M*N, 0, 255, opts ); +var x = discreteUniform( M, 0, 255, opts ); +var y = discreteUniform( N, 0, 255, opts ); -var y = new Float64Array( [ 1.0, 4.0, 0.0 ] ); -console.log( y ); +dger( 'row-major', M, N, 1.0, x, 1, y, 1, A, N ); +console.log( A ); -dger( 'row-major', N, M, 1.0, y, 1, x, 1, B, M ); -console.log( B ); +dger.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/dger/include.gypi b/lib/node_modules/@stdlib/blas/base/dger/include.gypi deleted file mode 100644 index 497aeca15320..000000000000 --- a/lib/node_modules/@stdlib/blas/base/dger/include.gypi +++ /dev/null @@ -1,70 +0,0 @@ -# @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 ] +*/ +function dger( 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 = alpha * y[ iy1 ]; + ix1 = offsetX; + oa = offsetA + (sa1*i1); + for ( i0 = 0; i0 < M; i0++ ) { + A[ oa+(sa0*i0) ] += x[ ix1 ] * tmp; + ix1 += strideX; + } + } + iy1 += strideY; + } + return A; + } + ix1 = offsetX; + for ( i1 = 0; i1 < M; i1++ ) { + if ( x[ ix1 ] !== 0.0 ) { + tmp = alpha * x[ ix1 ]; + iy1 = offsetY; + oa = offsetA + (sa1*i1); + for ( i0 = 0; i0 < N; i0++ ) { + A[ oa+(sa0*i0) ] += y[ iy1 ] * tmp; + iy1 += strideY; + } + } + ix1 += strideX; + } + return A; +} + + +// EXPORTS // + +module.exports = dger; diff --git a/lib/node_modules/@stdlib/blas/base/dger/lib/dger.js b/lib/node_modules/@stdlib/blas/base/dger/lib/dger.js old mode 100644 new mode 100755 index c3f3eb2fa88e..33f2b437dbd7 --- a/lib/node_modules/@stdlib/blas/base/dger/lib/dger.js +++ b/lib/node_modules/@stdlib/blas/base/dger/lib/dger.js @@ -16,45 +16,83 @@ * limitations under the License. */ -/* eslint-disable */ // FIXME - '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 = alpha*x*y^T + A`. +* 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 -* @param {Float64Array} x - an `M` element vector +* @param {Float64Array} x - first input vector * @param {integer} strideX - `x` stride length -* @param {Float64Array} y - an `N` element vector +* @param {Float64Array} y - second input vector * @param {integer} strideY - `y` stride length -* @param {Float64Array} A - matrix of coefficients +* @param {Float64Array} 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 {Float64Array} `A` * * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var M = 4; -* var N = 3; -* -* var B = new Float64Array( M*N ); -* -* var x = new Float64Array( [ 0.0, 1.0, 2.0, 3.0 ] ); -* var y = new Float64Array( [ 1.0, 4.0, 0.0 ] ); +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var x = new Float64Array( [ 1.0, 1.0 ] ); +* var y = new Float64Array( [ 1.0, 1.0, 1.0 ] ); * -* dger( 'row-major', N, M, 1.0, y, 1, x, 1, B, M ); -* // B => [ 0.0, 1.0, 2.0, 3.0, 0.0, 4.0, 8.0, 12.0, 0.0, 0.0, 0.0, 0.0 ] +* dger( '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 dger( order, M, N, alpha, x, strideX, y, strideY, A, LDA ) { - // TODO: implementation + var sa1; + var sa2; + var ox; + var oy; - return A; + 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 ); } diff --git a/lib/node_modules/@stdlib/blas/base/dger/lib/dger.native.js b/lib/node_modules/@stdlib/blas/base/dger/lib/dger.native.js deleted file mode 100644 index 80779dd74619..000000000000 --- a/lib/node_modules/@stdlib/blas/base/dger/lib/dger.native.js +++ /dev/null @@ -1,72 +0,0 @@ -/** -* @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 resolve = require( '@stdlib/blas/base/layout-resolve-enum' ); -var format = require( '@stdlib/string/format' ); -var addon = require( './../src/addon.node' ); - - -// MAIN // - -/** -* Performs the rank 1 operation `A = alpha*x*y^T + A`. -* -* @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 {Float64Array} x - an `M` element vector -* @param {integer} strideX - `x` stride length -* @param {Float64Array} y - an `N` element vector -* @param {integer} strideY - `y` stride length -* @param {Float64Array} 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 supported BLAS memory layout -* @returns {Float64Array} `A` -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var M = 4; -* var N = 3; -* -* var B = new Float64Array( M*N ); -* -* var x = new Float64Array( [ 0.0, 1.0, 2.0, 3.0 ] ); -* var y = new Float64Array( [ 1.0, 4.0, 0.0 ] ); -* -* dger( 'row-major', N, M, 1.0, y, 1, x, 1, B, M ); -* // B => [ 0.0, 1.0, 2.0, 3.0, 0.0, 4.0, 8.0, 12.0, 0.0, 0.0, 0.0, 0.0 ] -*/ -function dger( order, M, N, alpha, x, strideX, y, strideY, A, LDA ) { - var ord = resolve( order ); - if ( ord === null ) { - throw new TypeError( format( 'invalid argument. First argument must be a supported BLAS memory layout. Value: `%s`.', order ) ); - } - addon( ord, M, N, alpha, x, strideX, y, strideY, A, LDA ); - return A; -} - - -// EXPORTS // - -module.exports = dger; diff --git a/lib/node_modules/@stdlib/blas/base/dger/lib/index.js b/lib/node_modules/@stdlib/blas/base/dger/lib/index.js old mode 100644 new mode 100755 index 5641b87166fd..2222c83ee6b3 --- a/lib/node_modules/@stdlib/blas/base/dger/lib/index.js +++ b/lib/node_modules/@stdlib/blas/base/dger/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* BLAS level 2 routine to perform the rank 1 operation `A = alpha*x*y^T + A`. +* 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/dger * @@ -27,31 +27,23 @@ * var Float64Array = require( '@stdlib/array/float64' ); * var dger = require( '@stdlib/blas/base/dger' ); * -* var M = 4; -* var N = 3; +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var x = new Float64Array( [ 1.0, 1.0 ] ); +* var y = new Float64Array( [ 1.0, 1.0, 1.0 ] ); * -* var B = new Float64Array( M*N ); -* -* var x = new Float64Array( [ 0.0, 1.0, 2.0, 3.0 ] ); -* var y = new Float64Array( [ 1.0, 4.0, 0.0 ] ); -* -* dger( 'row-major', N, M, 1.0, y, 1, x, 1, B, M ); -* // B => [ 0.0, 1.0, 2.0, 3.0, 0.0, 4.0, 8.0, 12.0, 0.0, 0.0, 0.0, 0.0 ] +* dger( '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 Float64Array = require( '@stdlib/array/float64' ); * var dger = require( '@stdlib/blas/base/dger' ); * -* var M = 4; -* var N = 3; -* -* var B = new Float64Array( M*N ); -* -* var x = new Float64Array( [ 0.0, 1.0, 2.0, 3.0 ] ); -* var y = new Float64Array( [ 1.0, 4.0, 0.0 ] ); +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var x = new Float64Array( [ 1.0, 1.0 ] ); +* var y = new Float64Array( [ 1.0, 1.0, 1.0 ] ); * -* dger.ndarray( 'row-major', N, M, 1.0, y, 1, 0, x, 1, 0, B, M ); -* // B => [ 0.0, 1.0, 2.0, 3.0, 0.0, 4.0, 8.0, 12.0, 0.0, 0.0, 0.0, 0.0 ] +* dger.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 // diff --git a/lib/node_modules/@stdlib/blas/base/dger/lib/main.js b/lib/node_modules/@stdlib/blas/base/dger/lib/main.js old mode 100644 new mode 100755 diff --git a/lib/node_modules/@stdlib/blas/base/dger/lib/native.js b/lib/node_modules/@stdlib/blas/base/dger/lib/native.js deleted file mode 100644 index 18c0998f60c6..000000000000 --- a/lib/node_modules/@stdlib/blas/base/dger/lib/native.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @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 dger = require( './dger.native.js' ); -var ndarray = require( './ndarray.native.js' ); - - -// MAIN // - -setReadOnly( dger, 'ndarray', ndarray ); - - -// EXPORTS // - -module.exports = dger; diff --git a/lib/node_modules/@stdlib/blas/base/dger/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/dger/lib/ndarray.js old mode 100644 new mode 100755 index 5bc5629a9200..79dead9cb9a2 --- a/lib/node_modules/@stdlib/blas/base/dger/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/dger/lib/ndarray.js @@ -16,48 +16,66 @@ * limitations under the License. */ -/* eslint-disable */ // FIXME - 'use strict'; +// MODULES // + +var format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); + + // MAIN // /** -* Performs the rank 1 operation `A = alpha*x*y^T + A`. +* 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 {Float64Array} x - an `M` element vector +* @param {Float64Array} x - first input vector * @param {integer} strideX - `x` stride length -* @param {NonNegativeInteger} offsetX - starting `x` index -* @param {Float64Array} y - an `N` element vector +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @param {Float64Array} y - second input vector * @param {integer} strideY - `y` stride length -* @param {NonNegativeInteger} offsetY - starting `y` index -* @param {Float64Array} A - matrix of coefficients -* @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {NonNegativeInteger} offsetY - starting index for `y` +* @param {Float64Array} 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 {Float64Array} `A` * * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var M = 4; -* var N = 3; +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var x = new Float64Array( [ 1.0, 1.0 ] ); +* var y = new Float64Array( [ 1.0, 1.0, 1.0 ] ); * -* var B = new Float64Array( M*N ); -* -* var x = new Float64Array( [ 0.0, 1.0, 2.0, 3.0 ] ); -* var y = new Float64Array( [ 1.0, 4.0, 0.0 ] ); -* -* dger( 'row-major', N, M, 1.0, y, 1, 0, x, 1, 0, B, M ); -* // B => [ 0.0, 1.0, 2.0, 3.0, 0.0, 4.0, 8.0, 12.0, 0.0, 0.0, 0.0, 0.0 ] +* dger( 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 dger( order, M, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, LDA ) { - - // TODO: implementation - - return A; +function dger( 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 } diff --git a/lib/node_modules/@stdlib/blas/base/dger/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dger/lib/ndarray.native.js deleted file mode 100644 index c91cf81824e2..000000000000 --- a/lib/node_modules/@stdlib/blas/base/dger/lib/ndarray.native.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @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 minViewBufferIndex = require( '@stdlib/strided/base/min-view-buffer-index' ); -var offsetView = require( '@stdlib/strided/base/offset-view' ); -var resolve = require( '@stdlib/blas/base/layout-resolve-enum' ); -var format = require( '@stdlib/string/format' ); -var addon = require( './dger.native.js' ); - - -// MAIN // - -/** -* Performs the rank 1 operation `A = alpha*x*y^T + A`. -* -* @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 {Float64Array} x - an `M` element vector -* @param {integer} strideX - `x` stride length -* @param {NonNegativeInteger} offsetX - starting `x` index -* @param {Float64Array} y - an `N` element vector -* @param {integer} strideY - `y` stride length -* @param {NonNegativeInteger} offsetY - starting `y` index -* @param {Float64Array} 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 supported BLAS memory layout -* @returns {Float64Array} `A` -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var M = 4; -* var N = 3; -* -* var B = new Float64Array( M*N ); -* -* var x = new Float64Array( [ 0.0, 1.0, 2.0, 3.0 ] ); -* var y = new Float64Array( [ 1.0, 4.0, 0.0 ] ); -* -* dger( 'row-major', N, M, 1.0, y, 1, 0, x, 1, 0, B, M ); -* // B => [ 0.0, 1.0, 2.0, 3.0, 0.0, 4.0, 8.0, 12.0, 0.0, 0.0, 0.0, 0.0 ] -*/ -function dger( order, M, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, LDA ) { // eslint-disable-line max-len, max-params - var viewX; - var viewY; - var ord; - - ord = resolve( order ); - if ( ord === null ) { - throw new TypeError( format( 'invalid argument. First argument must be a supported BLAS memory layout. Value: `%s`.', order ) ); - } - offsetX = minViewBufferIndex( N, strideX, offsetX ); - offsetY = minViewBufferIndex( N, strideY, offsetY ); - - viewX = offsetView( x, offsetX ); - viewY = offsetView( y, offsetY ); - - addon( ord, M, N, alpha, viewX, strideX, viewY, strideY, A, LDA ); - return A; -} - - -// EXPORTS // - -module.exports = dger; diff --git a/lib/node_modules/@stdlib/blas/base/dger/manifest.json b/lib/node_modules/@stdlib/blas/base/dger/manifest.json deleted file mode 100644 index 7494358b4d85..000000000000 --- a/lib/node_modules/@stdlib/blas/base/dger/manifest.json +++ /dev/null @@ -1,433 +0,0 @@ -{ - "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/dger.f", - "./src/dger_f.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-float64array", - "@stdlib/napi/argv-double" - ] - }, - { - "task": "benchmark", - "os": "linux", - "blas": "", - "wasm": false, - "src": [ - "./src/dger.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/blas/base/shared", - "@stdlib/blas/base/xerbla" - ] - }, - { - "task": "examples", - "os": "linux", - "blas": "", - "wasm": false, - "src": [ - "./src/dger.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/blas/base/shared", - "@stdlib/blas/base/xerbla" - ] - }, - - { - "task": "build", - "os": "linux", - "blas": "openblas", - "wasm": false, - "src": [ - "./src/dger_cblas.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-float64array", - "@stdlib/napi/argv-double" - ] - }, - { - "task": "benchmark", - "os": "linux", - "blas": "openblas", - "wasm": false, - "src": [ - "./src/dger_cblas.c" - ], - "include": [ - "./include" - ], - "libraries": [ - "-lopenblas", - "-lpthread" - ], - "libpath": [], - "dependencies": [ - "@stdlib/blas/base/shared" - ] - }, - { - "task": "examples", - "os": "linux", - "blas": "openblas", - "wasm": false, - "src": [ - "./src/dger_cblas.c" - ], - "include": [ - "./include" - ], - "libraries": [ - "-lopenblas", - "-lpthread" - ], - "libpath": [], - "dependencies": [ - "@stdlib/blas/base/shared" - ] - }, - - { - "task": "build", - "os": "mac", - "blas": "", - "wasm": false, - "src": [ - "./src/dger.f", - "./src/dger_f.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-float64array", - "@stdlib/napi/argv-double" - ] - }, - { - "task": "benchmark", - "os": "mac", - "blas": "", - "wasm": false, - "src": [ - "./src/dger.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/blas/base/shared", - "@stdlib/blas/base/xerbla" - ] - }, - { - "task": "examples", - "os": "mac", - "blas": "", - "wasm": false, - "src": [ - "./src/dger.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/blas/base/shared", - "@stdlib/blas/base/xerbla" - ] - }, - - { - "task": "build", - "os": "mac", - "blas": "apple_accelerate_framework", - "wasm": false, - "src": [ - "./src/dger_cblas.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-float64array", - "@stdlib/napi/argv-double" - ] - }, - { - "task": "benchmark", - "os": "mac", - "blas": "apple_accelerate_framework", - "wasm": false, - "src": [ - "./src/dger_cblas.c" - ], - "include": [ - "./include" - ], - "libraries": [ - "-lblas" - ], - "libpath": [], - "dependencies": [ - "@stdlib/blas/base/shared" - ] - }, - { - "task": "examples", - "os": "mac", - "blas": "apple_accelerate_framework", - "wasm": false, - "src": [ - "./src/dger_cblas.c" - ], - "include": [ - "./include" - ], - "libraries": [ - "-lblas" - ], - "libpath": [], - "dependencies": [ - "@stdlib/blas/base/shared" - ] - }, - - { - "task": "build", - "os": "mac", - "blas": "openblas", - "wasm": false, - "src": [ - "./src/dger_cblas.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-float64array", - "@stdlib/napi/argv-double" - ] - }, - { - "task": "benchmark", - "os": "mac", - "blas": "openblas", - "wasm": false, - "src": [ - "./src/dger_cblas.c" - ], - "include": [ - "./include" - ], - "libraries": [ - "-lopenblas", - "-lpthread" - ], - "libpath": [], - "dependencies": [ - "@stdlib/blas/base/shared" - ] - }, - { - "task": "examples", - "os": "mac", - "blas": "openblas", - "wasm": false, - "src": [ - "./src/dger_cblas.c" - ], - "include": [ - "./include" - ], - "libraries": [ - "-lopenblas", - "-lpthread" - ], - "libpath": [], - "dependencies": [ - "@stdlib/blas/base/shared" - ] - }, - - { - "task": "build", - "os": "win", - "blas": "", - "wasm": false, - "src": [ - "./src/dger.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-float64array", - "@stdlib/napi/argv-double" - ] - }, - { - "task": "benchmark", - "os": "win", - "blas": "", - "wasm": false, - "src": [ - "./src/dger.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/blas/base/shared", - "@stdlib/blas/base/xerbla" - ] - }, - { - "task": "examples", - "os": "win", - "blas": "", - "wasm": false, - "src": [ - "./src/dger.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/blas/base/shared", - "@stdlib/blas/base/xerbla" - ] - }, - - { - "task": "build", - "os": "", - "blas": "", - "wasm": true, - "src": [ - "./src/dger.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/blas/base/shared", - "@stdlib/blas/base/xerbla" - ] - } - ] -} diff --git a/lib/node_modules/@stdlib/blas/base/dger/package.json b/lib/node_modules/@stdlib/blas/base/dger/package.json old mode 100644 new mode 100755 index 62732f278dd4..a4e79026e71d --- a/lib/node_modules/@stdlib/blas/base/dger/package.json +++ b/lib/node_modules/@stdlib/blas/base/dger/package.json @@ -15,12 +15,10 @@ ], "main": "./lib", "browser": "./lib/main.js", - "gypfile": true, "directories": { "example": "./examples", - "include": "./include", + "doc": "./docs", "lib": "./lib", - "src": "./src", "test": "./test" }, "types": "./docs/types", diff --git a/lib/node_modules/@stdlib/blas/base/dger/src/Makefile b/lib/node_modules/@stdlib/blas/base/dger/src/Makefile deleted file mode 100644 index bcf18aa46655..000000000000 --- a/lib/node_modules/@stdlib/blas/base/dger/src/Makefile +++ /dev/null @@ -1,70 +0,0 @@ -#/ -# @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/dger/src/addon.c b/lib/node_modules/@stdlib/blas/base/dger/src/addon.c deleted file mode 100644 index 10b035c54414..000000000000 --- a/lib/node_modules/@stdlib/blas/base/dger/src/addon.c +++ /dev/null @@ -1,61 +0,0 @@ - -/** -* @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 "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_double.h" -#include "stdlib/napi/argv_strided_float64array.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_DOUBLE( env, alpha, argv, 3 ); - - STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 5 ); - STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 7 ); - - STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, M, strideX, argv, 4 ); - STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Y, N, strideY, argv, 6 ); - - STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, A, ((M-1)*LDA) + N, 1, argv, 8 ); - - API_SUFFIX(c_dger)( layout, M, N, alpha, X, strideX, Y, strideY, A, LDA ); - - return NULL; -} - -STDLIB_NAPI_MODULE_EXPORT_FCN( addon ) diff --git a/lib/node_modules/@stdlib/blas/base/dger/src/dger.c b/lib/node_modules/@stdlib/blas/base/dger/src/dger.c deleted file mode 100644 index c96e481b7293..000000000000 --- a/lib/node_modules/@stdlib/blas/base/dger/src/dger.c +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @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/xerbla.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. -* -* ## Notes -* -* - The function follows the CBLAS interface which reflects the corresponding Fortran interface, which in turn assumes column-major order. As a matrix stored in row-major order is equivalent to storing the matrix's transpose in column-major order, we can interpret an M-by-N row-major matrix "B" as the matrix "A^T" stored in column-major. 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, the C calling convention for row-major order is to swap the order of input arguments such that for a column-major `A` where the stride of the "major" (outer) dimension is `LDA = N` -* -* ```c -* c_dger( CblasColMajor, M, N, alpha, X, strideX, Y, strideY, A, N ) -* ``` -* -* and for a row-major `B = A^T` where the stride of the "major" (outer) dimension is `LDA = M` -* -* ```c -* c_dger( CblasRowMajor, N, M, alpha, Y, strideY, X, strideX, A^T, M ) -* ``` -* -* @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 X stride length -* @param Y an `N` element vector -* @param strideY Y stride length -* @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_dger)( const CBLAS_LAYOUT layout, const CBLAS_INT M, const CBLAS_INT N, const double alpha, double *X, const CBLAS_INT strideX, double *Y, const CBLAS_INT strideY, double *A, const CBLAS_INT LDA ) { - CBLAS_INT info; - CBLAS_INT sx; - CBLAS_INT sy; - CBLAS_INT ix; - CBLAS_INT jy; - CBLAS_INT kx; - CBLAS_INT i; - CBLAS_INT j; - CBLAS_INT m; - CBLAS_INT n; - double tmp; - double *x; - double *y; - - // Perform input argument validation... - info = 0; - if ( M < 0 ) { - info = 1; - } else if ( N < 0 ) { - info = 2; - } else if ( strideX == 0 ) { - info = 5; - } else if ( strideY == 0 ) { - info = 7; - } else { - if ( M < 1 ) { - j = 1; - } else { - j = M; - } - if ( LDA < j ) { - info = 9; - } - } - if ( info != 0 ) { - c_xerbla( info, "c_dger", "" ); - return; - } - // Check whether we can avoid computation altogether... - if ( M == 0 || N == 0 || alpha == 0.0 ) { - return; - } - // When provided a row-major matrix, we need to swap arguments... - if ( layout == CblasRowMajor ) { - x = Y; - y = X; - m = N; - n = M; - sx = strideY; - sy = strideX; - } else { - x = X; - y = Y; - m = M; - n = N; - sx = strideX; - sy = strideY; - } - // Proceed with computation... - if ( sy > 0 ) { - jy = 0; - } else { - jy = ( 1 - n ) * sy; - } - if ( sx == 1 ) { - for ( j = 0; j < n; j++ ) { - if ( y[ jy ] != 0.0 ) { - tmp = alpha * y[ jy ]; - for ( i = 0; i < m; i++ ) { - A[ (j*LDA)+i ] += x[ i ] * tmp; // per above, x has unit stride - } - } - jy += sy; - } - return; - } - if ( sx > 0 ) { - kx = 0; - } else { - kx = ( 1 - m ) * sx; - } - for ( j = 0; j < n; j++ ) { - if ( y[ jy ] != 0.0 ) { - tmp = alpha * y[ jy ]; - ix = kx; - for ( i = 0; i < m; i++ ) { - A[ (j*LDA)+i ] += x[ ix ] * tmp; - ix += sx; - } - } - jy += sy; - } - return; -} diff --git a/lib/node_modules/@stdlib/blas/base/dger/src/dger.f b/lib/node_modules/@stdlib/blas/base/dger/src/dger.f deleted file mode 100644 index 0a56eb9da5c4..000000000000 --- a/lib/node_modules/@stdlib/blas/base/dger/src/dger.f +++ /dev/null @@ -1,148 +0,0 @@ -!> -! @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 {double} alpha - scalar constant -! @param {Array} X - an `M` element vector -! @param {integer} strideX - `X` stride length -! @param {Array} Y - an `N` element vector -! @param {integer} strideY - `Y` stride length -! @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 dger( M, N, alpha, X, strideX, Y, strideY, A, LDA ) - implicit none - ! .. - ! Internal parameters: - integer, parameter :: dp=kind(0.0d0) ! double-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( 'dger ', 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 dger \ No newline at end of file diff --git a/lib/node_modules/@stdlib/blas/base/dger/src/dger_cblas.c b/lib/node_modules/@stdlib/blas/base/dger/src/dger_cblas.c deleted file mode 100644 index d2445a4ed309..000000000000 --- a/lib/node_modules/@stdlib/blas/base/dger/src/dger_cblas.c +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @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/dger_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 X stride length -* @param Y an `N` element vector -* @param strideY Y stride length -* @param A matrix of coefficients -* @param LDA index of the first dimension of `A` -*/ -void API_SUFFIX(c_dger)( const CBLAS_LAYOUT layout, const CBLAS_INT M, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const double *Y, const CBLAS_INT strideY, double *A, const CBLAS_INT LDA ) { - API_SUFFIX(cblas_dger)( layout, M, N, alpha, X, strideX, Y, strideY, A, LDA ); -} diff --git a/lib/node_modules/@stdlib/blas/base/dger/src/dger_f.c b/lib/node_modules/@stdlib/blas/base/dger/src/dger_f.c deleted file mode 100644 index 9f5a8d88af0e..000000000000 --- a/lib/node_modules/@stdlib/blas/base/dger/src/dger_f.c +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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/dger_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 X stride length -* @param Y an `N` element vector -* @param strideY Y stride length -* @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_dger)( const CBLAS_LAYOUT layout, const CBLAS_INT M, const CBLAS_INT N, const double alpha, double *X, const CBLAS_INT strideX, double *Y, const CBLAS_INT strideY, double *A, const CBLAS_INT LDA ) { - extern int RowMajorStrg; // global flag - - RowMajorStrg = 0; - if ( layout == CblasColMajor ) { - dger( &M, &N, &alpha, X, &strideX, Y, &strideY, A, &LDA ); - return; - } - if ( layout == CblasRowMajor ) { - RowMajorStrg = 1; - dger( &N, &M, &alpha, Y, &strideY, X, &strideX, A, &LDA ); - RowMajorStrg = 0; - return; - } - c_xerbla( 1, "c_dger", "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/dger/test/fixtures/column_major.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major.json new file mode 100755 index 000000000000..19adb72ab470 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/column_major_complex_access_pattern.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_complex_access_pattern.json new file mode 100755 index 000000000000..d52726883a6d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/column_major_oa.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_oa.json new file mode 100755 index 000000000000..6bb4f94e3616 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/column_major_sa1_sa2.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_sa1_sa2.json new file mode 100755 index 000000000000..20c43b149187 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/column_major_sa1_sa2n.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_sa1_sa2n.json new file mode 100755 index 000000000000..ab7ac9e8897d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/column_major_sa1n_sa2.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_sa1n_sa2.json new file mode 100755 index 000000000000..82884c1c0804 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/column_major_sa1n_sa2n.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_sa1n_sa2n.json new file mode 100755 index 000000000000..ba307fda875c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/column_major_xnyn.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_xnyn.json new file mode 100755 index 000000000000..f107aa4eb727 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/column_major_xnyp.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_xnyp.json new file mode 100755 index 000000000000..fcfb609eb3f0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/column_major_xpyn.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_xpyn.json new file mode 100755 index 000000000000..2cc21048ac0d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/column_major_xpyp.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_xpyp.json new file mode 100755 index 000000000000..7ddda6580f6b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/row_major.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major.json new file mode 100755 index 000000000000..6c5a8c89a176 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/row_major_complex_access_pattern.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_complex_access_pattern.json new file mode 100755 index 000000000000..53f86d6f795d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/row_major_oa.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_oa.json new file mode 100755 index 000000000000..dce60e368fb3 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/row_major_sa1_sa2.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_sa1_sa2.json new file mode 100755 index 000000000000..6fd51996873f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/row_major_sa1_sa2n.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_sa1_sa2n.json new file mode 100755 index 000000000000..ab7ac9e8897d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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, 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/dger/test/fixtures/row_major_sa1n_sa2.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_sa1n_sa2.json new file mode 100755 index 000000000000..82884c1c0804 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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, 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/dger/test/fixtures/row_major_sa1n_sa2n.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_sa1n_sa2n.json new file mode 100755 index 000000000000..ba307fda875c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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, 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/dger/test/fixtures/row_major_xnyn.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_xnyn.json new file mode 100755 index 000000000000..7713b84d9d54 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/row_major_xnyp.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_xnyp.json new file mode 100755 index 000000000000..fea1b4dbd0a0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/row_major_xpyn.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_xpyn.json new file mode 100755 index 000000000000..e89ebada429c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/row_major_xpyp.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_xpyp.json new file mode 100755 index 000000000000..4291cb6a8b27 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/test.dger.js b/lib/node_modules/@stdlib/blas/base/dger/test/test.dger.js new file mode 100755 index 000000000000..a8da5b588089 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/test/test.dger.js @@ -0,0 +1,534 @@ +/** +* @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 Float64Array = require( '@stdlib/array/float64' ); +var dger = require( './../lib/dger.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' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dger, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 10', function test( t ) { + t.strictEqual( dger.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() { + dger( value, data.M, data.N, data.alpha, new Float64Array( data.x ), data.strideX, new Float64Array( data.y ), data.strideY, new Float64Array( 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() { + dger( data.order, value, data.N, data.alpha, new Float64Array( data.x ), data.strideX, new Float64Array( data.y ), data.strideY, new Float64Array( 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() { + dger( data.order, data.M, value, data.alpha, new Float64Array( data.x ), data.strideX, new Float64Array( data.y ), data.strideY, new Float64Array( 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() { + dger( data.order, data.M, data.N, data.alpha, new Float64Array( data.x ), value, new Float64Array( data.y ), data.strideY, new Float64Array( 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() { + dger( data.order, data.M, data.N, data.alpha, new Float64Array( data.x ), data.strideX, new Float64Array( data.y ), value, new Float64Array( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cm; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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)', function test( t ) { + var data; + var out; + var a; + var x; + var y; + + data = rm; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A ); + + out = dger( 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 = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A ); + + out = dger( 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 = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxpyp; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxnyp; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxnyp; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxpyn; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxpyn; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxnyn; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxnyn; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/dger/test/test.js b/lib/node_modules/@stdlib/blas/base/dger/test/test.js old mode 100644 new mode 100755 index eb3153fe3685..d1a424ff92d7 --- a/lib/node_modules/@stdlib/blas/base/dger/test/test.js +++ b/lib/node_modules/@stdlib/blas/base/dger/test/test.js @@ -22,14 +22,14 @@ var tape = require( 'tape' ); var proxyquire = require( 'proxyquire' ); -var isBrowser = require( '@stdlib/assert/is-browser' ); +var IS_BROWSER = require( '@stdlib/assert/is-browser' ); var dger = require( './../lib' ); // VARIABLES // var opts = { - 'skip': isBrowser + 'skip': IS_BROWSER }; diff --git a/lib/node_modules/@stdlib/blas/base/dger/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/dger/test/test.ndarray.js new file mode 100755 index 000000000000..494f9dd71007 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/test/test.ndarray.js @@ -0,0 +1,784 @@ +/** +* @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 Float64Array = require( '@stdlib/array/float64' ); +var dger = 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' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dger, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 13', function test( t ) { + t.strictEqual( dger.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() { + dger( value, data.N, data.alpha, new Float64Array( data.x ), data.strideX, data.offsetX, new Float64Array( data.y ), data.strideY, data.offsetY, new Float64Array( 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() { + dger( data.M, value, data.alpha, new Float64Array( data.x ), data.strideX, data.offsetX, new Float64Array( data.y ), data.strideY, data.offsetY, new Float64Array( 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() { + dger( data.M, data.N, data.alpha, new Float64Array( data.x ), value, data.offsetX, new Float64Array( data.y ), data.strideY, data.offsetY, new Float64Array( 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() { + dger( data.M, data.N, data.alpha, new Float64Array( data.x ), data.strideX, data.offsetX, new Float64Array( data.y ), value, data.offsetY, new Float64Array( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cm; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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)', function test( t ) { + var data; + var out; + var a; + var x; + var y; + + data = rm; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A ); + + out = dger( 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 = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A ); + + out = dger( 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 = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = csa1sa2; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rsa1nsa2; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = csa1nsa2; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rsa1sa2n; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = csa1sa2n; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rsa1nsa2n; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = csa1nsa2n; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = roa; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = coa; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxpyp; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxpyp; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxnyp; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxnyp; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxpyn; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxpyn; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxnyn; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxnyn; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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; + var out; + var a; + var x; + var y; + + data = rcap; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = ccap; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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(); +}); From 0f8696e8a89e5969d255ae4708403e93a0ae4ebe Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Wed, 26 Mar 2025 13:04:08 +0000 Subject: [PATCH 02/38] chore: update copyright years --- lib/node_modules/@stdlib/blas/base/dger/benchmark/benchmark.js | 2 +- .../@stdlib/blas/base/dger/benchmark/benchmark.ndarray.js | 2 +- lib/node_modules/@stdlib/blas/base/dger/docs/types/index.d.ts | 2 +- lib/node_modules/@stdlib/blas/base/dger/docs/types/test.ts | 2 +- lib/node_modules/@stdlib/blas/base/dger/lib/base.js | 2 +- lib/node_modules/@stdlib/blas/base/dger/test/test.dger.js | 2 +- lib/node_modules/@stdlib/blas/base/dger/test/test.ndarray.js | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dger/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/dger/benchmark/benchmark.js index 3d20265c4ee4..19760efde23d 100755 --- a/lib/node_modules/@stdlib/blas/base/dger/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/dger/benchmark/benchmark.ndarray.js index 9c26e795904b..c6827d87000a 100755 --- a/lib/node_modules/@stdlib/blas/base/dger/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/dger/docs/types/index.d.ts index f3ff52bbbb05..f9e61fce3fc8 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/dger/docs/types/test.ts index cd12e125011a..05a2df32cdef 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/lib/base.js b/lib/node_modules/@stdlib/blas/base/dger/lib/base.js index 6d9d7afe8f4c..84d15d55e228 100755 --- a/lib/node_modules/@stdlib/blas/base/dger/lib/base.js +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/test.dger.js b/lib/node_modules/@stdlib/blas/base/dger/test/test.dger.js index a8da5b588089..bbb5d60bff12 100755 --- a/lib/node_modules/@stdlib/blas/base/dger/test/test.dger.js +++ b/lib/node_modules/@stdlib/blas/base/dger/test/test.dger.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/dger/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/dger/test/test.ndarray.js index 494f9dd71007..c749f1a76dca 100755 --- a/lib/node_modules/@stdlib/blas/base/dger/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/dger/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. From f1792dcfd6e8a9fc756094ddc56398edc289c414 Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Wed, 26 Mar 2025 18:38:43 +0530 Subject: [PATCH 03/38] remove: c examples Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- .../blas/base/dger/examples/c/Makefile | 146 ------------------ .../blas/base/dger/examples/c/example.c | 54 ------- 2 files changed, 200 deletions(-) delete mode 100755 lib/node_modules/@stdlib/blas/base/dger/examples/c/Makefile delete mode 100755 lib/node_modules/@stdlib/blas/base/dger/examples/c/example.c diff --git a/lib/node_modules/@stdlib/blas/base/dger/examples/c/Makefile b/lib/node_modules/@stdlib/blas/base/dger/examples/c/Makefile deleted file mode 100755 index 6aed70daf167..000000000000 --- a/lib/node_modules/@stdlib/blas/base/dger/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @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 - -# 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 diff --git a/lib/node_modules/@stdlib/blas/base/dger/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/dger/examples/c/example.c deleted file mode 100755 index 63fb90b3ea5a..000000000000 --- a/lib/node_modules/@stdlib/blas/base/dger/examples/c/example.c +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 4x3 matrix `B` stored in row-major order (i.e., equivalent to the transpose `A^T` of a 3x4 matrix `A` stored in column-major order): - double B[ 4*3 ] = { - 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^T` and `y` vectors: - double x[ 4 ] = { 0.0, 1.0, 2.0, 3.0 }; // M - double y[ 3 ] = { 1.0, 4.0, 0.0 }; // N - - // Specify the number of rows and columns: - const int M = 4; - const int N = 3; - - // Specify stride lengths: - const int strideX = 1; - const int strideY = 1; - - // Specify the matrix layout: - const CBLAS_LAYOUT layout = CblasRowMajor; - - // Perform operation (note: arguments are reordered as: A_{M,N} = α⋅x_M⋅y^T_N + A_{M,N} => B = A^T = α⋅y⋅x^T + A^T = α⋅y⋅x^T + B): - c_dger( layout, N, M, 1.0, y, strideY, x, strideX, B, M ); - - // Print the result: - for ( int i = 0; i < N; i++ ) { - for ( int j = 0; j < M; j++ ) { - printf( "B[%i,%i] = %lf\n", i, j, B[ (i*M)+j ] ); - } - } -} From c773adf1fa7287c80258c01cac934365ed27e858 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Wed, 26 Mar 2025 18:43:09 +0530 Subject: [PATCH 04/38] fix: changed file permissions --- 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: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/blas/base/dger/README.md | 0 lib/node_modules/@stdlib/blas/base/dger/benchmark/benchmark.js | 0 .../@stdlib/blas/base/dger/benchmark/benchmark.ndarray.js | 0 lib/node_modules/@stdlib/blas/base/dger/examples/index.js | 0 lib/node_modules/@stdlib/blas/base/dger/lib/base.js | 0 lib/node_modules/@stdlib/blas/base/dger/lib/dger.js | 0 lib/node_modules/@stdlib/blas/base/dger/lib/index.js | 0 lib/node_modules/@stdlib/blas/base/dger/lib/main.js | 0 lib/node_modules/@stdlib/blas/base/dger/lib/ndarray.js | 0 lib/node_modules/@stdlib/blas/base/dger/package.json | 0 .../@stdlib/blas/base/dger/test/fixtures/column_major.json | 0 .../dger/test/fixtures/column_major_complex_access_pattern.json | 0 .../@stdlib/blas/base/dger/test/fixtures/column_major_oa.json | 0 .../blas/base/dger/test/fixtures/column_major_sa1_sa2.json | 0 .../blas/base/dger/test/fixtures/column_major_sa1_sa2n.json | 0 .../blas/base/dger/test/fixtures/column_major_sa1n_sa2.json | 0 .../blas/base/dger/test/fixtures/column_major_sa1n_sa2n.json | 0 .../@stdlib/blas/base/dger/test/fixtures/column_major_xnyn.json | 0 .../@stdlib/blas/base/dger/test/fixtures/column_major_xnyp.json | 0 .../@stdlib/blas/base/dger/test/fixtures/column_major_xpyn.json | 0 .../@stdlib/blas/base/dger/test/fixtures/column_major_xpyp.json | 0 .../@stdlib/blas/base/dger/test/fixtures/row_major.json | 0 .../base/dger/test/fixtures/row_major_complex_access_pattern.json | 0 .../@stdlib/blas/base/dger/test/fixtures/row_major_oa.json | 0 .../@stdlib/blas/base/dger/test/fixtures/row_major_sa1_sa2.json | 0 .../@stdlib/blas/base/dger/test/fixtures/row_major_sa1_sa2n.json | 0 .../@stdlib/blas/base/dger/test/fixtures/row_major_sa1n_sa2.json | 0 .../@stdlib/blas/base/dger/test/fixtures/row_major_sa1n_sa2n.json | 0 .../@stdlib/blas/base/dger/test/fixtures/row_major_xnyn.json | 0 .../@stdlib/blas/base/dger/test/fixtures/row_major_xnyp.json | 0 .../@stdlib/blas/base/dger/test/fixtures/row_major_xpyn.json | 0 .../@stdlib/blas/base/dger/test/fixtures/row_major_xpyp.json | 0 lib/node_modules/@stdlib/blas/base/dger/test/test.dger.js | 0 lib/node_modules/@stdlib/blas/base/dger/test/test.js | 0 lib/node_modules/@stdlib/blas/base/dger/test/test.ndarray.js | 0 35 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 lib/node_modules/@stdlib/blas/base/dger/README.md mode change 100755 => 100644 lib/node_modules/@stdlib/blas/base/dger/benchmark/benchmark.js mode change 100755 => 100644 lib/node_modules/@stdlib/blas/base/dger/benchmark/benchmark.ndarray.js mode change 100755 => 100644 lib/node_modules/@stdlib/blas/base/dger/examples/index.js mode change 100755 => 100644 lib/node_modules/@stdlib/blas/base/dger/lib/base.js mode change 100755 => 100644 lib/node_modules/@stdlib/blas/base/dger/lib/dger.js mode change 100755 => 100644 lib/node_modules/@stdlib/blas/base/dger/lib/index.js mode change 100755 => 100644 lib/node_modules/@stdlib/blas/base/dger/lib/main.js mode change 100755 => 100644 lib/node_modules/@stdlib/blas/base/dger/lib/ndarray.js mode change 100755 => 100644 lib/node_modules/@stdlib/blas/base/dger/package.json mode change 100755 => 100644 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major.json mode change 100755 => 100644 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_complex_access_pattern.json mode change 100755 => 100644 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_oa.json mode change 100755 => 100644 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_sa1_sa2.json mode change 100755 => 100644 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_sa1_sa2n.json mode change 100755 => 100644 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_sa1n_sa2.json mode change 100755 => 100644 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_sa1n_sa2n.json mode change 100755 => 100644 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_xnyn.json mode change 100755 => 100644 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_xnyp.json mode change 100755 => 100644 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_xpyn.json mode change 100755 => 100644 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_xpyp.json mode change 100755 => 100644 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major.json mode change 100755 => 100644 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_complex_access_pattern.json mode change 100755 => 100644 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_oa.json mode change 100755 => 100644 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_sa1_sa2.json mode change 100755 => 100644 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_sa1_sa2n.json mode change 100755 => 100644 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_sa1n_sa2.json mode change 100755 => 100644 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_sa1n_sa2n.json mode change 100755 => 100644 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_xnyn.json mode change 100755 => 100644 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_xnyp.json mode change 100755 => 100644 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_xpyn.json mode change 100755 => 100644 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_xpyp.json mode change 100755 => 100644 lib/node_modules/@stdlib/blas/base/dger/test/test.dger.js mode change 100755 => 100644 lib/node_modules/@stdlib/blas/base/dger/test/test.js mode change 100755 => 100644 lib/node_modules/@stdlib/blas/base/dger/test/test.ndarray.js diff --git a/lib/node_modules/@stdlib/blas/base/dger/README.md b/lib/node_modules/@stdlib/blas/base/dger/README.md old mode 100755 new mode 100644 diff --git a/lib/node_modules/@stdlib/blas/base/dger/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/dger/benchmark/benchmark.js old mode 100755 new mode 100644 diff --git a/lib/node_modules/@stdlib/blas/base/dger/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/dger/benchmark/benchmark.ndarray.js old mode 100755 new mode 100644 diff --git a/lib/node_modules/@stdlib/blas/base/dger/examples/index.js b/lib/node_modules/@stdlib/blas/base/dger/examples/index.js old mode 100755 new mode 100644 diff --git a/lib/node_modules/@stdlib/blas/base/dger/lib/base.js b/lib/node_modules/@stdlib/blas/base/dger/lib/base.js old mode 100755 new mode 100644 diff --git a/lib/node_modules/@stdlib/blas/base/dger/lib/dger.js b/lib/node_modules/@stdlib/blas/base/dger/lib/dger.js old mode 100755 new mode 100644 diff --git a/lib/node_modules/@stdlib/blas/base/dger/lib/index.js b/lib/node_modules/@stdlib/blas/base/dger/lib/index.js old mode 100755 new mode 100644 diff --git a/lib/node_modules/@stdlib/blas/base/dger/lib/main.js b/lib/node_modules/@stdlib/blas/base/dger/lib/main.js old mode 100755 new mode 100644 diff --git a/lib/node_modules/@stdlib/blas/base/dger/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/dger/lib/ndarray.js old mode 100755 new mode 100644 diff --git a/lib/node_modules/@stdlib/blas/base/dger/package.json b/lib/node_modules/@stdlib/blas/base/dger/package.json old mode 100755 new mode 100644 diff --git a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major.json old mode 100755 new mode 100644 diff --git a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_complex_access_pattern.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_complex_access_pattern.json old mode 100755 new mode 100644 diff --git a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_oa.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_oa.json old mode 100755 new mode 100644 diff --git a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_sa1_sa2.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_sa1_sa2.json old mode 100755 new mode 100644 diff --git a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_sa1_sa2n.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_sa1_sa2n.json old mode 100755 new mode 100644 diff --git a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_sa1n_sa2.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_sa1n_sa2.json old mode 100755 new mode 100644 diff --git a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_sa1n_sa2n.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_sa1n_sa2n.json old mode 100755 new mode 100644 diff --git a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_xnyn.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_xnyn.json old mode 100755 new mode 100644 diff --git a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_xnyp.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_xnyp.json old mode 100755 new mode 100644 diff --git a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_xpyn.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_xpyn.json old mode 100755 new mode 100644 diff --git a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_xpyp.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_xpyp.json old mode 100755 new mode 100644 diff --git a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major.json old mode 100755 new mode 100644 diff --git a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_complex_access_pattern.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_complex_access_pattern.json old mode 100755 new mode 100644 diff --git a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_oa.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_oa.json old mode 100755 new mode 100644 diff --git a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_sa1_sa2.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_sa1_sa2.json old mode 100755 new mode 100644 diff --git a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_sa1_sa2n.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_sa1_sa2n.json old mode 100755 new mode 100644 diff --git a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_sa1n_sa2.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_sa1n_sa2.json old mode 100755 new mode 100644 diff --git a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_sa1n_sa2n.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_sa1n_sa2n.json old mode 100755 new mode 100644 diff --git a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_xnyn.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_xnyn.json old mode 100755 new mode 100644 diff --git a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_xnyp.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_xnyp.json old mode 100755 new mode 100644 diff --git a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_xpyn.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_xpyn.json old mode 100755 new mode 100644 diff --git a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_xpyp.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_xpyp.json old mode 100755 new mode 100644 diff --git a/lib/node_modules/@stdlib/blas/base/dger/test/test.dger.js b/lib/node_modules/@stdlib/blas/base/dger/test/test.dger.js old mode 100755 new mode 100644 diff --git a/lib/node_modules/@stdlib/blas/base/dger/test/test.js b/lib/node_modules/@stdlib/blas/base/dger/test/test.js old mode 100755 new mode 100644 diff --git a/lib/node_modules/@stdlib/blas/base/dger/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/dger/test/test.ndarray.js old mode 100755 new mode 100644 From 0d43dbd06f530d136786a2aceb31254ff546061d Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Wed, 26 Mar 2025 18:49:13 +0530 Subject: [PATCH 05/38] fix: package.json lint error --- 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: passed - 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/dger/package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dger/package.json b/lib/node_modules/@stdlib/blas/base/dger/package.json index a4e79026e71d..eaef5fd98497 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/package.json +++ b/lib/node_modules/@stdlib/blas/base/dger/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/blas/base/dger", "version": "0.0.0", - "description": "Perform the rank 1 operation A = alpha⋅x⋅y^T + A.", + "description": "Perform the rank 1 operation `A = α*x*y^T + A`.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", @@ -14,10 +14,10 @@ } ], "main": "./lib", - "browser": "./lib/main.js", "directories": { - "example": "./examples", + "benchmark": "./benchmark", "doc": "./docs", + "example": "./examples", "lib": "./lib", "test": "./test" }, From ff417f41ab2c62852649f7b722477b4c3e517a1d Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Thu, 12 Jun 2025 22:10:43 +0530 Subject: [PATCH 06/38] chore: minor clean-up Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- lib/node_modules/@stdlib/blas/base/dger/docs/types/index.d.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dger/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/dger/docs/types/index.d.ts index f9e61fce3fc8..8c2d911e2b3b 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/dger/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 1f03887ea0663a6c6e1bb3e9f2b8d1eeb0d2b1b3 Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Thu, 12 Jun 2025 22:18:27 +0530 Subject: [PATCH 07/38] chore: minor clean-up Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- lib/node_modules/@stdlib/blas/base/dger/lib/base.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dger/lib/base.js b/lib/node_modules/@stdlib/blas/base/dger/lib/base.js index 84d15d55e228..55378dee300d 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/lib/base.js +++ b/lib/node_modules/@stdlib/blas/base/dger/lib/base.js @@ -82,9 +82,9 @@ function dger( M, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, strideA if ( y[ iy1 ] !== 0.0 ) { tmp = alpha * y[ iy1 ]; ix1 = offsetX; - oa = offsetA + (sa1*i1); + oa = offsetA + ( sa1 * i1 ); for ( i0 = 0; i0 < M; i0++ ) { - A[ oa+(sa0*i0) ] += x[ ix1 ] * tmp; + A[ oa + ( sa0 * i0 ) ] += x[ ix1 ] * tmp; ix1 += strideX; } } @@ -99,7 +99,7 @@ function dger( M, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, strideA iy1 = offsetY; oa = offsetA + (sa1*i1); for ( i0 = 0; i0 < N; i0++ ) { - A[ oa+(sa0*i0) ] += y[ iy1 ] * tmp; + A[ oa + ( sa0 * i0 ) ] += y[ iy1 ] * tmp; iy1 += strideY; } } From b589cc323367d8d8064cb97bd04aa82e6fe08b13 Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Thu, 12 Jun 2025 22:26:42 +0530 Subject: [PATCH 08/38] chore: add lda check Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- lib/node_modules/@stdlib/blas/base/dger/lib/dger.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/node_modules/@stdlib/blas/base/dger/lib/dger.js b/lib/node_modules/@stdlib/blas/base/dger/lib/dger.js index 33f2b437dbd7..490c183418ee 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/lib/dger.js +++ b/lib/node_modules/@stdlib/blas/base/dger/lib/dger.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 {Float64Array} `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 dger( 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 dger( 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 82da916e059bed54c5731674e7f19cad1b6865ee Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Thu, 12 Jun 2025 22:28:41 +0530 Subject: [PATCH 09/38] chore: minor clean-up Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- lib/node_modules/@stdlib/blas/base/dger/lib/dger.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/node_modules/@stdlib/blas/base/dger/lib/dger.js b/lib/node_modules/@stdlib/blas/base/dger/lib/dger.js index 490c183418ee..6a97873585b2 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/lib/dger.js +++ b/lib/node_modules/@stdlib/blas/base/dger/lib/dger.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 f40407f4b5f9ad6b406a683838b3f31c355a3820 Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Thu, 12 Jun 2025 22:36:54 +0530 Subject: [PATCH 10/38] chore: add matrix representation Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- .../@stdlib/blas/base/dger/test/fixtures/column_major.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major.json index 19adb72ab470..192f5a6abe6a 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major.json +++ b/lib/node_modules/@stdlib/blas/base/dger/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, 4.0, 2.0 ], + [ 5.0, 3.0, 6.0 ] + ], "lda": 2, "strideA1": 1, "strideA2": 2, From 74ba82fa8adc8007a6d4ebf9828c73ac21b37e99 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Thu, 12 Jun 2025 22:49:54 +0530 Subject: [PATCH 11/38] chore: add matrix representations --- 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/dger/test/fixtures/column_major.json | 4 +- .../dger/test/fixtures/column_major_ox.json | 22 +++++ .../dger/test/fixtures/column_major_oy.json | 22 +++++ .../dger/test/fixtures/column_major_xnyn.json | 4 + .../dger/test/fixtures/column_major_xnyp.json | 4 + .../dger/test/fixtures/column_major_xpyn.json | 4 + .../dger/test/fixtures/column_major_xpyp.json | 4 + .../base/dger/test/fixtures/row_major.json | 4 + .../base/dger/test/fixtures/row_major_ox.json | 22 +++++ .../base/dger/test/fixtures/row_major_oy.json | 22 +++++ .../dger/test/fixtures/row_major_xnyn.json | 4 + .../dger/test/fixtures/row_major_xnyp.json | 4 + .../dger/test/fixtures/row_major_xpyn.json | 4 + .../dger/test/fixtures/row_major_xpyp.json | 4 + .../blas/base/dger/test/test.ndarray.js | 92 +++++++++++++++++++ 15 files changed, 218 insertions(+), 2 deletions(-) create mode 100644 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_ox.json create mode 100644 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_oy.json create mode 100644 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_ox.json create mode 100644 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_oy.json diff --git a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major.json index 192f5a6abe6a..277c350146f0 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major.json +++ b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major.json @@ -11,8 +11,8 @@ "offsetY": 0, "A": [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ], "A_mat": [ - [ 1.0, 4.0, 2.0 ], - [ 5.0, 3.0, 6.0 ] + [ 1.0, 2.0, 3.0 ], + [ 4.0, 5.0, 6.0 ] ], "lda": 2, "strideA1": 1, diff --git a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_ox.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_ox.json new file mode 100644 index 000000000000..ac3db51d9545 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/column_major_oy.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_oy.json new file mode 100644 index 000000000000..d11a7ca06684 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/column_major_xnyn.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_xnyn.json index f107aa4eb727..df5d1cf78f43 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_xnyn.json +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/column_major_xnyp.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_xnyp.json index fcfb609eb3f0..33979ab2d0af 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_xnyp.json +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/column_major_xpyn.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_xpyn.json index 2cc21048ac0d..96cb5e88b6c9 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_xpyn.json +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/column_major_xpyp.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_xpyp.json index 7ddda6580f6b..33fbd18fdb62 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_xpyp.json +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/row_major.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major.json index 6c5a8c89a176..2ab84ca7d4d3 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major.json +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/row_major_ox.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_ox.json new file mode 100644 index 000000000000..776f9aadfadb --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/row_major_oy.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_oy.json new file mode 100644 index 000000000000..c95e6b470f60 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/row_major_xnyn.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_xnyn.json index 7713b84d9d54..f158f9dc7d90 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_xnyn.json +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/row_major_xnyp.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_xnyp.json index fea1b4dbd0a0..7fb10bf73ee5 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_xnyp.json +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/row_major_xpyn.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_xpyn.json index e89ebada429c..66a5aedb4406 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_xpyn.json +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/row_major_xpyp.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_xpyp.json index 4291cb6a8b27..43f67e9fb316 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_xpyp.json +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/dger/test/test.ndarray.js index c749f1a76dca..083be7dc3710 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/dger/test/test.ndarray.js @@ -31,6 +31,8 @@ var dger = 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' ); @@ -43,6 +45,8 @@ 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 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' ); @@ -739,6 +743,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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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; From 261345321f6bfcac9582bb2861ff1ac38eff994a Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Fri, 13 Jun 2025 10:20:36 +0530 Subject: [PATCH 12/38] 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 --- --- .../column_major_complex_access_pattern.json | 4 +++ .../dger/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 +++ .../row_major_complex_access_pattern.json | 4 +++ .../base/dger/test/fixtures/row_major_oa.json | 4 +++ .../dger/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 +++ .../@stdlib/blas/base/dger/test/test.dger.js | 27 +++++++++++++++++++ 13 files changed, 75 insertions(+) diff --git a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_complex_access_pattern.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_complex_access_pattern.json index d52726883a6d..a395d2dd0e44 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_complex_access_pattern.json +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/column_major_oa.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_oa.json index 6bb4f94e3616..375ff499e318 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_oa.json +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/column_major_sa1_sa2.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_sa1_sa2.json index 20c43b149187..3bdfd0849d8d 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_sa1_sa2.json +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/column_major_sa1_sa2n.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_sa1_sa2n.json index ab7ac9e8897d..31d8fa03f512 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_sa1_sa2n.json +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/column_major_sa1n_sa2.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_sa1n_sa2.json index 82884c1c0804..38229e4d9f20 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_sa1n_sa2.json +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/column_major_sa1n_sa2n.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_sa1n_sa2n.json index ba307fda875c..fce200afaa36 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_sa1n_sa2n.json +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/row_major_complex_access_pattern.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_complex_access_pattern.json index 53f86d6f795d..055b990e0c7d 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_complex_access_pattern.json +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/row_major_oa.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_oa.json index dce60e368fb3..809dfee2957e 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_oa.json +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/row_major_sa1_sa2.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_sa1_sa2.json index 6fd51996873f..0831d623801a 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_sa1_sa2.json +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/row_major_sa1_sa2n.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_sa1_sa2n.json index ab7ac9e8897d..31d8fa03f512 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_sa1_sa2n.json +++ b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_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/dger/test/fixtures/row_major_sa1n_sa2.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_sa1n_sa2.json index 82884c1c0804..38229e4d9f20 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_sa1n_sa2.json +++ b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_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/dger/test/fixtures/row_major_sa1n_sa2n.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_sa1n_sa2n.json index ba307fda875c..fce200afaa36 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_sa1n_sa2n.json +++ b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_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/dger/test/test.dger.js b/lib/node_modules/@stdlib/blas/base/dger/test/test.dger.js index bbb5d60bff12..04209b915c08 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/test.dger.js +++ b/lib/node_modules/@stdlib/blas/base/dger/test/test.dger.js @@ -177,6 +177,33 @@ 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 = [ + -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() { + dger( data.order, data.M, data.N, data.alpha, new Float64Array( data.x ), data.strideX, new Float64Array( data.y ), data.strideY, new Float64Array( 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 869375be8653935eda2944e41408361222bc6349 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Tue, 24 Jun 2025 15:11:28 +0530 Subject: [PATCH 13/38] chore: revert deleted files --- .../@stdlib/blas/base/dger/binding.gyp | 265 +++++++++++ .../blas/base/dger/examples/c/Makefile | 146 ++++++ .../blas/base/dger/examples/c/example.c | 54 +++ .../@stdlib/blas/base/dger/include.gypi | 70 +++ .../base/dger/include/stdlib/blas/base/dger.h | 43 ++ .../include/stdlib/blas/base/dger_cblas.h | 43 ++ .../include/stdlib/blas/base/dger_fortran.h | 41 ++ .../@stdlib/blas/base/dger/lib/dger.native.js | 72 +++ .../@stdlib/blas/base/dger/lib/native.js | 35 ++ .../blas/base/dger/lib/ndarray.native.js | 86 ++++ .../@stdlib/blas/base/dger/manifest.json | 433 ++++++++++++++++++ .../@stdlib/blas/base/dger/src/Makefile | 70 +++ .../@stdlib/blas/base/dger/src/addon.c | 61 +++ .../@stdlib/blas/base/dger/src/dger.c | 158 +++++++ .../@stdlib/blas/base/dger/src/dger.f | 148 ++++++ .../@stdlib/blas/base/dger/src/dger_cblas.c | 39 ++ .../@stdlib/blas/base/dger/src/dger_f.c | 55 +++ 17 files changed, 1819 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/dger/binding.gyp create mode 100644 lib/node_modules/@stdlib/blas/base/dger/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/dger/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/blas/base/dger/include.gypi create mode 100644 lib/node_modules/@stdlib/blas/base/dger/include/stdlib/blas/base/dger.h create mode 100644 lib/node_modules/@stdlib/blas/base/dger/include/stdlib/blas/base/dger_cblas.h create mode 100644 lib/node_modules/@stdlib/blas/base/dger/include/stdlib/blas/base/dger_fortran.h create mode 100644 lib/node_modules/@stdlib/blas/base/dger/lib/dger.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/dger/lib/native.js create mode 100644 lib/node_modules/@stdlib/blas/base/dger/lib/ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/dger/manifest.json create mode 100644 lib/node_modules/@stdlib/blas/base/dger/src/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/dger/src/addon.c create mode 100644 lib/node_modules/@stdlib/blas/base/dger/src/dger.c create mode 100644 lib/node_modules/@stdlib/blas/base/dger/src/dger.f create mode 100644 lib/node_modules/@stdlib/blas/base/dger/src/dger_cblas.c create mode 100644 lib/node_modules/@stdlib/blas/base/dger/src/dger_f.c diff --git a/lib/node_modules/@stdlib/blas/base/dger/binding.gyp b/lib/node_modules/@stdlib/blas/base/dger/binding.gyp new file mode 100644 index 000000000000..02a2799da097 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/examples/c/Makefile b/lib/node_modules/@stdlib/blas/base/dger/examples/c/Makefile new file mode 100644 index 000000000000..6aed70daf167 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/examples/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @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 + +# 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 diff --git a/lib/node_modules/@stdlib/blas/base/dger/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/dger/examples/c/example.c new file mode 100644 index 000000000000..63fb90b3ea5a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/examples/c/example.c @@ -0,0 +1,54 @@ +/** +* @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 4x3 matrix `B` stored in row-major order (i.e., equivalent to the transpose `A^T` of a 3x4 matrix `A` stored in column-major order): + double B[ 4*3 ] = { + 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^T` and `y` vectors: + double x[ 4 ] = { 0.0, 1.0, 2.0, 3.0 }; // M + double y[ 3 ] = { 1.0, 4.0, 0.0 }; // N + + // Specify the number of rows and columns: + const int M = 4; + const int N = 3; + + // Specify stride lengths: + const int strideX = 1; + const int strideY = 1; + + // Specify the matrix layout: + const CBLAS_LAYOUT layout = CblasRowMajor; + + // Perform operation (note: arguments are reordered as: A_{M,N} = α⋅x_M⋅y^T_N + A_{M,N} => B = A^T = α⋅y⋅x^T + A^T = α⋅y⋅x^T + B): + c_dger( layout, N, M, 1.0, y, strideY, x, strideX, B, M ); + + // Print the result: + for ( int i = 0; i < N; i++ ) { + for ( int j = 0; j < M; j++ ) { + printf( "B[%i,%i] = %lf\n", i, j, B[ (i*M)+j ] ); + } + } +} diff --git a/lib/node_modules/@stdlib/blas/base/dger/include.gypi b/lib/node_modules/@stdlib/blas/base/dger/include.gypi new file mode 100644 index 000000000000..497aeca15320 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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)', + ' [ 0.0, 1.0, 2.0, 3.0, 0.0, 4.0, 8.0, 12.0, 0.0, 0.0, 0.0, 0.0 ] +*/ +function dger( order, M, N, alpha, x, strideX, y, strideY, A, LDA ) { + var ord = resolve( order ); + if ( ord === null ) { + throw new TypeError( format( 'invalid argument. First argument must be a supported BLAS memory layout. Value: `%s`.', order ) ); + } + addon( ord, M, N, alpha, x, strideX, y, strideY, A, LDA ); + return A; +} + + +// EXPORTS // + +module.exports = dger; diff --git a/lib/node_modules/@stdlib/blas/base/dger/lib/native.js b/lib/node_modules/@stdlib/blas/base/dger/lib/native.js new file mode 100644 index 000000000000..18c0998f60c6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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 dger = require( './dger.native.js' ); +var ndarray = require( './ndarray.native.js' ); + + +// MAIN // + +setReadOnly( dger, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dger; diff --git a/lib/node_modules/@stdlib/blas/base/dger/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dger/lib/ndarray.native.js new file mode 100644 index 000000000000..c91cf81824e2 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/lib/ndarray.native.js @@ -0,0 +1,86 @@ +/** +* @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 minViewBufferIndex = require( '@stdlib/strided/base/min-view-buffer-index' ); +var offsetView = require( '@stdlib/strided/base/offset-view' ); +var resolve = require( '@stdlib/blas/base/layout-resolve-enum' ); +var format = require( '@stdlib/string/format' ); +var addon = require( './dger.native.js' ); + + +// MAIN // + +/** +* Performs the rank 1 operation `A = alpha*x*y^T + A`. +* +* @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 {Float64Array} x - an `M` element vector +* @param {integer} strideX - `x` stride length +* @param {NonNegativeInteger} offsetX - starting `x` index +* @param {Float64Array} y - an `N` element vector +* @param {integer} strideY - `y` stride length +* @param {NonNegativeInteger} offsetY - starting `y` index +* @param {Float64Array} 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 supported BLAS memory layout +* @returns {Float64Array} `A` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var M = 4; +* var N = 3; +* +* var B = new Float64Array( M*N ); +* +* var x = new Float64Array( [ 0.0, 1.0, 2.0, 3.0 ] ); +* var y = new Float64Array( [ 1.0, 4.0, 0.0 ] ); +* +* dger( 'row-major', N, M, 1.0, y, 1, 0, x, 1, 0, B, M ); +* // B => [ 0.0, 1.0, 2.0, 3.0, 0.0, 4.0, 8.0, 12.0, 0.0, 0.0, 0.0, 0.0 ] +*/ +function dger( order, M, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, LDA ) { // eslint-disable-line max-len, max-params + var viewX; + var viewY; + var ord; + + ord = resolve( order ); + if ( ord === null ) { + throw new TypeError( format( 'invalid argument. First argument must be a supported BLAS memory layout. Value: `%s`.', order ) ); + } + offsetX = minViewBufferIndex( N, strideX, offsetX ); + offsetY = minViewBufferIndex( N, strideY, offsetY ); + + viewX = offsetView( x, offsetX ); + viewY = offsetView( y, offsetY ); + + addon( ord, M, N, alpha, viewX, strideX, viewY, strideY, A, LDA ); + return A; +} + + +// EXPORTS // + +module.exports = dger; diff --git a/lib/node_modules/@stdlib/blas/base/dger/manifest.json b/lib/node_modules/@stdlib/blas/base/dger/manifest.json new file mode 100644 index 000000000000..7494358b4d85 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/manifest.json @@ -0,0 +1,433 @@ +{ + "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/dger.f", + "./src/dger_f.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-float64array", + "@stdlib/napi/argv-double" + ] + }, + { + "task": "benchmark", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/dger.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla" + ] + }, + { + "task": "examples", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/dger.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla" + ] + }, + + { + "task": "build", + "os": "linux", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/dger_cblas.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-float64array", + "@stdlib/napi/argv-double" + ] + }, + { + "task": "benchmark", + "os": "linux", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/dger_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + { + "task": "examples", + "os": "linux", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/dger_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + + { + "task": "build", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/dger.f", + "./src/dger_f.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-float64array", + "@stdlib/napi/argv-double" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/dger.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla" + ] + }, + { + "task": "examples", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/dger.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla" + ] + }, + + { + "task": "build", + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/dger_cblas.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-float64array", + "@stdlib/napi/argv-double" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/dger_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lblas" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + { + "task": "examples", + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/dger_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lblas" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + + { + "task": "build", + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/dger_cblas.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-float64array", + "@stdlib/napi/argv-double" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/dger_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + { + "task": "examples", + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/dger_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + + { + "task": "build", + "os": "win", + "blas": "", + "wasm": false, + "src": [ + "./src/dger.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-float64array", + "@stdlib/napi/argv-double" + ] + }, + { + "task": "benchmark", + "os": "win", + "blas": "", + "wasm": false, + "src": [ + "./src/dger.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla" + ] + }, + { + "task": "examples", + "os": "win", + "blas": "", + "wasm": false, + "src": [ + "./src/dger.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla" + ] + }, + + { + "task": "build", + "os": "", + "blas": "", + "wasm": true, + "src": [ + "./src/dger.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dger/src/Makefile b/lib/node_modules/@stdlib/blas/base/dger/src/Makefile new file mode 100644 index 000000000000..bcf18aa46655 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/src/addon.c b/lib/node_modules/@stdlib/blas/base/dger/src/addon.c new file mode 100644 index 000000000000..10b035c54414 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/src/addon.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 "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_double.h" +#include "stdlib/napi/argv_strided_float64array.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_DOUBLE( env, alpha, argv, 3 ); + + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 5 ); + STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 7 ); + + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, M, strideX, argv, 4 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Y, N, strideY, argv, 6 ); + + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, A, ((M-1)*LDA) + N, 1, argv, 8 ); + + API_SUFFIX(c_dger)( layout, M, N, alpha, X, strideX, Y, strideY, A, LDA ); + + return NULL; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN( addon ) diff --git a/lib/node_modules/@stdlib/blas/base/dger/src/dger.c b/lib/node_modules/@stdlib/blas/base/dger/src/dger.c new file mode 100644 index 000000000000..c96e481b7293 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/src/dger.c @@ -0,0 +1,158 @@ +/** +* @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/xerbla.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. +* +* ## Notes +* +* - The function follows the CBLAS interface which reflects the corresponding Fortran interface, which in turn assumes column-major order. As a matrix stored in row-major order is equivalent to storing the matrix's transpose in column-major order, we can interpret an M-by-N row-major matrix "B" as the matrix "A^T" stored in column-major. 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, the C calling convention for row-major order is to swap the order of input arguments such that for a column-major `A` where the stride of the "major" (outer) dimension is `LDA = N` +* +* ```c +* c_dger( CblasColMajor, M, N, alpha, X, strideX, Y, strideY, A, N ) +* ``` +* +* and for a row-major `B = A^T` where the stride of the "major" (outer) dimension is `LDA = M` +* +* ```c +* c_dger( CblasRowMajor, N, M, alpha, Y, strideY, X, strideX, A^T, M ) +* ``` +* +* @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 X stride length +* @param Y an `N` element vector +* @param strideY Y stride length +* @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_dger)( const CBLAS_LAYOUT layout, const CBLAS_INT M, const CBLAS_INT N, const double alpha, double *X, const CBLAS_INT strideX, double *Y, const CBLAS_INT strideY, double *A, const CBLAS_INT LDA ) { + CBLAS_INT info; + CBLAS_INT sx; + CBLAS_INT sy; + CBLAS_INT ix; + CBLAS_INT jy; + CBLAS_INT kx; + CBLAS_INT i; + CBLAS_INT j; + CBLAS_INT m; + CBLAS_INT n; + double tmp; + double *x; + double *y; + + // Perform input argument validation... + info = 0; + if ( M < 0 ) { + info = 1; + } else if ( N < 0 ) { + info = 2; + } else if ( strideX == 0 ) { + info = 5; + } else if ( strideY == 0 ) { + info = 7; + } else { + if ( M < 1 ) { + j = 1; + } else { + j = M; + } + if ( LDA < j ) { + info = 9; + } + } + if ( info != 0 ) { + c_xerbla( info, "c_dger", "" ); + return; + } + // Check whether we can avoid computation altogether... + if ( M == 0 || N == 0 || alpha == 0.0 ) { + return; + } + // When provided a row-major matrix, we need to swap arguments... + if ( layout == CblasRowMajor ) { + x = Y; + y = X; + m = N; + n = M; + sx = strideY; + sy = strideX; + } else { + x = X; + y = Y; + m = M; + n = N; + sx = strideX; + sy = strideY; + } + // Proceed with computation... + if ( sy > 0 ) { + jy = 0; + } else { + jy = ( 1 - n ) * sy; + } + if ( sx == 1 ) { + for ( j = 0; j < n; j++ ) { + if ( y[ jy ] != 0.0 ) { + tmp = alpha * y[ jy ]; + for ( i = 0; i < m; i++ ) { + A[ (j*LDA)+i ] += x[ i ] * tmp; // per above, x has unit stride + } + } + jy += sy; + } + return; + } + if ( sx > 0 ) { + kx = 0; + } else { + kx = ( 1 - m ) * sx; + } + for ( j = 0; j < n; j++ ) { + if ( y[ jy ] != 0.0 ) { + tmp = alpha * y[ jy ]; + ix = kx; + for ( i = 0; i < m; i++ ) { + A[ (j*LDA)+i ] += x[ ix ] * tmp; + ix += sx; + } + } + jy += sy; + } + return; +} diff --git a/lib/node_modules/@stdlib/blas/base/dger/src/dger.f b/lib/node_modules/@stdlib/blas/base/dger/src/dger.f new file mode 100644 index 000000000000..0a56eb9da5c4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/src/dger.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 {double} alpha - scalar constant +! @param {Array} X - an `M` element vector +! @param {integer} strideX - `X` stride length +! @param {Array} Y - an `N` element vector +! @param {integer} strideY - `Y` stride length +! @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 dger( M, N, alpha, X, strideX, Y, strideY, A, LDA ) + implicit none + ! .. + ! Internal parameters: + integer, parameter :: dp=kind(0.0d0) ! double-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( 'dger ', 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 dger \ No newline at end of file diff --git a/lib/node_modules/@stdlib/blas/base/dger/src/dger_cblas.c b/lib/node_modules/@stdlib/blas/base/dger/src/dger_cblas.c new file mode 100644 index 000000000000..d2445a4ed309 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/src/dger_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/dger.h" +#include "stdlib/blas/base/dger_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 X stride length +* @param Y an `N` element vector +* @param strideY Y stride length +* @param A matrix of coefficients +* @param LDA index of the first dimension of `A` +*/ +void API_SUFFIX(c_dger)( const CBLAS_LAYOUT layout, const CBLAS_INT M, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const double *Y, const CBLAS_INT strideY, double *A, const CBLAS_INT LDA ) { + API_SUFFIX(cblas_dger)( layout, M, N, alpha, X, strideX, Y, strideY, A, LDA ); +} diff --git a/lib/node_modules/@stdlib/blas/base/dger/src/dger_f.c b/lib/node_modules/@stdlib/blas/base/dger/src/dger_f.c new file mode 100644 index 000000000000..0be9e8b58350 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/src/dger_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/dger.h" +#include "stdlib/blas/base/dger_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 X stride length +* @param Y an `N` element vector +* @param strideY Y stride length +* @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_dger)( const CBLAS_LAYOUT layout, const CBLAS_INT M, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const double *Y, const CBLAS_INT strideY, double *A, const CBLAS_INT LDA ) { + extern int RowMajorStrg; // global flag + + RowMajorStrg = 0; + if ( layout == CblasColMajor ) { + dger( &M, &N, &alpha, X, &strideX, Y, &strideY, A, &LDA ); + return; + } + if ( layout == CblasRowMajor ) { + RowMajorStrg = 1; + dger( &N, &M, &alpha, Y, &strideY, X, &strideX, A, &LDA ); + RowMajorStrg = 0; + return; + } + c_xerbla( 1, "c_dger", "Error: invalid argument. First argument must be a valid storage layout. Value: `%d`.", layout ); + RowMajorStrg = 0; + return; +} From 156ef2025275afdce77e52076e8b6d162c783b1a Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Tue, 24 Jun 2025 15:18:55 +0530 Subject: [PATCH 14/38] chore: update package.json Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- lib/node_modules/@stdlib/blas/base/dger/package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dger/package.json b/lib/node_modules/@stdlib/blas/base/dger/package.json index eaef5fd98497..8bc86155377c 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/package.json +++ b/lib/node_modules/@stdlib/blas/base/dger/package.json @@ -14,11 +14,13 @@ } ], "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", From 427d8e789364375130ca5c592c13ba505dc7a6d3 Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Tue, 24 Jun 2025 15:27:13 +0530 Subject: [PATCH 15/38] chore: update package.json Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- lib/node_modules/@stdlib/blas/base/dger/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/dger/package.json b/lib/node_modules/@stdlib/blas/base/dger/package.json index 8bc86155377c..00df3c97c994 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/package.json +++ b/lib/node_modules/@stdlib/blas/base/dger/package.json @@ -14,7 +14,6 @@ } ], "main": "./lib", - "browser": "./lib/main.js", "gypfile": true, "directories": { "example": "./examples", From 697b398074ed272974ac5aab68d8fef057522c13 Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Tue, 24 Jun 2025 15:36:21 +0530 Subject: [PATCH 16/38] chore: update package.json Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- lib/node_modules/@stdlib/blas/base/dger/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/node_modules/@stdlib/blas/base/dger/package.json b/lib/node_modules/@stdlib/blas/base/dger/package.json index 00df3c97c994..8bc86155377c 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/package.json +++ b/lib/node_modules/@stdlib/blas/base/dger/package.json @@ -14,6 +14,7 @@ } ], "main": "./lib", + "browser": "./lib/main.js", "gypfile": true, "directories": { "example": "./examples", From de5b1afd1a667f6499a4a75f8b8bb64abe46a0aa Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Tue, 24 Jun 2025 17:46:49 +0530 Subject: [PATCH 17/38] chore: update implementation Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- .../@stdlib/blas/base/dger/lib/base.js | 66 +++++-------------- 1 file changed, 15 insertions(+), 51 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dger/lib/base.js b/lib/node_modules/@stdlib/blas/base/dger/lib/base.js index 55378dee300d..6e420a82e6c8 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/lib/base.js +++ b/lib/node_modules/@stdlib/blas/base/dger/lib/base.js @@ -18,11 +18,6 @@ 'use strict'; -// MODULES // - -var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); - - // MAIN // /** @@ -54,56 +49,25 @@ var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); * // A => [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] */ function dger( 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... + var idx; + var jy; + var ix; + var i; + var j; - 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 = alpha * y[ iy1 ]; - ix1 = offsetX; - oa = offsetA + ( sa1 * i1 ); - for ( i0 = 0; i0 < M; i0++ ) { - A[ oa + ( sa0 * i0 ) ] += x[ ix1 ] * tmp; - ix1 += strideX; - } - } - iy1 += strideY; - } - return A; - } - ix1 = offsetX; - for ( i1 = 0; i1 < M; i1++ ) { - if ( x[ ix1 ] !== 0.0 ) { - tmp = alpha * x[ ix1 ]; - iy1 = offsetY; - oa = offsetA + (sa1*i1); - for ( i0 = 0; i0 < N; i0++ ) { - A[ oa + ( sa0 * i0 ) ] += y[ iy1 ] * tmp; - iy1 += strideY; + jy = offsetY; + for ( j = 0; j < N; j++ ) { + if ( y[ jy ] !== 0.0 ) { + tmp = alpha * y[ jy ]; + ix = offsetX; + for ( i = 0; i < M; i++ ) { + idx = offsetA + ( i * strideA1 ) + ( j * strideA2 ); + A[ idx ] += x[ ix ] * tmp; + ix += strideX; } } - ix1 += strideX; + jy += strideY; } return A; } From 6319005fd54b970f4506eef81b1d97dc2aebab92 Mon Sep 17 00:00:00 2001 From: Athan Date: Tue, 24 Jun 2025 22:06:01 -0700 Subject: [PATCH 18/38] chore: initial 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: passed - 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/dger/lib/base.js | 3 +- .../@stdlib/blas/base/dger/lib/dger.js | 8 +-- .../@stdlib/blas/base/dger/lib/dger.native.js | 29 ++++---- .../@stdlib/blas/base/dger/lib/index.js | 4 +- .../@stdlib/blas/base/dger/lib/ndarray.js | 2 +- .../blas/base/dger/lib/ndarray.native.js | 69 +++++++++---------- 6 files changed, 58 insertions(+), 57 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dger/lib/base.js b/lib/node_modules/@stdlib/blas/base/dger/lib/base.js index 55378dee300d..4bc68b71d989 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/lib/base.js +++ b/lib/node_modules/@stdlib/blas/base/dger/lib/base.js @@ -26,8 +26,9 @@ 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. * +* @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 diff --git a/lib/node_modules/@stdlib/blas/base/dger/lib/dger.js b/lib/node_modules/@stdlib/blas/base/dger/lib/dger.js index 6a97873585b2..9321c2239fe3 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/lib/dger.js +++ b/lib/node_modules/@stdlib/blas/base/dger/lib/dger.js @@ -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 {Float64Array} `A` * * @example @@ -69,7 +69,6 @@ function dger( 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 ) ); } @@ -85,6 +84,7 @@ function dger( 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.' ) ); } + iscm = isColumnMajor( order ); if ( iscm ) { vala = M; } else { @@ -99,7 +99,7 @@ function dger( 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/dger/lib/dger.native.js b/lib/node_modules/@stdlib/blas/base/dger/lib/dger.native.js index 80779dd74619..ccbe511df02e 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/lib/dger.native.js +++ b/lib/node_modules/@stdlib/blas/base/dger/lib/dger.native.js @@ -28,39 +28,40 @@ var addon = require( './../src/addon.node' ); // MAIN // /** -* Performs the rank 1 operation `A = alpha*x*y^T + A`. +* Performs the rank 1 operation `A = alpha*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 {Float64Array} x - an `M` element vector +* @param {Float64Array} x - first input vector * @param {integer} strideX - `x` stride length -* @param {Float64Array} y - an `N` element vector +* @param {Float64Array} y - second input vector * @param {integer} strideY - `y` stride length * @param {Float64Array} 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 supported BLAS memory layout +* @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 {Float64Array} `A` * * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var M = 4; -* var N = 3; +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var x = new Float64Array( [ 1.0, 1.0 ] ); +* var y = new Float64Array( [ 1.0, 1.0, 1.0 ] ); * -* var B = new Float64Array( M*N ); -* -* var x = new Float64Array( [ 0.0, 1.0, 2.0, 3.0 ] ); -* var y = new Float64Array( [ 1.0, 4.0, 0.0 ] ); -* -* dger( 'row-major', N, M, 1.0, y, 1, x, 1, B, M ); -* // B => [ 0.0, 1.0, 2.0, 3.0, 0.0, 4.0, 8.0, 12.0, 0.0, 0.0, 0.0, 0.0 ] +* dger( '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 dger( order, M, N, alpha, x, strideX, y, strideY, A, LDA ) { var ord = resolve( order ); if ( ord === null ) { - throw new TypeError( format( 'invalid argument. First argument must be a supported BLAS memory layout. Value: `%s`.', order ) ); + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); } addon( ord, M, N, alpha, x, strideX, y, strideY, A, LDA ); return A; diff --git a/lib/node_modules/@stdlib/blas/base/dger/lib/index.js b/lib/node_modules/@stdlib/blas/base/dger/lib/index.js index 2222c83ee6b3..1464ad6f7991 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/lib/index.js +++ b/lib/node_modules/@stdlib/blas/base/dger/lib/index.js @@ -19,7 +19,7 @@ '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. +* 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/dger * @@ -42,7 +42,7 @@ * var x = new Float64Array( [ 1.0, 1.0 ] ); * var y = new Float64Array( [ 1.0, 1.0, 1.0 ] ); * -* dger.ndarray( 'row-major', 2, 3, 1.0, x, 1, 0, y, 1, 0, A, 3, 1, 0 ); +* dger.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 ] */ diff --git a/lib/node_modules/@stdlib/blas/base/dger/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/dger/lib/ndarray.js index 79dead9cb9a2..ec2313c9f013 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/dger/lib/ndarray.js @@ -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` diff --git a/lib/node_modules/@stdlib/blas/base/dger/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dger/lib/ndarray.native.js index c91cf81824e2..2867b6c9251c 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/dger/lib/ndarray.native.js @@ -20,63 +20,62 @@ // MODULES // -var minViewBufferIndex = require( '@stdlib/strided/base/min-view-buffer-index' ); -var offsetView = require( '@stdlib/strided/base/offset-view' ); -var resolve = require( '@stdlib/blas/base/layout-resolve-enum' ); var format = require( '@stdlib/string/format' ); -var addon = require( './dger.native.js' ); +var addon = require( './../src/addon.node' ); // MAIN // /** -* Performs the rank 1 operation `A = alpha*x*y^T + A`. +* Performs the rank 1 operation `A = alpha*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 {Float64Array} x - an `M` element vector +* @param {Float64Array} x - first input vector * @param {integer} strideX - `x` stride length * @param {NonNegativeInteger} offsetX - starting `x` index -* @param {Float64Array} y - an `N` element vector +* @param {Float64Array} y - second input vector * @param {integer} strideY - `y` stride length * @param {NonNegativeInteger} offsetY - starting `y` index -* @param {Float64Array} 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 supported BLAS memory layout +* @param {Float64Array} 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 {Float64Array} `A` * * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var M = 4; -* var N = 3; +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var x = new Float64Array( [ 1.0, 1.0 ] ); +* var y = new Float64Array( [ 1.0, 1.0, 1.0 ] ); * -* var B = new Float64Array( M*N ); -* -* var x = new Float64Array( [ 0.0, 1.0, 2.0, 3.0 ] ); -* var y = new Float64Array( [ 1.0, 4.0, 0.0 ] ); -* -* dger( 'row-major', N, M, 1.0, y, 1, 0, x, 1, 0, B, M ); -* // B => [ 0.0, 1.0, 2.0, 3.0, 0.0, 4.0, 8.0, 12.0, 0.0, 0.0, 0.0, 0.0 ] +* dger( 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 dger( order, M, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, LDA ) { // eslint-disable-line max-len, max-params - var viewX; - var viewY; - var ord; - - ord = resolve( order ); - if ( ord === null ) { - throw new TypeError( format( 'invalid argument. First argument must be a supported BLAS memory layout. Value: `%s`.', order ) ); +function dger( 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 ) ); } - offsetX = minViewBufferIndex( N, strideX, offsetX ); - offsetY = minViewBufferIndex( N, strideY, offsetY ); - - viewX = offsetView( x, offsetX ); - viewY = offsetView( y, offsetY ); - - addon( ord, M, N, alpha, viewX, strideX, viewY, strideY, A, LDA ); + 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; + } + addon.ndarray( M, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, strideA1, strideA2, offsetA ); // eslint-disable-line max-len return A; } From fb6a9287429e442430963ef33232a9e1463e9673 Mon Sep 17 00:00:00 2001 From: Athan Date: Tue, 24 Jun 2025 22:54:02 -0700 Subject: [PATCH 19/38] refactor: implement loop interchange --- 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: passed - 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/dger/lib/base.js | 89 ++++++++++++++++--- 1 file changed, 76 insertions(+), 13 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dger/lib/base.js b/lib/node_modules/@stdlib/blas/base/dger/lib/base.js index 1d2a0bb603f9..ee939d39c8a0 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/lib/base.js +++ b/lib/node_modules/@stdlib/blas/base/dger/lib/base.js @@ -18,11 +18,33 @@ 'use strict'; +// MODULES // + +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. * +* ## 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. Hence, we can interpret an `M` by `N` row-major matrix `B` as the matrix `A^T` stored in column-major. 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. 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` @@ -51,24 +73,65 @@ */ function dger( M, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, strideA1, strideA2, offsetA ) { // eslint-disable-line max-params, max-len var tmp; - var idx; - var jy; + var da0; + var da1; + var sx; + var sy; + var ia; var ix; - var i; - var j; + var iy; + var i0; + var i1; + var S0; + var S1; + + // Note on variable naming convention: S#, da#, ia#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + if ( isRowMajor( [ strideA1, strideA2 ] ) ) { + // 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 - jy = offsetY; - for ( j = 0; j < N; j++ ) { - if ( y[ jy ] !== 0.0 ) { - tmp = alpha * y[ jy ]; + // 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... + S0 = M; + S1 = N; + da0 = strideA1; // offset increment for innermost loop + da1 = strideA2 - ( S0*strideA1 ); // offset increment for outermost loop + } + sx = strideX; + sy = strideY; + ix = offsetX; + iy = offsetY; + ia = offsetA; + for ( i1 = 0; i1 < S1; i1++ ) { + if ( y[ iy ] === 0.0 ) { + ia += da0 * S0; + } else { + tmp = alpha * y[ iy ]; ix = offsetX; - for ( i = 0; i < M; i++ ) { - idx = offsetA + ( i * strideA1 ) + ( j * strideA2 ); - A[ idx ] += x[ ix ] * tmp; - ix += strideX; + for ( i0 = 0; i0 < S0; i0++ ) { + A[ ia ] += x[ ix ] * tmp; + ix += sx; + ia += da0; } } - jy += strideY; + iy += sy; + ia += da1; } return A; } From ad1bad0373fdfd2810ff43b5146c1cf24ed99e0a Mon Sep 17 00:00:00 2001 From: Athan Date: Tue, 24 Jun 2025 23:31:34 -0700 Subject: [PATCH 20/38] docs: update extended comment --- 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: passed - 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/dger/lib/base.js | 47 ++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/dger/lib/base.js b/lib/node_modules/@stdlib/blas/base/dger/lib/base.js index ee939d39c8a0..2f0c7564ed1e 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/lib/base.js +++ b/lib/node_modules/@stdlib/blas/base/dger/lib/base.js @@ -30,7 +30,52 @@ var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); * * ## 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. Hence, we can interpret an `M` by `N` row-major matrix `B` as the matrix `A^T` stored in column-major. In which case, we can derive an update equation for `B` as follows: +* - 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. In which case, we can derive an update equation for `B` as follows: * * ```tex * \begin{align*} From 35b9284d72a2ce5cc1a1b84e14235a88540a049c Mon Sep 17 00:00:00 2001 From: Athan Date: Tue, 24 Jun 2025 23:35:00 -0700 Subject: [PATCH 21/38] docs: update comment and add comment --- 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: passed - 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/dger/lib/base.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dger/lib/base.js b/lib/node_modules/@stdlib/blas/base/dger/lib/base.js index 2f0c7564ed1e..728b0e1e8690 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/lib/base.js +++ b/lib/node_modules/@stdlib/blas/base/dger/lib/base.js @@ -75,7 +75,7 @@ var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); * * 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. In which case, we can derive an update equation for `B` as follows: +* 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*} @@ -88,7 +88,7 @@ var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); * \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. That is the essence of loop interchange. +* 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` @@ -164,6 +164,7 @@ function dger( M, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, strideA 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 { From 2f588bc6b0db165dc77a32e55d56414794c2bce5 Mon Sep 17 00:00:00 2001 From: Athan Date: Tue, 24 Jun 2025 23:42:48 -0700 Subject: [PATCH 22/38] fix: include invalid arguments in error messages --- 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: passed - 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/dger/lib/dger.js | 4 ++-- lib/node_modules/@stdlib/blas/base/dger/lib/ndarray.js | 4 ++-- lib/node_modules/@stdlib/blas/base/dger/lib/ndarray.native.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dger/lib/dger.js b/lib/node_modules/@stdlib/blas/base/dger/lib/dger.js index 9321c2239fe3..6c74dff3c691 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/lib/dger.js +++ b/lib/node_modules/@stdlib/blas/base/dger/lib/dger.js @@ -79,10 +79,10 @@ function dger( 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 ) { diff --git a/lib/node_modules/@stdlib/blas/base/dger/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/dger/lib/ndarray.js index ec2313c9f013..28ba2cafbd49 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/dger/lib/ndarray.js @@ -66,10 +66,10 @@ function dger( 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/dger/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dger/lib/ndarray.native.js index 2867b6c9251c..4e54641278da 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/dger/lib/ndarray.native.js @@ -66,10 +66,10 @@ function dger( 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 ) { From 6e0cd156625714a3aaa494f0c7174ee0d611504c Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 25 Jun 2025 00:17:02 -0700 Subject: [PATCH 23/38] 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: passed - 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: 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: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/blas/base/dger/README.md | 126 +++++++++++++++--- .../@stdlib/blas/base/dger/docs/repl.txt | 14 +- .../blas/base/dger/docs/types/index.d.ts | 6 +- .../blas/base/dger/examples/c/example.c | 27 ++-- .../base/dger/include/stdlib/blas/base/dger.h | 5 + .../@stdlib/blas/base/dger/manifest.json | 6 + .../@stdlib/blas/base/dger/src/addon.c | 40 +++++- 7 files changed, 181 insertions(+), 43 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dger/README.md b/lib/node_modules/@stdlib/blas/base/dger/README.md index e6663f4db5a6..66188875a82f 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/README.md +++ b/lib/node_modules/@stdlib/blas/base/dger/README.md @@ -32,7 +32,7 @@ var dger = require( '@stdlib/blas/base/dger' ); #### dger( 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. +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 Float64Array = require( '@stdlib/array/float64' ); @@ -52,13 +52,13 @@ The function has the following parameters: - **N**: number of columns in the matrix `A`. - **α**: scalar constant. - **x**: input [`Float64Array`][mdn-float64array]. -- **sx**: index increment for `x`. +- **sx**: stride length for `x`. - **y**: output [`Float64Array`][mdn-float64array]. -- **sy**: index increment for `y`. +- **sy**: stride length for `y`. - **A**: input matrix stored in linear memory as a [`Float64Array`][mdn-float64array]. - **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 Float64Array = require( '@stdlib/array/float64' ); @@ -93,7 +93,7 @@ dger( 'column-major', 2, 3, 1.0, x1, -1, y1, -1, A, 2 ); #### dger.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 Float64Array = require( '@stdlib/array/float64' ); @@ -119,12 +119,12 @@ While [`typed array`][mdn-typed-array] views mandate a view offset based on the ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var A = new Float64Array( [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] ); -var x = new Float64Array( [ 1.0, 0.0, 1.0, 0.0 ] ); -var y = new Float64Array( [ 1.0, 0.0, 1.0, 0.0, 1.0, 0.0 ] ); +var A = new Float64Array( [ 0.0, 0.0, 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] ); +var x = new Float64Array( [ 0.0, 1.0, 0.0, 1.0, 0.0 ] ); +var y = new Float64Array( [ 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0 ] ); -dger.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 ] +dger.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 ] ``` @@ -200,18 +200,80 @@ console.log(A); #include "stdlib/blas/base/dger.h" ``` -#### TODO +#### c_dger( 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" + +double 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 double x[ 3 ] = { 1.0, 4.0, 0.0 }; +const double y[ 4 ] = { 0.0, 1.0, 2.0, 3.0 }; + +c_dger( 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] double` scalar constant. +- **X**: `[in] double*` an `M` element vector. +- **strideX**: `[in] CBLAS_INT` stride length for `X`. +- **Y**: `[in] double*` an `N` element vector. +- **strideY**: `[in] CBLAS_INT` stride length for `Y`. +- **A**: `[inout] double*` 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_dger( const CBLAS_LAYOUT layout, const CBLAS_INT M, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const double *Y, const CBLAS_INT strideY, double *A, const CBLAS_INT LDA ); +``` + +#### c_dger_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" + +double 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 double x[ 3 ] = { 1.0, 4.0, 0.0 }; +const double y[ 4 ] = { 0.0, 1.0, 2.0, 3.0 }; + +c_dger_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] double` scalar constant. +- **X**: `[in] double*` an `M` element vector. +- **sx**: `[in] CBLAS_INT` stride length for `X`. +- **ox**: `[in] CBLAS_INT` starting index for `X`. +- **Y**: `[in] double*` an `N` element vector. +- **sy**: `[in] CBLAS_INT` stride length for `Y`. +- **oy**: `[in] CBLAS_INT` starting index for `Y`. +- **A**: `[inout] double*` 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_dger( onst CBLAS_INT M, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA ); ``` @@ -233,7 +295,39 @@ TODO ### Examples ```c -TODO +#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: + double 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 double x[ 3 ] = { 1.0, 4.0, 0.0 }; // M + const double 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_dger( 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] = %lf\n", i, j, A[ (i*N)+j ] ); + } + } +} ``` diff --git a/lib/node_modules/@stdlib/blas/base/dger/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/dger/docs/repl.txt index ffd73eded85e..71d8b49e30cc 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/dger/docs/repl.txt @@ -1,13 +1,13 @@ {{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 + 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. + If `M`, `N`, or `α` is equal to `0`, the function returns `A` unchanged. Parameters ---------- @@ -27,13 +27,13 @@ First input vector. sx: integer - Index increment for `x`. + Stride length for `x`. y: Float64Array Second input vector. sy: integer - Index increment for `y`. + Stride length for `y`. A: Float64Array Input Matrix. @@ -68,7 +68,7 @@ {{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 +89,7 @@ First input vector. sx: integer - Index increment for `x`. + Stride length for `x`. ox: integer Starting index for `x`. @@ -98,7 +98,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/dger/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/dger/docs/types/index.d.ts index 8c2d911e2b3b..27457a7d214f 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/dger/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: Float64Array, strideX: number, y: Float64Array, strideY: number, A: Float64Array, LDA: number ): Float64Array; /** - * 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/dger/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/dger/examples/c/example.c index 63fb90b3ea5a..ec0acd6191b6 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/base/dger/examples/c/example.c @@ -21,34 +21,31 @@ #include int main( void ) { - // Define a 4x3 matrix `B` stored in row-major order (i.e., equivalent to the transpose `A^T` of a 3x4 matrix `A` stored in column-major order): - double B[ 4*3 ] = { + // Define a 3x4 matrix stored in row-major order: + double 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^T` and `y` vectors: - double x[ 4 ] = { 0.0, 1.0, 2.0, 3.0 }; // M - double y[ 3 ] = { 1.0, 4.0, 0.0 }; // N + // Define `x` and `y^T` vectors: + const double x[ 3 ] = { 1.0, 4.0, 0.0 }; // M + const double y[ 4 ] = { 0.0, 1.0, 2.0, 3.0 }; // N // Specify the number of rows and columns: - const int M = 4; - const int N = 3; + const int M = 3; + const int N = 4; // Specify stride lengths: const int strideX = 1; const int strideY = 1; - // Specify the matrix layout: - const CBLAS_LAYOUT layout = CblasRowMajor; - - // Perform operation (note: arguments are reordered as: A_{M,N} = α⋅x_M⋅y^T_N + A_{M,N} => B = A^T = α⋅y⋅x^T + A^T = α⋅y⋅x^T + B): - c_dger( layout, N, M, 1.0, y, strideY, x, strideX, B, M ); + // Perform operation: + c_dger( CblasRowMajor, M, N, 1.0, x, strideX, y, strideY, A, N ); // Print the result: - for ( int i = 0; i < N; i++ ) { - for ( int j = 0; j < M; j++ ) { - printf( "B[%i,%i] = %lf\n", i, j, B[ (i*M)+j ] ); + for ( int i = 0; i < M; i++ ) { + for ( int j = 0; j < N; j++ ) { + printf( "A[%i,%i] = %lf\n", i, j, A[ (i*N)+j ] ); } } } diff --git a/lib/node_modules/@stdlib/blas/base/dger/include/stdlib/blas/base/dger.h b/lib/node_modules/@stdlib/blas/base/dger/include/stdlib/blas/base/dger.h index 1b774738e5c5..3e2f97d528e6 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/include/stdlib/blas/base/dger.h +++ b/lib/node_modules/@stdlib/blas/base/dger/include/stdlib/blas/base/dger.h @@ -36,6 +36,11 @@ extern "C" { */ void API_SUFFIX(c_dger)( const CBLAS_LAYOUT layout, const CBLAS_INT M, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const double *Y, const CBLAS_INT strideY, double *A, const CBLAS_INT LDA ); +/** +* 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. +*/ +void API_SUFFIX(c_dger_ndarray)( const CBLAS_INT M, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA ); + #ifdef __cplusplus } #endif diff --git a/lib/node_modules/@stdlib/blas/base/dger/manifest.json b/lib/node_modules/@stdlib/blas/base/dger/manifest.json index 7494358b4d85..b0a6c05b071d 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/dger/manifest.json @@ -50,6 +50,7 @@ "@stdlib/napi/argv-int64", "@stdlib/napi/argv-int32", "@stdlib/napi/argv-strided-float64array", + "@stdlib/napi/argv-strided-float64array2d", "@stdlib/napi/argv-double" ] }, @@ -113,6 +114,7 @@ "@stdlib/napi/argv-int64", "@stdlib/napi/argv-int32", "@stdlib/napi/argv-strided-float64array", + "@stdlib/napi/argv-strided-float64array2d", "@stdlib/napi/argv-double" ] }, @@ -179,6 +181,7 @@ "@stdlib/napi/argv-int64", "@stdlib/napi/argv-int32", "@stdlib/napi/argv-strided-float64array", + "@stdlib/napi/argv-strided-float64array2d", "@stdlib/napi/argv-double" ] }, @@ -241,6 +244,7 @@ "@stdlib/napi/argv-int64", "@stdlib/napi/argv-int32", "@stdlib/napi/argv-strided-float64array", + "@stdlib/napi/argv-strided-float64array2d", "@stdlib/napi/argv-double" ] }, @@ -306,6 +310,7 @@ "@stdlib/napi/argv-int64", "@stdlib/napi/argv-int32", "@stdlib/napi/argv-strided-float64array", + "@stdlib/napi/argv-strided-float64array2d", "@stdlib/napi/argv-double" ] }, @@ -371,6 +376,7 @@ "@stdlib/napi/argv-int64", "@stdlib/napi/argv-int32", "@stdlib/napi/argv-strided-float64array", + "@stdlib/napi/argv-strided-float64array2d", "@stdlib/napi/argv-double" ] }, diff --git a/lib/node_modules/@stdlib/blas/base/dger/src/addon.c b/lib/node_modules/@stdlib/blas/base/dger/src/addon.c index 10b035c54414..a000fb01e1c6 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/src/addon.c +++ b/lib/node_modules/@stdlib/blas/base/dger/src/addon.c @@ -25,6 +25,7 @@ #include "stdlib/napi/argv_int32.h" #include "stdlib/napi/argv_double.h" #include "stdlib/napi/argv_strided_float64array.h" +#include "stdlib/napi/argv_strided_float64array2d.h" #include /** @@ -51,11 +52,46 @@ static napi_value addon( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, M, strideX, argv, 4 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Y, N, strideY, argv, 6 ); - STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, A, ((M-1)*LDA) + N, 1, argv, 8 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY2D( env, A, M, N, LDA, 1, argv, 8 ); API_SUFFIX(c_dger)( layout, M, N, alpha, X, strideX, Y, strideY, A, LDA ); return NULL; } -STDLIB_NAPI_MODULE_EXPORT_FCN( addon ) +/** +* 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_DOUBLE( 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_FLOAT64ARRAY( env, X, M, strideX, argv, 3 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Y, N, strideY, argv, 6 ); + + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY2D( env, A, M, N, strideA1, strideA2, argv, 9 ); + + API_SUFFIX(c_dger_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 ) From 7ecd138cf7bee589a2693474f2dce948044e880a Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 25 Jun 2025 00:18:36 -0700 Subject: [PATCH 24/38] docs: fix markup --- 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: 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/dger/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/dger/README.md b/lib/node_modules/@stdlib/blas/base/dger/README.md index 66188875a82f..9e1229b6311b 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/README.md +++ b/lib/node_modules/@stdlib/blas/base/dger/README.md @@ -22,7 +22,7 @@ limitations under the License. > Perform the rank 1 operation `A = α*x*y^T + A`. -
+
## Usage From 98ab9992bd8b9a91c1eb851ae5246ce4e37c21ef Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 25 Jun 2025 00:19:40 -0700 Subject: [PATCH 25/38] docs: add empty intro section --- 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: 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/dger/README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/node_modules/@stdlib/blas/base/dger/README.md b/lib/node_modules/@stdlib/blas/base/dger/README.md index 9e1229b6311b..e0522f430713 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/README.md +++ b/lib/node_modules/@stdlib/blas/base/dger/README.md @@ -22,6 +22,12 @@ limitations under the License. > Perform the rank 1 operation `A = α*x*y^T + A`. +
+ +
+ + +
## Usage From 256b68417640a74620263052bc1abbb8c475b18c Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 25 Jun 2025 00:23:54 -0700 Subject: [PATCH 26/38] refactor: perform consistent error handling --- 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: passed - 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/dger/lib/dger.native.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dger/lib/dger.native.js b/lib/node_modules/@stdlib/blas/base/dger/lib/dger.native.js index ccbe511df02e..c5ef2544669a 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/lib/dger.native.js +++ b/lib/node_modules/@stdlib/blas/base/dger/lib/dger.native.js @@ -20,6 +20,7 @@ // MODULES // +var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); var resolve = require( '@stdlib/blas/base/layout-resolve-enum' ); var format = require( '@stdlib/string/format' ); var addon = require( './../src/addon.node' ); @@ -59,11 +60,22 @@ var addon = require( './../src/addon.node' ); * // A => [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] */ function dger( order, M, N, alpha, x, strideX, y, strideY, A, LDA ) { - var ord = resolve( order ); - if ( ord === null ) { + if ( !isLayout( order ) ) { throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); } - addon( ord, M, N, alpha, x, strideX, y, strideY, A, LDA ); + 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 ) ); + } + addon( resolve( order ), M, N, alpha, x, strideX, y, strideY, A, LDA ); return A; } From 4e5206aa003f6721b73d3a9e519d1a58cd2e1472 Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 25 Jun 2025 02:11:13 -0700 Subject: [PATCH 27/38] chore: update native implementation and fix test fixtures --- 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: passed - 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: passed - 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/dger/lib/base.js | 5 +- .../@stdlib/blas/base/dger/manifest.json | 122 +++++++---- .../@stdlib/blas/base/dger/src/dger.c | 153 ++++---------- .../@stdlib/blas/base/dger/src/dger.f | 6 +- .../@stdlib/blas/base/dger/src/dger_cblas.c | 4 +- .../@stdlib/blas/base/dger/src/dger_f.c | 4 +- .../@stdlib/blas/base/dger/src/dger_ndarray.c | 199 ++++++++++++++++++ .../column_major_complex_access_pattern.json | 1 + .../dger/test/fixtures/column_major_oa.json | 1 + .../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 + .../row_major_complex_access_pattern.json | 1 + .../base/dger/test/fixtures/row_major_oa.json | 1 + .../dger/test/fixtures/row_major_sa1_sa2.json | 1 + .../test/fixtures/row_major_sa1_sa2n.json | 47 ++++- .../test/fixtures/row_major_sa1n_sa2.json | 51 ++++- .../test/fixtures/row_major_sa1n_sa2n.json | 47 ++++- 19 files changed, 478 insertions(+), 169 deletions(-) create mode 100644 lib/node_modules/@stdlib/blas/base/dger/src/dger_ndarray.c diff --git a/lib/node_modules/@stdlib/blas/base/dger/lib/base.js b/lib/node_modules/@stdlib/blas/base/dger/lib/base.js index 728b0e1e8690..f5466c874cfe 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/lib/base.js +++ b/lib/node_modules/@stdlib/blas/base/dger/lib/base.js @@ -120,6 +120,8 @@ function dger( M, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, strideA var tmp; var da0; var da1; + var S0; + var S1; var sx; var sy; var ia; @@ -127,11 +129,10 @@ function dger( M, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, strideA var iy; var i0; var i1; - var S0; - var S1; // Note on variable naming convention: S#, da#, ia#, i# where # corresponds to the loop number, with `0` being the innermost loop... + // 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... S0 = N; diff --git a/lib/node_modules/@stdlib/blas/base/dger/manifest.json b/lib/node_modules/@stdlib/blas/base/dger/manifest.json index b0a6c05b071d..1e7f47b3c13b 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/dger/manifest.json @@ -35,7 +35,8 @@ "wasm": false, "src": [ "./src/dger.f", - "./src/dger_f.c" + "./src/dger_f.c", + "./src/dger_ndarray.c" ], "include": [ "./include" @@ -51,7 +52,8 @@ "@stdlib/napi/argv-int32", "@stdlib/napi/argv-strided-float64array", "@stdlib/napi/argv-strided-float64array2d", - "@stdlib/napi/argv-double" + "@stdlib/napi/argv-double", + "@stdlib/ndarray/base/assert/is-row-major" ] }, { @@ -60,7 +62,8 @@ "blas": "", "wasm": false, "src": [ - "./src/dger.c" + "./src/dger.c", + "./src/dger_ndarray.c" ], "include": [ "./include" @@ -69,7 +72,9 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/blas/base/xerbla" + "@stdlib/blas/base/xerbla", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/strided/base/stride2offset" ] }, { @@ -78,7 +83,8 @@ "blas": "", "wasm": false, "src": [ - "./src/dger.c" + "./src/dger.c", + "./src/dger_ndarray.c" ], "include": [ "./include" @@ -87,7 +93,9 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/blas/base/xerbla" + "@stdlib/blas/base/xerbla", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/strided/base/stride2offset" ] }, @@ -97,7 +105,8 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/dger_cblas.c" + "./src/dger_cblas.c", + "./src/dger_ndarray.c" ], "include": [ "./include" @@ -115,7 +124,8 @@ "@stdlib/napi/argv-int32", "@stdlib/napi/argv-strided-float64array", "@stdlib/napi/argv-strided-float64array2d", - "@stdlib/napi/argv-double" + "@stdlib/napi/argv-double", + "@stdlib/ndarray/base/assert/is-row-major" ] }, { @@ -124,7 +134,8 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/dger_cblas.c" + "./src/dger_cblas.c", + "./src/dger_ndarray.c" ], "include": [ "./include" @@ -135,7 +146,8 @@ ], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/ndarray/base/assert/is-row-major" ] }, { @@ -144,7 +156,8 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/dger_cblas.c" + "./src/dger_cblas.c", + "./src/dger_ndarray.c" ], "include": [ "./include" @@ -155,7 +168,8 @@ ], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/ndarray/base/assert/is-row-major" ] }, @@ -166,7 +180,8 @@ "wasm": false, "src": [ "./src/dger.f", - "./src/dger_f.c" + "./src/dger_f.c", + "./src/dger_ndarray.c" ], "include": [ "./include" @@ -182,7 +197,8 @@ "@stdlib/napi/argv-int32", "@stdlib/napi/argv-strided-float64array", "@stdlib/napi/argv-strided-float64array2d", - "@stdlib/napi/argv-double" + "@stdlib/napi/argv-double", + "@stdlib/ndarray/base/assert/is-row-major" ] }, { @@ -191,7 +207,8 @@ "blas": "", "wasm": false, "src": [ - "./src/dger.c" + "./src/dger.c", + "./src/dger_ndarray.c" ], "include": [ "./include" @@ -200,7 +217,9 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/blas/base/xerbla" + "@stdlib/blas/base/xerbla", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/strided/base/stride2offset" ] }, { @@ -209,7 +228,8 @@ "blas": "", "wasm": false, "src": [ - "./src/dger.c" + "./src/dger.c", + "./src/dger_ndarray.c" ], "include": [ "./include" @@ -218,7 +238,9 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/blas/base/xerbla" + "@stdlib/blas/base/xerbla", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/strided/base/stride2offset" ] }, @@ -228,7 +250,8 @@ "blas": "apple_accelerate_framework", "wasm": false, "src": [ - "./src/dger_cblas.c" + "./src/dger_cblas.c", + "./src/dger_ndarray.c" ], "include": [ "./include" @@ -245,7 +268,8 @@ "@stdlib/napi/argv-int32", "@stdlib/napi/argv-strided-float64array", "@stdlib/napi/argv-strided-float64array2d", - "@stdlib/napi/argv-double" + "@stdlib/napi/argv-double", + "@stdlib/ndarray/base/assert/is-row-major" ] }, { @@ -254,7 +278,8 @@ "blas": "apple_accelerate_framework", "wasm": false, "src": [ - "./src/dger_cblas.c" + "./src/dger_cblas.c", + "./src/dger_ndarray.c" ], "include": [ "./include" @@ -264,7 +289,8 @@ ], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/ndarray/base/assert/is-row-major" ] }, { @@ -273,7 +299,8 @@ "blas": "apple_accelerate_framework", "wasm": false, "src": [ - "./src/dger_cblas.c" + "./src/dger_cblas.c", + "./src/dger_ndarray.c" ], "include": [ "./include" @@ -283,7 +310,8 @@ ], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/ndarray/base/assert/is-row-major" ] }, @@ -293,7 +321,8 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/dger_cblas.c" + "./src/dger_cblas.c", + "./src/dger_ndarray.c" ], "include": [ "./include" @@ -311,7 +340,8 @@ "@stdlib/napi/argv-int32", "@stdlib/napi/argv-strided-float64array", "@stdlib/napi/argv-strided-float64array2d", - "@stdlib/napi/argv-double" + "@stdlib/napi/argv-double", + "@stdlib/ndarray/base/assert/is-row-major" ] }, { @@ -320,7 +350,8 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/dger_cblas.c" + "./src/dger_cblas.c", + "./src/dger_ndarray.c" ], "include": [ "./include" @@ -331,7 +362,8 @@ ], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/ndarray/base/assert/is-row-major" ] }, { @@ -340,7 +372,8 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/dger_cblas.c" + "./src/dger_cblas.c", + "./src/dger_ndarray.c" ], "include": [ "./include" @@ -351,7 +384,8 @@ ], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/ndarray/base/assert/is-row-major" ] }, @@ -361,7 +395,8 @@ "blas": "", "wasm": false, "src": [ - "./src/dger.c" + "./src/dger.c", + "./src/dger_ndarray.c" ], "include": [ "./include" @@ -377,7 +412,9 @@ "@stdlib/napi/argv-int32", "@stdlib/napi/argv-strided-float64array", "@stdlib/napi/argv-strided-float64array2d", - "@stdlib/napi/argv-double" + "@stdlib/napi/argv-double", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/strided/base/stride2offset" ] }, { @@ -386,7 +423,8 @@ "blas": "", "wasm": false, "src": [ - "./src/dger.c" + "./src/dger.c", + "./src/dger_ndarray.c" ], "include": [ "./include" @@ -395,7 +433,9 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/blas/base/xerbla" + "@stdlib/blas/base/xerbla", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/strided/base/stride2offset" ] }, { @@ -404,7 +444,8 @@ "blas": "", "wasm": false, "src": [ - "./src/dger.c" + "./src/dger.c", + "./src/dger_ndarray.c" ], "include": [ "./include" @@ -413,7 +454,9 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/blas/base/xerbla" + "@stdlib/blas/base/xerbla", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/strided/base/stride2offset" ] }, @@ -423,7 +466,8 @@ "blas": "", "wasm": true, "src": [ - "./src/dger.c" + "./src/dger.c", + "./src/dger_ndarray.c" ], "include": [ "./include" @@ -432,7 +476,9 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/blas/base/xerbla" + "@stdlib/blas/base/xerbla", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/strided/base/stride2offset" ] } ] diff --git a/lib/node_modules/@stdlib/blas/base/dger/src/dger.c b/lib/node_modules/@stdlib/blas/base/dger/src/dger.c index c96e481b7293..6c9e9a8251f3 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/src/dger.c +++ b/lib/node_modules/@stdlib/blas/base/dger/src/dger.c @@ -17,142 +17,81 @@ */ #include "stdlib/blas/base/dger.h" -#include "stdlib/blas/base/xerbla.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. * -* ## Notes -* -* - The function follows the CBLAS interface which reflects the corresponding Fortran interface, which in turn assumes column-major order. As a matrix stored in row-major order is equivalent to storing the matrix's transpose in column-major order, we can interpret an M-by-N row-major matrix "B" as the matrix "A^T" stored in column-major. 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, the C calling convention for row-major order is to swap the order of input arguments such that for a column-major `A` where the stride of the "major" (outer) dimension is `LDA = N` -* -* ```c -* c_dger( CblasColMajor, M, N, alpha, X, strideX, Y, strideY, A, N ) -* ``` -* -* and for a row-major `B = A^T` where the stride of the "major" (outer) dimension is `LDA = M` -* -* ```c -* c_dger( CblasRowMajor, N, M, alpha, Y, strideY, X, strideX, A^T, M ) -* ``` -* * @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 X stride length +* @param strideX stride length for `X` * @param Y an `N` element vector -* @param strideY Y stride length +* @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_dger)( const CBLAS_LAYOUT layout, const CBLAS_INT M, const CBLAS_INT N, const double alpha, double *X, const CBLAS_INT strideX, double *Y, const CBLAS_INT strideY, double *A, const CBLAS_INT LDA ) { - CBLAS_INT info; - CBLAS_INT sx; - CBLAS_INT sy; - CBLAS_INT ix; - CBLAS_INT jy; - CBLAS_INT kx; - CBLAS_INT i; - CBLAS_INT j; - CBLAS_INT m; - CBLAS_INT n; - double tmp; - double *x; - double *y; +void API_SUFFIX(c_dger)( const CBLAS_LAYOUT layout, const CBLAS_INT M, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const double *Y, const CBLAS_INT strideY, double *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... - info = 0; + if ( layout != CblasRowMajor && layout != CblasColMajor ) { + c_xerbla( 1, "c_dger", "Error: invalid argument. First argument must be a valid storage layout. Value: `%d`.", layout ); + return; + } if ( M < 0 ) { - info = 1; - } else if ( N < 0 ) { - info = 2; - } else if ( strideX == 0 ) { - info = 5; - } else if ( strideY == 0 ) { - info = 7; - } else { - if ( M < 1 ) { - j = 1; - } else { - j = M; - } - if ( LDA < j ) { - info = 9; - } + c_xerbla( 2, "c_dger", "Error: invalid argument. Second argument must be a nonnegative integer. Value: `%d`.", M ); + return; } - if ( info != 0 ) { - c_xerbla( info, "c_dger", "" ); + if ( N < 0 ) { + c_xerbla( 3, "c_dger", "Error: invalid argument. Third argument must be a nonnegative integer. Value: `%d`.", N ); return; } - // Check whether we can avoid computation altogether... - if ( M == 0 || N == 0 || alpha == 0.0 ) { + if ( strideX == 0 ) { + c_xerbla( 6, "c_dger", "Error: invalid argument. Sixth argument must be nonzero. Value: `%d`.", strideX ); + return; + } + if ( strideY == 0 ) { + c_xerbla( 8, "c_dger", "Error: invalid argument. Eighth argument must be nonzero. Value: `%d`.", strideX ); return; } - // When provided a row-major matrix, we need to swap arguments... - if ( layout == CblasRowMajor ) { - x = Y; - y = X; - m = N; - n = M; - sx = strideY; - sy = strideX; + if ( layout == CblasColMajor ) { + v = M; } else { - x = X; - y = Y; - m = M; - n = N; - sx = strideX; - sy = strideY; + v = N; } - // Proceed with computation... - if ( sy > 0 ) { - jy = 0; + // max(1, v) + if ( v < 1 ) { + vala = 1; } else { - jy = ( 1 - n ) * sy; + vala = v; } - if ( sx == 1 ) { - for ( j = 0; j < n; j++ ) { - if ( y[ jy ] != 0.0 ) { - tmp = alpha * y[ jy ]; - for ( i = 0; i < m; i++ ) { - A[ (j*LDA)+i ] += x[ i ] * tmp; // per above, x has unit stride - } - } - jy += sy; - } + if ( LDA < v ) { + c_xerbla( 10, "c_dger", "Error: invalid argument. Tenth argument must be greater than or equal to max(1,%d). Value: `%d`.", vala, LDA ); return; } - if ( sx > 0 ) { - kx = 0; - } else { - kx = ( 1 - m ) * sx; + // Check whether we can avoid computation altogether... + if ( M == 0 || N == 0 || alpha == 0.0 ) { + return; } - for ( j = 0; j < n; j++ ) { - if ( y[ jy ] != 0.0 ) { - tmp = alpha * y[ jy ]; - ix = kx; - for ( i = 0; i < m; i++ ) { - A[ (j*LDA)+i ] += x[ ix ] * tmp; - ix += sx; - } - } - jy += sy; + 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_dger_ndarray)( M, N, alpha, X, strideX, ox, Y, strideY, oy, A, sa1, sa2, 0 ); return; } diff --git a/lib/node_modules/@stdlib/blas/base/dger/src/dger.f b/lib/node_modules/@stdlib/blas/base/dger/src/dger.f index 0a56eb9da5c4..687dffb4b58f 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/src/dger.f +++ b/lib/node_modules/@stdlib/blas/base/dger/src/dger.f @@ -54,9 +54,9 @@ ! @param {integer} N - number of columns in the matrix `A` ! @param {double} alpha - scalar constant ! @param {Array} X - an `M` element vector -! @param {integer} strideX - `X` stride length +! @param {integer} strideX - stride length for `X` ! @param {Array} Y - an `N` element vector -! @param {integer} strideY - `Y` stride length +! @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`) !< @@ -145,4 +145,4 @@ end subroutine xerbla end do end if return -end subroutine dger \ No newline at end of file +end subroutine dger diff --git a/lib/node_modules/@stdlib/blas/base/dger/src/dger_cblas.c b/lib/node_modules/@stdlib/blas/base/dger/src/dger_cblas.c index d2445a4ed309..0b0394609285 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/src/dger_cblas.c +++ b/lib/node_modules/@stdlib/blas/base/dger/src/dger_cblas.c @@ -28,9 +28,9 @@ * @param N number of columns in the matrix `A` * @param alpha scalar constant * @param X an `M` element vector -* @param strideX X stride length +* @param strideX stride length for `X` * @param Y an `N` element vector -* @param strideY Y stride length +* @param strideY stride length for `Y` * @param A matrix of coefficients * @param LDA index of the first dimension of `A` */ diff --git a/lib/node_modules/@stdlib/blas/base/dger/src/dger_f.c b/lib/node_modules/@stdlib/blas/base/dger/src/dger_f.c index 0be9e8b58350..96f95a4a86c7 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/src/dger_f.c +++ b/lib/node_modules/@stdlib/blas/base/dger/src/dger_f.c @@ -29,9 +29,9 @@ * @param N number of columns in the matrix `A` * @param alpha scalar constant * @param X an `M` element vector -* @param strideX X stride length +* @param strideX stride length for `X` * @param Y an `N` element vector -* @param strideY Y stride length +* @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`) */ diff --git a/lib/node_modules/@stdlib/blas/base/dger/src/dger_ndarray.c b/lib/node_modules/@stdlib/blas/base/dger/src/dger_ndarray.c new file mode 100644 index 000000000000..acd47df0352e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/src/dger_ndarray.c @@ -0,0 +1,199 @@ +/** +* @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 "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_dger_ndarray)( const CBLAS_INT M, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA ) { + const double *x; + const double *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; + double 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_dger_ndarray", "Error: invalid argument. First argument must be a nonnegative integer. Value: `%d`.", M ); + return; + } + if ( N < 0 ) { + c_xerbla( 2, "c_dger_ndarray", "Error: invalid argument. Second argument must be a nonnegative integer. Value: `%d`.", N ); + return; + } + if ( strideX == 0 ) { + c_xerbla( 5, "c_dger_ndarray", "Error: invalid argument. Fifth argument must be a nonzero. Value: `%d`.", strideX ); + return; + } + if ( strideY == 0 ) { + c_xerbla( 8, "c_dger_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/dger/test/fixtures/column_major_complex_access_pattern.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_complex_access_pattern.json index a395d2dd0e44..220746be33c5 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_complex_access_pattern.json +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/column_major_oa.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_oa.json index 375ff499e318..fd257c7fba48 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_oa.json +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/column_major_sa1_sa2.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_sa1_sa2.json index 3bdfd0849d8d..702e051e70b9 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_sa1_sa2.json +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/column_major_sa1_sa2n.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_sa1_sa2n.json index 31d8fa03f512..f6b6b56f07a6 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_sa1_sa2n.json +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/column_major_sa1n_sa2.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_sa1n_sa2.json index 38229e4d9f20..a4df499c44c5 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_sa1n_sa2.json +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/column_major_sa1n_sa2n.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_sa1n_sa2n.json index fce200afaa36..9bbdcc5d25ff 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_sa1n_sa2n.json +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/row_major_complex_access_pattern.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_complex_access_pattern.json index 055b990e0c7d..545a9ac46edc 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_complex_access_pattern.json +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/row_major_oa.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_oa.json index 809dfee2957e..e85a1ca258c6 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_oa.json +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/row_major_sa1_sa2.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_sa1_sa2.json index 0831d623801a..b48f82809b26 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_sa1_sa2.json +++ b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_sa1_sa2.json @@ -1,4 +1,5 @@ { + "order": "row-major", "M": 2, "N": 3, "alpha": 1.0, diff --git a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_sa1_sa2n.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_sa1_sa2n.json index 31d8fa03f512..37ad4b28b117 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_sa1_sa2n.json +++ b/lib/node_modules/@stdlib/blas/base/dger/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, 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": [ + 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": 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 ] + "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/dger/test/fixtures/row_major_sa1n_sa2.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_sa1n_sa2.json index 38229e4d9f20..5feaa8e8f17b 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_sa1n_sa2.json +++ b/lib/node_modules/@stdlib/blas/base/dger/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, 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": [ + 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": -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 ] + "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/dger/test/fixtures/row_major_sa1n_sa2n.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_sa1n_sa2n.json index fce200afaa36..e989a4189495 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_sa1n_sa2n.json +++ b/lib/node_modules/@stdlib/blas/base/dger/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, 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": [ + 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": -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 ] + "strideA1": -8, + "strideA2": -2, + "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 + ] } From b1403442b4bafe5f656a9383690af530e9b44a78 Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 25 Jun 2025 02:14:10 -0700 Subject: [PATCH 28/38] docs: fix copyright year --- 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: passed - 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/dger/src/dger_ndarray.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/dger/src/dger_ndarray.c b/lib/node_modules/@stdlib/blas/base/dger/src/dger_ndarray.c index acd47df0352e..daddc65a6544 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/src/dger_ndarray.c +++ b/lib/node_modules/@stdlib/blas/base/dger/src/dger_ndarray.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 9f1f11d8ff928cd8bbc383741ec1201a48a50e8b Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 25 Jun 2025 02:24:14 -0700 Subject: [PATCH 29/38] test: add native add-on tests --- 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: 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/dger/lib/dger.js | 6 +- .../@stdlib/blas/base/dger/lib/dger.native.js | 15 + .../blas/base/dger/test/test.dger.native.js | 570 +++++++++++ .../base/dger/test/test.ndarray.native.js | 885 ++++++++++++++++++ 4 files changed, 1473 insertions(+), 3 deletions(-) create mode 100644 lib/node_modules/@stdlib/blas/base/dger/test/test.dger.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/dger/test/test.ndarray.native.js diff --git a/lib/node_modules/@stdlib/blas/base/dger/lib/dger.js b/lib/node_modules/@stdlib/blas/base/dger/lib/dger.js index 6c74dff3c691..640c7e2423e9 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/lib/dger.js +++ b/lib/node_modules/@stdlib/blas/base/dger/lib/dger.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/dger/lib/dger.native.js b/lib/node_modules/@stdlib/blas/base/dger/lib/dger.native.js index c5ef2544669a..a8b753560766 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/lib/dger.native.js +++ b/lib/node_modules/@stdlib/blas/base/dger/lib/dger.native.js @@ -20,8 +20,10 @@ // 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' ); @@ -60,6 +62,7 @@ var addon = require( './../src/addon.node' ); * // A => [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] */ function dger( 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 ) ); } @@ -75,6 +78,18 @@ function dger( 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. 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; } diff --git a/lib/node_modules/@stdlib/blas/base/dger/test/test.dger.native.js b/lib/node_modules/@stdlib/blas/base/dger/test/test.dger.native.js new file mode 100644 index 000000000000..d2234dc9330e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/test/test.dger.native.js @@ -0,0 +1,570 @@ +/** +* @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 Float64Array = require( '@stdlib/array/float64' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var dger = tryRequire( resolve( __dirname, './../lib/dger.native.js' ) ); +var opts = { + 'skip': ( dger 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 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' ); + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dger, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 10', opts, function test( t ) { + t.strictEqual( dger.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() { + dger( value, data.M, data.N, data.alpha, new Float64Array( data.x ), data.strideX, new Float64Array( data.y ), data.strideY, new Float64Array( 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() { + dger( data.order, value, data.N, data.alpha, new Float64Array( data.x ), data.strideX, new Float64Array( data.y ), data.strideY, new Float64Array( 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() { + dger( data.order, data.M, value, data.alpha, new Float64Array( data.x ), data.strideX, new Float64Array( data.y ), data.strideY, new Float64Array( 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() { + dger( data.order, data.M, data.N, data.alpha, new Float64Array( data.x ), value, new Float64Array( data.y ), data.strideY, new Float64Array( 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() { + dger( data.order, data.M, data.N, data.alpha, new Float64Array( data.x ), data.strideX, new Float64Array( data.y ), value, new Float64Array( 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() { + dger( data.order, data.M, data.N, data.alpha, new Float64Array( data.x ), data.strideX, new Float64Array( data.y ), data.strideY, new Float64Array( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A ); + + out = dger( 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 = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A ); + + out = dger( 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 = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A ); + + out = dger( 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)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxpyp; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/dger/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dger/test/test.ndarray.native.js new file mode 100644 index 000000000000..50f38c35bcbb --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/test/test.ndarray.native.js @@ -0,0 +1,885 @@ +/** +* @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 Float64Array = require( '@stdlib/array/float64' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var dger = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( dger 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 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' ); + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dger, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 13', opts, function test( t ) { + t.strictEqual( dger.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() { + dger( value, data.N, data.alpha, new Float64Array( data.x ), data.strideX, data.offsetX, new Float64Array( data.y ), data.strideY, data.offsetY, new Float64Array( 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() { + dger( data.M, value, data.alpha, new Float64Array( data.x ), data.strideX, data.offsetX, new Float64Array( data.y ), data.strideY, data.offsetY, new Float64Array( 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() { + dger( data.M, data.N, data.alpha, new Float64Array( data.x ), value, data.offsetX, new Float64Array( data.y ), data.strideY, data.offsetY, new Float64Array( 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() { + dger( data.M, data.N, data.alpha, new Float64Array( data.x ), data.strideX, data.offsetX, new Float64Array( data.y ), value, data.offsetY, new Float64Array( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A ); + + out = dger( 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 = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A ); + + out = dger( 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 = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A ); + + out = dger( 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)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rsa1sa2; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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(); +}); From 80f0061967866077554a946d538e3312781c4f1c Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 25 Jun 2025 02:25:27 -0700 Subject: [PATCH 30/38] chore: fix missing directories --- 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: passed - 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/dger/package.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/node_modules/@stdlib/blas/base/dger/package.json b/lib/node_modules/@stdlib/blas/base/dger/package.json index 8bc86155377c..a227006ceed5 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/package.json +++ b/lib/node_modules/@stdlib/blas/base/dger/package.json @@ -17,6 +17,8 @@ "browser": "./lib/main.js", "gypfile": true, "directories": { + "benchmark": "./benchmark", + "doc": "./docs", "example": "./examples", "include": "./include", "lib": "./lib", From aebe53be7173685a3a5675f386beddb16250b15a Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 25 Jun 2025 02:28:30 -0700 Subject: [PATCH 31/38] bench: add native add-on benchmarks --- 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: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../base/dger/benchmark/benchmark.native.js | 110 ++++++++++++++++++ .../benchmark/benchmark.ndarray.native.js | 110 ++++++++++++++++++ 2 files changed, 220 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/dger/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/dger/benchmark/benchmark.ndarray.native.js diff --git a/lib/node_modules/@stdlib/blas/base/dger/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/base/dger/benchmark/benchmark.native.js new file mode 100644 index 000000000000..eab8538a3b42 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +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 dger = tryRequire( resolve( __dirname, './../lib/dger.native.js' ) ); +var opts = { + 'skip': ( dger instanceof Error ) +}; +var options = { + 'dtype': 'float64' +}; + + +// 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 = dger( 'row-major', N, N, 1.0, x, 1, y, 1, A, N ); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( 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/dger/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dger/benchmark/benchmark.ndarray.native.js new file mode 100644 index 000000000000..7ef2d4a26607 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +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 dger = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( dger instanceof Error ) +}; +var options = { + 'dtype': 'float64' +}; + + +// 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 = dger( N, N, 1.0, x, 1, 0, y, 1, 0, A, N, 1, 0 ); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( 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(); From 45c9525f45beac215403580b402e5a10aac96594 Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 25 Jun 2025 02:41:15 -0700 Subject: [PATCH 32/38] bench: add C benchmarks --- 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: passed - 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/dger/benchmark/c/Makefile | 146 +++++++++++++ .../base/dger/benchmark/c/benchmark.length.c | 206 ++++++++++++++++++ 2 files changed, 352 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/dger/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/dger/benchmark/c/benchmark.length.c diff --git a/lib/node_modules/@stdlib/blas/base/dger/benchmark/c/Makefile b/lib/node_modules/@stdlib/blas/base/dger/benchmark/c/Makefile new file mode 100644 index 000000000000..cce2c865d7ad --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/dger/benchmark/c/benchmark.length.c new file mode 100644 index 000000000000..7c4df3f89600 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger.h" +#include "stdlib/blas/base/shared.h" +#include +#include +#include +#include +#include + +#define NAME "dger" +#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 double rand_double( void ) { + int r = rand(); + return (double)r / ( (double)RAND_MAX + 1.0 ); +} + +/** +* 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; + double A[ N*N ]; + double x[ N ]; + double y[ N ]; + double t; + int i; + int j; + + for ( i = 0, j = 0; i < N; i++, j += 2 ) { + x[ i ] = ( rand_double()*20.0 ) - 10.0; + y[ i ] = ( rand_double()*20.0 ) - 10.0; + A[ j ] = ( rand_double()*20.0 ) - 10.0; + A[ j+1 ] = ( rand_double()*20.0 ) - 10.0; + } + t = tic(); + for ( i = 0; i < iterations; i++ ) { + // cppcheck-suppress uninitvar + c_dger( CblasRowMajor, N, N, 1.0, 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; + double A[ N*N ]; + double x[ N ]; + double y[ N ]; + double t; + int i; + int j; + + for ( i = 0, j = 0; i < N; i++, j += 2 ) { + x[ i ] = ( rand_double()*20.0 ) - 10.0; + y[ i ] = ( rand_double()*20.0 ) - 10.0; + A[ j ] = ( rand_double()*20.0 ) - 10.0; + A[ j+1 ] = ( rand_double()*20.0 ) - 10.0; + } + t = tic(); + for ( i = 0; i < iterations; i++ ) { + // cppcheck-suppress uninitvar + c_dger_ndarray( N, N, 1.0, 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 ); +} From 24226d88143a4daf1b8c5ad7cbd1ea74dc1d3a80 Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 25 Jun 2025 03:00:20 -0700 Subject: [PATCH 33/38] bench: add Fortran benchmark --- 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/dger/benchmark/fortran/Makefile | 141 ++++++++++++ .../dger/benchmark/fortran/benchmark.length.f | 217 ++++++++++++++++++ 2 files changed, 358 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/dger/benchmark/fortran/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/dger/benchmark/fortran/benchmark.length.f diff --git a/lib/node_modules/@stdlib/blas/base/dger/benchmark/fortran/Makefile b/lib/node_modules/@stdlib/blas/base/dger/benchmark/fortran/Makefile new file mode 100644 index 000000000000..449d44a3f1c2 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger.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/dger/benchmark/fortran/benchmark.length.f b/lib/node_modules/@stdlib/blas/base/dger/benchmark/fortran/benchmark.length.f new file mode 100644 index 000000000000..4a1312ef5dac --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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 = 'dger' ! 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 dger( M, N, alpha, X, strideX, Y, strideY, A, LDA ) + integer :: strideX, strideY, LDA, M, N + double precision :: X(*), Y(*), A(LDA, *) + double precision :: alpha + end subroutine dger + end interface + ! .. + ! Scalar arguments: + integer, intent(in) :: iterations, N + ! .. + ! Local scalars: + double precision :: elapsed, r + double precision :: t1, t2 + integer :: i, j + ! .. + ! Local arrays: + double 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 dger( 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 From 303db0b7e69d4c083a2ef9f218d871f97e8aded6 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Tue, 24 Jun 2025 15:32:27 +0530 Subject: [PATCH 34/38] chore: revert package.json --- lib/node_modules/@stdlib/blas/base/dger/package.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dger/package.json b/lib/node_modules/@stdlib/blas/base/dger/package.json index a227006ceed5..62732f278dd4 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/package.json +++ b/lib/node_modules/@stdlib/blas/base/dger/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/blas/base/dger", "version": "0.0.0", - "description": "Perform the rank 1 operation `A = α*x*y^T + A`.", + "description": "Perform the rank 1 operation A = alpha⋅x⋅y^T + A.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", @@ -17,8 +17,6 @@ "browser": "./lib/main.js", "gypfile": true, "directories": { - "benchmark": "./benchmark", - "doc": "./docs", "example": "./examples", "include": "./include", "lib": "./lib", From 59b0f328089f971e8ce2183b0afbba2653c9aa6d Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Wed, 25 Jun 2025 16:32:21 +0530 Subject: [PATCH 35/38] 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: passed - task: lint_javascript_src status: passed - 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/dger/docs/repl.txt | 9 +++++++++ .../@stdlib/blas/base/dger/lib/dger.native.js | 2 +- .../@stdlib/blas/base/dger/lib/ndarray.native.js | 2 +- .../blas/base/dger/test/fixtures/column_major.json | 4 ++-- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dger/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/dger/docs/repl.txt index 71d8b49e30cc..a6ea82361bd8 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/dger/docs/repl.txt @@ -64,6 +64,15 @@ > {{alias}}( ord, 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/float64}}( [ 0.0, 1.0, 1.0 ] ); + > var y0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 1.0 ] ); + > A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var y1 = new {{alias:@stdlib/array/float64}}( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); + > {{alias}}( ord, 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 diff --git a/lib/node_modules/@stdlib/blas/base/dger/lib/dger.native.js b/lib/node_modules/@stdlib/blas/base/dger/lib/dger.native.js index a8b753560766..3a823879e860 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/lib/dger.native.js +++ b/lib/node_modules/@stdlib/blas/base/dger/lib/dger.native.js @@ -31,7 +31,7 @@ var addon = require( './../src/addon.node' ); // MAIN // /** -* Performs the rank 1 operation `A = alpha*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 {NonNegativeInteger} M - number of rows in the matrix `A` diff --git a/lib/node_modules/@stdlib/blas/base/dger/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dger/lib/ndarray.native.js index 4e54641278da..4ce3449dcb01 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/dger/lib/ndarray.native.js @@ -27,7 +27,7 @@ var addon = require( './../src/addon.node' ); // MAIN // /** -* Performs the rank 1 operation `A = alpha*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` diff --git a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major.json index 277c350146f0..3f7881dd3860 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major.json +++ b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major.json @@ -6,7 +6,7 @@ "x": [ 1.0, 1.0 ], "strideX": 1, "offsetX": 0, - "y": [ 1.0, 1.0, 1.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 ], @@ -18,5 +18,5 @@ "strideA1": 1, "strideA2": 2, "offsetA": 0, - "A_out": [ 2.0, 5.0, 3.0, 6.0, 4.0, 7.0 ] + "A_out": [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] } From edc384c93cd9c32dd484f5edcb5eb99dc749f317 Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Wed, 25 Jun 2025 17:22:53 +0530 Subject: [PATCH 36/38] chore: minor clean-up Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- lib/node_modules/@stdlib/blas/base/dger/package.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/dger/package.json b/lib/node_modules/@stdlib/blas/base/dger/package.json index 62732f278dd4..541862fac43c 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/package.json +++ b/lib/node_modules/@stdlib/blas/base/dger/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/blas/base/dger", "version": "0.0.0", - "description": "Perform the rank 1 operation A = alpha⋅x⋅y^T + A.", + "description": "Perform the rank 1 operation A = α⋅x⋅y^T + A.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", @@ -17,6 +17,8 @@ "browser": "./lib/main.js", "gypfile": true, "directories": { + "benchmark": "./benchmark", + "doc": "./docs", "example": "./examples", "include": "./include", "lib": "./lib", From 87b663704bccb860e253e79be9fcd93a243d1686 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Wed, 25 Jun 2025 17:50:20 +0530 Subject: [PATCH 37/38] 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/dger/test/fixtures/column_major.json | 4 +- .../test/fixtures/column_major_x_zeros.json | 22 +++++ .../test/fixtures/column_major_y_zeros.json | 22 +++++ .../dger/test/fixtures/row_major_x_zeros.json | 22 +++++ .../dger/test/fixtures/row_major_y_zeros.json | 22 +++++ .../@stdlib/blas/base/dger/test/test.dger.js | 94 ++++++++++++++++++- 6 files changed, 183 insertions(+), 3 deletions(-) create mode 100644 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_x_zeros.json create mode 100644 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_y_zeros.json create mode 100644 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_x_zeros.json create mode 100644 lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_y_zeros.json diff --git a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major.json index 3f7881dd3860..277c350146f0 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major.json +++ b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major.json @@ -6,7 +6,7 @@ "x": [ 1.0, 1.0 ], "strideX": 1, "offsetX": 0, - "y": [ 0.0, 0.0, 0.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 ], @@ -18,5 +18,5 @@ "strideA1": 1, "strideA2": 2, "offsetA": 0, - "A_out": [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] + "A_out": [ 2.0, 5.0, 3.0, 6.0, 4.0, 7.0 ] } diff --git a/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_x_zeros.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_x_zeros.json new file mode 100644 index 000000000000..7b48b4908fde --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/column_major_y_zeros.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/column_major_y_zeros.json new file mode 100644 index 000000000000..3f7881dd3860 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/row_major_x_zeros.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_x_zeros.json new file mode 100644 index 000000000000..e677e3e2b655 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/fixtures/row_major_y_zeros.json b/lib/node_modules/@stdlib/blas/base/dger/test/fixtures/row_major_y_zeros.json new file mode 100644 index 000000000000..3aadc0dd60ca --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dger/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/dger/test/test.dger.js b/lib/node_modules/@stdlib/blas/base/dger/test/test.dger.js index 04209b915c08..8fcf1ff63331 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/test.dger.js +++ b/lib/node_modules/@stdlib/blas/base/dger/test/test.dger.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 // @@ -472,7 +476,95 @@ tape( 'the function supports specifying a negative `x` stride (column-major)', f t.end(); }); -tape( 'the function supports specifying a negative `y` stride (row-major)', function test( t ) { +tape( 'the function returns the input matrix unchanged if input `x` filled with zeroes (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rx0; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 the input matrix unchanged if input `x` filled with zeroes (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cx0; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 the input matrix unchanged if input `y` filled with zeroes (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = ry0; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 the input matrix unchanged if input `y` filled with zeroes (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cy0; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 (row-major)', function test( t ) { var expected; var data; var out; From 525f4f61926202e17688bc31c05ee4085db422cc Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 25 Jun 2025 17:04:11 -0700 Subject: [PATCH 38/38] test: fix test description and add tests --- 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 --- --- .../@stdlib/blas/base/dger/test/test.dger.js | 34 +++---- .../blas/base/dger/test/test.dger.native.js | 92 +++++++++++++++++++ .../blas/base/dger/test/test.ndarray.js | 92 +++++++++++++++++++ .../base/dger/test/test.ndarray.native.js | 92 +++++++++++++++++++ 4 files changed, 293 insertions(+), 17 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dger/test/test.dger.js b/lib/node_modules/@stdlib/blas/base/dger/test/test.dger.js index 8fcf1ff63331..9a6d9d88635f 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/test.dger.js +++ b/lib/node_modules/@stdlib/blas/base/dger/test/test.dger.js @@ -388,7 +388,7 @@ tape( 'if `α` is `0.0`, the function returns the input matrix unchanged (column t.end(); }); -tape( 'the function supports specifying `x` and `y` strides (row-major)', function test( t ) { +tape( 'if `x` contains only zeros, the function returns the input matrix unchanged (row-major)', function test( t ) { var expected; var data; var out; @@ -396,7 +396,7 @@ tape( 'the function supports specifying `x` and `y` strides (row-major)', functi var x; var y; - data = rxpyp; + data = rx0; a = new Float64Array( data.A ); x = new Float64Array( data.x ); @@ -410,7 +410,7 @@ tape( 'the function supports specifying `x` and `y` strides (row-major)', functi t.end(); }); -tape( 'the function supports specifying `x` and `y` strides (column-major)', function test( t ) { +tape( 'if `x` contains only zeros, the function returns the input matrix unchanged (column-major)', function test( t ) { var expected; var data; var out; @@ -418,7 +418,7 @@ tape( 'the function supports specifying `x` and `y` strides (column-major)', fun var x; var y; - data = cxpyp; + data = cx0; a = new Float64Array( data.A ); x = new Float64Array( data.x ); @@ -432,7 +432,7 @@ tape( 'the function supports specifying `x` and `y` strides (column-major)', fun t.end(); }); -tape( 'the function supports specifying a negative `x` stride (row-major)', function test( t ) { +tape( 'if `y` contains only zeros, the function returns the input matrix unchanged (row-major)', function test( t ) { var expected; var data; var out; @@ -440,7 +440,7 @@ tape( 'the function supports specifying a negative `x` stride (row-major)', func var x; var y; - data = rxnyp; + data = ry0; a = new Float64Array( data.A ); x = new Float64Array( data.x ); @@ -454,7 +454,7 @@ tape( 'the function supports specifying a negative `x` stride (row-major)', func t.end(); }); -tape( 'the function supports specifying a negative `x` stride (column-major)', function test( t ) { +tape( 'if `y` contains only zeros, the function returns the input matrix unchanged (column-major)', function test( t ) { var expected; var data; var out; @@ -462,7 +462,7 @@ tape( 'the function supports specifying a negative `x` stride (column-major)', f var x; var y; - data = cxnyp; + data = cy0; a = new Float64Array( data.A ); x = new Float64Array( data.x ); @@ -476,7 +476,7 @@ tape( 'the function supports specifying a negative `x` stride (column-major)', f t.end(); }); -tape( 'the function returns the input matrix unchanged if input `x` filled with zeroes (row-major)', function test( t ) { +tape( 'the function supports specifying `x` and `y` strides (row-major)', function test( t ) { var expected; var data; var out; @@ -484,7 +484,7 @@ tape( 'the function returns the input matrix unchanged if input `x` filled with var x; var y; - data = rx0; + data = rxpyp; a = new Float64Array( data.A ); x = new Float64Array( data.x ); @@ -498,7 +498,7 @@ tape( 'the function returns the input matrix unchanged if input `x` filled with t.end(); }); -tape( 'the function returns the input matrix unchanged if input `x` filled with zeroes (column-major)', function test( t ) { +tape( 'the function supports specifying `x` and `y` strides (column-major)', function test( t ) { var expected; var data; var out; @@ -506,7 +506,7 @@ tape( 'the function returns the input matrix unchanged if input `x` filled with var x; var y; - data = cx0; + data = cxpyp; a = new Float64Array( data.A ); x = new Float64Array( data.x ); @@ -520,7 +520,7 @@ tape( 'the function returns the input matrix unchanged if input `x` filled with t.end(); }); -tape( 'the function returns the input matrix unchanged if input `y` filled with zeroes (row-major)', function test( t ) { +tape( 'the function supports specifying a negative `x` stride (row-major)', function test( t ) { var expected; var data; var out; @@ -528,7 +528,7 @@ tape( 'the function returns the input matrix unchanged if input `y` filled with var x; var y; - data = ry0; + data = rxnyp; a = new Float64Array( data.A ); x = new Float64Array( data.x ); @@ -542,7 +542,7 @@ tape( 'the function returns the input matrix unchanged if input `y` filled with t.end(); }); -tape( 'the function returns the input matrix unchanged if input `y` filled with zeroes (column-major)', function test( t ) { +tape( 'the function supports specifying a negative `x` stride (column-major)', function test( t ) { var expected; var data; var out; @@ -550,7 +550,7 @@ tape( 'the function returns the input matrix unchanged if input `y` filled with var x; var y; - data = cy0; + data = cxnyp; a = new Float64Array( data.A ); x = new Float64Array( data.x ); @@ -564,7 +564,7 @@ tape( 'the function returns the input matrix unchanged if input `y` filled with t.end(); }); -tape( 'the function returns (row-major)', function test( t ) { +tape( 'the function supports specifying a negative `y` stride (row-major)', function test( t ) { var expected; var data; var out; diff --git a/lib/node_modules/@stdlib/blas/base/dger/test/test.dger.native.js b/lib/node_modules/@stdlib/blas/base/dger/test/test.dger.native.js index d2234dc9330e..239d64c91413 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/test.dger.native.js +++ b/lib/node_modules/@stdlib/blas/base/dger/test/test.dger.native.js @@ -43,12 +43,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 // @@ -393,6 +397,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)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rx0; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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; diff --git a/lib/node_modules/@stdlib/blas/base/dger/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/dger/test/test.ndarray.js index 083be7dc3710..744fca0da1de 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/dger/test/test.ndarray.js @@ -42,6 +42,8 @@ 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' ); @@ -56,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 // @@ -347,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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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; diff --git a/lib/node_modules/@stdlib/blas/base/dger/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dger/test/test.ndarray.native.js index 50f38c35bcbb..d9720c66bca7 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/dger/test/test.ndarray.native.js @@ -51,6 +51,8 @@ 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' ); @@ -65,6 +67,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 // @@ -356,6 +360,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)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rx0; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dger( 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;