diff --git a/lib/node_modules/@stdlib/blas/base/sspr2/README.md b/lib/node_modules/@stdlib/blas/base/sspr2/README.md new file mode 100644 index 000000000000..a05421434416 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspr2/README.md @@ -0,0 +1,265 @@ + + +# sspr2 + +> Perform the symmetric rank 2 operation `A := α*x*y**T + α*y*x**T + A`. + +
+ +## Usage + +```javascript +var sspr2 = require( '@stdlib/blas/base/sspr2' ); +``` + +#### sspr2( order, uplo, N, α, x, sx, y, sy, AP ) + +Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` where `α` is a scalar, `x` and `y` are `N` element vector, and `A` is an `N` by `N` symmetric matrix supplied in packed form. + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var AP = new Float32Array( [ 1.0, 2.0, 3.0, 1.0, 2.0, 1.0 ] ); +var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +var y = new Float32Array( [ 1.0, 2.0, 3.0 ] ); + +sspr2( 'row-major', 'upper', 3, 1.0, x, 1, y, 1, AP ); +// AP => [ 3.0, 6.0, 9.0, 9.0, 14.0, 19.0 ] +``` + +The function has the following parameters: + +- **order**: storage layout. +- **uplo**: specifies whether the upper or lower triangular part of the symmetric matrix `A` is supplied. +- **N**: number of elements along each dimension of `A`. +- **α**: scalar constant. +- **x**: first input [`Float32Array`][mdn-float32array]. +- **sx**: index increment for `x`. +- **y**: second input [`Float32Array`][mdn-float32array]. +- **sy**: index increment for `y`. +- **AP**: packed form of a symmetric matrix `A` stored as a [`Float32Array`][mdn-float32array]. + +The stride parameters determine how elements in the input arrays are accessed at runtime. For example, to iterate over the elements of `x` and `y` in reverse order, + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var AP = new Float32Array( [ 1.0, 2.0, 3.0, 1.0, 2.0, 1.0 ] ); +var x = new Float32Array( [ 3.0, 2.0, 1.0 ] ); +var y = new Float32Array( [ 3.0, 2.0, 1.0 ] ); + +sspr2( 'row-major', 'upper', 3, 1.0, x, -1, y, -1, AP ); +// AP => [ 3.0, 6.0, 9.0, 9.0, 14.0, 19.0 ] +``` + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +// Initial arrays... +var x0 = new Float32Array( [ 0.0, 3.0, 2.0, 1.0 ] ); +var y0 = new Float32Array( [ 0.0, 3.0, 2.0, 1.0 ] ); +var AP = new Float32Array( [ 1.0, 2.0, 3.0, 1.0, 2.0, 1.0 ] ); + +// Create offset views... +var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var y1 = new Float32Array( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +sspr2( 'row-major', 'upper', 3, 1.0, x1, -1, y1, -1, AP ); +// AP => [ 3.0, 6.0, 9.0, 9.0, 14.0, 19.0 ] +``` + +#### sspr2.ndarray( uplo, N, α, x, sx, ox, y, sy, oy, AP, sap, oap ) + +Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`, using alternative indexing semantics and where `α` is a scalar, `x` and `y` are `N` element vector, and `A` is an `N` by `N` symmetric matrix supplied in packed form. + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var AP = new Float32Array( [ 1.0, 2.0, 1.0, 3.0, 2.0, 1.0 ] ); +var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +var y = new Float32Array( [ 1.0, 2.0, 3.0 ] ); + +sspr2.ndarray( 'column-major', 'upper', 3, 1.0, x, 1, 0, y, 1, 0, AP, 1, 0 ); +// AP => [ 3.0, 6.0, 9.0, 9.0, 14.0, 19.0 ] +``` + +The function has the following additional parameters: + +- **ox**: starting index for `x`. +- **oy**: starting index for `y`. +- **sap**: `AP` stride length. +- **oap**: starting index for `AP`. + +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var AP = new Float32Array( [ 1.0, 2.0, 1.0, 3.0, 2.0, 1.0 ] ); +var x = new Float32Array( [ 3.0, 2.0, 1.0 ] ); +var y = new Float32Array( [ 3.0, 2.0, 1.0 ] ); + +sspr2.ndarray( 'column-major', 'upper', 3, 1.0, x, -1, 2, y, -1, 2, AP, 1, 0 ); +// AP => [ 3.0, 6.0, 9.0, 9.0, 14.0, 19.0 ] +``` + +
+ + + +
+ +## Notes + +- `sspr2()` corresponds to the [BLAS][blas] level 2 function [`sspr2`][blas-sspr2]. + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var sspr2 = require( '@stdlib/blas/base/sspr2' ); + +var opts = { + 'dtype': 'float32' +}; + +var N = 5; + +var AP = discreteUniform( N * ( N + 1 ) / 2, -10.0, 10.0, opts ); +var x = discreteUniform( N, -10.0, 10.0, opts ); +var y = discreteUniform( N, -10.0, 10.0, opts ); + +sspr2( 'column-major', 'upper', N, 1.0, x, 1, y, 1, AP ); +console.log( AP ); + +sspr2.ndarray( 'column-major', 'upper', N, 1.0, x, 1, 0, y, 1, 0, AP, 1, 0 ); +console.log( AP ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +TODO +``` + +#### TODO + +TODO. + +```c +TODO +``` + +TODO + +```c +TODO +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +TODO +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/base/sspr2/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/sspr2/benchmark/benchmark.js new file mode 100644 index 000000000000..217362019b65 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspr2/benchmark/benchmark.js @@ -0,0 +1,105 @@ +/** +* @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 bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var pkg = require( './../package.json' ).name; +var sspr2 = require( './../lib/sspr2.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float32' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var AP = uniform( N * ( N + 1 ) / 2, -10.0, 10.0, options ); + var x = uniform( N, -10.0, 10.0, options ); + var y = uniform( 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 = sspr2( 'row-major', 'upper', N, 1.0, x, 1, y, 1, AP ); + if ( isnanf( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( len ); + bench( pkg+':size='+( len * ( len + 1 ) / 2 ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/sspr2/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/sspr2/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..4b6878506012 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspr2/benchmark/benchmark.ndarray.js @@ -0,0 +1,105 @@ +/** +* @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 bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var pkg = require( './../package.json' ).name; +var sspr2 = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float32' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var AP = uniform( N * ( N + 1 ) / 2, -10.0, 10.0, options ); + var x = uniform( N, -10.0, 10.0, options ); + var y = uniform( 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 = sspr2( 'row-major', 'upper', N, 1.0, x, 1, 0, y, 1, 0, AP, 1, 0 ); + if ( isnanf( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( len ); + bench( pkg+':ndarray:size='+( len * ( len + 1 ) / 2 ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/sspr2/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/sspr2/docs/repl.txt new file mode 100644 index 000000000000..58a980c08850 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspr2/docs/repl.txt @@ -0,0 +1,127 @@ + +{{alias}}( ord, uplo, N, α, x, sx, y, sy, AP ) + Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` where + `α` is a scalar, `x` and `y` are `N` element vector, and `A` is an `N` by + `N` symmetric matrix supplied in packed form. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + If `N` is equal to `0` or `α` is equal to `0`, the function returns `AP` + unchanged. + + Parameters + ---------- + ord: string + Row-major (C-style) or column-major (Fortran-style) order. Must be + either 'row-major' or 'column-major'. + + uplo: string + Specifies whether the upper or lower triangular matrix of `A` is + supplied. Must be either 'upper' or 'lower'. + + N: integer + Number of elements along each dimension of `A`. + + α: number + Scalar constant. + + x: Float32Array + First input vector. + + sx: integer + Index increment for `x`. + + y: Float32Array + Second input vector. + + sy: integer + Index increment for `y`. + + AP: Float32Array + Matrix in packed form. + + Returns + ------- + AP: Float32Array + Matrix in packed form. + + Examples + -------- + > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > var y = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > var AP = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0 ] ); + > {{alias}}( 'row-major', 'upper', 2, 1.0, x, 1, y, 1, AP ) + [ 3.0, 4.0, 5.0 ] + + +{{alias}}.ndarray( ord, uplo, N, α, x, sx, ox, y, sy, oy, AP, sap, oap ) + Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` using + alternative indexing sematics and where `α` is a scalar, `x` and `y` are `N` + element vector, and `A` is an `N` by `N` symmetric matrix supplied in packed + form. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameters support indexing semantics based on starting + indices. + + Parameters + ---------- + ord: string + Row-major (C-style) or column-major (Fortran-style) order. Must be + either 'row-major' or 'column-major'. + + uplo: string + Specifies whether the upper or lower triangular matrix of `A` is + supplied. Must be either 'upper' or 'lower'. + + N: integer + Number of elements along each dimension of `A`. + + α: number + Scalar. + + x: Float32Array + First input vector. + + sx: integer + Index increment for `x`. + + ox: integer + Starting index for `x`. + + y: Float32Array + Second input vector. + + sy: integer + Index increment for `y`. + + oy: integer + Starting index for `y`. + + AP: Float32Array + Matrix in packed form. + + sap: integer + Index increment for `ap`. + + oap: integer + Starting index for `ap`. + + Returns + ------- + AP: Float32Array + Matrix in packed form. + + Examples + -------- + > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > var y = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > var AP = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0 ] ); + > var ord = 'row-major'; + > var uplo = 'upper'; + > {{alias}}.ndarray( ord, uplo, 2, 1.0, x, 1, 0, y, 1, 0, AP, 1, 0 ) + [ 3.0, 4.0, 5.0 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/blas/base/sspr2/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/sspr2/docs/types/index.d.ts new file mode 100644 index 000000000000..41689bff60cf --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspr2/docs/types/index.d.ts @@ -0,0 +1,125 @@ +/* +* @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, MatrixTriangle } from '@stdlib/types/blas'; + +/** +* Interface describing `sspr2`. +*/ +interface Routine { + /** + * Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` where `α` is a scalar, `x` and `y` are `N` element vector, and `A` is an `N` by `N` symmetric matrix supplied in packed form. + * + * @param order - storage layout + * @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is supplied + * @param N - number of elements along each dimension of `A` + * @param alpha - scalar constant + * @param x - first input vector + * @param strideX - `x` stride length + * @param y - second input vector + * @param strideX - `y` stride length + * @param AP - packed form of a symmetric matrix `A` + * @returns `AP` + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * + * var AP = new Float32Array( [ 1.0, 2.0, 3.0, 1.0, 2.0, 1.0 ] ); // => [ [ 1.0, 2.0, 3.0 ], [ 0.0, 1.0, 2.0 ], [ 0.0, 0.0, 1.0 ] ] + * var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); + * var y = new Float32Array( [ 1.0, 2.0, 3.0 ] ); + * + * sspr2( 'row-major', 'upper', 3, 1.0, x, 1, y, 1, AP ); + * // AP => [ 3.0, 6.0, 9.0, 9.0, 14.0, 19.0 ] + */ + ( order: Layout, uplo: MatrixTriangle, N: number, alpha: number, x: Float32Array, strideX: number, y: Float32Array, strideY: number, AP: Float32Array ): Float32Array; + + /** + * Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`, using alternative indexing semantics and where `α` is a scalar, `x` and `y` are `N` element vector, and `A` is an `N` by `N` symmetric matrix supplied in packed form. + * + * @param order - storage layout + * @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is supplied + * @param N - number of elements along each dimension of `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 AP - packed form of a symmetric matrix `A` + * @param strideAP - `AP` stride length + * @param offsetAP - starting index for `AP` + * @returns `AP` + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * + * var AP = new Float32Array( [ 1.0, 2.0, 3.0, 1.0, 2.0, 1.0 ] ); // => [ [ 1.0, 2.0, 3.0 ], [ 0.0, 1.0, 2.0 ], [ 0.0, 0.0, 1.0 ] ] + * var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); + * var y = new Float32Array( [ 1.0, 2.0, 3.0 ] ); + * + * sspr2.ndarray( 'row-major', 'upper', 3, 1.0, x, 1, 0, y, 1, 0, AP, 1, 0 ); + * // AP => [ 3.0, 6.0, 9.0, 9.0, 14.0, 19.0 ] + */ + ndarray( order: Layout, uplo: MatrixTriangle, N: number, alpha: number, x: Float32Array, strideX: number, offsetX: number, y: Float32Array, strideY: number, offsetY: number, AP: Float32Array, strideAP: number, offsetAP: number ): Float32Array; +} + +/** +* Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` where `α` is a scalar, `x` and `y` are `N` element vector, and `A` is an `N` by `N` symmetric matrix supplied in packed form. +* +* @param order - storage layout +* @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is supplied +* @param N - number of elements along each dimension of `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 AP - packed form of a symmetric matrix `A` +* @returns `AP` +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var AP = new Float32Array( [ 1.0, 2.0, 1.0, 3.0, 2.0, 1.0 ] ); +* var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* var y = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* +* sspr2( 'column-major', 'upper', 3, 1.0, x, 1, y, 1, AP ); +* // AP => [ 3.0, 6.0, 9.0, 9.0, 14.0, 19.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var AP = new Float32Array( [ 1.0, 2.0, 1.0, 3.0, 2.0, 1.0 ] ); +* var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* var y = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* +* sspr2.ndarray( 'column-major', 'upper', 3, 1.0, x, 1, 0, y, 1, 0, AP, 1, 0 ); +* // AP => [ 3.0, 6.0, 9.0, 9.0, 14.0, 19.0 ] +*/ +declare var sspr2: Routine; + + +// EXPORTS // + +export = sspr2; diff --git a/lib/node_modules/@stdlib/blas/base/sspr2/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/sspr2/docs/types/test.ts new file mode 100644 index 000000000000..ae315f8231ff --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspr2/docs/types/test.ts @@ -0,0 +1,432 @@ +/* +* @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 sspr2 = require( './index' ); + + +// TESTS // + +// The function returns a Float32Array... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspr2( 'row-major', 'upper', 10, 1.0, x, 1, y, 1, A ); // $ExpectType Float32Array +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspr2( 10, 'upper', 10, 1.0, x, 1, y, 1, A ); // $ExpectError + sspr2( true, 'upper', 10, 1.0, x, 1, y, 1, A ); // $ExpectError + sspr2( false, 'upper', 10, 1.0, x, 1, y, 1, A ); // $ExpectError + sspr2( null, 'upper', 10, 1.0, x, 1, y, 1, A ); // $ExpectError + sspr2( void 0, 'upper', 10, 1.0, x, 1, y, 1, A ); // $ExpectError + sspr2( [], 'upper', 10, 1.0, x, 1, y, 1, A ); // $ExpectError + sspr2( {}, 'upper', 10, 1.0, x, 1, y, 1, A ); // $ExpectError + sspr2( ( x: number ): number => x, 'upper', 10, 1.0, x, 1, y, 1, A ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a string... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspr2( 'row-major', 10, 10, 1.0, x, 1, y, 1, A ); // $ExpectError + sspr2( 'row-major', true, 10, 1.0, x, 1, y, 1, A ); // $ExpectError + sspr2( 'row-major', false, 10, 1.0, x, 1, y, 1, A ); // $ExpectError + sspr2( 'row-major', null, 10, 1.0, x, 1, y, 1, A ); // $ExpectError + sspr2( 'row-major', void 0, 10, 1.0, x, 1, y, 1, A ); // $ExpectError + sspr2( 'row-major', [ '1' ], 10, 1.0, x, 1, y, 1, A ); // $ExpectError + sspr2( 'row-major', {}, 10, 1.0, x, 1, y, 1, A ); // $ExpectError + sspr2( 'row-major', ( x: number ): number => x, 10, 1.0, x, 1, y, 1, A ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspr2( 'row-major', 'upper', '10', 1.0, x, 1, y, 1, A ); // $ExpectError + sspr2( 'row-major', 'upper', true, 1.0, x, 1, y, 1, A ); // $ExpectError + sspr2( 'row-major', 'upper', false, 1.0, x, 1, y, 1, A ); // $ExpectError + sspr2( 'row-major', 'upper', null, 1.0, x, 1, y, 1, A ); // $ExpectError + sspr2( 'row-major', 'upper', void 0, 1.0, x, 1, y, 1, A ); // $ExpectError + sspr2( 'row-major', 'upper', [], 1.0, x, 1, y, 1, A ); // $ExpectError + sspr2( 'row-major', 'upper', {}, 1.0, x, 1, y, 1, A ); // $ExpectError + sspr2( 'row-major', 'upper', ( x: number ): number => x, 1.0, x, 1, y, 1, A ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspr2( 'row-major', 'upper', 10, '10', x, 1, y, 1, A ); // $ExpectError + sspr2( 'row-major', 'upper', 10, true, x, 1, y, 1, A ); // $ExpectError + sspr2( 'row-major', 'upper', 10, false, x, 1, y, 1, A ); // $ExpectError + sspr2( 'row-major', 'upper', 10, null, x, 1, y, 1, A ); // $ExpectError + sspr2( 'row-major', 'upper', 10, void 0, x, 1, y, 1, A ); // $ExpectError + sspr2( 'row-major', 'upper', 10, [], x, 1, y, 1, A ); // $ExpectError + sspr2( 'row-major', 'upper', 10, {}, x, 1, y, 1, A ); // $ExpectError + sspr2( 'row-major', 'upper', 10, ( x: number ): number => x, x, 1, y, 1, A ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a Float32Array... +{ + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspr2( 'row-major', 'upper', 10, 1.0, 10, 1, y, 1, A ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, '10', 1, y, 1, A ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, true, 1, y, 1, A ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, false, 1, y, 1, A ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, null, 1, y, 1, A ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, void 0, 1, y, 1, A ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, [ '1' ], 1, y, 1, A ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, {}, 1, y, 1, A ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, ( x: number ): number => x, 1, y, 1, A ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspr2( 'row-major', 'upper', 10, 1.0, x, '10', y, 1, A ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, x, true, y, 1, A ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, x, false, y, 1, A ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, x, null, y, 1, A ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, x, void 0, y, 1, A ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, x, [], y, 1, A ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, x, {}, y, 1, A ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, x, ( x: number ): number => x, y, 1, A ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a Float32Array... +{ + const x = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspr2( 'row-major', 'upper', 10, 1.0, x, 1, 10, 1, A ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, x, 1, '10', 1, A ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, x, 1, true, 1, A ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, x, 1, false, 1, A ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, x, 1, null, 1, A ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, x, 1, void 0, 1, A ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, x, 1, [ '1' ], 1, A ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, x, 1, {}, 1, A ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, x, 1, ( x: number ): number => x, 1, A ); // $ExpectError +} + +// The compiler throws an error if the function is provided a eighth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspr2( 'row-major', 'upper', 10, 1.0, x, 1, y, '10', A ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, x, 1, y, true, A ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, x, 1, y, false, A ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, x, 1, y, null, A ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, x, 1, y, void 0, A ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, x, 1, y, [], A ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, x, 1, y, {}, A ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, x, 1, y, ( x: number ): number => x, A ); // $ExpectError +} + +// The compiler throws an error if the function is provided a ninth argument which is not a Float32Array... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + + sspr2( 'row-major', 'upper', 10, 1.0, x, 1, y, 1, 10 ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, x, 1, y, 1, '10' ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, x, 1, y, 1, true ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, x, 1, y, 1, false ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, x, 1, y, 1, null ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, x, 1, y, 1, void 0 ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, x, 1, y, 1, [ '1' ] ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, x, 1, y, 1, {} ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, x, 1, y, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspr2(); // $ExpectError + sspr2( 'row-major' ); // $ExpectError + sspr2( 'row-major', 'upper' ); // $ExpectError + sspr2( 'row-major', 'upper', 10 ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0 ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, x ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, x, 1 ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, x, 1, y ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, x, 1, y, 1 ); // $ExpectError + sspr2( 'row-major', 'upper', 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Float32Array... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectType Float32Array +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspr2.ndarray( 10, 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( true, 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( false, 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( null, 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( void 0, 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( [], 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( {}, 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( ( x: number ): number => x, 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a string... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspr2.ndarray( 'row-major', 10, 10, 1.0, x, 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', true, 10, 1.0, x, 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', false, 10, 1.0, x, 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', null, 10, 1.0, x, 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', void 0, 10, 1.0, x, 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', [ '1' ], 10, 1.0, x, 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', {}, 10, 1.0, x, 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', ( x: number ): number => x, 10, 1.0, x, 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspr2.ndarray( 'row-major', 'upper', '10', 1.0, x, 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', true, 1.0, x, 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', false, 1.0, x, 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', null, 1.0, x, 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', void 0, 1.0, x, 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', [], 1.0, x, 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', {}, 1.0, x, 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', ( x: number ): number => x, 1.0, x, 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspr2.ndarray( 'row-major', 'upper', 10, '10', x, 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, true, x, 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, false, x, 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, null, x, 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, void 0, x, 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, [], x, 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, {}, x, 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, ( x: number ): number => x, x, 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a Float32Array... +{ + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, 10, 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, '10', 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, true, 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, false, 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, null, 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, void 0, 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, [ '1' ], 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, {}, 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, ( x: number ): number => x, 1, 0, y, 1, 0, A, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, '10', 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, true, 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, false, 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, null, 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, void 0, 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, [], 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, {}, 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, ( x: number ): number => x, 0, y, 1, 0, A, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, '10', y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, true, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, false, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, null, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, void 0, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, [], y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, {}, y, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, ( x: number ): number => x, y, 1, 0, A, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a eighth argument which is not a Float32Array... +{ + const x = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, 10, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, '10', 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, true, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, false, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, null, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, void 0, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, [ '1' ], 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, {}, 1, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, ( x: number ): number => x, 1, 0, A, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a ninth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, '10', 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, true, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, false, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, null, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, void 0, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, [], 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, {}, 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, ( x: number ): number => x, 0, A, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a tenth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, 1, '10', A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, 1, true, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, 1, false, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, 1, null, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, 1, void 0, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, 1, [], A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, 1, {}, A, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, 1, ( x: number ): number => x, A, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eleventh argument which is not a Float32Array... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, 1, 0, 10, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, 1, 0, '10', 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, 1, 0, true, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, 1, 0, false, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, 1, 0, null, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, 1, 0, void 0, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, 1, 0, [ '1' ], 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, 1, 0, {}, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a twelfth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, '10', 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, true, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, false, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, null, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, void 0, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, [], 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, {}, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a thirteenth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, 1, '10' ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, 1, true ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, 1, false ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, 1, null ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, 1, void 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, 1, [] ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, 1, {} ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspr2.ndarray(); // $ExpectError + sspr2.ndarray( 'row-major' ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper' ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, 1 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, 1, 0, ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, 1 ); // $ExpectError + sspr2.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/base/sspr2/examples/index.js b/lib/node_modules/@stdlib/blas/base/sspr2/examples/index.js new file mode 100644 index 000000000000..69deb564b31c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspr2/examples/index.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var sspr2 = require( './../lib' ); + +var opts = { + 'dtype': 'float32' +}; + +var N = 5; + +var AP = discreteUniform( N * ( N + 1 ) / 2, -10.0, 10.0, opts ); +var x = discreteUniform( N, -10.0, 10.0, opts ); +var y = discreteUniform( N, -10.0, 10.0, opts ); + +sspr2( 'column-major', 'upper', N, 1.0, x, 1, y, 1, AP ); +console.log( AP ); + +sspr2.ndarray( 'column-major', 'upper', N, 1.0, x, 1, 0, y, 1, 0, AP, 1, 0 ); +console.log( AP ); diff --git a/lib/node_modules/@stdlib/blas/base/sspr2/lib/base.js b/lib/node_modules/@stdlib/blas/base/sspr2/lib/base.js new file mode 100644 index 000000000000..e814a969bff7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspr2/lib/base.js @@ -0,0 +1,121 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var f32 = require( '@stdlib/number/float64/base/to-float32' ); + + +// MAIN // + +/** +* Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` where `α` is a scalar, `x` and `y` are `N` element vector, and `A` is an `N` by `N` symmetric matrix supplied in packed form. +* +* @private +* @param {string} order - storage layout +* @param {string} uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is supplied +* @param {NonNegativeInteger} N - number of elements along each dimension of `A` +* @param {number} alpha - scalar +* @param {Float32Array} x - first input vector +* @param {integer} strideX - `x` stride length +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @param {Float32Array} y - second input vector +* @param {integer} strideY - `y` stride length +* @param {NonNegativeInteger} offsetY - starting index for `y` +* @param {Float32Array} AP - packed form of a symmetric matrix `A` +* @param {integer} strideAP - `AP` stride length +* @param {NonNegativeInteger} offsetAP - starting index for `AP` +* @returns {Float32Array} `AP` +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var AP = new Float32Array( [ 1.0, 2.0, 3.0, 1.0, 2.0, 1.0 ] ); // => [ [ 1.0, 2.0, 3.0 ], [ 0.0, 1.0, 2.0 ], [ 0.0, 0.0, 1.0 ] ] +* var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* var y = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* +* sspr2( 'row-major', 'upper', 3, 1.0, x, 1, 0, y, 1, 0, AP, 1, 0 ); +* // AP => [ 3.0, 6.0, 9.0, 9.0, 14.0, 19.0 ] +*/ +function sspr2( order, uplo, N, alpha, x, strideX, offsetX, y, strideY, offsetY, AP, strideAP, offsetAP ) { // eslint-disable-line max-len, max-params + var tmp1; + var tmp2; + var ix0; + var ix1; + var iy0; + var iy1; + var iap; + var i0; + var i1; + var kk; + + ix1 = offsetX; + iy1 = offsetY; + kk = offsetAP; + if ( + ( order === 'column-major' && uplo === 'upper' ) || + ( order === 'row-major' && uplo === 'lower' ) + ) { + for ( i1 = 0; i1 < N; i1++ ) { + if ( x[ ix1 ] !== 0.0 || y[ iy1 ] !== 0.0 ) { + tmp1 = f32( alpha * y[ iy1 ] ); + tmp2 = f32( alpha * x[ ix1 ] ); + ix0 = offsetX; + iy0 = offsetY; + iap = kk; + for ( i0 = 0; i0 <= i1; i0++ ) { + AP[ iap ] += f32( f32( x[ ix0 ] * tmp1 ) + f32( y[ iy0 ] * tmp2 ) ); // eslint-disable-line max-len + ix0 += strideX; + iy0 += strideY; + iap += strideAP; + } + } + ix1 += strideX; + iy1 += strideY; + kk += ( i1 + 1 ) * strideAP; + } + return AP; + } + // ( order === 'column-major' && uplo === 'lower' ) || ( order === 'row-major' && uplo === 'upper' ) + for ( i1 = 0; i1 < N; i1++ ) { + if ( x[ ix1 ] !== 0.0 || y[ iy1 ] !== 0.0 ) { + tmp1 = f32( alpha * y[ iy1 ] ); + tmp2 = f32( alpha * x[ ix1 ] ); + ix0 = ix1; + iy0 = iy1; + iap = kk; + for ( i0 = 0; i0 < N - i1; i0++ ) { + AP[ iap ] += f32( f32( x[ ix0 ] * tmp1 ) + f32( y[ iy0 ] * tmp2 ) ); // eslint-disable-line max-len + ix0 += strideX; + iy0 += strideY; + iap += strideAP; + } + } + ix1 += strideX; + iy1 += strideY; + kk += ( N - i1 ) * strideAP; + } + return AP; +} + + +// EXPORTS // + +module.exports = sspr2; diff --git a/lib/node_modules/@stdlib/blas/base/sspr2/lib/index.js b/lib/node_modules/@stdlib/blas/base/sspr2/lib/index.js new file mode 100644 index 000000000000..9b166ffdd4a1 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspr2/lib/index.js @@ -0,0 +1,72 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* BLAS level 2 routine to perform the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` where `α` is a scalar, `x` and `y` are `N` element vector, and `A` is an `N` by `N` symmetric matrix supplied in packed form. +* +* @module @stdlib/blas/base/sspr2 +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* var sspr2 = require( '@stdlib/blas/base/sspr2' ); +* +* var AP = new Float32Array( [ 1.0, 2.0, 3.0, 1.0, 2.0, 1.0 ] ); // => [ [ 1.0, 2.0, 3.0 ], [ 0.0, 1.0, 2.0 ], [ 0.0, 0.0, 1.0 ] ] +* var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* var y = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* +* sspr2( 'row-major', 'upper', 3, 1.0, x, 1, y, 1, AP ); +* // AP => [ 3.0, 6.0, 9.0, 9.0, 14.0, 19.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* var sspr2 = require( '@stdlib/blas/base/sspr2' ); +* +* var AP = new Float32Array( [ 1.0, 2.0, 3.0, 1.0, 2.0, 1.0 ] ); // => [ [ 1.0, 2.0, 3.0 ], [ 0.0, 1.0, 2.0 ], [ 0.0, 0.0, 1.0 ] ] +* var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* var y = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* +* sspr2.ndarray( 'row-major', 'upper', 3, 1.0, x, 1, 0, y, 1, 0, AP, 1, 0 ); +* // AP => [ 3.0, 6.0, 9.0, 9.0, 14.0, 19.0 ] +*/ + +// MODULES // + +var join = require( 'path' ).join; +var tryRequire = require( '@stdlib/utils/try-require' ); +var isError = require( '@stdlib/assert/is-error' ); +var main = require( './main.js' ); + + +// MAIN // + +var sspr2; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + sspr2 = main; +} else { + sspr2 = tmp; +} + + +// EXPORTS // + +module.exports = sspr2; + +// exports: { "ndarray": "sspr2.ndarray" } diff --git a/lib/node_modules/@stdlib/blas/base/sspr2/lib/main.js b/lib/node_modules/@stdlib/blas/base/sspr2/lib/main.js new file mode 100644 index 000000000000..c849acf5dc4b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspr2/lib/main.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var sspr2 = require( './sspr2.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( sspr2, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = sspr2; diff --git a/lib/node_modules/@stdlib/blas/base/sspr2/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/sspr2/lib/ndarray.js new file mode 100644 index 000000000000..a8a3748f453e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspr2/lib/ndarray.js @@ -0,0 +1,93 @@ +/** +* @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 isLayout = require( '@stdlib/blas/base/assert/is-layout' ); +var isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); +var format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` where `α` is a scalar, `x` and `y` are `N` element vector, and `A` is an `N` by `N` symmetric matrix supplied in packed form. +* +* @param {string} order - storage layout +* @param {string} uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is supplied +* @param {NonNegativeInteger} N - number of elements along each dimension of `A` +* @param {number} alpha - scalar +* @param {Float32Array} x - first input vector +* @param {integer} strideX - `x` stride length +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @param {Float32Array} y - second input vector +* @param {integer} strideY - `y` stride length +* @param {NonNegativeInteger} offsetY - starting index for `y` +* @param {Float32Array} AP - packed form of a symmetric matrix `A` +* @param {integer} strideAP - `AP` stride length +* @param {NonNegativeInteger} offsetAP - starting index for `AP` +* @throws {TypeError} first argument must be a valid order +* @throws {TypeError} second argument must specify whether the lower or upper triangular matrix is supplied +* @throws {RangeError} third argument must be a nonnegative integer +* @throws {RangeError} sixth argument must be non-zero +* @throws {RangeError} ninth argument must be non-zero +* @throws {RangeError} twelfth argument must be non-zero +* @returns {Float32Array} `AP` +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var AP = new Float32Array( [ 1.0, 2.0, 3.0, 1.0, 2.0, 1.0 ] ); // => [ [ 1.0, 2.0, 3.0 ], [ 0.0, 1.0, 2.0 ], [ 0.0, 0.0, 1.0 ] ] +* var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* var y = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* +* sspr2( 'row-major', 'upper', 3, 1.0, x, 1, 0, y, 1, 0, AP, 1, 0 ); +* // AP => [ 3.0, 6.0, 9.0, 9.0, 14.0, 19.0 ] +*/ +function sspr2( order, uplo, N, alpha, x, strideX, offsetX, y, strideY, offsetY, AP, strideAP, offsetAP ) { // eslint-disable-line max-len, max-params + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + if ( !isMatrixTriangle( uplo ) ) { + throw new TypeError( format( 'invalid argument. Second argument must specify whether the lower or upper triangular matrix is supplied. Value: `%s`.', uplo ) ); + } + 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. Ninth argument must be non-zero. Value: `%d`.', strideY ) ); + } + if ( strideAP === 0 ) { + throw new RangeError( format( 'invalid argument. Twelfth argument must be non-zero. Value: `%d`.', strideAP ) ); + } + if ( N === 0 || alpha === 0.0 ) { + return AP; + } + return base( order, uplo, N, alpha, x, strideX, offsetX, y, strideY, offsetY, AP, strideAP, offsetAP ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = sspr2; diff --git a/lib/node_modules/@stdlib/blas/base/sspr2/lib/sspr2.js b/lib/node_modules/@stdlib/blas/base/sspr2/lib/sspr2.js new file mode 100644 index 000000000000..e5f620b9faa6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspr2/lib/sspr2.js @@ -0,0 +1,91 @@ +/** +* @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 isLayout = require( '@stdlib/blas/base/assert/is-layout' ); +var isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); +var stride2offset = require( '@stdlib/strided/base/stride2offset' ); +var format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` where `α` is a scalar, `x` and `y` are `N` element vector, and `A` is an `N` by `N` symmetric matrix supplied in packed form. +* +* @param {string} order - storage layout +* @param {string} uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is supplied +* @param {NonNegativeInteger} N - number of elements along each dimension of `A` +* @param {number} alpha - scalar +* @param {Float32Array} x - first input vector +* @param {integer} strideX - `x` stride length +* @param {Float32Array} y - second input vector +* @param {integer} strideY - `y` stride length +* @param {Float32Array} AP - packed form of a symmetric matrix `A` +* @throws {TypeError} first argument must be a valid order +* @throws {TypeError} second argument must specify whether to reference the lower or upper triangular matrix +* @throws {RangeError} third argument must be a nonnegative integer +* @throws {RangeError} sixth argument must be non-zero +* @throws {RangeError} eighth argument must be non-zero +* @returns {Float32Array} `AP` +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var AP = new Float32Array( [ 1.0, 2.0, 3.0, 1.0, 2.0, 1.0 ] ); // => [ [ 1.0, 2.0, 3.0 ], [ 0.0, 1.0, 2.0 ], [ 0.0, 0.0, 1.0 ] ] +* var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* var y = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* +* sspr2( 'row-major', 'upper', 3, 1.0, x, 1, y, 1, AP ); +* // AP => [ 3.0, 6.0, 9.0, 9.0, 14.0, 19.0 ] +*/ +function sspr2( order, uplo, N, alpha, x, strideX, y, strideY, AP ) { + var ox; + var oy; + + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + if ( !isMatrixTriangle( uplo ) ) { + throw new TypeError( format( 'invalid argument. Second argument must specify whether the lower or upper triangular matrix is supplied. Value: `%s`.', uplo ) ); + } + if ( N < 0 ) { + throw new RangeError( format( 'invalid argument. Third argument must be a nonnegative integer. Value: `%d`.', N ) ); + } + if ( strideX === 0 ) { + throw new RangeError( format( 'invalid argument. Sixth argument must be non-zero. Value: `%d`.', strideX ) ); + } + if ( strideY === 0 ) { + throw new RangeError( format( 'invalid argument. Eighth argument must be non-zero. Value: `%d`.', strideY ) ); + } + if ( N === 0 || alpha === 0.0 ) { + return AP; + } + ox = stride2offset( N, strideX ); + oy = stride2offset( N, strideY ); + return base( order, uplo, N, alpha, x, strideX, ox, y, strideY, oy, AP, 1, 0 ); +} + + +// EXPORTS // + +module.exports = sspr2; diff --git a/lib/node_modules/@stdlib/blas/base/sspr2/package.json b/lib/node_modules/@stdlib/blas/base/sspr2/package.json new file mode 100644 index 000000000000..48484125cc55 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspr2/package.json @@ -0,0 +1,68 @@ +{ + "name": "@stdlib/blas/base/sspr2", + "version": "0.0.0", + "description": "Perform the symmetric rank 2 operation `A := α*x*y**T + α*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", + "sspr2", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "float32", + "float", + "float32array" + ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/column_major_complex_access_pattern.json b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/column_major_complex_access_pattern.json new file mode 100644 index 000000000000..9cbf8644e870 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/column_major_complex_access_pattern.json @@ -0,0 +1,16 @@ +{ + "order": "column-major", + "uplo": "lower", + "N": 3, + "alpha": 1.0, + "x": [ 0.0, 3.0, 0.0, 2.0, 0.0, 1.0 ], + "strideX": -2, + "offsetX": 5, + "y": [ 0.0, 3.0, 0.0, 2.0, 0.0, 1.0 ], + "strideY": -2, + "offsetY": 5, + "AP": [ 0.0, 3.0, 0.0, 2.0, 0.0, 2.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0 ], + "strideAP": -2, + "offsetAP": 11, + "AP_out": [ 0.0, 21.0, 0.0, 14.0, 0.0, 10.0, 0.0, 7.0, 0.0, 5.0, 0.0, 3.0, 0.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/column_major_l.json b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/column_major_l.json new file mode 100644 index 000000000000..4ac728d1a575 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/column_major_l.json @@ -0,0 +1,16 @@ +{ + "order": "column-major", + "uplo": "lower", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "offsetX": 0, + "y": [ 1.0, 2.0, 3.0 ], + "strideY": 1, + "offsetY": 0, + "AP": [ 1.0, 1.0, 1.0, 2.0, 2.0, 3.0 ], + "strideAP": 1, + "offsetAP": 0, + "AP_out": [ 3.0, 5.0, 7.0, 10.0, 14.0, 21.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/column_major_oap.json b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/column_major_oap.json new file mode 100644 index 000000000000..6655aed16636 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/column_major_oap.json @@ -0,0 +1,16 @@ +{ + "order": "column-major", + "uplo": "lower", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "offsetX": 0, + "y": [ 1.0, 2.0, 3.0 ], + "strideY": 1, + "offsetY": 0, + "AP": [ 0.0, 0.0, 1.0, 1.0, 1.0, 2.0, 2.0, 3.0 ], + "strideAP": 1, + "offsetAP": 2, + "AP_out": [ 0.0, 0.0, 3.0, 5.0, 7.0, 10.0, 14.0, 21.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/column_major_ox.json b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/column_major_ox.json new file mode 100644 index 000000000000..a3d2389b2c40 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/column_major_ox.json @@ -0,0 +1,16 @@ +{ + "order": "column-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 0.0, 3.0, 2.0, 1.0 ], + "strideX": -1, + "offsetX": 3, + "y": [ 1.0, 2.0, 3.0 ], + "strideY": 1, + "offsetY": 0, + "AP": [ 1.0, 2.0, 1.0, 3.0, 2.0, 1.0 ], + "strideAP": 1, + "offsetAP": 0, + "AP_out": [ 3.0, 6.0, 9.0, 9.0, 14.0, 19.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/column_major_oy.json b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/column_major_oy.json new file mode 100644 index 000000000000..4fab36ef0ba6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/column_major_oy.json @@ -0,0 +1,16 @@ +{ + "order": "column-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "offsetX": 0, + "y": [ 0.0, 3.0, 2.0, 1.0 ], + "strideY": -1, + "offsetY": 3, + "AP": [ 1.0, 2.0, 1.0, 3.0, 2.0, 1.0 ], + "strideAP": 1, + "offsetAP": 0, + "AP_out": [ 3.0, 6.0, 9.0, 9.0, 14.0, 19.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/column_major_sap.json b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/column_major_sap.json new file mode 100644 index 000000000000..43778c13e5a6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/column_major_sap.json @@ -0,0 +1,16 @@ +{ + "order": "column-major", + "uplo": "lower", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "offsetX": 0, + "y": [ 1.0, 2.0, 3.0 ], + "strideY": 1, + "offsetY": 0, + "AP": [ 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 2.0, 0.0, 2.0, 0.0, 3.0 ], + "strideAP": 2, + "offsetAP": 1, + "AP_out": [ 0.0, 3.0, 0.0, 5.0, 0.0, 7.0, 0.0, 10.0, 0.0, 14.0, 0.0, 21.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/column_major_sapn.json b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/column_major_sapn.json new file mode 100644 index 000000000000..48dee540bd29 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/column_major_sapn.json @@ -0,0 +1,16 @@ +{ + "order": "column-major", + "uplo": "lower", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "offsetX": 0, + "y": [ 1.0, 2.0, 3.0 ], + "strideY": 1, + "offsetY": 0, + "AP": [ 0.0, 3.0, 0.0, 2.0, 0.0, 2.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0 ], + "strideAP": -2, + "offsetAP": 11, + "AP_out": [ 0.0, 21.0, 0.0, 14.0, 0.0, 10.0, 0.0, 7.0, 0.0, 5.0, 0.0, 3.0, 0.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/column_major_u.json b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/column_major_u.json new file mode 100644 index 000000000000..afbd8bb5f7a9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/column_major_u.json @@ -0,0 +1,16 @@ +{ + "order": "column-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "offsetX": 0, + "y": [ 1.0, 2.0, 3.0 ], + "strideY": 1, + "offsetY": 0, + "AP": [ 1.0, 2.0, 1.0, 3.0, 2.0, 1.0 ], + "strideAP": 1, + "offsetAP": 0, + "AP_out": [ 3.0, 6.0, 9.0, 9.0, 14.0, 19.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/column_major_xnyn.json b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/column_major_xnyn.json new file mode 100644 index 000000000000..283908e936dd --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/column_major_xnyn.json @@ -0,0 +1,16 @@ +{ + "order": "column-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 3.0, 2.0, 1.0 ], + "strideX": -1, + "offsetX": 2, + "y": [ 3.0, 2.0, 1.0 ], + "strideY": -1, + "offsetY": 2, + "AP": [ 1.0, 2.0, 1.0, 3.0, 2.0, 1.0 ], + "strideAP": 1, + "offsetAP": 0, + "AP_out": [ 3.0, 6.0, 9.0, 9.0, 14.0, 19.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/column_major_xnyp.json b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/column_major_xnyp.json new file mode 100644 index 000000000000..3db442d3dec9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/column_major_xnyp.json @@ -0,0 +1,16 @@ +{ + "order": "column-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 3.0, 2.0, 1.0 ], + "strideX": -1, + "offsetX": 2, + "y": [ 1.0, 2.0, 3.0 ], + "strideY": 1, + "offsetY": 0, + "AP": [ 1.0, 2.0, 1.0, 3.0, 2.0, 1.0 ], + "strideAP": 1, + "offsetAP": 0, + "AP_out": [ 3.0, 6.0, 9.0, 9.0, 14.0, 19.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/column_major_xpyn.json b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/column_major_xpyn.json new file mode 100644 index 000000000000..a512fd3e4a2c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/column_major_xpyn.json @@ -0,0 +1,16 @@ +{ + "order": "column-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "offsetX": 0, + "y": [ 3.0, 2.0, 1.0 ], + "strideY": -1, + "offsetY": 2, + "AP": [ 1.0, 2.0, 1.0, 3.0, 2.0, 1.0 ], + "strideAP": 1, + "offsetAP": 0, + "AP_out": [ 3.0, 6.0, 9.0, 9.0, 14.0, 19.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/column_major_xpyp.json b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/column_major_xpyp.json new file mode 100644 index 000000000000..c0ae512a6cc0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/column_major_xpyp.json @@ -0,0 +1,16 @@ +{ + "order": "column-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 0.0, 2.0, 0.0, 3.0 ], + "strideX": 2, + "offsetX": 0, + "y": [ 1.0, 0.0, 2.0, 0.0, 3.0 ], + "strideY": 2, + "offsetY": 0, + "AP": [ 1.0, 2.0, 1.0, 3.0, 2.0, 1.0 ], + "strideAP": 1, + "offsetAP": 0, + "AP_out": [ 3.0, 6.0, 9.0, 9.0, 14.0, 19.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/row_major_complex_access_pattern.json b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/row_major_complex_access_pattern.json new file mode 100644 index 000000000000..ad9d6428524e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/row_major_complex_access_pattern.json @@ -0,0 +1,16 @@ +{ + "order": "row-major", + "uplo": "lower", + "N": 3, + "alpha": 1.0, + "x": [ 0.0, 3.0, 0.0, 2.0, 0.0, 1.0 ], + "strideX": -2, + "offsetX": 5, + "y": [ 0.0, 3.0, 0.0, 2.0, 0.0, 1.0 ], + "strideY": -2, + "offsetY": 5, + "AP": [ 3.0, 0.0, 2.0, 0.0, 1.0, 0.0, 2.0, 0.0, 1.0, 0.0, 1.0 ], + "strideAP": -2, + "offsetAP": 10, + "AP_out": [ 21.0, 0.0, 14.0, 0.0, 7.0, 0.0, 10.0, 0.0, 5.0, 0.0, 3.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/row_major_l.json b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/row_major_l.json new file mode 100644 index 000000000000..a0cc23d0069d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/row_major_l.json @@ -0,0 +1,16 @@ +{ + "order": "row-major", + "uplo": "lower", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "offsetX": 0, + "y": [ 1.0, 2.0, 3.0 ], + "strideY": 1, + "offsetY": 0, + "AP": [ 1.0, 1.0, 2.0, 1.0, 2.0, 3.0 ], + "strideAP": 1, + "offsetAP": 0, + "AP_out": [ 3.0, 5.0, 10.0, 7.0, 14.0, 21.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/row_major_oap.json b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/row_major_oap.json new file mode 100644 index 000000000000..015bbf5375e1 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/row_major_oap.json @@ -0,0 +1,16 @@ +{ + "order": "row-major", + "uplo": "lower", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "offsetX": 0, + "y": [ 1.0, 2.0, 3.0 ], + "strideY": 1, + "offsetY": 0, + "AP": [ 0.0, 0.0, 1.0, 1.0, 2.0, 1.0, 2.0, 3.0 ], + "strideAP": 1, + "offsetAP": 2, + "AP_out": [ 0.0, 0.0, 3.0, 5.0, 10.0, 7.0, 14.0, 21.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/row_major_ox.json b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/row_major_ox.json new file mode 100644 index 000000000000..a31f9623898a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/row_major_ox.json @@ -0,0 +1,16 @@ +{ + "order": "row-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 0.0, 3.0, 0.0, 2.0, 0.0, 1.0 ], + "strideX": -2, + "offsetX": 5, + "y": [ 1.0, 0.0, 2.0, 0.0, 3.0 ], + "strideY": 2, + "offsetY": 0, + "AP": [ 1.0, 2.0, 3.0, 1.0, 2.0, 1.0 ], + "strideAP": 1, + "offsetAP": 0, + "AP_out": [ 3.0, 6.0, 9.0, 9.0, 14.0, 19.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/row_major_oy.json b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/row_major_oy.json new file mode 100644 index 000000000000..9f022dab7b67 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/row_major_oy.json @@ -0,0 +1,16 @@ +{ + "order": "row-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 0.0, 2.0, 0.0, 3.0 ], + "strideX": 2, + "offsetX": 0, + "y": [ 0.0, 3.0, 0.0, 2.0, 0.0, 1.0 ], + "strideY": -2, + "offsetY": 5, + "AP": [ 1.0, 2.0, 3.0, 1.0, 2.0, 1.0 ], + "strideAP": 1, + "offsetAP": 0, + "AP_out": [ 3.0, 6.0, 9.0, 9.0, 14.0, 19.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/row_major_sap.json b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/row_major_sap.json new file mode 100644 index 000000000000..3195a4a4b060 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/row_major_sap.json @@ -0,0 +1,16 @@ +{ + "order": "row-major", + "uplo": "lower", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "offsetX": 0, + "y": [ 1.0, 2.0, 3.0 ], + "strideY": 1, + "offsetY": 0, + "AP": [ 0.0, 1.0, 0.0, 1.0, 0.0, 2.0, 0.0, 1.0, 0.0, 2.0, 0.0, 3.0 ], + "strideAP": 2, + "offsetAP": 1, + "AP_out": [ 0.0, 3.0, 0.0, 5.0, 0.0, 10.0, 0.0, 7.0, 0.0, 14.0, 0.0, 21.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/row_major_sapn.json b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/row_major_sapn.json new file mode 100644 index 000000000000..1c9a1bd023ae --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/row_major_sapn.json @@ -0,0 +1,16 @@ +{ + "order": "row-major", + "uplo": "lower", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "offsetX": 0, + "y": [ 1.0, 2.0, 3.0 ], + "strideY": 1, + "offsetY": 0, + "AP": [ 3.0, 0.0, 2.0, 0.0, 1.0, 0.0, 2.0, 0.0, 1.0, 0.0, 1.0 ], + "strideAP": -2, + "offsetAP": 10, + "AP_out": [ 21.0, 0.0, 14.0, 0.0, 7.0, 0.0, 10.0, 0.0, 5.0, 0.0, 3.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/row_major_u.json b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/row_major_u.json new file mode 100644 index 000000000000..a4ac4923f997 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/row_major_u.json @@ -0,0 +1,16 @@ +{ + "order": "row-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "offsetX": 0, + "y": [ 1.0, 2.0, 3.0 ], + "strideY": 1, + "offsetY": 0, + "AP": [ 1.0, 2.0, 3.0, 1.0, 2.0, 1.0 ], + "strideAP": 1, + "offsetAP": 0, + "AP_out": [ 3.0, 6.0, 9.0, 9.0, 14.0, 19.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/row_major_xnyn.json b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/row_major_xnyn.json new file mode 100644 index 000000000000..b082ea5870f5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/row_major_xnyn.json @@ -0,0 +1,16 @@ +{ + "order": "row-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 3.0, 0.0, 2.0, 0.0, 1.0 ], + "strideX": -2, + "offsetX": 4, + "y": [ 3.0, 0.0, 2.0, 0.0, 1.0 ], + "strideY": -2, + "offsetY": 4, + "AP": [ 1.0, 2.0, 3.0, 1.0, 2.0, 1.0 ], + "strideAP": 1, + "offsetAP": 0, + "AP_out": [ 3.0, 6.0, 9.0, 9.0, 14.0, 19.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/row_major_xnyp.json b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/row_major_xnyp.json new file mode 100644 index 000000000000..1e6766da88e1 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/row_major_xnyp.json @@ -0,0 +1,16 @@ +{ + "order": "row-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 3.0, 0.0, 2.0, 0.0, 1.0 ], + "strideX": -2, + "offsetX": 4, + "y": [ 1.0, 0.0, 2.0, 0.0, 3.0 ], + "strideY": 2, + "offsetY": 0, + "AP": [ 1.0, 2.0, 3.0, 1.0, 2.0, 1.0 ], + "strideAP": 1, + "offsetAP": 0, + "AP_out": [ 3.0, 6.0, 9.0, 9.0, 14.0, 19.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/row_major_xpyn.json b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/row_major_xpyn.json new file mode 100644 index 000000000000..4a104bf73d1b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/row_major_xpyn.json @@ -0,0 +1,16 @@ +{ + "order": "row-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 0.0, 2.0, 0.0, 3.0 ], + "strideX": 2, + "offsetX": 0, + "y": [ 3.0, 0.0, 2.0, 0.0, 1.0 ], + "strideY": -2, + "offsetY": 4, + "AP": [ 1.0, 2.0, 3.0, 1.0, 2.0, 1.0 ], + "strideAP": 1, + "offsetAP": 0, + "AP_out": [ 3.0, 6.0, 9.0, 9.0, 14.0, 19.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/row_major_xpyp.json b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/row_major_xpyp.json new file mode 100644 index 000000000000..546953f043dc --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspr2/test/fixtures/row_major_xpyp.json @@ -0,0 +1,16 @@ +{ + "order": "row-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 0.0, 2.0, 0.0, 3.0 ], + "strideX": 2, + "offsetX": 0, + "y": [ 1.0, 0.0, 2.0, 0.0, 3.0 ], + "strideY": 2, + "offsetY": 0, + "AP": [ 1.0, 2.0, 3.0, 1.0, 2.0, 1.0 ], + "strideAP": 1, + "offsetAP": 0, + "AP_out": [ 3.0, 6.0, 9.0, 9.0, 14.0, 19.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sspr2/test/test.js b/lib/node_modules/@stdlib/blas/base/sspr2/test/test.js new file mode 100644 index 000000000000..8d1ebee51c49 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspr2/test/test.js @@ -0,0 +1,82 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var proxyquire = require( 'proxyquire' ); +var IS_BROWSER = require( '@stdlib/assert/is-browser' ); +var sspr2 = require( './../lib' ); + + +// VARIABLES // + +var opts = { + 'skip': IS_BROWSER +}; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof sspr2, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the main export is a method providing an ndarray interface', function test( t ) { + t.strictEqual( typeof sspr2.ndarray, 'function', 'method is a function' ); + t.end(); +}); + +tape( 'if a native implementation is available, the main export is the native implementation', opts, function test( t ) { + var sspr2 = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( sspr2, mock, 'returns expected value' ); + t.end(); + + function tryRequire() { + return mock; + } + + function mock() { + // Mock... + } +}); + +tape( 'if a native implementation is not available, the main export is a JavaScript implementation', opts, function test( t ) { + var sspr2; + var main; + + main = require( './../lib/sspr2.js' ); + + sspr2 = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( sspr2, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/blas/base/sspr2/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/sspr2/test/test.ndarray.js new file mode 100644 index 000000000000..9a571878b3f7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspr2/test/test.ndarray.js @@ -0,0 +1,841 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float32Array = require( '@stdlib/array/float32' ); +var sspr2 = require( './../lib/ndarray.js' ); + + +// FIXTURES // + +var rl = require( './fixtures/row_major_l.json' ); +var ru = require( './fixtures/row_major_u.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 rsap = require( './fixtures/row_major_sap.json' ); +var rsapn = require( './fixtures/row_major_sapn.json' ); +var rox = require( './fixtures/row_major_ox.json' ); +var roy = require( './fixtures/row_major_oy.json' ); +var roap = require( './fixtures/row_major_oap.json' ); +var rcap = require( './fixtures/row_major_complex_access_pattern.json' ); + +var cl = require( './fixtures/column_major_l.json' ); +var cu = require( './fixtures/column_major_u.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 csap = require( './fixtures/column_major_sap.json' ); +var csapn = require( './fixtures/column_major_sapn.json' ); +var cox = require( './fixtures/column_major_ox.json' ); +var coy = require( './fixtures/column_major_oy.json' ); +var coap = require( './fixtures/column_major_oap.json' ); +var ccap = require( './fixtures/column_major_complex_access_pattern.json' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof sspr2, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 13', function test( t ) { + t.strictEqual( sspr2.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 = rl; + + 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() { + sspr2( value, data.uplo, data.N, data.alpha, new Float32Array( data.x ), data.strideX, data.offsetX, new Float32Array( data.y ), data.strideY, data.offsetY, data.AP, data.strideAP, data.offsetAP ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid second argument', function test( t ) { + var values; + var data; + var i; + + data = rl; + + 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() { + sspr2( data.order, value, data.N, data.alpha, new Float32Array( data.x ), data.strideX, data.offsetX, new Float32Array( data.y ), data.strideY, data.offsetY, data.AP, data.strideAP, data.offsetAP ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid third argument', function test( t ) { + var values; + var data; + var i; + + data = rl; + + 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() { + sspr2( data.order, data.uplo, value, data.alpha, new Float32Array( data.x ), data.strideX, data.offsetX, new Float32Array( data.y ), data.strideY, data.offsetY, data.AP, data.strideAP, data.offsetAP ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid sixth argument', function test( t ) { + var values; + var data; + var i; + + data = rl; + + 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() { + sspr2( data.order, data.uplo, data.N, data.alpha, new Float32Array( data.x ), value, data.offsetX, new Float32Array( data.y ), data.strideY, data.offsetY, data.AP, data.strideAP, data.offsetAP ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid ninth argument', function test( t ) { + var values; + var data; + var i; + + data = rl; + + 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() { + sspr2( data.order, data.uplo, data.N, data.alpha, new Float32Array( data.x ), data.strideX, data.offsetX, new Float32Array( data.y ), value, data.offsetY, data.AP, data.strideAP, data.offsetAP ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid twelfth argument', function test( t ) { + var values; + var data; + var i; + + data = rl; + + 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() { + sspr2( data.order, data.uplo, data.N, data.alpha, new Float32Array( data.x ), data.strideX, data.offsetX, new Float32Array( data.y ), data.strideY, data.offsetY, data.AP, value, data.offsetAP ); + }; + } +}); + +tape( 'the function performs the symmetric rank 2 operation `A := α*x*y**T + α*y*x**T + A` (row-major, lower)', function test( t ) { + var expected; + var data; + var out; + var ap; + var x; + var y; + + data = rl; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.AP_out ); + + out = sspr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, ap, data.strideAP, data.offsetAP ); + t.strictEqual( out, ap, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function performs the symmetric rank 2 operation `A := α*x*y**T + α*y*x**T + A` (column-major, lower)', function test( t ) { + var expected; + var data; + var out; + var ap; + var x; + var y; + + data = cl; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.AP_out ); + + out = sspr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, ap, data.strideAP, data.offsetAP ); + t.strictEqual( out, ap, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function performs the symmetric rank 2 operation `A := α*x*y**T + α*y*x**T + A` (row-major, upper)', function test( t ) { + var expected; + var data; + var out; + var ap; + var x; + var y; + + data = ru; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.AP_out ); + + out = sspr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, ap, data.strideAP, data.offsetAP ); + t.strictEqual( out, ap, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function performs the symmetric rank 2 operation `A := α*x*y**T + α*y*x**T + A` (column-major, upper)', function test( t ) { + var expected; + var data; + var out; + var ap; + var x; + var y; + + data = cu; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.AP_out ); + + out = sspr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, ap, data.strideAP, data.offsetAP ); + t.strictEqual( out, ap, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a reference to the packed form of a symmetric matrix `A`', function test( t ) { + var data; + var out; + var ap; + var x; + var y; + + data = rl; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + out = sspr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, ap, data.strideAP, data.offsetAP ); + t.strictEqual( out, ap, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `N` is zero or `α` is zero, respectively, the function returns `AP` unchanged (row-major)', function test( t ) { + var expected; + var data; + var out; + var ap; + var x; + var y; + + data = ru; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.AP ); + + out = sspr2( data.order, data.uplo, 0, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, ap, data.strideAP, data.offsetAP ); + t.strictEqual( out, ap, 'returns expected value' ); + t.deepEqual( ap, expected, 'returns expected value' ); + + out = sspr2( data.order, data.uplo, data.N, 0.0, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, ap, data.strideAP, data.offsetAP ); + t.strictEqual( out, ap, 'returns expected value' ); + t.deepEqual( ap, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `N` is zero or `α` is zero, respectively, the function returns `AP` unchanged (column-major)', function test( t ) { + var expected; + var data; + var out; + var ap; + var x; + var y; + + data = cu; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.AP ); + + out = sspr2( data.order, data.uplo, 0, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, ap, data.strideAP, data.offsetAP ); + t.strictEqual( out, ap, 'returns expected value' ); + t.deepEqual( ap, expected, 'returns expected value' ); + + out = sspr2( data.order, data.uplo, data.N, 0.0, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, ap, data.strideAP, data.offsetAP ); + t.strictEqual( out, ap, 'returns expected value' ); + t.deepEqual( ap, 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 ap; + var x; + var y; + + data = rxpyp; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.AP_out ); + + out = sspr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, ap, data.strideAP, data.offsetAP ); + t.strictEqual( out, ap, '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 ap; + var x; + var y; + + data = cxpyp; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.AP_out ); + + out = sspr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, ap, data.strideAP, data.offsetAP ); + t.strictEqual( out, ap, '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 ap; + var x; + var y; + + data = rxnyp; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.AP_out ); + + out = sspr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, ap, data.strideAP, data.offsetAP ); + t.strictEqual( out, ap, '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 ap; + var x; + var y; + + data = cxnyp; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.AP_out ); + + out = sspr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, ap, data.strideAP, data.offsetAP ); + t.strictEqual( out, ap, '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 ap; + var x; + var y; + + data = rxpyn; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.AP_out ); + + out = sspr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, ap, data.strideAP, data.offsetAP ); + t.strictEqual( out, ap, '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 ap; + var x; + var y; + + data = cxpyn; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.AP_out ); + + out = sspr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, ap, data.strideAP, data.offsetAP ); + t.strictEqual( out, ap, '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 ap; + var x; + var y; + + data = rxnyn; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.AP_out ); + + out = sspr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, ap, data.strideAP, data.offsetAP ); + t.strictEqual( out, ap, '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 ap; + var x; + var y; + + data = cxnyn; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.AP_out ); + + out = sspr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, ap, data.strideAP, data.offsetAP ); + t.strictEqual( out, ap, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying an `x` offset (row-major)', function test( t ) { + var expected; + var data; + var out; + var ap; + var x; + var y; + + data = rox; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.AP_out ); + + out = sspr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, ap, data.strideAP, data.offsetAP ); + t.strictEqual( out, ap, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying an `x` offset (column-major)', function test( t ) { + var expected; + var data; + var out; + var ap; + var x; + var y; + + data = cox; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.AP_out ); + + out = sspr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, ap, data.strideAP, data.offsetAP ); + t.strictEqual( out, ap, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying an `y` offset (row-major)', function test( t ) { + var expected; + var data; + var out; + var ap; + var x; + var y; + + data = roy; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.AP_out ); + + out = sspr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, ap, data.strideAP, data.offsetAP ); + t.strictEqual( out, ap, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying an `y` offset (column-major)', function test( t ) { + var expected; + var data; + var out; + var ap; + var x; + var y; + + data = coy; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.AP_out ); + + out = sspr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, ap, data.strideAP, data.offsetAP ); + t.strictEqual( out, ap, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying stride for `AP` (row-major)', function test( t ) { + var expected; + var data; + var out; + var ap; + var x; + var y; + + data = rsap; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.AP_out ); + + out = sspr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, ap, data.strideAP, data.offsetAP ); + t.strictEqual( out, ap, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying stride for `AP` (column-major)', function test( t ) { + var expected; + var data; + var out; + var ap; + var x; + var y; + + data = csap; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.AP_out ); + + out = sspr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, ap, data.strideAP, data.offsetAP ); + t.strictEqual( out, ap, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `AP` (row-major)', function test( t ) { + var expected; + var data; + var out; + var ap; + var x; + var y; + + data = rsapn; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.AP_out ); + + out = sspr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, ap, data.strideAP, data.offsetAP ); + t.strictEqual( out, ap, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `AP` (column-major)', function test( t ) { + var expected; + var data; + var out; + var ap; + var x; + var y; + + data = csapn; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.AP_out ); + + out = sspr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, ap, data.strideAP, data.offsetAP ); + t.strictEqual( out, ap, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying an offset for `AP` (row-major)', function test( t ) { + var expected; + var data; + var out; + var ap; + var x; + var y; + + data = roap; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.AP_out ); + + out = sspr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, ap, data.strideAP, data.offsetAP ); + t.strictEqual( out, ap, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying an offset for `AP` (column-major)', function test( t ) { + var expected; + var data; + var out; + var ap; + var x; + var y; + + data = coap; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.AP_out ); + + out = sspr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, ap, data.strideAP, data.offsetAP ); + t.strictEqual( out, ap, '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 ap; + var x; + var y; + + data = rcap; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.AP_out ); + + out = sspr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, ap, data.strideAP, data.offsetAP ); + t.strictEqual( out, ap, '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 ap; + var x; + var y; + + data = ccap; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.AP_out ); + + out = sspr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, ap, data.strideAP, data.offsetAP ); + t.strictEqual( out, ap, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/sspr2/test/test.sspr2.js b/lib/node_modules/@stdlib/blas/base/sspr2/test/test.sspr2.js new file mode 100644 index 000000000000..a5259868f466 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspr2/test/test.sspr2.js @@ -0,0 +1,530 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float32Array = require( '@stdlib/array/float32' ); +var sspr2 = require( './../lib/sspr2.js' ); + + +// FIXTURES // + +var rl = require( './fixtures/row_major_l.json' ); +var ru = require( './fixtures/row_major_u.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 cl = require( './fixtures/column_major_l.json' ); +var cu = require( './fixtures/column_major_u.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' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof sspr2, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 9', function test( t ) { + t.strictEqual( sspr2.length, 9, '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 = rl; + + 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() { + sspr2( value, data.uplo, data.N, data.alpha, new Float32Array( data.x ), data.strideX, new Float32Array( data.y ), data.strideY, data.AP ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid second argument', function test( t ) { + var values; + var data; + var i; + + data = rl; + + 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() { + sspr2( data.order, value, data.N, data.alpha, new Float32Array( data.x ), data.strideX, new Float32Array( data.y ), data.strideY, data.AP ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid third argument', function test( t ) { + var values; + var data; + var i; + + data = rl; + + 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() { + sspr2( data.order, data.uplo, value, data.alpha, new Float32Array( data.x ), data.strideX, new Float32Array( data.y ), data.strideY, data.AP ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid sixth argument', function test( t ) { + var values; + var data; + var i; + + data = rl; + + 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() { + sspr2( data.order, data.uplo, data.N, data.alpha, new Float32Array( data.x ), value, new Float32Array( data.y ), data.strideY, data.AP ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid eighth argument', function test( t ) { + var values; + var data; + var i; + + data = rl; + + 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() { + sspr2( data.order, data.uplo, data.N, data.alpha, new Float32Array( data.x ), data.strideX, new Float32Array( data.y ), value, data.AP ); + }; + } +}); + +tape( 'the function performs the symmetric rank 2 operation `A := α*x*y**T + α*y*x**T + A` (row-major, lower)', function test( t ) { + var expected; + var data; + var out; + var ap; + var x; + var y; + + data = rl; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.AP_out ); + + out = sspr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, ap ); + t.strictEqual( out, ap, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function performs the symmetric rank 2 operation `A := α*x*y**T + α*y*x**T + A` (column-major, lower)', function test( t ) { + var expected; + var data; + var out; + var ap; + var x; + var y; + + data = cl; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.AP_out ); + + out = sspr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, ap ); + t.strictEqual( out, ap, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function performs the symmetric rank 2 operation `A := α*x*y**T + α*y*x**T + A` (row-major, upper)', function test( t ) { + var expected; + var data; + var out; + var ap; + var x; + var y; + + data = ru; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.AP_out ); + + out = sspr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, ap ); + t.strictEqual( out, ap, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function performs the symmetric rank 2 operation `A := α*x*y**T + α*y*x**T + A` (column-major, upper)', function test( t ) { + var expected; + var data; + var out; + var ap; + var x; + var y; + + data = cu; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.AP_out ); + + out = sspr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, ap ); + t.strictEqual( out, ap, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a reference to the packed form of a symmetric matrix `A`', function test( t ) { + var data; + var out; + var ap; + var x; + var y; + + data = rl; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + out = sspr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, ap ); + t.strictEqual( out, ap, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `N` is zero or `α` is zero, respectively, the function returns `AP` unchanged (row-major)', function test( t ) { + var expected; + var data; + var out; + var ap; + var x; + var y; + + data = ru; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.AP ); + + out = sspr2( data.order, data.uplo, 0, data.alpha, x, data.strideX, y, data.strideY, ap ); + t.strictEqual( out, ap, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + out = sspr2( data.order, data.uplo, data.N, 0.0, x, data.strideX, y, data.strideY, ap ); + t.strictEqual( out, ap, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `N` is zero or `α` is zero, respectively, the function returns `AP` unchanged (column-major)', function test( t ) { + var expected; + var data; + var out; + var ap; + var x; + var y; + + data = cu; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.AP ); + + out = sspr2( data.order, data.uplo, 0, data.alpha, x, data.strideX, y, data.strideY, ap ); + t.strictEqual( out, ap, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + out = sspr2( data.order, data.uplo, data.N, 0.0, x, data.strideX, y, data.strideY, ap ); + t.strictEqual( out, ap, '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 ap; + var x; + var y; + + data = rxpyp; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.AP_out ); + + out = sspr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, ap ); + t.strictEqual( out, ap, '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 ap; + var x; + var y; + + data = cxpyp; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.AP_out ); + + out = sspr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, ap ); + t.strictEqual( out, ap, '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 ap; + var x; + var y; + + data = rxnyp; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.AP_out ); + + out = sspr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, ap ); + t.strictEqual( out, ap, '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 ap; + var x; + var y; + + data = cxnyp; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.AP_out ); + + out = sspr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, ap ); + t.strictEqual( out, ap, '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 ap; + var x; + var y; + + data = rxpyn; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.AP_out ); + + out = sspr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, ap ); + t.strictEqual( out, ap, '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 ap; + var x; + var y; + + data = cxpyn; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.AP_out ); + + out = sspr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, ap ); + t.strictEqual( out, ap, '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 ap; + var x; + var y; + + data = rxnyn; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.AP_out ); + + out = sspr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, ap ); + t.strictEqual( out, ap, '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 ap; + var x; + var y; + + data = cxnyn; + + ap = new Float32Array( data.AP ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.AP_out ); + + out = sspr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, ap ); + t.strictEqual( out, ap, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +});