diff --git a/lib/node_modules/@stdlib/blas/base/csscal/README.md b/lib/node_modules/@stdlib/blas/base/csscal/README.md new file mode 100644 index 000000000000..9e14ecd19994 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csscal/README.md @@ -0,0 +1,174 @@ + + +# csscal + +> Scale a single-precision complex floating-point vector by a single-precision floating-point constant. + +
+ +## Usage + +```javascript +var csscal = require( '@stdlib/blas/base/csscal' ); +``` + +#### csscal( N, alpha, x, strideX ) + +Scales a single-precision complex floating-point vector by a single-precision floating-point constant. + +```javascript +var Complex64Array = require( '@stdlib/array/complex64' ); + +var x = new Complex64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); + +csscal( 3, 2.0, x, 1 ); +// x => [ 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 ] +``` + +The function has the following parameters: + +- **N**: number of indexed elements. +- **alpha**: scalar constant. +- **x**: input [`Complex64Array`][@stdlib/array/complex64]. +- **strideX**: stride length for `x`. + +The `N` and stride parameters determine which elements in `x` are scaled by `alpha`. For example, to scale every other element in `x` by `alpha`, + +```javascript +var Complex64Array = require( '@stdlib/array/complex64' ); + +var x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + +csscal( 2, 2.0, x, 2 ); +// x => [ 2.0, 4.0, 3.0, 4.0, 10.0, 12.0, 7.0, 8.0 ] +``` + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +```javascript +var Complex64Array = require( '@stdlib/array/complex64' ); + +// Initial array: +var x0 = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + +// Create an offset view: +var x1 = new Complex64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +// Scale every element in `x1`: +csscal( 3, 2.0, x1, 1 ); +// x0 => [ 1.0, 2.0, 6.0, 8.0, 10.0, 12.0, 14.0, 16.0 ] +``` + +#### csscal.ndarray( N, alpha, x, strideX, offsetX ) + +Scales a single-precision complex floating-point vector by a single-precision floating-point constant using alternative indexing semantics. + +```javascript +var Complex64Array = require( '@stdlib/array/complex64' ); + +var x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + +csscal.ndarray( 3, 2.0, x, 1, 0 ); +// x => [ 2.0, 4.0, 6.0, 8.0, 10.0, 12.0 ] +``` + +The function has the following additional parameters: + +- **offsetX**: starting index for `x`. + +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to scale every other element in the input strided array starting from the second element, + +```javascript +var Complex64Array = require( '@stdlib/array/complex64' ); + +var x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + +csscal.ndarray( 2, 2.0, x, 2, 1 ); +// x => [ 1.0, 2.0, 6.0, 8.0, 5.0, 6.0, 14.0, 16.0 ] +``` + +
+ + + +
+ +## Notes + +- If `N <= 0`, both functions return `x` unchanged. +- `csscal()` corresponds to the [BLAS][blas] level 1 function [`csscal`][csscal]. + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var csscal = require( '@stdlib/blas/base/csscal' ); + +function rand() { + return new Complex64( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) ); +} + +var x = filledarrayBy( 10, 'complex64', rand ); +console.log( x.toString() ); + +csscal( x.length, 2.0, x, 1 ); +console.log( x.toString() ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/base/csscal/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/csscal/benchmark/benchmark.js new file mode 100644 index 000000000000..dee197c7b13f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csscal/benchmark/benchmark.js @@ -0,0 +1,107 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var 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 Complex64Array = require( '@stdlib/array/complex64' ); +var pkg = require( './../package.json' ).name; +var csscal = require( './../lib/csscal.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float32' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var xbuf; + var x; + + xbuf = uniform( len*2, -100.0, 100.0, options ); + x = new Complex64Array( xbuf.buffer ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + csscal( x.length, 2.0, x, 1 ); + if ( isnanf( xbuf[ i%(len*2) ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( xbuf[ i%(len*2) ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+':len='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/csscal/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/csscal/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..38daa8f164c6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csscal/benchmark/benchmark.ndarray.js @@ -0,0 +1,107 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var 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 Complex64Array = require( '@stdlib/array/complex64' ); +var pkg = require( './../package.json' ).name; +var csscal = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float32' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var xbuf; + var x; + + xbuf = uniform( len*2, -100.0, 100.0, options ); + x = new Complex64Array( xbuf.buffer ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + csscal( x.length, 2.0, x, 1, 0 ); + if ( isnanf( xbuf[ i%(len*2) ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( xbuf[ i%(len*2) ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+':ndarray:len='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/csscal/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/csscal/docs/repl.txt new file mode 100644 index 000000000000..b8bfcedd7366 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csscal/docs/repl.txt @@ -0,0 +1,98 @@ + +{{alias}}( N, alpha, x, strideX ) + Scales a single-precision complex floating-point vector by a single- + precision floating-point constant. + + The `N` and stride parameters determine which elements in `x` are scaled by + `alpha`. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + If `N` is less than or equal to `0`, the function returns `x` unchanged. + + + Parameters + ---------- + N: integer + Number of indexed elements. + + alpha: single + Scalar constant. + + x: Complex64Array + Input array. + + strideX: integer + Stride length for `x`. + + Returns + ------- + x: Complex64Array + Input array. + + Examples + -------- + // Standard usage: + > var x = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > {{alias}}( 2, 2.0, x, 1 ) + [ 2.0, 4.0, 6.0, 8.0 ] + + // N and stride parameters: + > x = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > {{alias}}( 2, 2.0, x, 2 ) + [ 2.0, 4.0, 3.0, 4.0, 10.0, 12.0 ] + + // Using typed array views: + > var x0 = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > var x1 = new {{alias:@stdlib/array/complex64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > {{alias}}( 2, 2.0, x1, 1 ) + [ 6.0, 8.0, 10.0, 12.0 ] + > x0 + [ 1.0, 2.0, 6.0, 8.0, 10.0, 12.0 ] + + +{{alias}}.ndarray( N, alpha, x, strideX, offsetX ) + Scales a single-precision complex floating-point vector by a single- + precision floating-point constant using alternative indexing semantics. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameter supports indexing semantics based on a starting + index. + + Parameters + ---------- + N: integer + Number of indexed elements. + + alpha: number + Scalar constant. + + x: Complex64Array + Input array. + + strideX: integer + Stride length for `x`. + + offsetX: integer + Starting index for `x`. + + Returns + ------- + x: Complex64Array + Input array. + + Examples + -------- + // Standard usage: + > var x = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > {{alias}}.ndarray( 2, 2.0, x, 1, 0 ) + [ 2.0, 4.0, 6.0, 8.0 ] + + // Advanced indexing: + > x = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + > {{alias}}.ndarray( 2, 2.0, x, 1, 2 ) + [ 1.0, 2.0, 3.0, 4.0, 10.0, 12.0, 14.0, 16.0 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/blas/base/csscal/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/csscal/docs/types/index.d.ts new file mode 100644 index 000000000000..40e43217e588 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csscal/docs/types/index.d.ts @@ -0,0 +1,99 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +import { Complex64Array } from '@stdlib/types/array'; + +/** +* Interface describing `csscal`. +*/ +interface Routine { + /** + * Scales a single-precision complex floating-point vector by a single-precision floating-point constant. + * + * @param N - number of indexed elements + * @param alpha - scalar constant + * @param x - input array + * @param strideX - `x` stride length + * @returns input array + * + * @example + * var Complex64Array = require( '@stdlib/array/complex64' ); + * + * var x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + * + * csscal( 3, 2.0, x, 1 ); + * // x => [ 2.0, 4.0, 6.0, 8.0, 10.0, 12.0 ] + */ + ( N: number, alpha: number, x: Complex64Array, strideX: number ): Complex64Array; + + /** + * Scales a single-precision complex floating-point vector by a single-precision floating-point constant. + * + * @param N - number of indexed elements + * @param alpha - scalar constant + * @param x - input array + * @param strideX - `x` stride length + * @param offsetX - starting index for `x` + * @returns input array + * + * @example + * var Complex64Array = require( '@stdlib/array/complex64' ); + * + * var x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + * + * csscal.ndarray( 3, 2.0, x, 1, 0 ); + * // x => [ 2.0, 4.0, 6.0, 8.0, 10.0, 12.0 ] + */ + ndarray( N: number, alpha: number, x: Complex64Array, strideX: number, offsetX: number ): Complex64Array; +} + +/** +* Scales a single-precision complex floating-point vector by a single-precision floating-point constant. +* +* @param N - number of indexed elements +* @param alpha - scalar constant +* @param x - input array +* @param strideX - `x` stride length +* @returns input array +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* +* var x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* csscal( 3, 2.0, x, 1 ); +* // x => [ 2.0, 4.0, 6.0, 8.0, 10.0, 12.0 ] +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* +* var x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* csscal.ndarray( 2, 2.0, x, 1, 1 ); +* // x => [ 1.0, 2.0, 6.0, 8.0, 10.0, 12.0 ] +*/ +declare var csscal: Routine; + + +// EXPORTS // + +export = csscal; diff --git a/lib/node_modules/@stdlib/blas/base/csscal/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/csscal/docs/types/test.ts new file mode 100644 index 000000000000..7376f99c1b52 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csscal/docs/types/test.ts @@ -0,0 +1,191 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import Complex64Array = require( '@stdlib/array/complex64' ); +import Complex64 = require( '@stdlib/complex/float32/ctor' ); +import csscal = require( './index' ); + + +// TESTS // + +// The function returns a Complex64Array... +{ + const x = new Complex64Array( 10 ); + + csscal( x.length, 2.0, x, 1 ); // $ExpectType Complex64Array +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const x = new Complex64Array( 10 ); + + csscal( '10', 2.0, x, 1 ); // $EzxpectError + csscal( true, 2.0, x, 1 ); // $ExpectError + csscal( false, 2.0, x, 1 ); // $ExpectError + csscal( null, 2.0, x, 1 ); // $ExpectError + csscal( undefined, 2.0, x, 1 ); // $ExpectError + csscal( [], 2.0, x, 1 ); // $ExpectError + csscal( {}, 2.0, x, 1 ); // $ExpectError + csscal( ( x: number ): number => x, 2.0, x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const x = new Complex64Array( 10 ); + + csscal( x.length, new Complex64( 1.0, 2.0 ), x, 1 ); // $ExpectError + csscal( x.length, '10', x, 1 ); // $ExpectError + csscal( x.length, true, x, 1 ); // $ExpectError + csscal( x.length, false, x, 1 ); // $ExpectError + csscal( x.length, null, x, 1 ); // $ExpectError + csscal( x.length, undefined, x, 1 ); // $ExpectError + csscal( x.length, [ '1' ], x, 1 ); // $ExpectError + csscal( x.length, {}, x, 1 ); // $ExpectError + csscal( x.length, ( x: number ): number => x, x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a Complex64Array... +{ + const x = new Complex64Array( 10 ); + + csscal( x.length, 2.0, 10, 1 ); // $ExpectError + csscal( x.length, 2.0, '10', 1 ); // $ExpectError + csscal( x.length, 2.0, true, 1 ); // $ExpectError + csscal( x.length, 2.0, false, 1 ); // $ExpectError + csscal( x.length, 2.0, null, 1 ); // $ExpectError + csscal( x.length, 2.0, undefined, 1 ); // $ExpectError + csscal( x.length, 2.0, [ '1' ], 1 ); // $ExpectError + csscal( x.length, 2.0, {}, 1 ); // $ExpectError + csscal( x.length, 2.0, ( x: number ): number => x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const x = new Complex64Array( 10 ); + + csscal( x.length, 2.0, x, '10' ); // $ExpectError + csscal( x.length, 2.0, x, true ); // $ExpectError + csscal( x.length, 2.0, x, false ); // $ExpectError + csscal( x.length, 2.0, x, null ); // $ExpectError + csscal( x.length, 2.0, x, undefined ); // $ExpectError + csscal( x.length, 2.0, x, [] ); // $ExpectError + csscal( x.length, 2.0, x, {} ); // $ExpectError + csscal( x.length, 2.0, x, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = new Complex64Array( 10 ); + + csscal(); // $ExpectError + csscal( x.length ); // $ExpectError + csscal( x.length, 2.0 ); // $ExpectError + csscal( x.length, 2.0, x ); // $ExpectError + csscal( x.length, 2.0, x, 1, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Complex64Array... +{ + const x = new Complex64Array( 10 ); + + csscal.ndarray( x.length, 2.0, x, 1, 0 ); // $ExpectType Complex64Array +} + +// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... +{ + const x = new Complex64Array( 10 ); + + csscal.ndarray( '10', 2.0, x, 1, 0 ); // $ExpectError + csscal.ndarray( true, 2.0, x, 1, 0 ); // $ExpectError + csscal.ndarray( false, 2.0, x, 1, 0 ); // $ExpectError + csscal.ndarray( null, 2.0, x, 1, 0 ); // $ExpectError + csscal.ndarray( undefined, 2.0, x, 1, 0 ); // $ExpectError + csscal.ndarray( [], 2.0, x, 1, 0 ); // $ExpectError + csscal.ndarray( {}, 2.0, x, 1, 0 ); // $ExpectError + csscal.ndarray( ( x: number ): number => x, 2.0, x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a second argument which is not a number... +{ + const x = new Complex64Array( 10 ); + + csscal.ndarray( x.length, new Complex64( 1.0, 2.0 ), x, 1, 0 ); // $ExpectError + csscal.ndarray( x.length, '10', x, 1, 0 ); // $ExpectError + csscal.ndarray( x.length, true, x, 1, 0 ); // $ExpectError + csscal.ndarray( x.length, false, x, 1, 0 ); // $ExpectError + csscal.ndarray( x.length, null, x, 1, 0 ); // $ExpectError + csscal.ndarray( x.length, undefined, x, 1, 0 ); // $ExpectError + csscal.ndarray( x.length, [ '1' ], x, 1, 0 ); // $ExpectError + csscal.ndarray( x.length, {}, x, 1, 0 ); // $ExpectError + csscal.ndarray( x.length, ( x: number ): number => x, x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a third argument which is not a Complex64Array... +{ + const x = new Complex64Array( 10 ); + + csscal.ndarray( x.length, 2.0, 10, 1, 0 ); // $ExpectError + csscal.ndarray( x.length, 2.0, '10', 1, 0 ); // $ExpectError + csscal.ndarray( x.length, 2.0, true, 1, 0 ); // $ExpectError + csscal.ndarray( x.length, 2.0, false, 1, 0 ); // $ExpectError + csscal.ndarray( x.length, 2.0, null, 1, 0 ); // $ExpectError + csscal.ndarray( x.length, 2.0, undefined, 1, 0 ); // $ExpectError + csscal.ndarray( x.length, 2.0, [ '1' ], 1, 0 ); // $ExpectError + csscal.ndarray( x.length, 2.0, {}, 1, 0 ); // $ExpectError + csscal.ndarray( x.length, 2.0, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... +{ + const x = new Complex64Array( 10 ); + + csscal.ndarray( x.length, 2.0, x, '10', 0 ); // $ExpectError + csscal.ndarray( x.length, 2.0, x, true, 0 ); // $ExpectError + csscal.ndarray( x.length, 2.0, x, false, 0 ); // $ExpectError + csscal.ndarray( x.length, 2.0, x, null, 0 ); // $ExpectError + csscal.ndarray( x.length, 2.0, x, undefined, 0 ); // $ExpectError + csscal.ndarray( x.length, 2.0, x, [], 0 ); // $ExpectError + csscal.ndarray( x.length, 2.0, x, {}, 0 ); // $ExpectError + csscal.ndarray( x.length, 2.0, x, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... +{ + const x = new Complex64Array( 10 ); + + csscal.ndarray( x.length, 2.0, x, 1, '10' ); // $ExpectError + csscal.ndarray( x.length, 2.0, x, 1, true ); // $ExpectError + csscal.ndarray( x.length, 2.0, x, 1, false ); // $ExpectError + csscal.ndarray( x.length, 2.0, x, 1, null ); // $ExpectError + csscal.ndarray( x.length, 2.0, x, 1, undefined ); // $ExpectError + csscal.ndarray( x.length, 2.0, x, 1, [] ); // $ExpectError + csscal.ndarray( x.length, 2.0, x, 1, {} ); // $ExpectError + csscal.ndarray( x.length, 2.0, x, 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 Complex64Array( 10 ); + + csscal.ndarray(); // $ExpectError + csscal.ndarray( x.length ); // $ExpectError + csscal.ndarray( x.length, 2.0 ); // $ExpectError + csscal.ndarray( x.length, 2.0, x ); // $ExpectError + csscal.ndarray( x.length, 2.0, x, 1 ); // $ExpectError + csscal.ndarray( x.length, 2.0, x, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/base/csscal/examples/index.js b/lib/node_modules/@stdlib/blas/base/csscal/examples/index.js new file mode 100644 index 000000000000..049d2f0ffdb7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csscal/examples/index.js @@ -0,0 +1,34 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var csscal = require( './../lib' ); + +function rand() { + return new Complex64( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) ); +} + +var x = filledarrayBy( 10, 'complex64', rand ); +console.log( x.toString() ); + +csscal( x.length, 2.0, x, 1 ); +console.log( x.toString() ); diff --git a/lib/node_modules/@stdlib/blas/base/csscal/lib/csscal.js b/lib/node_modules/@stdlib/blas/base/csscal/lib/csscal.js new file mode 100644 index 000000000000..995546b905b4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csscal/lib/csscal.js @@ -0,0 +1,53 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var stride2offset = require( '@stdlib/strided/base/stride2offset' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +/** +* Scales a single-precision complex floating-point vector by a single-precision floating-point constant. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {number} alpha - constant +* @param {Complex64Array} x - input array +* @param {integer} strideX - `x` stride length +* @returns {Complex64Array} input array +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* +* var x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* csscal( 3, 2.0, x, 1 ); +* // x => [ 2.0, 4.0, 6.0, 8.0, 10.0, 12.0 ] +*/ +function csscal( N, alpha, x, strideX ) { + return ndarray( N, alpha, x, strideX, stride2offset( N, strideX ) ); +} + + +// EXPORTS // + +module.exports = csscal; diff --git a/lib/node_modules/@stdlib/blas/base/csscal/lib/index.js b/lib/node_modules/@stdlib/blas/base/csscal/lib/index.js new file mode 100644 index 000000000000..ef5bbf9925c8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csscal/lib/index.js @@ -0,0 +1,68 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* BLAS level 1 routine to scale a single-precision complex floating-point vector by a single-precision floating-point constant. +* +* @module @stdlib/blas/base/csscal +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var csscal = require( '@stdlib/blas/base/csscal' ); +* +* var x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* csscal( 3, 2.0, x, 1 ); +* // x => [ 2.0, 4.0, 6.0, 8.0, 10.0, 12.0 ] +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var csscal = require( '@stdlib/blas/base/csscal' ); +* +* var x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* csscal.ndarray( 3, 2.0, x, 1, 0 ); +* // x => [ 2.0, 4.0, 6.0, 8.0, 10.0, 12.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 csscal; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + csscal = main; +} else { + csscal = tmp; +} + + +// EXPORTS // + +module.exports = csscal; + +// exports: { "ndarray": "csscal.ndarray" } diff --git a/lib/node_modules/@stdlib/blas/base/csscal/lib/main.js b/lib/node_modules/@stdlib/blas/base/csscal/lib/main.js new file mode 100644 index 000000000000..054d07172b31 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csscal/lib/main.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var csscal = require( './csscal.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( csscal, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = csscal; diff --git a/lib/node_modules/@stdlib/blas/base/csscal/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/csscal/lib/ndarray.js new file mode 100644 index 000000000000..a20a4c2072c8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csscal/lib/ndarray.js @@ -0,0 +1,73 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); +var scale = require( '@stdlib/complex/float32/base/scale' ).strided; + + +// MAIN // + +/** +* Scales a single-precision complex floating-point vector by a single-precision floating-point constant. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {number} alpha - constant +* @param {Complex64Array} x - input array +* @param {integer} strideX - `x` stride length +* @param {NonNegativeInteger} offsetX - starting `x` index +* @returns {Complex64Array} input array +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* +* var x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* csscal( 3, 2.0, x, 1, 0 ); +* // x => [ 2.0, 4.0, 6.0, 8.0, 10.0, 12.0 ] +*/ +function csscal( N, alpha, x, strideX, offsetX ) { + var x32; + var ix; + var sx; + var i; + + if ( N <= 0 || alpha === 1.0 ) { + return x; + } + // Reinterpret the input array as a real-valued array of interleaved real and imaginary components: + x32 = reinterpret( x, 0 ); + + // Adjust the stride and offset accordingly: + ix = offsetX * 2; + sx = strideX * 2; + + for ( i = 0; i < N; i++ ) { + scale( alpha, x32, 1, ix, x32, 1, ix ); + ix += sx; + } + return x; +} + + +// EXPORTS // + +module.exports = csscal; diff --git a/lib/node_modules/@stdlib/blas/base/csscal/package.json b/lib/node_modules/@stdlib/blas/base/csscal/package.json new file mode 100644 index 000000000000..a0a82c29e5a7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csscal/package.json @@ -0,0 +1,77 @@ +{ + "name": "@stdlib/blas/base/csscal", + "version": "0.0.0", + "description": "Scale a single-precision complex floating-point vector by a single-precision floating-point constant.", + "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", + "browser": "./lib/main.js", + "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 1", + "linear", + "algebra", + "subroutines", + "csscal", + "scale", + "vector", + "typed", + "array", + "ndarray", + "complex", + "complex64", + "single", + "float32", + "float32array" + ], + "__stdlib__": { + "wasm": false + } +} diff --git a/lib/node_modules/@stdlib/blas/base/csscal/test/test.csscal.js b/lib/node_modules/@stdlib/blas/base/csscal/test/test.csscal.js new file mode 100644 index 000000000000..83f87c9aa8cd --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csscal/test/test.csscal.js @@ -0,0 +1,217 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var csscal = require( './../lib/csscal.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof csscal, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 4', function test( t ) { + t.strictEqual( csscal.length, 4, 'arity of 4' ); + t.end(); +}); + +tape( 'the function scales elements from `x` by `alpha`', function test( t ) { + var expected; + var x; + + x = new Complex64Array([ + 0.3, // 1 + 0.1, // 1 + 0.5, // 2 + 0.0, // 2 + 0.0, // 3 + 0.5, // 3 + 0.0, // 4 + 0.2 // 4 + ]); + + csscal( 4, 2.0, x, 1 ); + + expected = new Complex64Array([ + 0.6, // 1 + 0.2, // 1 + 1.0, // 2 + 0.0, // 2 + 0.0, // 3 + 1.0, // 3 + 0.0, // 4 + 0.4 // 4 + ]); + t.strictEqual( isSameComplex64Array( x, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `x` stride', function test( t ) { + var expected; + var x; + + x = new Complex64Array([ + 0.1, // 1 + 0.1, // 1 + 3.0, + 6.0, + -0.6, // 2 + 0.1, // 2 + 4.0, + 7.0, + 0.1, // 3 + -0.3, // 3 + 7.0, + 2.0 + ]); + + csscal( 3, 2.0, x, 2 ); + + expected = new Complex64Array([ + 0.2, // 1 + 0.2, // 1 + 3.0, + 6.0, + -1.2, // 2 + 0.2, // 2 + 4.0, + 7.0, + 0.2, // 3 + -0.6, // 3 + 7.0, + 2.0 + ]); + t.strictEqual( isSameComplex64Array( x, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var expected; + var x; + + x = new Complex64Array([ + 0.1, // 3 + 0.1, // 3 + 3.0, + 6.0, + -0.6, // 2 + 0.1, // 2 + 4.0, + 7.0, + 0.1, // 1 + -0.3, // 1 + 7.0, + 2.0 + ]); + + csscal( 3, 2.0, x, -2 ); + + expected = new Complex64Array([ + 0.2, // 3 + 0.2, // 3 + 3.0, + 6.0, + -1.2, // 2 + 0.2, // 2 + 4.0, + 7.0, + 0.2, // 1 + -0.6, // 1 + 7.0, + 2.0 + ]); + t.strictEqual( isSameComplex64Array( x, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a reference to the input array', function test( t ) { + var out; + var x; + + x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + out = csscal( 4, 2.0, x, 1 ); + + t.strictEqual( out, x, 'same reference' ); + t.end(); +}); + +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns the input array unchanged', function test( t ) { + var expected; + var x; + + x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + + csscal( -1, 2.0, x, 1 ); + t.strictEqual( isSameComplex64Array( x, expected ), true, 'returns expected value' ); + + csscal( 0, 2.0, x, 1 ); + t.strictEqual( isSameComplex64Array( x, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var expected; + var x0; + var x1; + + // Initial array: + x0 = new Complex64Array([ + 0.1, + -0.3, + 8.0, // 1 + 9.0, // 1 + 0.5, // 2 + -0.1, // 2 + 2.0, // 3 + 5.0, // 3 + 2.0, + 3.0 + ]); + + // Create offset view: + x1 = new Complex64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // begin at 2nd element + + csscal( 3, 2.0, x1, 1 ); + + expected = new Complex64Array([ + 0.1, + -0.3, + 16.0, // 1 + 18.0, // 1 + 1.0, // 2 + -0.2, // 2 + 4.0, // 3 + 10.0, // 3 + 2.0, + 3.0 + ]); + t.strictEqual( isSameComplex64Array( x0, expected ), true, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/csscal/test/test.js b/lib/node_modules/@stdlib/blas/base/csscal/test/test.js new file mode 100644 index 000000000000..ba2459339e72 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csscal/test/test.js @@ -0,0 +1,82 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var proxyquire = require( 'proxyquire' ); +var isBrowser = require( '@stdlib/assert/is-browser' ); +var csscal = require( './../lib' ); + + +// VARIABLES // + +var opts = { + 'skip': isBrowser +}; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof csscal, '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 csscal.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 csscal = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( csscal, mock, 'returns native implementation' ); + 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 csscal; + var main; + + main = require( './../lib/csscal.js' ); + + csscal = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( csscal, main, 'returns JavaScript implementation' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/blas/base/csscal/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/csscal/test/test.ndarray.js new file mode 100644 index 000000000000..33682441dd37 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csscal/test/test.ndarray.js @@ -0,0 +1,267 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var csscal = require( './../lib/ndarray.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof csscal, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 5', function test( t ) { + t.strictEqual( csscal.length, 5, 'arity of 5' ); + t.end(); +}); + +tape( 'the function scales elements from `x` by `alpha`', function test( t ) { + var expected; + var x; + + x = new Complex64Array([ + 0.3, // 1 + 0.1, // 1 + 0.5, // 2 + 0.0, // 2 + 0.0, // 3 + 0.5, // 3 + 0.0, // 4 + 0.2, // 4 + 2.0, + 3.0, + 2.0, + 3.0 + ]); + + csscal( 4, 2.0, x, 1, 0 ); + + expected = new Complex64Array([ + 0.6, // 1 + 0.2, // 1 + 1.0, // 2 + 0.0, // 2 + 0.0, // 3 + 1.0, // 3 + 0.0, // 4 + 0.4, // 4 + 2.0, + 3.0, + 2.0, + 3.0 + ]); + t.strictEqual( isSameComplex64Array( x, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `x` stride', function test( t ) { + var expected; + var x; + + x = new Complex64Array([ + 0.1, // 1 + 0.1, // 1 + 3.0, + 6.0, + -0.6, // 2 + 0.1, // 2 + 4.0, + 7.0, + 0.1, // 3 + -0.3, // 3 + 7.0, + 2.0 + ]); + + csscal( 3, 2.0, x, 2, 0 ); + + expected = new Complex64Array([ + 0.2, // 1 + 0.2, // 1 + 3.0, + 6.0, + -1.2, // 2 + 0.2, // 2 + 4.0, + 7.0, + 0.2, // 3 + -0.6, // 3 + 7.0, + 2.0 + ]); + t.strictEqual( isSameComplex64Array( x, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var expected; + var x; + + x = new Complex64Array([ + 0.1, // 3 + 0.1, // 3 + 3.0, + 6.0, + -0.6, // 2 + 0.1, // 2 + 4.0, + 7.0, + 0.1, // 1 + -0.3, // 1 + 7.0, + 2.0 + ]); + + csscal( 3, 2.0, x, -2, 4 ); + + expected = new Complex64Array([ + 0.2, // 3 + 0.2, // 3 + 3.0, + 6.0, + -1.2, // 2 + 0.2, // 2 + 4.0, + 7.0, + 0.2, // 1 + -0.6, // 1 + 7.0, + 2.0 + ]); + t.strictEqual( isSameComplex64Array( x, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `x` offset', function test( t ) { + var expected; + var x; + + x = new Complex64Array([ + 0.1, + 0.1, + 3.0, + 6.0, + -0.6, + 0.1, + 4.0, // 1 + 6.0, // 1 + 0.1, // 2 + -0.3, // 2 + 7.0, // 3 + 2.0 // 3 + ]); + + csscal( 3, 2.0, x, 1, 3 ); + + expected = new Complex64Array([ + 0.1, + 0.1, + 3.0, + 6.0, + -0.6, + 0.1, + 8.0, // 1 + 12.0, // 1 + 0.2, // 2 + -0.6, // 2 + 14.0, // 3 + 4.0 // 3 + ]); + t.strictEqual( isSameComplex64Array( x, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a reference to the input array', function test( t ) { + var out; + var x; + + x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + out = csscal( 4, 2.0, x, 1, 0 ); + + t.strictEqual( out, x, 'same reference' ); + t.end(); +}); + +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns the input array unchanged', function test( t ) { + var expected; + var x; + + x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + + csscal( -1, 2.0, x, 1, 0 ); + t.strictEqual( isSameComplex64Array( x, expected ), true, 'returns expected value' ); + + csscal( 0, 2.0, x, 1, 0 ); + t.strictEqual( isSameComplex64Array( x, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports complex access patterns', function test( t ) { + var expected; + var x; + + x = new Complex64Array([ + 0.1, + 0.1, + 3.0, + 6.0, + -0.6, + 0.1, + 4.0, // 2 + 6.0, // 2 + 0.1, + -0.3, + 7.0, + 2.0, + 2.0, // 1 + 3.0 // 1 + ]); + + csscal( 2, 2.0, x, -3, 6 ); + + expected = new Complex64Array([ + 0.1, + 0.1, + 3.0, + 6.0, + -0.6, + 0.1, + 8.0, // 2 + 12.0, // 2 + 0.1, + -0.3, + 7.0, + 2.0, + 4.0, // 1 + 6.0 // 1 + ]); + t.strictEqual( isSameComplex64Array( x, expected ), true, 'returns expected value' ); + t.end(); +});