diff --git a/lib/node_modules/@stdlib/blas/base/zdscal/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/zdscal/benchmark/benchmark.js new file mode 100644 index 000000000000..45a7085a598a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdscal/benchmark/benchmark.js @@ -0,0 +1,106 @@ +/** +* @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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var pkg = require( './../package.json' ).name; +var zdscal = require( './../lib/zdscal.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var zxbuf; + var zx; + + zxbuf = uniform( len*2, -100.0, 100.0, options ); + zx = new Complex128Array( zxbuf.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++ ) { + zdscal( zx.length, 1.01, zx, 1 ); + if ( isnan( zxbuf[ i%(len*2) ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( zxbuf[ 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/zdscal/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/zdscal/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..56f7aac50e83 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdscal/benchmark/benchmark.ndarray.js @@ -0,0 +1,106 @@ +/** +* @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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var pkg = require( './../package.json' ).name; +var zdscal = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var zxbuf; + var zx; + + zxbuf = uniform( len*2, -100.0, 100.0, options ); + zx = new Complex128Array( zxbuf.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++ ) { + zdscal( zx.length, 1.01, zx, 1, 0 ); + if ( isnan( zxbuf[ i%(len*2) ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( zxbuf[ 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/zdscal/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/zdscal/docs/repl.txt new file mode 100644 index 000000000000..9c230a233e8f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdscal/docs/repl.txt @@ -0,0 +1,118 @@ + +{{alias}}( N, alpha, zx, strideX ) + Scales a double-precision complex floating-point vector by a double- + precision floating-point constant. + + The `N` and stride parameters determine how values from `zx` are scaled by + `alpha`. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + If `N` or `strideX` is less than or equal to `0`, the function returns `zx` + unchanged. + + + Parameters + ---------- + N: integer + Number of indexed elements. + + alpha: Float64 + Complex constant. + + zx: Complex128Array + Input array. + + strideX: integer + Index increment for `zx`. + + Returns + ------- + zx: Complex128Array + Input array. + + Examples + -------- + // Standard usage: + > var zx = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > {{alias}}( 2, 5.0, zx, 1 ); + > var z = zx.get( 0 ); + > var re = {{alias:@stdlib/complex/float64/real}}( z ) + 5.0 + > var im = {{alias:@stdlib/complex/float64/imag}}( z ) + 10.0 + + // Advanced indexing: + > zx = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > {{alias}}( 2, 5.0, zx, 2 ); + > z = zx.get( 0 ); + > re = {{alias:@stdlib/complex/float64/real}}( z ) + 5.0 + > im = {{alias:@stdlib/complex/float64/imag}}( z ) + 10.0 + + // Using typed array views: + > var zx0 = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > var zx1 = new {{alias:@stdlib/array/complex128}}( zx0.buffer, zx0.BYTES_PER_ELEMENT*1 ); + > {{alias}}( 2, 5.0, zx1, 1 ); + > z = zx0.get( 1 ); + > re = {{alias:@stdlib/complex/float64/real}}( z ) + 15.0 + > im = {{alias:@stdlib/complex/float64/imag}}( z ) + 20.0 + + +{{alias}}.ndarray( N, za, zx, strideX, offsetX ) + Scales a double-precision complex floating-point vector by a double- + 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: Float64 + Float constant. + + zx: Complex128Array + Input array. + + strideX: integer + Index increment for `zx`. + + offsetX: integer + Starting index for `zx`. + + Returns + ------- + zx: Complex128Array + Input array. + + Examples + -------- + // Standard usage: + > var zx = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > {{alias}}.ndarray( 2, 5.0, zx, 1, 0 ); + > var z = zx.get( 0 ); + > var re = {{alias:@stdlib/complex/float64/real}}( z ) + 5.0 + > var im = {{alias:@stdlib/complex/float64/imag}}( z ) + 10.0 + + // Advanced indexing: + > zx = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + > {{alias}}.ndarray( 2, 2.0, zx, 1, 2 ); + > z = zx.get( 2 ); + > re = {{alias:@stdlib/complex/float64/real}}( z ) + 10.0 + > im = {{alias:@stdlib/complex/float64/imag}}( z ) + 12.0 + + See Also + -------- diff --git a/lib/node_modules/@stdlib/blas/base/zdscal/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/zdscal/docs/types/index.d.ts new file mode 100644 index 000000000000..39c8d05fa908 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdscal/docs/types/index.d.ts @@ -0,0 +1,99 @@ +/* +* @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 { Complex128Array } from '@stdlib/types/array'; + +/** +* Interface describing `zdscal`. +*/ +interface Routine { + /** + * Scales a double-precision complex floating-point vector by a double-precision floating-point constant. + * + * @param N - number of indexed elements + * @param alpha - scalar constant + * @param zx - input array + * @param strideX - `zx` stride length + * @returns input array + * + * @example + * var Complex128Array = require( '@stdlib/array/complex128' ); + * + * var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + * + * zdscal( 3, 2.0, zx, 1 ); + * // y => [ 2.0, 4.0, 6.0, 8.0, 10.0, 12.0 ] + */ + ( N: number, alpha: number, zx: Complex128Array, strideX: number ): Complex128Array; + + /** + * Scales a double-precision complex floating-point vector by a double-precision floating-point constant. + * + * @param N - number of indexed elements + * @param alpha - scalar constant + * @param zx - input array + * @param strideX - `zx` stride length + * @param offsetX - starting index for `zx` + * @returns input array + * + * @example + * var Complex128Array = require( '@stdlib/array/complex128' ); + * + * var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + * + * zdscal.ndarray( 3, 2.0, zx, 1, 0 ); + * // y => [ 2.0, 4.0, 6.0, 8.0, 10.0, 12.0 ] + */ + ndarray( N: number, alpha: number, zx: Complex128Array, strideX: number, offsetX: number ): Complex128Array; +} + +/** +* Scales a double-precision complex floating-point vector by a double-precision floating-point constant. +* +* @param N - number of indexed elements +* @param alpha - scalar constant +* @param zx - input array +* @param strideX - `zx` stride length +* @returns input array +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* +* var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* zdscal( 3, 2.0, zx, 1 ); +* // y => [ 2.0, 4.0, 6.0, 8.0, 10.0, 12.0 ] +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* +* var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* zdscal.ndarray( 3, 2.0, zx, 1, 0 ); +* // y => [ 2.0, 4.0, 6.0, 8.0, 10.0, 12.0 ] +*/ +declare var zdscal: Routine; + + +// EXPORTS // + +export = zdscal; diff --git a/lib/node_modules/@stdlib/blas/base/zdscal/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/zdscal/docs/types/test.ts new file mode 100644 index 000000000000..907a823aaba0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdscal/docs/types/test.ts @@ -0,0 +1,191 @@ +/* +* @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 Complex128Array = require( '@stdlib/array/complex128' ); +import Complex128 = require( '@stdlib/complex/float64/ctor' ); +import zdscal = require( './index' ); + + +// TESTS // + +// The function returns a Complex128Array... +{ + const zx = new Complex128Array( 10 ); + + zdscal( zx.length, 5.0, zx, 1 ); // $ExpectType Complex128Array +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const zx = new Complex128Array( 10 ); + + zdscal( '10', 5.0, zx, 1 ); // $EzxpectError + zdscal( true, 5.0, zx, 1 ); // $ExpectError + zdscal( false, 5.0, zx, 1 ); // $ExpectError + zdscal( null, 5.0, zx, 1 ); // $ExpectError + zdscal( undefined, 5.0, zx, 1 ); // $ExpectError + zdscal( [], 5.0, zx, 1 ); // $ExpectError + zdscal( {}, 5.0, zx, 1 ); // $ExpectError + zdscal( ( zx: number ): number => zx, 5.0, zx, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a complex number... +{ + const zx = new Complex128Array( 10 ); + + zdscal( zx.length, 10, zx, 1 ); // $ExpectError + zdscal( zx.length, '10', zx, 1 ); // $ExpectError + zdscal( zx.length, true, zx, 1 ); // $ExpectError + zdscal( zx.length, false, zx, 1 ); // $ExpectError + zdscal( zx.length, null, zx, 1 ); // $ExpectError + zdscal( zx.length, undefined, zx, 1 ); // $ExpectError + zdscal( zx.length, [ '1' ], zx, 1 ); // $ExpectError + zdscal( zx.length, {}, zx, 1 ); // $ExpectError + zdscal( zx.length, ( zx: number ): number => zx, zx, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a Complex128Array... +{ + const zx = new Complex128Array( 10 ); + + zdscal( zx.length, 5.0, 10, 1 ); // $ExpectError + zdscal( zx.length, 5.0, '10', 1 ); // $ExpectError + zdscal( zx.length, 5.0, true, 1 ); // $ExpectError + zdscal( zx.length, 5.0, false, 1 ); // $ExpectError + zdscal( zx.length, 5.0, null, 1 ); // $ExpectError + zdscal( zx.length, 5.0, undefined, 1 ); // $ExpectError + zdscal( zx.length, 5.0, [ '1' ], 1 ); // $ExpectError + zdscal( zx.length, 5.0, {}, 1 ); // $ExpectError + zdscal( zx.length, 5.0, ( zx: number ): number => zx, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const zx = new Complex128Array( 10 ); + + zdscal( zx.length, 5.0, zx, '10' ); // $ExpectError + zdscal( zx.length, 5.0, zx, true ); // $ExpectError + zdscal( zx.length, 5.0, zx, false ); // $ExpectError + zdscal( zx.length, 5.0, zx, null ); // $ExpectError + zdscal( zx.length, 5.0, zx, undefined ); // $ExpectError + zdscal( zx.length, 5.0, zx, [] ); // $ExpectError + zdscal( zx.length, 5.0, zx, {} ); // $ExpectError + zdscal( zx.length, 5.0, zx, ( zx: number ): number => zx ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const zx = new Complex128Array( 10 ); + + zdscal(); // $ExpectError + zdscal( zx.length ); // $ExpectError + zdscal( zx.length, 5.0 ); // $ExpectError + zdscal( zx.length, 5.0, zx ); // $ExpectError + zdscal( zx.length, 5.0, zx, 1, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Complex128Array... +{ + const zx = new Complex128Array( 10 ); + + zdscal.ndarray( zx.length, 5.0, zx, 1, 0 ); // $ExpectType Complex128Array +} + +// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... +{ + const zx = new Complex128Array( 10 ); + + zdscal.ndarray( '10', 5.0, zx, 1, 0 ); // $ExpectError + zdscal.ndarray( true, 5.0, zx, 1, 0 ); // $ExpectError + zdscal.ndarray( false, 5.0, zx, 1, 0 ); // $ExpectError + zdscal.ndarray( null, 5.0, zx, 1, 0 ); // $ExpectError + zdscal.ndarray( undefined, 5.0, zx, 1, 0 ); // $ExpectError + zdscal.ndarray( [], 5.0, zx, 1, 0 ); // $ExpectError + zdscal.ndarray( {}, 5.0, zx, 1, 0 ); // $ExpectError + zdscal.ndarray( ( zx: number ): number => zx, 5.0, zx, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a second argument which is not a complex number... +{ + const zx = new Complex128Array( 10 ); + + zdscal.ndarray( zx.length, 10, zx, 1, 0 ); // $ExpectError + zdscal.ndarray( zx.length, '10', zx, 1, 0 ); // $ExpectError + zdscal.ndarray( zx.length, true, zx, 1, 0 ); // $ExpectError + zdscal.ndarray( zx.length, false, zx, 1, 0 ); // $ExpectError + zdscal.ndarray( zx.length, null, zx, 1, 0 ); // $ExpectError + zdscal.ndarray( zx.length, undefined, zx, 1, 0 ); // $ExpectError + zdscal.ndarray( zx.length, [ '1' ], zx, 1, 0 ); // $ExpectError + zdscal.ndarray( zx.length, {}, zx, 1, 0 ); // $ExpectError + zdscal.ndarray( zx.length, ( zx: number ): number => zx, zx, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a third argument which is not a Complex128Array... +{ + const zx = new Complex128Array( 10 ); + + zdscal( zx.length, 5.0, 10, 1, 0 ); // $ExpectError + zdscal( zx.length, 5.0, '10', 1, 0 ); // $ExpectError + zdscal( zx.length, 5.0, true, 1, 0 ); // $ExpectError + zdscal( zx.length, 5.0, false, 1, 0 ); // $ExpectError + zdscal( zx.length, 5.0, null, 1, 0 ); // $ExpectError + zdscal( zx.length, 5.0, undefined, 1, 0 ); // $ExpectError + zdscal( zx.length, 5.0, [ '1' ], 1, 0 ); // $ExpectError + zdscal( zx.length, 5.0, {}, 1, 0 ); // $ExpectError + zdscal( zx.length, 5.0, ( zx: number ): number => zx, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... +{ + const zx = new Complex128Array( 10 ); + + zdscal.ndarray( zx.length, 5.0, zx, '10', 0 ); // $ExpectError + zdscal.ndarray( zx.length, 5.0, zx, true, 0 ); // $ExpectError + zdscal.ndarray( zx.length, 5.0, zx, false, 0 ); // $ExpectError + zdscal.ndarray( zx.length, 5.0, zx, null, 0 ); // $ExpectError + zdscal.ndarray( zx.length, 5.0, zx, undefined, 0 ); // $ExpectError + zdscal.ndarray( zx.length, 5.0, zx, [], 0 ); // $ExpectError + zdscal.ndarray( zx.length, 5.0, zx, {}, 0 ); // $ExpectError + zdscal.ndarray( zx.length, 5.0, zx, ( zx: number ): number => zx, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... +{ + const zx = new Complex128Array( 10 ); + + zdscal.ndarray( zx.length, 5.0, zx, 1, '10' ); // $ExpectError + zdscal.ndarray( zx.length, 5.0, zx, 1, true ); // $ExpectError + zdscal.ndarray( zx.length, 5.0, zx, 1, false ); // $ExpectError + zdscal.ndarray( zx.length, 5.0, zx, 1, null ); // $ExpectError + zdscal.ndarray( zx.length, 5.0, zx, 1, undefined ); // $ExpectError + zdscal.ndarray( zx.length, 5.0, zx, 1, [] ); // $ExpectError + zdscal.ndarray( zx.length, 5.0, zx, 1, {} ); // $ExpectError + zdscal.ndarray( zx.length, 5.0, zx, 1, ( zx: number ): number => zx ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const zx = new Complex128Array( 10 ); + + zdscal.ndarray(); // $ExpectError + zdscal.ndarray( zx.length ); // $ExpectError + zdscal.ndarray( zx.length, 5.0 ); // $ExpectError + zdscal.ndarray( zx.length, 5.0, zx ); // $ExpectError + zdscal.ndarray( zx.length, 5.0, zx, 1 ); // $ExpectError + zdscal.ndarray( zx.length, 5.0, zx, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/base/zdscal/examples/index.js b/lib/node_modules/@stdlib/blas/base/zdscal/examples/index.js new file mode 100644 index 000000000000..4cd1587f767b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdscal/examples/index.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'; + +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var zscal = require( '@stdlib/blas/base/zscal' ); + +function rand() { + return new Complex128( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) ); +} + +var zx = filledarrayBy( 10, 'complex128', rand ); +console.log( zx.toString() ); + +// Scale elements from `zx` by `za`: +zscal( zx.length, 5.0, zx, 1 ); +console.log( zx.get( zx.length-1 ).toString() ); diff --git a/lib/node_modules/@stdlib/blas/base/zdscal/lib/index.js b/lib/node_modules/@stdlib/blas/base/zdscal/lib/index.js new file mode 100644 index 000000000000..ed492a653093 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdscal/lib/index.js @@ -0,0 +1,68 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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 multiply a double-precision complex floating-point vector by a double-precision floating-point constant. +* +* @module @stdlib/blas/base/zdscal +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var zdscal = require( '@stdlib/blas/base/zdscal' ); +* +* var zx = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); +* +* zdscal( zx.length, 5.0, x, 1 ); +* // zx => [ -10.0, 5.0, 15.0, -25.0, 20.0, 0.0, -5.0, -15.0 ] +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var zdscal = require( '@stdlib/blas/base/zdscal' ); +* +* var zx = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); +* +* zdscal.ndarray( zx.length, 5.0, x, 1, 0 ); +* // zx => [ -10.0, 5.0, 15.0, -25.0, 20.0, 0.0, -5.0, -15.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 zdscal; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + zdscal = main; +} else { + zdscal = tmp; +} + + +// EXPORTS // + +module.exports = zdscal; + +// exports: { "ndarray": "zdscal.ndarray" } diff --git a/lib/node_modules/@stdlib/blas/base/zdscal/lib/main.js b/lib/node_modules/@stdlib/blas/base/zdscal/lib/main.js new file mode 100644 index 000000000000..7a1d793dfe4a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdscal/lib/main.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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 zdscal = require( './zdscal.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( zdscal, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = zdscal; diff --git a/lib/node_modules/@stdlib/blas/base/zdscal/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/zdscal/lib/ndarray.js new file mode 100644 index 000000000000..ce40cbaff256 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdscal/lib/ndarray.js @@ -0,0 +1,97 @@ +/** +* @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'; + +// VARIABLES // + +var M = 5; + + +// MAIN // + +/** +* Scales a double-precision complex floating-point vector by a double-precision floating-point constant. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {Complex128} alpha - constant +* @param {Complex128Array} zx - input array +* @param {integer} strideX - `zx` stride length +* @param {NonNegativeInteger} offsetX - starting `zx` index +* @returns {Complex128Array} input array +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* +* var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* zscal( 3, 2.0, zx, 1, 0 ); +* // y => [ 2.0, 4.0, 6.0, 8.0, 10.0, 12.0 ] +*/ +function zdscal( N, alpha, zx, strideX, offsetX ) { + var ix; + var m; + var i; + + if ( N <= 0 || alpha === 1.0 ) { + return zx; + } + ix = offsetX; + + // Use loop unrolling if the stride is equal to `1`... + if ( strideX === 1 ) { + m = N % M; + + // If we have a remainder, run a clean-up loop... + if ( m > 0 ) { + for ( i = 0; i < m; i++ ) { + zx[ ix ] *= alpha; + zx[ ix+ 1 ] *= alpha; + ix += 2; + } + } + if ( N < M ) { + return zx; + } + for ( i = m; i < N; i += M ) { + zx[ ix ] *= alpha; + zx[ ix+1 ] *= alpha; + zx[ ix+2 ] *= alpha; + zx[ ix+3 ] *= alpha; + zx[ ix+4 ] *= alpha; + zx[ ix+5 ] *= alpha; + zx[ ix+6 ] *= alpha; + zx[ ix+7 ] *= alpha; + zx[ ix+8 ] *= alpha; + zx[ ix+9 ] *= alpha; + ix += 2 * M; + } + return zx; + } + for ( i = 0; i < N; i++ ) { + zx[ ix ] *= alpha; + zx[ ix+1 ] *= alpha; + ix += 2 * strideX; + } + return zx; +} + + +// EXPORTS // + +module.exports = zdscal; diff --git a/lib/node_modules/@stdlib/blas/base/zdscal/lib/zdscal.js b/lib/node_modules/@stdlib/blas/base/zdscal/lib/zdscal.js new file mode 100644 index 000000000000..17705e4b8adb --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdscal/lib/zdscal.js @@ -0,0 +1,54 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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 double-precision complex floating-point vector by a double-precision floating-point constant. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {number} alpha - scalar +* @param {Float64Array} x - input array +* @param {integer} stride - index increment +* @returns {Float64Array} input array +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* +* var zx = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); +* +* dscal( zx.length / 2, 5.0, zx, 1 ); +* // zx => [ -10.0, 5.0, 15.0, -25.0, 20.0, 0.0, -5.0, -15.0 ] +*/ +function zdscal( N, alpha, zx, stride ) { + var ox = stride2offset( N, stride ); + return ndarray( N, alpha, zx, stride, ox ); +} + + +// EXPORTS // + +module.exports = zdscal; diff --git a/lib/node_modules/@stdlib/blas/base/zdscal/package.json b/lib/node_modules/@stdlib/blas/base/zdscal/package.json new file mode 100644 index 000000000000..acd8ccf5ab93 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdscal/package.json @@ -0,0 +1,78 @@ +{ + "name": "@stdlib/blas/base/zdscal", + "version": "0.0.0", + "description": "Scale a double-precision complex floating-point vector by a double-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", + "gypfile": true, + "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", + "zdscal", + "scale", + "vector", + "typed", + "array", + "ndarray", + "complex", + "complex128", + "double", + "float64", + "float64array" + ], + "__stdlib__": { + "wasm": false + } + }