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..7b1021e1c9a3 --- /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, sa, cx, strideZX ) + +Scales a single-precision complex floating-point vector by a single-precision floating-point constant. + +```javascript +var Complex64Array = require( '@stdlib/array/complex64' ); + +var cx = new Complex64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); + +csscal( 3, 2.0, cx, 1 ); +// cx => [ 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 ] +``` + +The function has the following parameters: + +- **N**: number of indexed elements. +- **sa**: scalar constant. +- **cx**: input [`Complex64Array`][@stdlib/array/complex64]. +- **strideZX**: stride length for `cx`. + +The `N` and stride parameters determine which elements in `cx` are scaled by `sa`. For example, to scale every other element in `cx` by `sa`, + +```javascript +var Complex64Array = require( '@stdlib/array/complex64' ); + +var cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + +csscal( 2, 2.0, cx, 2 ); +// cx => [ 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 cx0 = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + +// Create an offset view: +var cx1 = new Complex64Array( cx0.buffer, cx0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +// Scale every element in `cx1`: +csscal( 3, 2.0, cx1, 1 ); +// cx0 => [ 1.0, 2.0, 6.0, 8.0, 10.0, 12.0, 14.0, 16.0 ] +``` + +#### csscal.ndarray( N, sa, cx, strideZX, offsetZX ) + +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 cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + +csscal.ndarray( 3, 2.0, cx, 1, 0 ); +// cx => [ 2.0, 4.0, 6.0, 8.0, 10.0, 12.0 ] +``` + +The function has the following additional parameters: + +- **offsetZX**: starting index for `cx`. + +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 cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + +csscal.ndarray( 2, 2.0, cx, 2, 1 ); +// cx => [ 1.0, 2.0, 6.0, 8.0, 5.0, 6.0, 14.0, 16.0 ] +``` + +
+ + + +
+ +## Notes + +- If `N <= 0`, both functions return `cx` 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 cx = filledarrayBy( 10, 'complex64', rand ); +console.log( cx.toString() ); + +csscal( cx.length, 2.0, cx, 1 ); +console.log( cx.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..45a40b33dca6 --- /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 cxbuf; + var cx; + + cxbuf = uniform( len*2, -100.0, 100.0, options ); + cx = new Complex64Array( cxbuf.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( cx.length, 2.0, cx, 1 ); + if ( isnanf( cxbuf[ i%(len*2) ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( cxbuf[ 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..63c9a3c3b914 --- /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 cxbuf; + var cx; + + cxbuf = uniform( len*2, -100.0, 100.0, options ); + cx = new Complex64Array( cxbuf.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( cx.length, 2.0, cx, 1, 0 ); + if ( isnanf( cxbuf[ i%(len*2) ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( cxbuf[ 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..f590e278360c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csscal/docs/repl.txt @@ -0,0 +1,98 @@ + +{{alias}}( N, sa, cx, strideCX ) + Scales a single-precision complex floating-point vector by a single- + precision floating-point constant. + + The `N` and stride parameters determine which elements in `cx` are scaled by + `sa`. + + 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 `cx` unchanged. + + + Parameters + ---------- + N: integer + Number of indexed elements. + + sa: single + Scalar constant. + + cx: Complex64Array + Input array. + + strideCX: integer + Stride length for `cx`. + + Returns + ------- + cx: Complex64Array + Input array. + + Examples + -------- + // Standard usage: + > var cx = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > {{alias}}( 2, 2.0, cx, 1 ) + [ 2.0, 4.0, 6.0, 8.0 ] + + // N and stride parameters: + > cx = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > {{alias}}( 2, 2.0, cx, 2 ) + [ 2.0, 4.0, 3.0, 4.0, 10.0, 12.0 ] + + // Using typed array views: + > var cx0 = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > var cx1 = new {{alias:@stdlib/array/complex64}}( cx0.buffer, cx0.BYTES_PER_ELEMENT*1 ); + > {{alias}}( 2, 2.0, cx1, 1 ) + [ 6.0, 8.0, 10.0, 12.0 ] + > cx0 + [ 1.0, 2.0, 6.0, 8.0, 10.0, 12.0 ] + + +{{alias}}.ndarray( N, sa, cx, strideCX, offsetCX ) + 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. + + sa: number + Scalar constant. + + cx: Complex64Array + Input array. + + strideCX: integer + Stride length for `cx`. + + offsetCX: integer + Starting index for `cx`. + + Returns + ------- + cx: Complex64Array + Input array. + + Examples + -------- + // Standard usage: + > var cx = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > {{alias}}.ndarray( 2, 2.0, cx, 1, 0 ) + [ 2.0, 4.0, 6.0, 8.0 ] + + // Advanced indexing: + > cx = 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, cx, 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..0c33bb227d82 --- /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 sa - scalar constant + * @param cx - input array + * @param strideCX - `cx` stride length + * @returns input array + * + * @example + * var Complex64Array = require( '@stdlib/array/complex64' ); + * + * var cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + * + * csscal( 3, 2.0, cx, 1 ); + * // cx => [ 2.0, 4.0, 6.0, 8.0, 10.0, 12.0 ] + */ + ( N: number, sa: number, cx: Complex64Array, strideCX: number ): Complex64Array; + + /** + * Scales a single-precision complex floating-point vector by a single-precision floating-point constant. + * + * @param N - number of indexed elements + * @param sa - scalar constant + * @param cx - input array + * @param strideCX - `cx` stride length + * @param offsetCX - starting index for `cx` + * @returns input array + * + * @example + * var Complex64Array = require( '@stdlib/array/complex64' ); + * + * var cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + * + * csscal.ndarray( 3, 2.0, cx, 1, 0 ); + * // cx => [ 2.0, 4.0, 6.0, 8.0, 10.0, 12.0 ] + */ + ndarray( N: number, sa: number, cx: Complex64Array, strideCX: number, offsetCX: number ): Complex64Array; +} + +/** +* Scales a single-precision complex floating-point vector by a single-precision floating-point constant. +* +* @param N - number of indexed elements +* @param sa - scalar constant +* @param cx - input array +* @param strideCX - `cx` stride length +* @returns input array +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* +* var cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* csscal( 3, 2.0, cx, 1 ); +* // cx => [ 2.0, 4.0, 6.0, 8.0, 10.0, 12.0 ] +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* +* var cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* csscal.ndarray( 2, 2.0, cx, 1, 1 ); +* // cx => [ 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..7b5946da77af --- /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 cx = new Complex64Array( 10 ); + + csscal( cx.length, 2.0, cx, 1 ); // $ExpectType Complex64Array +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const cx = new Complex64Array( 10 ); + + csscal( '10', 2.0, cx, 1 ); // $EzxpectError + csscal( true, 2.0, cx, 1 ); // $ExpectError + csscal( false, 2.0, cx, 1 ); // $ExpectError + csscal( null, 2.0, cx, 1 ); // $ExpectError + csscal( undefined, 2.0, cx, 1 ); // $ExpectError + csscal( [], 2.0, cx, 1 ); // $ExpectError + csscal( {}, 2.0, cx, 1 ); // $ExpectError + csscal( ( cx: number ): number => cx, 2.0, cx, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const cx = new Complex64Array( 10 ); + + csscal( cx.length, new Complex64( 1.0, 2.0 ), cx, 1 ); // $ExpectError + csscal( cx.length, '10', cx, 1 ); // $ExpectError + csscal( cx.length, true, cx, 1 ); // $ExpectError + csscal( cx.length, false, cx, 1 ); // $ExpectError + csscal( cx.length, null, cx, 1 ); // $ExpectError + csscal( cx.length, undefined, cx, 1 ); // $ExpectError + csscal( cx.length, [ '1' ], cx, 1 ); // $ExpectError + csscal( cx.length, {}, cx, 1 ); // $ExpectError + csscal( cx.length, ( cx: number ): number => cx, cx, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a Complex64Array... +{ + const cx = new Complex64Array( 10 ); + + csscal( cx.length, 2.0, 10, 1 ); // $ExpectError + csscal( cx.length, 2.0, '10', 1 ); // $ExpectError + csscal( cx.length, 2.0, true, 1 ); // $ExpectError + csscal( cx.length, 2.0, false, 1 ); // $ExpectError + csscal( cx.length, 2.0, null, 1 ); // $ExpectError + csscal( cx.length, 2.0, undefined, 1 ); // $ExpectError + csscal( cx.length, 2.0, [ '1' ], 1 ); // $ExpectError + csscal( cx.length, 2.0, {}, 1 ); // $ExpectError + csscal( cx.length, 2.0, ( cx: number ): number => cx, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const cx = new Complex64Array( 10 ); + + csscal( cx.length, 2.0, cx, '10' ); // $ExpectError + csscal( cx.length, 2.0, cx, true ); // $ExpectError + csscal( cx.length, 2.0, cx, false ); // $ExpectError + csscal( cx.length, 2.0, cx, null ); // $ExpectError + csscal( cx.length, 2.0, cx, undefined ); // $ExpectError + csscal( cx.length, 2.0, cx, [] ); // $ExpectError + csscal( cx.length, 2.0, cx, {} ); // $ExpectError + csscal( cx.length, 2.0, cx, ( cx: number ): number => cx ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const cx = new Complex64Array( 10 ); + + csscal(); // $ExpectError + csscal( cx.length ); // $ExpectError + csscal( cx.length, 2.0 ); // $ExpectError + csscal( cx.length, 2.0, cx ); // $ExpectError + csscal( cx.length, 2.0, cx, 1, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Complex64Array... +{ + const cx = new Complex64Array( 10 ); + + csscal.ndarray( cx.length, 2.0, cx, 1, 0 ); // $ExpectType Complex64Array +} + +// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... +{ + const cx = new Complex64Array( 10 ); + + csscal.ndarray( '10', 2.0, cx, 1, 0 ); // $ExpectError + csscal.ndarray( true, 2.0, cx, 1, 0 ); // $ExpectError + csscal.ndarray( false, 2.0, cx, 1, 0 ); // $ExpectError + csscal.ndarray( null, 2.0, cx, 1, 0 ); // $ExpectError + csscal.ndarray( undefined, 2.0, cx, 1, 0 ); // $ExpectError + csscal.ndarray( [], 2.0, cx, 1, 0 ); // $ExpectError + csscal.ndarray( {}, 2.0, cx, 1, 0 ); // $ExpectError + csscal.ndarray( ( cx: number ): number => cx, 2.0, cx, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a second argument which is not a number... +{ + const cx = new Complex64Array( 10 ); + + csscal.ndarray( cx.length, new Complex64( 1.0, 2.0 ), cx, 1, 0 ); // $ExpectError + csscal.ndarray( cx.length, '10', cx, 1, 0 ); // $ExpectError + csscal.ndarray( cx.length, true, cx, 1, 0 ); // $ExpectError + csscal.ndarray( cx.length, false, cx, 1, 0 ); // $ExpectError + csscal.ndarray( cx.length, null, cx, 1, 0 ); // $ExpectError + csscal.ndarray( cx.length, undefined, cx, 1, 0 ); // $ExpectError + csscal.ndarray( cx.length, [ '1' ], cx, 1, 0 ); // $ExpectError + csscal.ndarray( cx.length, {}, cx, 1, 0 ); // $ExpectError + csscal.ndarray( cx.length, ( cx: number ): number => cx, cx, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a third argument which is not a Complex64Array... +{ + const cx = new Complex64Array( 10 ); + + csscal( cx.length, 2.0, 10, 1, 0 ); // $ExpectError + csscal( cx.length, 2.0, '10', 1, 0 ); // $ExpectError + csscal( cx.length, 2.0, true, 1, 0 ); // $ExpectError + csscal( cx.length, 2.0, false, 1, 0 ); // $ExpectError + csscal( cx.length, 2.0, null, 1, 0 ); // $ExpectError + csscal( cx.length, 2.0, undefined, 1, 0 ); // $ExpectError + csscal( cx.length, 2.0, [ '1' ], 1, 0 ); // $ExpectError + csscal( cx.length, 2.0, {}, 1, 0 ); // $ExpectError + csscal( cx.length, 2.0, ( cx: number ): number => cx, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... +{ + const cx = new Complex64Array( 10 ); + + csscal.ndarray( cx.length, 2.0, cx, '10', 0 ); // $ExpectError + csscal.ndarray( cx.length, 2.0, cx, true, 0 ); // $ExpectError + csscal.ndarray( cx.length, 2.0, cx, false, 0 ); // $ExpectError + csscal.ndarray( cx.length, 2.0, cx, null, 0 ); // $ExpectError + csscal.ndarray( cx.length, 2.0, cx, undefined, 0 ); // $ExpectError + csscal.ndarray( cx.length, 2.0, cx, [], 0 ); // $ExpectError + csscal.ndarray( cx.length, 2.0, cx, {}, 0 ); // $ExpectError + csscal.ndarray( cx.length, 2.0, cx, ( cx: number ): number => cx, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... +{ + const cx = new Complex64Array( 10 ); + + csscal.ndarray( cx.length, 2.0, cx, 1, '10' ); // $ExpectError + csscal.ndarray( cx.length, 2.0, cx, 1, true ); // $ExpectError + csscal.ndarray( cx.length, 2.0, cx, 1, false ); // $ExpectError + csscal.ndarray( cx.length, 2.0, cx, 1, null ); // $ExpectError + csscal.ndarray( cx.length, 2.0, cx, 1, undefined ); // $ExpectError + csscal.ndarray( cx.length, 2.0, cx, 1, [] ); // $ExpectError + csscal.ndarray( cx.length, 2.0, cx, 1, {} ); // $ExpectError + csscal.ndarray( cx.length, 2.0, cx, 1, ( cx: number ): number => cx ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const cx = new Complex64Array( 10 ); + + csscal.ndarray(); // $ExpectError + csscal.ndarray( cx.length ); // $ExpectError + csscal.ndarray( cx.length, 2.0 ); // $ExpectError + csscal.ndarray( cx.length, 2.0, cx ); // $ExpectError + csscal.ndarray( cx.length, 2.0, cx, 1 ); // $ExpectError + csscal.ndarray( cx.length, 2.0, cx, 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..c1af5fe2f143 --- /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 cx = filledarrayBy( 10, 'complex64', rand ); +console.log( cx.toString() ); + +csscal( cx.length, 2.0, cx, 1 ); +console.log( cx.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..00f722913600 --- /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} sa - constant +* @param {Complex64Array} cx - input array +* @param {integer} strideCX - `cx` stride length +* @returns {Complex64Array} input array +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* +* var cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* csscal( 3, 2.0, cx, 1 ); +* // cx => [ 2.0, 4.0, 6.0, 8.0, 10.0, 12.0 ] +*/ +function csscal( N, sa, cx, strideCX ) { + return ndarray( N, sa, cx, strideCX, stride2offset( N, strideCX ) ); +} + + +// 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..42e454f8a710 --- /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 cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* csscal( 3, 2.0, cx, 1 ); +* // cx => [ 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 cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* csscal.ndarray( 3, 2.0, cx, 1, 0 ); +* // cx => [ 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..4fcfbe8ee6c4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csscal/lib/ndarray.js @@ -0,0 +1,74 @@ +/** +* @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/float64/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} sa - constant +* @param {Complex64Array} cx - input array +* @param {integer} strideCX - `cx` stride length +* @param {NonNegativeInteger} offsetCX - starting `cx` index +* @returns {Complex64Array} input array +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* +* var cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* csscal( 3, 2.0, cx, 1, 0 ); +* // cx => [ 2.0, 4.0, 6.0, 8.0, 10.0, 12.0 ] +*/ +function csscal( N, sa, cx, strideCX, offsetCX ) { + var cx32; + var ix; + var sx; + var i; + + if ( N <= 0 || sa === 1.0 ) { + return cx; + } + // Reinterpret the input array as a real-valued array of interleaved real and imaginary components: + cx32 = reinterpret( cx, 0 ); + + // Adjust the stride and offset accordingly: + ix = offsetCX * 2; + sx = strideCX * 2; + + for ( i = 0; i < N; i++ ) { + scale( sa, cx32, 1, ix, cx32, 1, ix ); + ix += sx; + } + return cx; +} + + +// 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..7eaca000946e --- /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 `cx` by `sa`', function test( t ) { + var expected; + var cx; + + cx = 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, cx, 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( cx, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `cx` stride', function test( t ) { + var expected; + var cx; + + cx = 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, cx, 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( cx, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a negative `cx` stride', function test( t ) { + var expected; + var cx; + + cx = 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, cx, -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( cx, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a reference to the input array', function test( t ) { + var out; + var cx; + + cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + out = csscal( 4, 2.0, cx, 1 ); + + t.strictEqual( out, cx, '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 cx; + + cx = 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, cx, 1 ); + t.strictEqual( isSameComplex64Array( cx, expected ), true, 'returns expected value' ); + + csscal( 0, 2.0, cx, 1 ); + t.strictEqual( isSameComplex64Array( cx, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var expected; + var cx0; + var cx1; + + // Initial array: + cx0 = 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: + cx1 = new Complex64Array( cx0.buffer, cx0.BYTES_PER_ELEMENT*1 ); // begin at 2nd element + + csscal( 3, 2.0, cx1, 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( cx0, 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..351a9a08fdd3 --- /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 `cx` by `sa`', function test( t ) { + var expected; + var cx; + + cx = 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, cx, 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( cx, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `cx` stride', function test( t ) { + var expected; + var cx; + + cx = 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, cx, 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( cx, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a negative `cx` stride', function test( t ) { + var expected; + var cx; + + cx = 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, cx, -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( cx, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `cx` offset', function test( t ) { + var expected; + var cx; + + cx = 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, cx, 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( cx, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a reference to the input array', function test( t ) { + var out; + var cx; + + cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + out = csscal( 4, 2.0, cx, 1, 0 ); + + t.strictEqual( out, cx, '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 cx; + + cx = 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, cx, 1, 0 ); + t.strictEqual( isSameComplex64Array( cx, expected ), true, 'returns expected value' ); + + csscal( 0, 2.0, cx, 1, 0 ); + t.strictEqual( isSameComplex64Array( cx, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports complex access patterns', function test( t ) { + var expected; + var cx; + + cx = 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, cx, -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( cx, expected ), true, 'returns expected value' ); + t.end(); +});