From 71a1980fbcb1979b5b232309e9865629ce938994 Mon Sep 17 00:00:00 2001 From: kaustubh Date: Sat, 13 Jun 2026 12:53:41 +0530 Subject: [PATCH 1/3] feat: add blas/base/ndarray/ssyr2 --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../@stdlib/blas/base/ndarray/ssyr2/README.md | 130 ++++++++ .../base/ndarray/ssyr2/benchmark/benchmark.js | 114 +++++++ .../blas/base/ndarray/ssyr2/docs/repl.txt | 38 +++ .../base/ndarray/ssyr2/docs/types/index.d.ts | 65 ++++ .../base/ndarray/ssyr2/docs/types/test.ts | 75 +++++ .../blas/base/ndarray/ssyr2/examples/index.js | 40 +++ .../blas/base/ndarray/ssyr2/lib/index.js | 55 ++++ .../blas/base/ndarray/ssyr2/lib/main.js | 80 +++++ .../blas/base/ndarray/ssyr2/package.json | 73 +++++ .../blas/base/ndarray/ssyr2/test/test.js | 302 ++++++++++++++++++ 10 files changed, 972 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/README.md create mode 100644 lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/package.json create mode 100644 lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/test/test.js diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/README.md b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/README.md new file mode 100644 index 000000000000..79cbf8a61ddd --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/README.md @@ -0,0 +1,130 @@ + + +# ssyr2 + +> Perform the symmetric rank 2 operation `A = alpha*x*y^T + alpha*y*x^T + A`. + +
+ +
+ + + +
+ +## Usage + +```javascript +var ssyr2 = require( '@stdlib/blas/base/ndarray/ssyr2' ); +``` + +#### ssyr2( arrays ) + +Performs the symmetric rank 2 operation `A = alpha*x*y^T + alpha*y*x^T + A`, where `alpha` is a scalar, `x` and `y` are `N` element ndarrays, and `A` is an `N` by `N` symmetric matrix. + +```javascript +var Float32Vector = require( '@stdlib/ndarray/vector/float32' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var Float32Array = require( '@stdlib/array/float32' ); + +var x = new Float32Vector( [ 1.0, 2.0, 3.0 ] ); +var y = new Float32Vector( [ 2.0, 1.0, 3.0 ] ); +var A = new ndarray( 'float32', new Float32Array( [ 1.0, 2.0, 3.0, 2.0, 1.0, 2.0, 3.0, 2.0, 1.0 ] ), [ 3, 3 ], [ 3, 1 ], 0, 'row-major' ); + +var alpha = scalar2ndarray( 2.0, { + 'dtype': 'float32' +}); + +var out = ssyr2( [ x, y, A, alpha ] ); +// returns [ [ 9.0, 12.0, 21.0 ], [ 2.0, 9.0, 20.0 ], [ 3.0, 2.0, 37.0 ] ] + +var bool = ( out === A ); +// returns true +``` + +The function has the following parameters: + +- **arrays**: array-like object containing the following ndarrays: + + - first one-dimensional input ndarray. + - second one-dimensional input ndarray. + - a two-dimensional input/output ndarray. + - a zero-dimensional ndarray containing a scalar constant. + +
+ + + +
+ +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float32Vector = require( '@stdlib/ndarray/vector/float32' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var ssyr2 = require( '@stdlib/blas/base/ndarray/ssyr2' ); + +var opts = { + 'dtype': 'float32' +}; + +var x = new Float32Vector( discreteUniform( 3, 0, 10, opts ) ); +var y = new Float32Vector( discreteUniform( 3, 0, 10, opts ) ); +var A = new ndarray( 'float32', new Float32Array( discreteUniform( 9, 0, 10, opts ) ), [ 3, 3 ], [ 3, 1 ], 0, 'row-major' ); + +var alpha = scalar2ndarray( 1.0, opts ); + +var out = ssyr2( [ x, y, A, alpha ] ); +console.log( ndarray2array( out ) ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/benchmark/benchmark.js new file mode 100644 index 000000000000..477eb2ee2329 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/benchmark/benchmark.js @@ -0,0 +1,114 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/uniform' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var ssyr2 = require( './../lib' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float32' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var alpha; + var x; + var y; + var A; + + x = uniform( [ len ], -100.0, 100.0, options ); + y = uniform( [ len ], -100.0, 100.0, options ); + A = uniform( [ len, len ], -100.0, 100.0, options ); + + alpha = scalar2ndarray( 1.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 = ssyr2( [ x, y, A, alpha ] ); + if ( typeof z !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( isnanf( z.get( 0, i%len ) ) ) { + 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 = 3; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( format( '%s:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/docs/repl.txt new file mode 100644 index 000000000000..0575737d93f0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/docs/repl.txt @@ -0,0 +1,38 @@ + +{{alias}}( arrays ) + Performs the symmetric rank 2 operation `A = alpha*x*y^T + alpha*y*x^T + A`, + where `alpha` is a scalar, `x` and `y` are `N` element ndarrays, and `A` is + an `N` by `N` symmetric matrix. + + Parameters + ---------- + arrays: ArrayLikeObject + Array-like object containing the following ndarrays: + + - first one-dimensional input ndarray. + - second one-dimensional input ndarray. + - a two-dimensional input/output ndarray. + - a zero-dimensional ndarray containing a scalar constant. + + Returns + ------- + out: ndarray + Output ndarray. + + Examples + -------- + > var x = new {{alias:@stdlib/ndarray/vector/float32}}( [ 1.0, 2.0 ] ); + > var y = new {{alias:@stdlib/ndarray/vector/float32}}( [ 3.0, 4.0 ] ); + > var buf = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 2.0, 1.0 ] ); + > var sh = [ 2, 2 ]; + > var st = [ 2, 1 ]; + > var A = new {{alias:@stdlib/ndarray/base/ctor}}( 'float32', buf, sh, st, 0, 'row-major' ); + > var alpha = {{alias:@stdlib/ndarray/from-scalar}}( 2.0, { 'dtype': 'float32' }); + + > {{alias}}( [ x, y, A, alpha ] ); + > A + [ [ 13.0, 22.0 ], [ 2.0, 33.0 ] ] + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/docs/types/index.d.ts new file mode 100644 index 000000000000..592df1696903 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/docs/types/index.d.ts @@ -0,0 +1,65 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +import { float32ndarray } from '@stdlib/types/ndarray'; + +/** +* Performs the symmetric rank 2 operation `A = alpha*x*y^T + alpha*y*x^T + A`, where `alpha` is a scalar, `x` and `y` are `N` element ndarrays, and `A` is an `N` by `N` symmetric matrix. +* +* ## Notes +* +* - The function expects the following ndarrays: +* +* - first one-dimensional input ndarray. +* - second one-dimensional input ndarray. +* - a two-dimensional input/output ndarray. +* - a zero-dimensional ndarray containing a scalar constant. +* +* @param arrays - array-like object containing ndarrays +* @returns output ndarray +* +* @example +* var Float32Vector = require( '@stdlib/ndarray/vector/float32' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* var ndarray = require( '@stdlib/ndarray/base/ctor' ); +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var x = new Float32Vector( [ 1.0, 2.0, 3.0 ] ); +* var y = new Float32Vector( [ 2.0, 1.0, 3.0 ] ); +* var A = new ndarray( 'float32', new Float32Array( [ 1.0, 2.0, 3.0, 2.0, 1.0, 2.0, 3.0, 2.0, 1.0 ] ), [ 3, 3 ], [ 3, 1 ], 0, 'row-major' ); +* +* var alpha = scalar2ndarray( 2.0, { +* 'dtype': 'float32' +* }); +* +* var out = ssyr2( [ x, y, A, alpha ] ); +* // returns [ [ 9.0, 12.0, 21.0 ], [ 2.0, 9.0, 20.0 ], [ 3.0, 2.0, 37.0 ] ] +* +* var bool = ( out === A ); +* // returns true +*/ +declare function ssyr2( arrays: [ float32ndarray, float32ndarray, float32ndarray, float32ndarray ] ): float32ndarray; + + +// EXPORTS // + +export = ssyr2; diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/docs/types/test.ts new file mode 100644 index 000000000000..f767fff09812 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/docs/types/test.ts @@ -0,0 +1,75 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable space-in-parens */ + +import zeros = require( '@stdlib/ndarray/zeros' ); +import ssyr2 = require( '@stdlib/blas/base/ndarray/ssyr2' ); + + +// TESTS // + +// The function returns an ndarray... +{ + const x = zeros( [ 3 ], { + 'dtype': 'float32' + }); + const y = zeros( [ 3 ], { + 'dtype': 'float32' + }); + const A = zeros( [ 3, 3 ], { + 'dtype': 'float32' + }); + const alpha = zeros( [], { + 'dtype': 'float32' + }); + + ssyr2( [ x, y, A, alpha ] ); // $ExpectType float32ndarray +} + +// The compiler throws an error if the function is provided a first argument which is not an array of ndarrays... +{ + ssyr2( '10' ); // $ExpectError + ssyr2( 10 ); // $ExpectError + ssyr2( true ); // $ExpectError + ssyr2( false ); // $ExpectError + ssyr2( null ); // $ExpectError + ssyr2( undefined ); // $ExpectError + ssyr2( [] ); // $ExpectError + ssyr2( {} ); // $ExpectError + ssyr2( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = zeros( [ 3 ], { + 'dtype': 'float32' + }); + const y = zeros( [ 3 ], { + 'dtype': 'float32' + }); + const A = zeros( [ 3, 3 ], { + 'dtype': 'float32' + }); + const alpha = zeros( [], { + 'dtype': 'float32' + }); + + ssyr2(); // $ExpectError + ssyr2( [ x, y, A, alpha ], {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/examples/index.js b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/examples/index.js new file mode 100644 index 000000000000..4f511314b978 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/examples/index.js @@ -0,0 +1,40 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float32Vector = require( '@stdlib/ndarray/vector/float32' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var ssyr2 = require( './../lib' ); + +var opts = { + 'dtype': 'float32' +}; + +var x = new Float32Vector( discreteUniform( 3, 0, 10, opts ) ); +var y = new Float32Vector( discreteUniform( 3, 0, 10, opts ) ); +var A = new ndarray( 'float32', new Float32Array( discreteUniform( 9, 0, 10, opts ) ), [ 3, 3 ], [ 3, 1 ], 0, 'row-major' ); + +var alpha = scalar2ndarray( 1.0, opts ); + +var out = ssyr2( [ x, y, A, alpha ] ); +console.log( ndarray2array( out ) ); diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/lib/index.js b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/lib/index.js new file mode 100644 index 000000000000..df8724e211fa --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/lib/index.js @@ -0,0 +1,55 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* BLAS level 2 routine to perform the symmetric rank 2 operation `A = alpha*x*y^T + alpha*y*x^T + A`. +* +* @module @stdlib/blas/base/ndarray/ssyr2 +* +* @example +* var Float32Vector = require( '@stdlib/ndarray/vector/float32' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* var ndarray = require( '@stdlib/ndarray/base/ctor' ); +* var Float32Array = require( '@stdlib/array/float32' ); +* var ssyr2 = require( '@stdlib/blas/base/ndarray/ssyr2' ); +* +* var x = new Float32Vector( [ 1.0, 2.0, 3.0 ] ); +* var y = new Float32Vector( [ 2.0, 1.0, 3.0 ] ); +* var A = new ndarray( 'float32', new Float32Array( [ 1.0, 2.0, 3.0, 2.0, 1.0, 2.0, 3.0, 2.0, 1.0 ] ), [ 3, 3 ], [ 3, 1 ], 0, 'row-major' ); +* +* var alpha = scalar2ndarray( 2.0, { +* 'dtype': 'float32' +* }); +* +* var out = ssyr2( [ x, y, A, alpha ] ); +* // returns [ [ 9.0, 12.0, 21.0 ], [ 2.0, 9.0, 20.0 ], [ 3.0, 2.0, 37.0 ] ] +* +* var bool = ( out === A ); +* // returns true +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/lib/main.js b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/lib/main.js new file mode 100644 index 000000000000..9cb116519d8c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/lib/main.js @@ -0,0 +1,80 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var numelDimension = require( '@stdlib/ndarray/base/numel-dimension' ); +var getStride = require( '@stdlib/ndarray/base/stride' ); +var getOffset = require( '@stdlib/ndarray/base/offset' ); +var getData = require( '@stdlib/ndarray/base/data-buffer' ); +var ndarraylike2scalar = require( '@stdlib/ndarray/base/ndarraylike2scalar' ); +var strided = require( '@stdlib/blas/base/ssyr2' ).ndarray; + + +// MAIN // + +/** +* Performs the symmetric rank 2 operation `A = alpha*x*y^T + alpha*y*x^T + A`, where `alpha` is a scalar, `x` and `y` are `N` element ndarrays, and `A` is an `N` by `N` symmetric matrix. +* +* ## Notes +* +* - The function expects the following ndarrays: +* +* - first one-dimensional input ndarray. +* - second one-dimensional input ndarray. +* - a two-dimensional input/output ndarray. +* - a zero-dimensional ndarray containing a scalar constant. +* +* @param {ArrayLikeObject} arrays - array-like object containing ndarrays +* @returns {Object} output ndarray +* +* @example +* var Float32Vector = require( '@stdlib/ndarray/vector/float32' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* var ndarray = require( '@stdlib/ndarray/base/ctor' ); +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var x = new Float32Vector( [ 1.0, 2.0, 3.0 ] ); +* var y = new Float32Vector( [ 2.0, 1.0, 3.0 ] ); +* var A = new ndarray( 'float32', new Float32Array( [ 1.0, 2.0, 3.0, 2.0, 1.0, 2.0, 3.0, 2.0, 1.0 ] ), [ 3, 3 ], [ 3, 1 ], 0, 'row-major' ); +* +* var alpha = scalar2ndarray( 2.0, { +* 'dtype': 'float32' +* }); +* +* var out = ssyr2( [ x, y, A, alpha ] ); +* // returns [ [ 9.0, 12.0, 21.0 ], [ 2.0, 9.0, 20.0 ], [ 3.0, 2.0, 37.0 ] ] +* +* var bool = ( out === A ); +* // returns true +*/ +function ssyr2( arrays ) { + var alpha = ndarraylike2scalar( arrays[ 3 ] ); + var x = arrays[ 0 ]; + var y = arrays[ 1 ]; + var A = arrays[ 2 ]; + strided( 'upper', numelDimension( A, 0 ), alpha, getData( x ), getStride( x, 0 ), getOffset( x ), getData( y ), getStride( y, 0 ), getOffset( y ), getData( A ), getStride( A, 0 ), getStride( A, 1 ), getOffset( A ) ); + return A; +} + + +// EXPORTS // + +module.exports = ssyr2; diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/package.json b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/package.json new file mode 100644 index 000000000000..094a63371320 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/package.json @@ -0,0 +1,73 @@ +{ + "name": "@stdlib/blas/base/ndarray/ssyr2", + "version": "0.0.0", + "description": "Perform the symmetric rank 2 operation `A = alpha*x*y^T + alpha*y*x^T + A`.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "blas", + "level 2", + "ssyr2", + "linear", + "algebra", + "subroutines", + "symmetric", + "rank-2", + "update", + "vector", + "matrix", + "array", + "ndarray", + "float32", + "single", + "float32array" + ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/test/test.js b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/test/test.js new file mode 100644 index 000000000000..09b83cc25a3e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/test/test.js @@ -0,0 +1,302 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isSameFloat32Array = require( '@stdlib/assert/is-same-float32array' ); +var Float32Array = require( '@stdlib/array/float32' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var getData = require( '@stdlib/ndarray/data-buffer' ); +var ssyr2 = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Returns a one-dimensional ndarray. +* +* @private +* @param {Collection} buffer - underlying data buffer +* @param {NonNegativeInteger} length - number of indexed elements +* @param {integer} stride - stride length +* @param {NonNegativeInteger} offset - index offset +* @returns {ndarray} one-dimensional ndarray +*/ +function vector( buffer, length, stride, offset ) { + return new ndarray( 'float32', buffer, [ length ], [ stride ], offset, 'row-major' ); +} + +/** +* Returns a two-dimensional ndarray. +* +* @private +* @param {Collection} buffer - underlying data buffer +* @param {NonNegativeInteger} N - number of rows and columns +* @param {integer} stride0 - stride of the first dimension +* @param {integer} stride1 - stride of the second dimension +* @param {NonNegativeInteger} offset - index offset +* @returns {ndarray} two-dimensional ndarray +*/ +function matrix( buffer, N, stride0, stride1, offset ) { + return new ndarray( 'float32', buffer, [ N, N ], [ stride0, stride1 ], offset, 'row-major' ); +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof ssyr2, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 1', function test( t ) { + t.strictEqual( ssyr2.length, 1, 'has expected arity' ); + t.end(); +}); + +tape( 'the function performs the symmetric rank 2 operation `A = alpha*x*y^T + alpha*y*x^T + A`', function test( t ) { + var expected; + var alpha; + var xbuf; + var ybuf; + var Abuf; + var x; + var y; + var A; + var v; + + xbuf = new Float32Array( [ 1.0, 2.0, 3.0 ] ); + ybuf = new Float32Array( [ 2.0, 1.0, 3.0 ] ); + Abuf = new Float32Array( [ 1.0, 2.0, 3.0, 2.0, 1.0, 2.0, 3.0, 2.0, 1.0 ] ); + x = vector( xbuf, 3, 1, 0 ); + y = vector( ybuf, 3, 1, 0 ); + A = matrix( Abuf, 3, 3, 1, 0 ); + alpha = scalar2ndarray( 2.0, { + 'dtype': 'float32' + }); + + v = ssyr2( [ x, y, A, alpha ] ); + + expected = new Float32Array( [ 9.0, 12.0, 21.0, 2.0, 9.0, 20.0, 3.0, 2.0, 37.0 ] ); + t.strictEqual( v, A, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( getData( v ), expected ), true, 'returns expected value' ); + + xbuf = new Float32Array( [ 1.0, 1.0, 1.0 ] ); + ybuf = new Float32Array( [ 1.0, 1.0, 1.0 ] ); + Abuf = new Float32Array( [ 1.0, 2.0, 3.0, 2.0, 1.0, 2.0, 3.0, 2.0, 1.0 ] ); + x = vector( xbuf, 3, 1, 0 ); + y = vector( ybuf, 3, 1, 0 ); + A = matrix( Abuf, 3, 1, 3, 0 ); + alpha = scalar2ndarray( 2.0, { + 'dtype': 'float32' + }); + + v = ssyr2( [ x, y, A, alpha ] ); + + expected = new Float32Array( [ 5.0, 2.0, 3.0, 6.0, 5.0, 2.0, 7.0, 6.0, 5.0 ] ); + t.strictEqual( v, A, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( getData( v ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `alpha` is `0`, the function returns `A` unchanged', function test( t ) { + var expected; + var alpha; + var xbuf; + var ybuf; + var Abuf; + var x; + var y; + var A; + var v; + + xbuf = new Float32Array( [ 1.0, 2.0, 3.0 ] ); + ybuf = new Float32Array( [ 2.0, 1.0, 3.0 ] ); + Abuf = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); + x = vector( xbuf, 3, 1, 0 ); + y = vector( ybuf, 3, 1, 0 ); + A = matrix( Abuf, 3, 3, 1, 0 ); + alpha = scalar2ndarray( 0.0, { + 'dtype': 'float32' + }); + + v = ssyr2( [ x, y, A, alpha ] ); + + expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); + t.strictEqual( v, A, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( getData( v ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports ndarrays having non-unit strides', function test( t ) { + var expected; + var alpha; + var xbuf; + var ybuf; + var Abuf; + var x; + var y; + var A; + var v; + + xbuf = new Float32Array([ + 1.0, // 0 + 0.0, + 2.0, // 1 + 0.0, + 3.0 // 2 + ]); + x = vector( xbuf, 3, 2, 0 ); + + ybuf = new Float32Array([ + 2.0, // 0 + 0.0, + 1.0, // 1 + 0.0, + 3.0 // 2 + ]); + y = vector( ybuf, 3, 2, 0 ); + + Abuf = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + A = matrix( Abuf, 3, 3, 1, 0 ); + alpha = scalar2ndarray( 2.0, { + 'dtype': 'float32' + }); + + v = ssyr2( [ x, y, A, alpha ] ); + + expected = new Float32Array( [ 8.0, 10.0, 18.0, 0.0, 8.0, 18.0, 0.0, 0.0, 36.0 ] ); + t.strictEqual( v, A, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( getData( v ), expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports ndarrays having negative strides', function test( t ) { + var expected; + var alpha; + var xbuf; + var ybuf; + var Abuf; + var x; + var y; + var A; + var v; + + xbuf = new Float32Array([ + 3.0, // 2 + 2.0, // 1 + 1.0 // 0 + ]); + x = vector( xbuf, 3, -1, 2 ); + + ybuf = new Float32Array([ + 3.0, // 2 + 1.0, // 1 + 2.0 // 0 + ]); + y = vector( ybuf, 3, -1, 2 ); + + Abuf = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + A = matrix( Abuf, 3, 3, 1, 0 ); + alpha = scalar2ndarray( 2.0, { + 'dtype': 'float32' + }); + + v = ssyr2( [ x, y, A, alpha ] ); + + expected = new Float32Array( [ 8.0, 10.0, 18.0, 0.0, 8.0, 18.0, 0.0, 0.0, 36.0 ] ); + t.strictEqual( v, A, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( getData( v ), expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports ndarrays having non-zero offsets', function test( t ) { + var expected; + var alpha; + var xbuf; + var ybuf; + var Abuf; + var x; + var y; + var A; + var v; + + xbuf = new Float32Array([ + 0.0, + 1.0, // 0 + 0.0, + 2.0, // 1 + 0.0, + 3.0 // 2 + ]); + x = vector( xbuf, 3, 2, 1 ); + + ybuf = new Float32Array([ + 0.0, + 2.0, // 0 + 0.0, + 1.0, // 1 + 0.0, + 3.0 // 2 + ]); + y = vector( ybuf, 3, 2, 1 ); + + Abuf = new Float32Array([ + 999.0, + 999.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + A = matrix( Abuf, 3, 3, 1, 2 ); + alpha = scalar2ndarray( 2.0, { + 'dtype': 'float32' + }); + + v = ssyr2( [ x, y, A, alpha ] ); + + expected = new Float32Array([ + 999.0, + 999.0, + 8.0, + 10.0, + 18.0, + 0.0, + 8.0, + 18.0, + 0.0, + 0.0, + 36.0 + ]); + t.strictEqual( v, A, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( getData( v ), expected ), true, 'returns expected value' ); + t.end(); +}); From 8258e6db8932597fe171b36d2beca990840e69de Mon Sep 17 00:00:00 2001 From: kaustubh Date: Mon, 13 Jul 2026 11:51:32 +0530 Subject: [PATCH 2/3] feat: add Float32Matrix and cleanup --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../@stdlib/blas/base/ndarray/ssyr2/README.md | 39 ++++++---- .../base/ndarray/ssyr2/benchmark/benchmark.js | 7 +- .../blas/base/ndarray/ssyr2/docs/repl.txt | 41 ++++++----- .../base/ndarray/ssyr2/docs/types/index.d.ts | 28 ++++---- .../base/ndarray/ssyr2/docs/types/test.ts | 10 ++- .../blas/base/ndarray/ssyr2/examples/index.js | 11 +-- .../blas/base/ndarray/ssyr2/lib/index.js | 11 +-- .../blas/base/ndarray/ssyr2/lib/main.js | 55 +++++++++----- .../blas/base/ndarray/ssyr2/package.json | 2 +- .../blas/base/ndarray/ssyr2/test/test.js | 72 +++++++++++++++++-- 10 files changed, 196 insertions(+), 80 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/README.md b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/README.md index 79cbf8a61ddd..94acf7795c3d 100644 --- a/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/README.md +++ b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/README.md @@ -20,7 +20,7 @@ limitations under the License. # ssyr2 -> Perform the symmetric rank 2 operation `A = alpha*x*y^T + alpha*y*x^T + A`. +> Performs the symmetric rank 2 operation `A = alpha*x*y^T + alpha*y*x^T + A`.
@@ -38,26 +38,30 @@ var ssyr2 = require( '@stdlib/blas/base/ndarray/ssyr2' ); #### ssyr2( arrays ) -Performs the symmetric rank 2 operation `A = alpha*x*y^T + alpha*y*x^T + A`, where `alpha` is a scalar, `x` and `y` are `N` element ndarrays, and `A` is an `N` by `N` symmetric matrix. +Performs the symmetric rank 2 operation `A = alpha*x*y^T + alpha*y*x^T + A`, where `alpha` is a scalar, `x` and `y` are one-dimensional ndarrays, and `A` is an `N` by `N` symmetric matrix. ```javascript +/* eslint-disable max-len */ +var Float32Matrix = require( '@stdlib/ndarray/matrix/float32' ); var Float32Vector = require( '@stdlib/ndarray/vector/float32' ); +var resolveEnum = require( '@stdlib/blas/base/matrix-triangle-resolve-enum' ); var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); -var ndarray = require( '@stdlib/ndarray/base/ctor' ); -var Float32Array = require( '@stdlib/array/float32' ); +var A = new Float32Matrix( [ [ 1.0, 2.0, 3.0 ], [ 2.0, 1.0, 2.0 ], [ 3.0, 2.0, 1.0 ] ] ); var x = new Float32Vector( [ 1.0, 2.0, 3.0 ] ); var y = new Float32Vector( [ 2.0, 1.0, 3.0 ] ); -var A = new ndarray( 'float32', new Float32Array( [ 1.0, 2.0, 3.0, 2.0, 1.0, 2.0, 3.0, 2.0, 1.0 ] ), [ 3, 3 ], [ 3, 1 ], 0, 'row-major' ); +var uplo = scalar2ndarray( resolveEnum( 'upper' ), { + 'dtype': 'int8' +}); var alpha = scalar2ndarray( 2.0, { 'dtype': 'float32' }); -var out = ssyr2( [ x, y, A, alpha ] ); +var z = ssyr2( [ x, y, A, uplo, alpha ] ); // returns [ [ 9.0, 12.0, 21.0 ], [ 2.0, 9.0, 20.0 ], [ 3.0, 2.0, 37.0 ] ] -var bool = ( out === A ); +var bool = ( z === A ); // returns true ``` @@ -65,10 +69,11 @@ The function has the following parameters: - **arrays**: array-like object containing the following ndarrays: - - first one-dimensional input ndarray. - - second one-dimensional input ndarray. - - a two-dimensional input/output ndarray. - - a zero-dimensional ndarray containing a scalar constant. + - a one-dimensional input ndarray corresponding to `x`. + - a one-dimensional input ndarray corresponding to `y`. + - a two-dimensional input/output ndarray corresponding to `A`. + - a zero-dimensional ndarray specifying whether `A` should be referenced as an upper or lower triangular matrix. + - a zero-dimensional ndarray containing a scalar constant corresponding to `alpha`.
@@ -87,10 +92,11 @@ The function has the following parameters: ```javascript +/* eslint-disable max-len */ var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var ndarray = require( '@stdlib/ndarray/base/ctor' ); -var Float32Array = require( '@stdlib/array/float32' ); +var Float32Matrix = require( '@stdlib/ndarray/matrix/float32' ); var Float32Vector = require( '@stdlib/ndarray/vector/float32' ); +var resolveEnum = require( '@stdlib/blas/base/matrix-triangle-resolve-enum' ); var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); var ndarray2array = require( '@stdlib/ndarray/to-array' ); var ssyr2 = require( '@stdlib/blas/base/ndarray/ssyr2' ); @@ -101,11 +107,14 @@ var opts = { var x = new Float32Vector( discreteUniform( 3, 0, 10, opts ) ); var y = new Float32Vector( discreteUniform( 3, 0, 10, opts ) ); -var A = new ndarray( 'float32', new Float32Array( discreteUniform( 9, 0, 10, opts ) ), [ 3, 3 ], [ 3, 1 ], 0, 'row-major' ); +var A = new Float32Matrix( discreteUniform( 9, 0, 10, opts ).buffer, 0, [ 3, 3 ] ); +var uplo = scalar2ndarray( resolveEnum( 'upper' ), { + 'dtype': 'int8' +}); var alpha = scalar2ndarray( 1.0, opts ); -var out = ssyr2( [ x, y, A, alpha ] ); +var out = ssyr2( [ x, y, A, uplo, alpha ] ); console.log( ndarray2array( out ) ); ``` diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/benchmark/benchmark.js index 477eb2ee2329..1d553e56ef8e 100644 --- a/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/benchmark/benchmark.js @@ -25,6 +25,7 @@ var uniform = require( '@stdlib/random/uniform' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var pow = require( '@stdlib/math/base/special/pow' ); var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var resolveEnum = require( '@stdlib/blas/base/matrix-triangle-resolve-enum' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var ssyr2 = require( './../lib' ); @@ -48,6 +49,7 @@ var options = { */ function createBenchmark( len ) { var alpha; + var uplo; var x; var y; var A; @@ -57,6 +59,9 @@ function createBenchmark( len ) { A = uniform( [ len, len ], -100.0, 100.0, options ); alpha = scalar2ndarray( 1.0, options ); + uplo = scalar2ndarray( resolveEnum( 'upper' ), { + 'dtype': 'int8' + }); return benchmark; @@ -72,7 +77,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - z = ssyr2( [ x, y, A, alpha ] ); + z = ssyr2( [ x, y, A, uplo, alpha ] ); if ( typeof z !== 'object' ) { b.fail( 'should return an ndarray' ); } diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/docs/repl.txt index 0575737d93f0..5eb758bc91ee 100644 --- a/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/docs/repl.txt @@ -1,18 +1,21 @@ {{alias}}( arrays ) Performs the symmetric rank 2 operation `A = alpha*x*y^T + alpha*y*x^T + A`, - where `alpha` is a scalar, `x` and `y` are `N` element ndarrays, and `A` is - an `N` by `N` symmetric matrix. + where `alpha` is a scalar, `x` and `y` are one-dimensional ndarrays, and + `A` is an `N` by `N` symmetric matrix. Parameters ---------- arrays: ArrayLikeObject Array-like object containing the following ndarrays: - - first one-dimensional input ndarray. - - second one-dimensional input ndarray. - - a two-dimensional input/output ndarray. - - a zero-dimensional ndarray containing a scalar constant. + - a one-dimensional input ndarray corresponding to `x`. + - a one-dimensional input ndarray corresponding to `y`. + - a two-dimensional input/output ndarray corresponding to `A`. + - a zero-dimensional ndarray specifying whether `A` should be + referenced as an upper or lower triangular matrix. + - a zero-dimensional ndarray containing a scalar constant corresponding + to `alpha`. Returns ------- @@ -21,17 +24,23 @@ Examples -------- - > var x = new {{alias:@stdlib/ndarray/vector/float32}}( [ 1.0, 2.0 ] ); - > var y = new {{alias:@stdlib/ndarray/vector/float32}}( [ 3.0, 4.0 ] ); - > var buf = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 2.0, 1.0 ] ); - > var sh = [ 2, 2 ]; - > var st = [ 2, 1 ]; - > var A = new {{alias:@stdlib/ndarray/base/ctor}}( 'float32', buf, sh, st, 0, 'row-major' ); - > var alpha = {{alias:@stdlib/ndarray/from-scalar}}( 2.0, { 'dtype': 'float32' }); - - > {{alias}}( [ x, y, A, alpha ] ); + > var xbuf = [ 1.0, 2.0, 3.0 ]; + > var x = new {{alias:@stdlib/ndarray/vector/float32}}( xbuf ); + + > var ybuf = [ 2.0, 1.0, 3.0 ]; + > var y = new {{alias:@stdlib/ndarray/vector/float32}}( ybuf ); + + > var abuf = [ [ 1.0, 2.0, 3.0 ], [ 2.0, 1.0, 2.0 ], [ 3.0, 2.0, 1.0 ] ]; + > var A = new {{alias:@stdlib/ndarray/matrix/float32}}( abuf ); + + > var uplo = {{alias:@stdlib/ndarray/from-scalar}}( 'upper' ); + + > var opts = { 'dtype': 'float32' }; + > var alpha = {{alias:@stdlib/ndarray/from-scalar}}( 2.0, opts ); + + > {{alias}}( [ x, y, A, uplo, alpha ] ); > A - [ [ 13.0, 22.0 ], [ 2.0, 33.0 ] ] + [ [ 9.0, 12.0, 21.0 ], [ 2.0, 9.0, 20.0 ], [ 3.0, 2.0, 37.0 ] ] See Also -------- diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/docs/types/index.d.ts index 592df1696903..3fcd0c35e758 100644 --- a/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/docs/types/index.d.ts @@ -20,44 +20,48 @@ /// -import { float32ndarray } from '@stdlib/types/ndarray'; +import { float32ndarray, ndarray } from '@stdlib/types/ndarray'; /** -* Performs the symmetric rank 2 operation `A = alpha*x*y^T + alpha*y*x^T + A`, where `alpha` is a scalar, `x` and `y` are `N` element ndarrays, and `A` is an `N` by `N` symmetric matrix. +* Performs the symmetric rank 2 operation `A = alpha*x*y^T + alpha*y*x^T + A`, where `alpha` is a scalar, `x` and `y` are one-dimensional ndarrays, and `A` is an `N` by `N` symmetric matrix. * * ## Notes * * - The function expects the following ndarrays: * -* - first one-dimensional input ndarray. -* - second one-dimensional input ndarray. -* - a two-dimensional input/output ndarray. -* - a zero-dimensional ndarray containing a scalar constant. +* - a one-dimensional input ndarray corresponding to `x`. +* - a one-dimensional input ndarray corresponding to `y`. +* - a two-dimensional input/output ndarray corresponding to `A`. +* - a zero-dimensional ndarray specifying whether `A` should be referenced as an upper or lower triangular matrix. +* - a zero-dimensional ndarray containing a scalar constant corresponding to `alpha`. * * @param arrays - array-like object containing ndarrays * @returns output ndarray * * @example +* var Float32Matrix = require( '@stdlib/ndarray/matrix/float32' ); * var Float32Vector = require( '@stdlib/ndarray/vector/float32' ); +* var resolveEnum = require( '@stdlib/blas/base/matrix-triangle-resolve-enum' ); * var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); -* var ndarray = require( '@stdlib/ndarray/base/ctor' ); -* var Float32Array = require( '@stdlib/array/float32' ); * +* var A = new Float32Matrix( [ [ 1.0, 2.0, 3.0 ], [ 2.0, 1.0, 2.0 ], [ 3.0, 2.0, 1.0 ] ] ); * var x = new Float32Vector( [ 1.0, 2.0, 3.0 ] ); * var y = new Float32Vector( [ 2.0, 1.0, 3.0 ] ); -* var A = new ndarray( 'float32', new Float32Array( [ 1.0, 2.0, 3.0, 2.0, 1.0, 2.0, 3.0, 2.0, 1.0 ] ), [ 3, 3 ], [ 3, 1 ], 0, 'row-major' ); * +* var uplo = scalar2ndarray( resolveEnum( 'upper' ), { +* 'dtype': 'int8' +* }); * var alpha = scalar2ndarray( 2.0, { * 'dtype': 'float32' * }); * -* var out = ssyr2( [ x, y, A, alpha ] ); +* var z = ssyr2( [ x, y, A, uplo, alpha ] ); * // returns [ [ 9.0, 12.0, 21.0 ], [ 2.0, 9.0, 20.0 ], [ 3.0, 2.0, 37.0 ] ] * -* var bool = ( out === A ); +* var bool = ( z === A ); * // returns true */ -declare function ssyr2( arrays: [ float32ndarray, float32ndarray, float32ndarray, float32ndarray ] ): float32ndarray; +declare function ssyr2( arrays: [ float32ndarray, float32ndarray, float32ndarray, ndarray, float32ndarray ] ): float32ndarray; // EXPORTS // diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/docs/types/test.ts index f767fff09812..212e68837338 100644 --- a/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/docs/types/test.ts @@ -35,11 +35,14 @@ import ssyr2 = require( '@stdlib/blas/base/ndarray/ssyr2' ); const A = zeros( [ 3, 3 ], { 'dtype': 'float32' }); + const uplo = zeros( [], { + 'dtype': 'float32' + }); const alpha = zeros( [], { 'dtype': 'float32' }); - ssyr2( [ x, y, A, alpha ] ); // $ExpectType float32ndarray + ssyr2( [ x, y, A, uplo, alpha ] ); // $ExpectType float32ndarray } // The compiler throws an error if the function is provided a first argument which is not an array of ndarrays... @@ -66,10 +69,13 @@ import ssyr2 = require( '@stdlib/blas/base/ndarray/ssyr2' ); const A = zeros( [ 3, 3 ], { 'dtype': 'float32' }); + const uplo = zeros( [], { + 'dtype': 'float32' + }); const alpha = zeros( [], { 'dtype': 'float32' }); ssyr2(); // $ExpectError - ssyr2( [ x, y, A, alpha ], {} ); // $ExpectError + ssyr2( [ x, y, A, uplo, alpha ], {} ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/examples/index.js b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/examples/index.js index 4f511314b978..28cea18ed4d6 100644 --- a/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/examples/index.js +++ b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/examples/index.js @@ -19,9 +19,9 @@ 'use strict'; var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var ndarray = require( '@stdlib/ndarray/base/ctor' ); -var Float32Array = require( '@stdlib/array/float32' ); +var Float32Matrix = require( '@stdlib/ndarray/matrix/float32' ); var Float32Vector = require( '@stdlib/ndarray/vector/float32' ); +var resolveEnum = require( '@stdlib/blas/base/matrix-triangle-resolve-enum' ); var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); var ndarray2array = require( '@stdlib/ndarray/to-array' ); var ssyr2 = require( './../lib' ); @@ -32,9 +32,12 @@ var opts = { var x = new Float32Vector( discreteUniform( 3, 0, 10, opts ) ); var y = new Float32Vector( discreteUniform( 3, 0, 10, opts ) ); -var A = new ndarray( 'float32', new Float32Array( discreteUniform( 9, 0, 10, opts ) ), [ 3, 3 ], [ 3, 1 ], 0, 'row-major' ); +var A = new Float32Matrix( discreteUniform( 9, 0, 10, opts ).buffer, 0, [ 3, 3 ] ); +var uplo = scalar2ndarray( resolveEnum( 'upper' ), { + 'dtype': 'int8' +}); var alpha = scalar2ndarray( 1.0, opts ); -var out = ssyr2( [ x, y, A, alpha ] ); +var out = ssyr2( [ x, y, A, uplo, alpha ] ); console.log( ndarray2array( out ) ); diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/lib/index.js b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/lib/index.js index df8724e211fa..39d32f448497 100644 --- a/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/lib/index.js +++ b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/lib/index.js @@ -24,21 +24,24 @@ * @module @stdlib/blas/base/ndarray/ssyr2 * * @example +* var Float32Matrix = require( '@stdlib/ndarray/matrix/float32' ); * var Float32Vector = require( '@stdlib/ndarray/vector/float32' ); +* var resolveEnum = require( '@stdlib/blas/base/matrix-triangle-resolve-enum' ); * var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); -* var ndarray = require( '@stdlib/ndarray/base/ctor' ); -* var Float32Array = require( '@stdlib/array/float32' ); * var ssyr2 = require( '@stdlib/blas/base/ndarray/ssyr2' ); * * var x = new Float32Vector( [ 1.0, 2.0, 3.0 ] ); * var y = new Float32Vector( [ 2.0, 1.0, 3.0 ] ); -* var A = new ndarray( 'float32', new Float32Array( [ 1.0, 2.0, 3.0, 2.0, 1.0, 2.0, 3.0, 2.0, 1.0 ] ), [ 3, 3 ], [ 3, 1 ], 0, 'row-major' ); +* var A = new Float32Matrix( [ [ 1.0, 2.0, 3.0 ], [ 2.0, 1.0, 2.0 ], [ 3.0, 2.0, 1.0 ] ] ); * * var alpha = scalar2ndarray( 2.0, { * 'dtype': 'float32' * }); * -* var out = ssyr2( [ x, y, A, alpha ] ); +* var uplo = scalar2ndarray( resolveEnum( 'upper' ), { +* 'dtype': 'int8' +* }); +* var out = ssyr2( [ x, y, A, uplo, alpha ] ); * // returns [ [ 9.0, 12.0, 21.0 ], [ 2.0, 9.0, 20.0 ], [ 3.0, 2.0, 37.0 ] ] * * var bool = ( out === A ); diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/lib/main.js b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/lib/main.js index 9cb116519d8c..dbfee65b3777 100644 --- a/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/lib/main.js +++ b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/lib/main.js @@ -20,10 +20,12 @@ // MODULES // -var numelDimension = require( '@stdlib/ndarray/base/numel-dimension' ); +var getShape = require( '@stdlib/ndarray/base/shape' ); +var getStrides = require( '@stdlib/ndarray/base/strides' ); var getStride = require( '@stdlib/ndarray/base/stride' ); var getOffset = require( '@stdlib/ndarray/base/offset' ); var getData = require( '@stdlib/ndarray/base/data-buffer' ); +var resolveStr = require( '@stdlib/blas/base/matrix-triangle-resolve-str' ); var ndarraylike2scalar = require( '@stdlib/ndarray/base/ndarraylike2scalar' ); var strided = require( '@stdlib/blas/base/ssyr2' ).ndarray; @@ -31,46 +33,63 @@ var strided = require( '@stdlib/blas/base/ssyr2' ).ndarray; // MAIN // /** -* Performs the symmetric rank 2 operation `A = alpha*x*y^T + alpha*y*x^T + A`, where `alpha` is a scalar, `x` and `y` are `N` element ndarrays, and `A` is an `N` by `N` symmetric matrix. +* Performs the symmetric rank 2 operation `A = alpha*x*y^T + alpha*y*x^T + A`, where `alpha` is a scalar, `x` and `y` are one-dimensional ndarrays, and `A` is an `N` by `N` symmetric matrix. * * ## Notes * * - The function expects the following ndarrays: -* -* - first one-dimensional input ndarray. -* - second one-dimensional input ndarray. -* - a two-dimensional input/output ndarray. -* - a zero-dimensional ndarray containing a scalar constant. +* - a one-dimensional input ndarray corresponding to `x`. +* - a one-dimensional input ndarray corresponding to `y`. +* - a two-dimensional input/output ndarray corresponding to `A`. +* - a zero-dimensional ndarray specifying whether `A` should be referenced as an upper or lower triangular matrix. +* - a zero-dimensional ndarray containing a scalar constant corresponding to `alpha`. * * @param {ArrayLikeObject} arrays - array-like object containing ndarrays * @returns {Object} output ndarray * -* @example +* var Float32Matrix = require( '@stdlib/ndarray/matrix/float32' ); * var Float32Vector = require( '@stdlib/ndarray/vector/float32' ); +* var resolveEnum = require( '@stdlib/blas/base/matrix-triangle-resolve-enum' ); * var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); -* var ndarray = require( '@stdlib/ndarray/base/ctor' ); -* var Float32Array = require( '@stdlib/array/float32' ); * +* var A = new Float32Matrix( [ [ 1.0, 2.0, 3.0 ], [ 2.0, 1.0, 2.0 ], [ 3.0, 2.0, 1.0 ] ] ); * var x = new Float32Vector( [ 1.0, 2.0, 3.0 ] ); * var y = new Float32Vector( [ 2.0, 1.0, 3.0 ] ); -* var A = new ndarray( 'float32', new Float32Array( [ 1.0, 2.0, 3.0, 2.0, 1.0, 2.0, 3.0, 2.0, 1.0 ] ), [ 3, 3 ], [ 3, 1 ], 0, 'row-major' ); * +* var uplo = scalar2ndarray( resolveEnum( 'upper' ), { +* 'dtype': 'int8' +* }); * var alpha = scalar2ndarray( 2.0, { * 'dtype': 'float32' * }); * -* var out = ssyr2( [ x, y, A, alpha ] ); +* var z = ssyr2( [ x, y, A, uplo, alpha ] ); * // returns [ [ 9.0, 12.0, 21.0 ], [ 2.0, 9.0, 20.0 ], [ 3.0, 2.0, 37.0 ] ] * -* var bool = ( out === A ); +* var bool = ( z === A ); * // returns true */ function ssyr2( arrays ) { - var alpha = ndarraylike2scalar( arrays[ 3 ] ); - var x = arrays[ 0 ]; - var y = arrays[ 1 ]; - var A = arrays[ 2 ]; - strided( 'upper', numelDimension( A, 0 ), alpha, getData( x ), getStride( x, 0 ), getOffset( x ), getData( y ), getStride( y, 0 ), getOffset( y ), getData( A ), getStride( A, 0 ), getStride( A, 1 ), getOffset( A ) ); + var alpha; + var uplo; + var sh; + var st; + var A; + var x; + var y; + + x = arrays[ 0 ]; + y = arrays[ 1 ]; + A = arrays[ 2 ]; + + uplo = resolveStr( ndarraylike2scalar( arrays[ 3 ] ) ); + alpha = ndarraylike2scalar( arrays[ 4 ] ); + + sh = getShape( A, false ); + st = getStrides( A, false ); + + strided( uplo, sh[ 0 ], alpha, getData( x ), getStride( x, 0 ), getOffset( x ), getData( y ), getStride( y, 0 ), getOffset( y ), getData( A ), st[ 0 ], st[ 1 ], getOffset( A ) ); + return A; } diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/package.json b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/package.json index 094a63371320..50528550dfc9 100644 --- a/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/package.json +++ b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/blas/base/ndarray/ssyr2", "version": "0.0.0", - "description": "Perform the symmetric rank 2 operation `A = alpha*x*y^T + alpha*y*x^T + A`.", + "description": "Performs the symmetric rank 2 operation `A = alpha*x*y^T + alpha*y*x^T + A`.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/test/test.js b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/test/test.js index 09b83cc25a3e..5ff9dac5db21 100644 --- a/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/test/test.js +++ b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/test/test.js @@ -24,6 +24,7 @@ var tape = require( 'tape' ); var isSameFloat32Array = require( '@stdlib/assert/is-same-float32array' ); var Float32Array = require( '@stdlib/array/float32' ); var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var resolveEnum = require( '@stdlib/blas/base/matrix-triangle-resolve-enum' ); var ndarray = require( '@stdlib/ndarray/base/ctor' ); var getData = require( '@stdlib/ndarray/data-buffer' ); var ssyr2 = require( './../lib' ); @@ -74,12 +75,13 @@ tape( 'the function has an arity of 1', function test( t ) { t.end(); }); -tape( 'the function performs the symmetric rank 2 operation `A = alpha*x*y^T + alpha*y*x^T + A`', function test( t ) { +tape( 'the function performs the symmetric rank 2 operation `A = alpha*x*y^T + alpha*y*x^T + A` (upper)', function test( t ) { var expected; var alpha; var xbuf; var ybuf; var Abuf; + var uplo; var x; var y; var A; @@ -95,7 +97,10 @@ tape( 'the function performs the symmetric rank 2 operation `A = alpha*x*y^T + a 'dtype': 'float32' }); - v = ssyr2( [ x, y, A, alpha ] ); + uplo = scalar2ndarray( resolveEnum( 'upper' ), { + 'dtype': 'int8' + }); + v = ssyr2( [ x, y, A, uplo, alpha ] ); expected = new Float32Array( [ 9.0, 12.0, 21.0, 2.0, 9.0, 20.0, 3.0, 2.0, 37.0 ] ); t.strictEqual( v, A, 'returns expected value' ); @@ -111,7 +116,10 @@ tape( 'the function performs the symmetric rank 2 operation `A = alpha*x*y^T + a 'dtype': 'float32' }); - v = ssyr2( [ x, y, A, alpha ] ); + uplo = scalar2ndarray( resolveEnum( 'upper' ), { + 'dtype': 'int8' + }); + v = ssyr2( [ x, y, A, uplo, alpha ] ); expected = new Float32Array( [ 5.0, 2.0, 3.0, 6.0, 5.0, 2.0, 7.0, 6.0, 5.0 ] ); t.strictEqual( v, A, 'returns expected value' ); @@ -120,12 +128,47 @@ tape( 'the function performs the symmetric rank 2 operation `A = alpha*x*y^T + a t.end(); }); +tape( 'the function performs the symmetric rank 2 operation `A = alpha*x*y^T + alpha*y*x^T + A` (lower)', function test( t ) { + var expected; + var alpha; + var xbuf; + var ybuf; + var Abuf; + var uplo; + var x; + var y; + var A; + var v; + + xbuf = new Float32Array( [ 1.0, 2.0, 3.0 ] ); + ybuf = new Float32Array( [ 2.0, 1.0, 3.0 ] ); + Abuf = new Float32Array( [ 1.0, 2.0, 3.0, 2.0, 1.0, 2.0, 3.0, 2.0, 1.0 ] ); + x = vector( xbuf, 3, 1, 0 ); + y = vector( ybuf, 3, 1, 0 ); + A = matrix( Abuf, 3, 3, 1, 0 ); + alpha = scalar2ndarray( 2.0, { + 'dtype': 'float32' + }); + + uplo = scalar2ndarray( resolveEnum( 'lower' ), { + 'dtype': 'int8' + }); + v = ssyr2( [ x, y, A, uplo, alpha ] ); + + expected = new Float32Array( [ 9.0, 2.0, 3.0, 12.0, 9.0, 2.0, 21.0, 20.0, 37.0 ] ); + t.strictEqual( v, A, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( getData( v ), expected ), true, 'returns expected value' ); + + t.end(); +}); + tape( 'if `alpha` is `0`, the function returns `A` unchanged', function test( t ) { var expected; var alpha; var xbuf; var ybuf; var Abuf; + var uplo; var x; var y; var A; @@ -141,7 +184,10 @@ tape( 'if `alpha` is `0`, the function returns `A` unchanged', function test( t 'dtype': 'float32' }); - v = ssyr2( [ x, y, A, alpha ] ); + uplo = scalar2ndarray( resolveEnum( 'upper' ), { + 'dtype': 'int8' + }); + v = ssyr2( [ x, y, A, uplo, alpha ] ); expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); t.strictEqual( v, A, 'returns expected value' ); @@ -156,6 +202,7 @@ tape( 'the function supports ndarrays having non-unit strides', function test( t var xbuf; var ybuf; var Abuf; + var uplo; var x; var y; var A; @@ -185,7 +232,10 @@ tape( 'the function supports ndarrays having non-unit strides', function test( t 'dtype': 'float32' }); - v = ssyr2( [ x, y, A, alpha ] ); + uplo = scalar2ndarray( resolveEnum( 'upper' ), { + 'dtype': 'int8' + }); + v = ssyr2( [ x, y, A, uplo, alpha ] ); expected = new Float32Array( [ 8.0, 10.0, 18.0, 0.0, 8.0, 18.0, 0.0, 0.0, 36.0 ] ); t.strictEqual( v, A, 'returns expected value' ); @@ -199,6 +249,7 @@ tape( 'the function supports ndarrays having negative strides', function test( t var xbuf; var ybuf; var Abuf; + var uplo; var x; var y; var A; @@ -224,7 +275,10 @@ tape( 'the function supports ndarrays having negative strides', function test( t 'dtype': 'float32' }); - v = ssyr2( [ x, y, A, alpha ] ); + uplo = scalar2ndarray( resolveEnum( 'upper' ), { + 'dtype': 'int8' + }); + v = ssyr2( [ x, y, A, uplo, alpha ] ); expected = new Float32Array( [ 8.0, 10.0, 18.0, 0.0, 8.0, 18.0, 0.0, 0.0, 36.0 ] ); t.strictEqual( v, A, 'returns expected value' ); @@ -238,6 +292,7 @@ tape( 'the function supports ndarrays having non-zero offsets', function test( t var xbuf; var ybuf; var Abuf; + var uplo; var x; var y; var A; @@ -281,7 +336,10 @@ tape( 'the function supports ndarrays having non-zero offsets', function test( t 'dtype': 'float32' }); - v = ssyr2( [ x, y, A, alpha ] ); + uplo = scalar2ndarray( resolveEnum( 'upper' ), { + 'dtype': 'int8' + }); + v = ssyr2( [ x, y, A, uplo, alpha ] ); expected = new Float32Array([ 999.0, From c01e89bcb2703944a7ca990b7aeb446fb97969c3 Mon Sep 17 00:00:00 2001 From: Kaustubh Patange Date: Tue, 14 Jul 2026 11:53:32 +0530 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Kaustubh Patange Signed-off-by: Kaustubh Patange --- .../@stdlib/blas/base/ndarray/ssyr2/README.md | 16 ++++++++-------- .../blas/base/ndarray/ssyr2/examples/index.js | 10 ++++------ .../@stdlib/blas/base/ndarray/ssyr2/lib/main.js | 3 +-- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/README.md b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/README.md index 94acf7795c3d..49e4e4b4ed3e 100644 --- a/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/README.md +++ b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/README.md @@ -40,8 +40,9 @@ var ssyr2 = require( '@stdlib/blas/base/ndarray/ssyr2' ); Performs the symmetric rank 2 operation `A = alpha*x*y^T + alpha*y*x^T + A`, where `alpha` is a scalar, `x` and `y` are one-dimensional ndarrays, and `A` is an `N` by `N` symmetric matrix. + + ```javascript -/* eslint-disable max-len */ var Float32Matrix = require( '@stdlib/ndarray/matrix/float32' ); var Float32Vector = require( '@stdlib/ndarray/vector/float32' ); var resolveEnum = require( '@stdlib/blas/base/matrix-triangle-resolve-enum' ); @@ -89,13 +90,12 @@ The function has the following parameters: ## Examples + + ```javascript -/* eslint-disable max-len */ -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var Float32Matrix = require( '@stdlib/ndarray/matrix/float32' ); -var Float32Vector = require( '@stdlib/ndarray/vector/float32' ); +var discreteUniform = require( '@stdlib/random/discrete-uniform' ); var resolveEnum = require( '@stdlib/blas/base/matrix-triangle-resolve-enum' ); var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); var ndarray2array = require( '@stdlib/ndarray/to-array' ); @@ -105,9 +105,9 @@ var opts = { 'dtype': 'float32' }; -var x = new Float32Vector( discreteUniform( 3, 0, 10, opts ) ); -var y = new Float32Vector( discreteUniform( 3, 0, 10, opts ) ); -var A = new Float32Matrix( discreteUniform( 9, 0, 10, opts ).buffer, 0, [ 3, 3 ] ); +var x = discreteUniform( [ 3 ], 0, 10, opts ); +var y = discreteUniform( [ 3 ], 0, 10, opts ); +var A = discreteUniform( [ 3, 3 ], 0, 10, opts ); var uplo = scalar2ndarray( resolveEnum( 'upper' ), { 'dtype': 'int8' diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/examples/index.js b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/examples/index.js index 28cea18ed4d6..c1a14308e102 100644 --- a/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/examples/index.js +++ b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/examples/index.js @@ -18,9 +18,7 @@ 'use strict'; -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var Float32Matrix = require( '@stdlib/ndarray/matrix/float32' ); -var Float32Vector = require( '@stdlib/ndarray/vector/float32' ); +var discreteUniform = require( '@stdlib/random/discrete-uniform' ); var resolveEnum = require( '@stdlib/blas/base/matrix-triangle-resolve-enum' ); var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); var ndarray2array = require( '@stdlib/ndarray/to-array' ); @@ -30,9 +28,9 @@ var opts = { 'dtype': 'float32' }; -var x = new Float32Vector( discreteUniform( 3, 0, 10, opts ) ); -var y = new Float32Vector( discreteUniform( 3, 0, 10, opts ) ); -var A = new Float32Matrix( discreteUniform( 9, 0, 10, opts ).buffer, 0, [ 3, 3 ] ); +var x = discreteUniform( [ 3 ], 0, 10, opts ); +var y = discreteUniform( [ 3 ], 0, 10, opts ); +var A = discreteUniform( [ 3, 3 ], 0, 10, opts ); var uplo = scalar2ndarray( resolveEnum( 'upper' ), { 'dtype': 'int8' diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/lib/main.js b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/lib/main.js index dbfee65b3777..497b54c369c4 100644 --- a/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/lib/main.js +++ b/lib/node_modules/@stdlib/blas/base/ndarray/ssyr2/lib/main.js @@ -25,7 +25,6 @@ var getStrides = require( '@stdlib/ndarray/base/strides' ); var getStride = require( '@stdlib/ndarray/base/stride' ); var getOffset = require( '@stdlib/ndarray/base/offset' ); var getData = require( '@stdlib/ndarray/base/data-buffer' ); -var resolveStr = require( '@stdlib/blas/base/matrix-triangle-resolve-str' ); var ndarraylike2scalar = require( '@stdlib/ndarray/base/ndarraylike2scalar' ); var strided = require( '@stdlib/blas/base/ssyr2' ).ndarray; @@ -82,7 +81,7 @@ function ssyr2( arrays ) { y = arrays[ 1 ]; A = arrays[ 2 ]; - uplo = resolveStr( ndarraylike2scalar( arrays[ 3 ] ) ); + uplo = ndarraylike2scalar( arrays[ 3 ] ); alpha = ndarraylike2scalar( arrays[ 4 ] ); sh = getShape( A, false );