diff --git a/lib/node_modules/@stdlib/math/base/special/csignumf/README.md b/lib/node_modules/@stdlib/math/base/special/csignumf/README.md index cb5d79226780..2ba9cbde5ea7 100644 --- a/lib/node_modules/@stdlib/math/base/special/csignumf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/csignumf/README.md @@ -22,16 +22,12 @@ limitations under the License. > Evaluate the [signum][signum] function of a single-precision complex floating-point number. - -
- -
## Usage @@ -77,19 +73,58 @@ im = imag( v ); // returns NaN ``` -
+#### csignumf.assign( re, im, out, strideOut, offsetOut ) - +Evaluates the signum function of single-precision complex floating-point number and assigns the result to a provided output array. + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); - +var out = new Float32Array( 2 ); +var v = csignumf.assign( -4.2, 5.5, out, 1, 0 ); +// returns [ ~-0.607, ~0.795 ] -
+var bool = ( out === v ); +// returns true +``` -
+The function supports the following parameters: - +- **re**: real component of the complex number. +- **im**: imaginary component of the complex number. +- **out**: output array. +- **strideOut**: stride length for `out`. +- **offsetOut**: starting index for `out`. + +#### csignumf.strided( z, sz, oz, out, so, oo ) - +Evaluates the signum function for single-precision complex floating-point number stored in a real-valued strided array and assigns results to a strided output array. + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var z = new Float32Array( [ -4.2, 5.5 ] ); +var out = new Float32Array( 2 ); + +var v = csignumf.strided( z, 1, 0, out, 1, 0 ); +// returns [ ~-0.607, ~0.795 ] + +var bool = ( out === v ); +// returns true +``` + +The function supports the following parameters: + +- **z**: complex number strided array view. +- **sz**: stride length for `z`. +- **oz**: starting index for `z`. +- **out**: output array. +- **so**: stride length for `out`. +- **oo**: starting index for `out`. + + + +
diff --git a/lib/node_modules/@stdlib/math/base/special/csignumf/benchmark/benchmark.assign.js b/lib/node_modules/@stdlib/math/base/special/csignumf/benchmark/benchmark.assign.js new file mode 100644 index 000000000000..f09c60f486b6 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/csignumf/benchmark/benchmark.assign.js @@ -0,0 +1,69 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var pkg = require( './../package.json' ).name; +var csignumf = require( './../lib' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float32' +}; + + +// MAIN // + +bench( pkg+':assign', function benchmark( b ) { + var out; + var re; + var im; + var N; + var i; + var j; + + N = 100; + re = uniform( N, -500.0, 500.0, options ); + im = uniform( N, -500.0, 500.0, options ); + + out = new Float32Array( 2 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + j = i % N; + out = csignumf.assign( re[ j ], im[ j ], out, 1, 0 ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + + if ( isnanf( out[ 0 ] ) || isnanf( out[ 1 ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/csignumf/benchmark/benchmark.strided.js b/lib/node_modules/@stdlib/math/base/special/csignumf/benchmark/benchmark.strided.js new file mode 100644 index 000000000000..6342e1c41e23 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/csignumf/benchmark/benchmark.strided.js @@ -0,0 +1,65 @@ +/** +* @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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var Float32Array = require( '@stdlib/array/float32' ); +var pkg = require( './../package.json' ).name; +var csignumf = require( './../lib' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float32' +}; + + +// MAIN // + +bench( pkg+':strided', function benchmark( b ) { + var out; + var z; + var N; + var i; + var j; + + N = 50; + z = uniform( N*2, -500.0, 500.0, options ); + out = new Float32Array( 2 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + j = ( i % N ) * 2; + out = csignumf.strided( z, 1, j, out, 1, 0 ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( isnan( out[ 0 ] ) || isnan( out[ 1 ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/csignumf/docs/repl.txt b/lib/node_modules/@stdlib/math/base/special/csignumf/docs/repl.txt index 7e43ca521e76..08c29f9ad712 100644 --- a/lib/node_modules/@stdlib/math/base/special/csignumf/docs/repl.txt +++ b/lib/node_modules/@stdlib/math/base/special/csignumf/docs/repl.txt @@ -22,6 +22,76 @@ > var im = {{alias:@stdlib/complex/float32/imag}}( v ) ~0.795 - See Also + +{{alias}}.assign( re, im, out, strideOut, offsetOut ) + Evaluates the signum function of a single-precision floating-point complex + number and assigns results to a provided output array. + + Parameters + ---------- + re: number + Real component of the complex number. + + im: number + Imaginary component of the complex number. + + out: ArrayLikeObject + Output array. + + strideOut: integer + Stride length. + + offsetOut: integer + Starting index. + + Returns + ------- + out: ArrayLikeObject + Output array. + + Examples + -------- + > var out = new {{alias:@stdlib/array/float32}}( 2 ); + > {{alias}}.assign( -4.2, 5.5, out, 1, 0 ) + [ ~-0.607, ~0.795 ] + + +{{alias}}.strided( z, sz, oz, out, so, oo ) + Evaluates the signum function of a single-precision floating-point complex + number stored in a real-valued strided array view and assigns results to a + provided strided output array. + + Parameters + ---------- + z: ArrayLikeObject + Complex number view. + + sz: integer + Stride length for `z`. + + oz: integer + Starting index for `z`. + + out: ArrayLikeObject + Output array. + + so: integer + Stride length for `out`. + + oo: integer + Starting index for `out`. + + Returns + ------- + out: ArrayLikeObject + Output array. + + Examples -------- + > var z = new {{alias:@stdlib/array/float32}}( [ -4.2, 5.5 ] ); + > var out = new {{alias:@stdlib/array/float32}}( 2 ); + > {{alias}}.strided( z, 1, 0, out, 1, 0 ) + [ ~-0.607, ~0.795 ] + See Also + -------- diff --git a/lib/node_modules/@stdlib/math/base/special/csignumf/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/csignumf/docs/types/index.d.ts index 329284c21864..552ad93d8891 100644 --- a/lib/node_modules/@stdlib/math/base/special/csignumf/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/math/base/special/csignumf/docs/types/index.d.ts @@ -21,6 +21,79 @@ /// import { Complex64 } from '@stdlib/types/complex'; +import { NumericArray, Collection } from '@stdlib/types/array'; + +/** +* Interface for evaluating the signum function of a single-precision complex number. +*/ +interface Csignumf { + /** + * Evaluates the signum function of a single-precision complex floating-point number. + * + * @param z - complex number + * @returns result + * + * @example + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * + * var z = new Complex64( -4.2, 5.5 ); + * // returns + * + * var out = csignumf( z ); + * // returns + * + * var re = real( out ); + * // returns ~-0.607 + * + * var im = imag( out ); + * // returns ~0.795 + */ + ( z: Complex64 ): Complex64; + + /** + * Evaluates the signum function and assigns the result to a provided output array. + * + * @param re - real component of the complex number + * @param im - imaginary component of the complex number + * @param out - output array + * @param strideOut - stride length + * @param offsetOut - starting index + * @returns output array + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * + * var out = new Float32Array( 2 ); + * var v = csignumf.assign( -4.2, 5.5, out, 1, 0 ); + * // returns [ ~-0.607, ~0.795 ] + * + * var bool = (out === v); + * // returns true + */ + assign>( re: number, im: number, out: T, strideOut: number, offsetOut: number ): T; + + /** + * Evaluates the signum function for single-precision complex floating-point numbers stored in real-valued strided array views and assigns results to a provided strided output array. + * + * @param z - complex number view + * @param strideZ - stride length for `z` + * @param offsetZ - starting index for `z` + * @param out - output array + * @param strideOut - stride length for `out` + * @param offsetOut - starting index for `out` + * @returns output array + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * + * var z = new Float32Array( [ -4.2, 5.5 ] ); + * var out = csignumf.strided( z, 1, 0, out, 1, 0 ); + * // returns [ ~-0.607, ~0.795 ] + */ + strided, U extends NumericArray | Collection>( z: T, strideZ: number, offsetZ: number, out: U, strideOut: number, offsetOut: number ): U; +} /** * Evaluates the signum function of a single-precision complex floating-point number. @@ -30,19 +103,40 @@ import { Complex64 } from '@stdlib/types/complex'; * * @example * var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* var real = require( '@stdlib/complex/float32/real' ); -* var imag = require( '@stdlib/complex/float32/imag' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* +* var z = new Complex64( -4.2, 5.5 ); +* // returns * -* var v = csignumf( new Complex64( -4.2, 5.5 ) ); +* var out = csignumf( z ); * // returns * -* var re = real( v ); +* var re = real( out ); * // returns ~-0.607 * -* var im = imag( v ); +* var im = imag( out ); * // returns ~0.795 +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var out = new Float32Array( 2 ); +* var v = csignumf.assign( -4.2, 5.5, out, 1, 0 ); +* // returns [ ~-0.607, ~0.795 ] +* +* var bool = (out === v); +* // returns true +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var z = new Float32Array( [ -4.2, 5.5 ] ); +* +* var out = csignumf.strided( z, 1, 0, out, 1, 0 ); +* // returns [ ~-0.607, ~0.795 ] */ -declare function csignumf( z: Complex64 ): Complex64; +declare const csignumf: Csignumf; // EXPORTS // diff --git a/lib/node_modules/@stdlib/math/base/special/csignumf/docs/types/test.ts b/lib/node_modules/@stdlib/math/base/special/csignumf/docs/types/test.ts index b3befff79ae5..a614cf67bf80 100644 --- a/lib/node_modules/@stdlib/math/base/special/csignumf/docs/types/test.ts +++ b/lib/node_modules/@stdlib/math/base/special/csignumf/docs/types/test.ts @@ -43,3 +43,203 @@ import csignumf = require( './index' ); { csignumf(); // $ExpectError } + +// Attached to the main export is an `assign` method which returns a collection... +{ + csignumf.assign( 1.0, 1.0, new Float64Array( 2 ), 1, 0 ); // $ExpectType Float64Array + csignumf.assign( 1.0, 1.0, new Float32Array( 2 ), 1, 0 ); // $ExpectType Float32Array + csignumf.assign( 1.0, 1.0, [ 0.0, 0.0 ], 1, 0 ); // $ExpectType number[] +} + +// The compiler throws an error if the `assign` method is provided a first argument which is not a number... +{ + const out = new Float32Array( 2 ); + + csignumf.assign( true, 2.0, out, 1, 0 ); // $ExpectError + csignumf.assign( false, 2.0, out, 1, 0 ); // $ExpectError + csignumf.assign( null, 2.0, out, 1, 0 ); // $ExpectError + csignumf.assign( undefined, 2.0, out, 1, 0 ); // $ExpectError + csignumf.assign( '5', 2.0, out, 1, 0 ); // $ExpectError + csignumf.assign( [], 2.0, out, 1, 0 ); // $ExpectError + csignumf.assign( {}, 2.0, out, 1, 0 ); // $ExpectError + csignumf.assign( ( x: number ): number => x, 2.0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided a second argument which is not a number... +{ + const out = new Float32Array( 2 ); + + csignumf.assign( 1.0, true, out, 1, 0 ); // $ExpectError + csignumf.assign( 1.0, false, out, 1, 0 ); // $ExpectError + csignumf.assign( 1.0, null, out, 1, 0 ); // $ExpectError + csignumf.assign( 1.0, undefined, out, 1, 0 ); // $ExpectError + csignumf.assign( 1.0, '5', out, 1, 0 ); // $ExpectError + csignumf.assign( 1.0, [], out, 1, 0 ); // $ExpectError + csignumf.assign( 1.0, {}, out, 1, 0 ); // $ExpectError + csignumf.assign( 1.0, ( x: number ): number => x, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided a third argument which is not a collection... +{ + csignumf.assign( 1.0, 2.0, 1, 1, 0 ); // $ExpectError + csignumf.assign( 1.0, 2.0, true, 1, 0 ); // $ExpectError + csignumf.assign( 1.0, 2.0, false, 1, 0 ); // $ExpectError + csignumf.assign( 1.0, 2.0, null, 1, 0 ); // $ExpectError + csignumf.assign( 1.0, 2.0, undefined, 1, 0 ); // $ExpectError + csignumf.assign( 1.0, 2.0, '5', 1, 0 ); // $ExpectError + csignumf.assign( 1.0, 2.0, [ '5' ], 1, 0 ); // $ExpectError + csignumf.assign( 1.0, 2.0, {}, 1, 0 ); // $ExpectError + csignumf.assign( 1.0, 2.0, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided a fourth argument which is not a number... +{ + const out = new Float32Array( 2 ); + + csignumf.assign( 1.0, 2.0, out, true, 0 ); // $ExpectError + csignumf.assign( 1.0, 2.0, out, false, 0 ); // $ExpectError + csignumf.assign( 1.0, 2.0, out, null, 0 ); // $ExpectError + csignumf.assign( 1.0, 2.0, out, undefined, 0 ); // $ExpectError + csignumf.assign( 1.0, 2.0, out, '5', 0 ); // $ExpectError + csignumf.assign( 1.0, 2.0, out, [], 0 ); // $ExpectError + csignumf.assign( 1.0, 2.0, out, {}, 0 ); // $ExpectError + csignumf.assign( 1.0, 2.0, out, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided a fifth argument which is not a number... +{ + const out = new Float32Array( 2 ); + + csignumf.assign( 1.0, 2.0, out, 1, true ); // $ExpectError + csignumf.assign( 1.0, 2.0, out, 1, false ); // $ExpectError + csignumf.assign( 1.0, 2.0, out, 1, null ); // $ExpectError + csignumf.assign( 1.0, 2.0, out, 1, undefined ); // $ExpectError + csignumf.assign( 1.0, 2.0, out, 1, '5' ); // $ExpectError + csignumf.assign( 1.0, 2.0, out, 1, [] ); // $ExpectError + csignumf.assign( 1.0, 2.0, out, 1, {} ); // $ExpectError + csignumf.assign( 1.0, 2.0, out, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... +{ + const out = new Float32Array( 2 ); + + csignumf.assign(); // $ExpectError + csignumf.assign( 1.0 ); // $ExpectError + csignumf.assign( 1.0, 2.0 ); // $ExpectError + csignumf.assign( 1.0, 2.0, out ); // $ExpectError + csignumf.assign( 1.0, 2.0, out, 1 ); // $ExpectError + csignumf.assign( 1.0, 2.0, out, 1, 0, {} ); // $ExpectError +} + +// Attached to the main export is a `strided` method which returns a collection... +{ + const z = new Float32Array( 2 ); + + csignumf.strided( z, 1, 0, new Float64Array( 2 ), 1, 0 ); // $ExpectType Float64Array + csignumf.strided( z, 1, 0, new Float32Array( 2 ), 1, 0 ); // $ExpectType Float32Array + csignumf.strided( z, 1, 0, [ 0.0, 0.0 ], 1, 0 ); // $ExpectType number[] +} + +// The compiler throws an error if the `strided` method is provided a first argument which is not a collection... +{ + const z = new Float32Array( 2 ); + const out = new Float32Array( z.length ); + + csignumf.strided( true, 1, 0, out, 1, 0 ); // $ExpectError + csignumf.strided( false, 1, 0, out, 1, 0 ); // $ExpectError + csignumf.strided( null, 1, 0, out, 1, 0 ); // $ExpectError + csignumf.strided( undefined, 1, 0, out, 1, 0 ); // $ExpectError + csignumf.strided( '5', 1, 0, out, 1, 0 ); // $ExpectError + csignumf.strided( [ '5' ], 1, 0, out, 1, 0 ); // $ExpectError + csignumf.strided( {}, 1, 0, out, 1, 0 ); // $ExpectError + csignumf.strided( ( x: number ): number => x, 1, 0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `strided` method is provided a second argument which is not a number... +{ + const z = new Float32Array( 2 ); + const out = new Float32Array( z.length ); + + csignumf.strided( z, true, 0, out, 1, 0 ); // $ExpectError + csignumf.strided( z, false, 0, out, 1, 0 ); // $ExpectError + csignumf.strided( z, null, 0, out, 1, 0 ); // $ExpectError + csignumf.strided( z, undefined, 0, out, 1, 0 ); // $ExpectError + csignumf.strided( z, '5', 0, out, 1, 0 ); // $ExpectError + csignumf.strided( z, [ '5' ], 0, out, 1, 0 ); // $ExpectError + csignumf.strided( z, {}, 0, out, 1, 0 ); // $ExpectError + csignumf.strided( z, ( x: number ): number => x, 0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `strided` method is provided a third argument which is not a number... +{ + const z = new Float32Array( 2 ); + const out = new Float32Array( z.length ); + + csignumf.strided( z, 1, true, out, 1, 0 ); // $ExpectError + csignumf.strided( z, 1, false, out, 1, 0 ); // $ExpectError + csignumf.strided( z, 1, null, out, 1, 0 ); // $ExpectError + csignumf.strided( z, 1, undefined, out, 1, 0 ); // $ExpectError + csignumf.strided( z, 1, '5', out, 1, 0 ); // $ExpectError + csignumf.strided( z, 1, [ '5' ], out, 1, 0 ); // $ExpectError + csignumf.strided( z, 1, {}, out, 1, 0 ); // $ExpectError + csignumf.strided( z, 1, ( x: number ): number => x, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `strided` method is provided a fourth argument which is not a collection... +{ + const z = new Float32Array( 2 ); + + csignumf.strided( z, 1, 0, true, 1, 0 ); // $ExpectError + csignumf.strided( z, 1, 0, false, 1, 0 ); // $ExpectError + csignumf.strided( z, 1, 0, null, 1, 0 ); // $ExpectError + csignumf.strided( z, 1, 0, undefined, 1, 0 ); // $ExpectError + csignumf.strided( z, 1, 0, '5', 1, 0 ); // $ExpectError + csignumf.strided( z, 1, 0, [ '5' ], 1, 0 ); // $ExpectError + csignumf.strided( z, 1, 0, {}, 1, 0 ); // $ExpectError + csignumf.strided( z, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `strided` method is provided a fifth argument which is not a number... +{ + const z = new Float32Array( 2 ); + const out = new Float32Array( z.length ); + + csignumf.strided( z, 1, 0, out, true, 0 ); // $ExpectError + csignumf.strided( z, 1, 0, out, false, 0 ); // $ExpectError + csignumf.strided( z, 1, 0, out, null, 0 ); // $ExpectError + csignumf.strided( z, 1, 0, out, undefined, 0 ); // $ExpectError + csignumf.strided( z, 1, 0, out, '5', 0 ); // $ExpectError + csignumf.strided( z, 1, 0, out, [ '5' ], 0 ); // $ExpectError + csignumf.strided( z, 1, 0, out, {}, 0 ); // $ExpectError + csignumf.strided( z, 1, 0, out, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the `strided` method is provided a sixth argument which is not a number... +{ + const z = new Float32Array( 2 ); + const out = new Float32Array( z.length ); + + csignumf.strided( z, 1, 0, out, 1, true ); // $ExpectError + csignumf.strided( z, 1, 0, out, 1, false ); // $ExpectError + csignumf.strided( z, 1, 0, out, 1, null ); // $ExpectError + csignumf.strided( z, 1, 0, out, 1, undefined ); // $ExpectError + csignumf.strided( z, 1, 0, out, 1, '5' ); // $ExpectError + csignumf.strided( z, 1, 0, out, 1, [ '5' ] ); // $ExpectError + csignumf.strided( z, 1, 0, out, 1, {} ); // $ExpectError + csignumf.strided( z, 1, 0, out, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `strided` method is provided an unsupported number of arguments... +{ + const z = new Float32Array( 2 ); + const out = new Float32Array( z.length ); + + csignumf.strided(); // $ExpectError + csignumf.strided( z ); // $ExpectError + csignumf.strided( z, 1 ); // $ExpectError + csignumf.strided( z, 1, 0 ); // $ExpectError + csignumf.strided( z, 1, 0, out ); // $ExpectError + csignumf.strided( z, 1, 0, out, 1 ); // $ExpectError + csignumf.strided( z, 1, 0, out, 1, 0, {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/math/base/special/csignumf/lib/assign.js b/lib/node_modules/@stdlib/math/base/special/csignumf/lib/assign.js new file mode 100644 index 000000000000..c1282a6dbae8 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/csignumf/lib/assign.js @@ -0,0 +1,64 @@ +/** +* @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 Complex64 = require( '@stdlib/complex/float32/ctor' ); +var f32 = require( '@stdlib/number/float64/base/to-float32' ); +var real = require( '@stdlib/complex/float32/real' ); +var imag = require( '@stdlib/complex/float32/imag' ); +var csignumf = require( './main.js' ); + + +// MAIN // + +/** +* Evaluates the signum function of a single-precision floating-point complex number and assigns results to a provided output array. +* +* @param {number} re - real component +* @param {number} im - imaginary component +* @param {Collection} out - output array +* @param {integer} strideOut - stride length +* @param {NonNegativeInteger} offsetOut - starting index +* @returns {Collection} output array +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var out = assign( -4.2, 5.5, new Float32Array( 2 ), 1, 0 ); +* // returns [ ~-0.607, ~0.795 ] +*/ +function assign( re, im, out, strideOut, offsetOut ) { + var z; + var v; + + z = new Complex64( f32( re ), f32( im ) ); + v = csignumf( z ); + + out[ offsetOut ] = real( v ); + out[ offsetOut + strideOut ] = imag( v ); + + return out; +} + + +// EXPORTS // + +module.exports = assign; diff --git a/lib/node_modules/@stdlib/math/base/special/csignumf/lib/index.js b/lib/node_modules/@stdlib/math/base/special/csignumf/lib/index.js index 6c012fe58fee..3b19fda51de3 100644 --- a/lib/node_modules/@stdlib/math/base/special/csignumf/lib/index.js +++ b/lib/node_modules/@stdlib/math/base/special/csignumf/lib/index.js @@ -59,9 +59,20 @@ // MODULES // +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); var main = require( './main.js' ); +var assign = require( './assign.js' ); +var strided = require( './strided.js' ); + + +// MAIN // + +setReadOnly( main, 'assign', assign ); +setReadOnly( main, 'strided', strided ); // EXPORTS // module.exports = main; + +// exports: { "assign": "main.assign", "strided": "main.strided" } diff --git a/lib/node_modules/@stdlib/math/base/special/csignumf/lib/strided.js b/lib/node_modules/@stdlib/math/base/special/csignumf/lib/strided.js new file mode 100644 index 000000000000..0d73f95e891f --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/csignumf/lib/strided.js @@ -0,0 +1,64 @@ +/** +* @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 Complex64 = require( '@stdlib/complex/float32/ctor' ); +var real = require( '@stdlib/complex/float32/real' ); +var imag = require( '@stdlib/complex/float32/imag' ); +var csignumf = require( './main.js' ); + + +// MAIN // + +/** +* Evaluates the signum function of a single-precision floating-point complex number stored in a real-valued strided array view and assigns results to a provided strided output array. +* +* @param {Float32Array} z - complex number view +* @param {integer} strideZ - stride length for `z` +* @param {NonNegativeInteger} offsetZ - starting index for `z` +* @param {Collection} out - output array +* @param {integer} strideOut - stride length for `out` +* @param {NonNegativeInteger} offsetOut - starting index for `out` +* @returns {Collection} output array +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var z = new Float32Array( [ -4.2, 5.5 ] ); +* +* var out = strided( z, 1, 0, new Float32Array( 2 ), 1, 0 ); +* // returns [ ~-0.607, ~0.795 ] +*/ +function strided( z, strideZ, offsetZ, out, strideOut, offsetOut ) { + var v; + + v = csignumf( new Complex64( z[ offsetZ ], z[ offsetZ + strideZ ] ) ); + + out[ offsetOut ] = real( v ); + out[ offsetOut + strideOut ] = imag( v ); + + return out; +} + + +// EXPORTS // + +module.exports = strided; diff --git a/lib/node_modules/@stdlib/math/base/special/csignumf/test/test.assign.js b/lib/node_modules/@stdlib/math/base/special/csignumf/test/test.assign.js new file mode 100644 index 000000000000..878c182c51c9 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/csignumf/test/test.assign.js @@ -0,0 +1,195 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var absf = require( '@stdlib/math/base/special/absf' ); +var EPS = require( '@stdlib/constants/float32/eps' ); +var PINF = require( '@stdlib/constants/float32/pinf' ); +var NINF = require( '@stdlib/constants/float32/ninf' ); +var isSameFloat32Array = require( '@stdlib/assert/is-same-float32array' ); +var csignumf = require( './../lib' ); + + +// FIXTURES // + +var data = require( './fixtures/julia/data.json' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof csignumf.assign, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function evaluates the signum function of a single-precision floating-point complex number', function test( t ) { + var delta; + var tol; + var ere; + var eim; + var out; + var re; + var im; + var i; + + re = data.re; + im = data.im; + ere = data.expected_re; + eim = data.expected_im; + + for ( i = 0; i < re.length; i++ ) { + out = new Float32Array( 2 ); + csignumf.assign( re[ i ], im[ i ], out, 1, 0 ); + if ( isnanf( ere[i] ) || isnanf( eim[i] ) ) { + t.strictEqual( isnanf( out[ 0 ] ), true, 're is NaN' ); + t.strictEqual( isnanf( out[ 1 ] ), true, 'im is NaN' ); + continue; + } else if ( out[ 0 ] === ere[ i ] && out[ 1 ] === eim[ i ] ) { + t.strictEqual( out[ 0 ], ere[ i ], 're: ' + re[ i ] + '. Expected: ' + ere[ i ] ); + t.strictEqual( out[ 1 ], eim[ i ], 'im: ' + im[ i ] + '. Expected: ' + eim[ i ] ); + } else { + delta = absf( out[ 0 ] - ere[ i ] ); + tol = EPS * absf( ere[ i ] ); + t.ok( delta <= tol, 'within tolerance. re: ' + re[ i ] + '. im: ' + im[ i ] + '. Actual re: ' + out[ 0 ] + '. Expected re: '+ere[ i ]+ '. delta: ' + delta + '. tol: ' + tol + '.' ); + + delta = absf( out[ 1 ] - eim[ i ] ); + tol = EPS * absf( eim[ i ] ); + t.ok( delta <= tol, 'within tolerance. im: ' + im[ i ] + '. im: ' + im[ i ] + '. Actual im: ' + out[ 1 ] + '. Expected im: '+ere[ i ]+ '. delta: ' + delta + '. tol: ' + tol + '.' ); + } + } + t.end(); +}); + +tape( 'if a real or imaginary component is `NaN`, the output component is `NaN`', function test( t ) { + var expected; + var out; + var v; + + out = new Float32Array( 2 ); + expected = new Float32Array( [ NaN, NaN ] ); + + v = csignumf.assign( NaN, 1.0, out, 1, 0 ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + out = new Float32Array( 2 ); + expected = new Float32Array( [ NaN, NaN ] ); + + v = csignumf.assign( 1.0, NaN, out, 1, 0 ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + out = new Float32Array( 2 ); + expected = new Float32Array( [ NaN, NaN ] ); + + v = csignumf.assign( NaN, 0.0, out, 1, 0 ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + out = new Float32Array( 2 ); + expected = new Float32Array( [ NaN, NaN ] ); + + v = csignumf.assign( 0.0, NaN, out, 1, 0 ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + out = new Float32Array( 2 ); + expected = new Float32Array( [ NaN, NaN ] ); + + v = csignumf.assign( NaN, -2.5, out, 1, 0 ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + out = new Float32Array( 2 ); + expected = new Float32Array( [ NaN, NaN ] ); + + v = csignumf.assign( -2.5, NaN, out, 1, 0 ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + out = new Float32Array( 2 ); + expected = new Float32Array( [ NaN, NaN ] ); + + v = csignumf.assign( NaN, NaN, out, 1, 0 ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns `+0` if provided `+0`', function test( t ) { + var expected; + var out; + var v; + + out = new Float32Array( 2 ); + expected = new Float32Array( [ +0.0, +0.0 ] ); + + v = csignumf.assign( +0.0, +0.0, out, 1, 0 ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns `-0` if provided `-0`', function test( t ) { + var expected; + var out; + var v; + + out = new Float32Array( 2 ); + expected = new Float32Array( [ -0.0, -0.0 ] ); + + v = csignumf.assign( -0.0, -0.0, out, 1, 0 ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a `NaN` if provided `infinity`', function test( t ) { + var expected; + var out; + var v; + + out = new Float32Array( 2 ); + expected = new Float32Array( [ NaN, NaN ] ); + + v = csignumf.assign( PINF, PINF, out, 1, 0 ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a `NaN` if provided `-infinity`', function test( t ) { + var expected; + var out; + var v; + + out = new Float32Array( 2 ); + expected = new Float32Array( [ NaN, NaN ] ); + + v = csignumf.assign( NINF, NINF, out, 1, 0 ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/csignumf/test/test.js b/lib/node_modules/@stdlib/math/base/special/csignumf/test/test.js index 742b9bb7e22e..8ee33d4c79a9 100644 --- a/lib/node_modules/@stdlib/math/base/special/csignumf/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/csignumf/test/test.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2018 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. diff --git a/lib/node_modules/@stdlib/math/base/special/csignumf/test/test.strided.js b/lib/node_modules/@stdlib/math/base/special/csignumf/test/test.strided.js new file mode 100644 index 000000000000..68e8255a6d5c --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/csignumf/test/test.strided.js @@ -0,0 +1,200 @@ +/** +* @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 PINF = require( '@stdlib/constants/float32/pinf' ); +var NINF = require( '@stdlib/constants/float32/ninf' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var EPS = require( '@stdlib/constants/float32/eps' ); +var absf = require( '@stdlib/math/base/special/absf' ); +var Float32Array = require( '@stdlib/array/float32' ); +var isSameFloat32Array = require( '@stdlib/assert/is-same-float32array' ); +var csignumf = require( './../lib' ); + + +// FIXTURES // + +var data = require( './fixtures/julia/data.json' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof csignumf.strided, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function evaluates the signum function of a single-precision floating-point complex number', function test( t ) { + var delta; + var tol; + var ere; + var eim; + var out; + var re; + var im; + var z; + var i; + + re = data.re; + im = data.im; + ere = data.expected_re; + eim = data.expected_im; + + for ( i = 0; i < re.length; i++ ) { + z = new Float32Array( [ re[ i ], im[ i ] ] ); + out = new Float32Array( 2 ); + + csignumf.strided( z, 1, 0, out, 1, 0 ); + + if ( isnanf( ere[ i ] ) || isnanf( eim[ i ] ) ) { + t.strictEqual( isnanf( out[ 0 ] ), true, 're is NaN' ); + t.strictEqual( isnanf( out[ 1 ] ), true, 'im is NaN' ); + continue; + } else if ( out[ 0 ] === ere[ i ] && out[ 1 ] === eim[ i ] ) { + t.strictEqual( out[ 0 ], ere[ i ], 're: ' + re[ i ] + '. Expected: ' + ere[ i ] ); + t.strictEqual( out[ 1 ], eim[ i ], 'im: ' + im[ i ] + '. Expected: ' + eim[ i ] ); + } else { + delta = absf( out[ 0 ] - ere[ i ] ); + tol = EPS * absf( ere[ i ] ); + t.ok( delta <= tol, 'within tolerance. re: ' + re[ i ] + '. im: ' + im[ i ] + '. Actual re: ' + out[ 0 ] + '. Expected re: '+ere[ i ]+ '. delta: ' + delta + '. tol: ' + tol + '.' ); + + delta = absf( out[ 1 ] - eim[ i ] ); + tol = EPS * absf( eim[ i ] ); + t.ok( delta <= tol, 'within tolerance. im: ' + im[ i ] + '. Actual im: ' + out[ 1 ] + '. Expected im: '+eim[ i ]+ '. delta: ' + delta + '. tol: ' + tol + '.' ); + } + } + t.end(); +}); + +tape( 'if a real or imaginary component is `NaN`, the output component is `NaN`', function test( t ) { + var expected; + var out; + var z; + var v; + + z = new Float32Array( [ NaN, 1.0 ] ); + out = new Float32Array( 2 ); + expected = new Float32Array( [ NaN, NaN ] ); + + v = csignumf.strided( z, 1, 0, out, 1, 0 ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + z = new Float32Array( [ 1.0, NaN ] ); + out = new Float32Array( 2 ); + expected = new Float32Array( [ NaN, NaN ] ); + + v = csignumf.strided( z, 1, 0, out, 1, 0 ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + z = new Float32Array( [ NaN, 0.0 ] ); + out = new Float32Array( 2 ); + expected = new Float32Array( [ NaN, NaN ] ); + + v = csignumf.strided( z, 1, 0, out, 1, 0 ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + z = new Float32Array( [ 0.0, NaN ] ); + out = new Float32Array( 2 ); + expected = new Float32Array( [ NaN, NaN ] ); + + v = csignumf.strided( z, 1, 0, out, 1, 0 ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + z = new Float32Array( [ NaN, -2.5 ] ); + out = new Float32Array( 2 ); + expected = new Float32Array( [ NaN, NaN ] ); + + v = csignumf.strided( z, 1, 0, out, 1, 0 ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + z = new Float32Array( [ -2.5, NaN ] ); + out = new Float32Array( 2 ); + expected = new Float32Array( [ NaN, NaN ] ); + + v = csignumf.strided( z, 1, 0, out, 1, 0 ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + z = new Float32Array( [ NaN, NaN ] ); + out = new Float32Array( 2 ); + expected = new Float32Array( [ NaN, NaN ] ); + + v = csignumf.strided( z, 1, 0, out, 1, 0 ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `-0` if provided `-0`', function test( t ) { + var expected; + var out; + var z; + var v; + + z = new Float32Array( [ -0.0, -0.0 ] ); + out = new Float32Array( 2 ); + expected = new Float32Array( [ -0.0, -0.0 ] ); + + v = csignumf.strided( z, 1, 0, out, 1, 0 ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a `NaN` if provided `infinity`', function test( t ) { + var expected; + var out; + var z; + var v; + + z = new Float32Array( [ PINF, PINF ] ); + out = new Float32Array( 2 ); + expected = new Float32Array( [ NaN, NaN ] ); + + v = csignumf.strided( z, 1, 0, out, 1, 0 ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a `NaN` if provided `-infinity`', function test( t ) { + var expected; + var out; + var z; + var v; + + z = new Float32Array( [ NINF, NINF ] ); + out = new Float32Array( 2 ); + expected = new Float32Array( [ NaN, NaN ] ); + v = csignumf.strided( z, 1, 0, out, 1, 0 ); + + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/zeros/README.md b/lib/node_modules/@stdlib/ndarray/base/zeros/README.md index 1fae188a6ad4..6d56674c96d9 100644 --- a/lib/node_modules/@stdlib/ndarray/base/zeros/README.md +++ b/lib/node_modules/@stdlib/ndarray/base/zeros/README.md @@ -57,7 +57,7 @@ var dt = arr.dtype; The function accepts the following arguments: -- **dtype**: underlying [data type][@stdlib/ndarray/dtypes]. Must be a numeric [data type][@stdlib/ndarray/dtypes] or "generic". +- **dtype**: underlying [data type][@stdlib/ndarray/dtypes]. Must be a numeric [data type][@stdlib/ndarray/dtypes] or "generic". - **shape**: array shape. - **order**: specifies whether an [ndarray][@stdlib/ndarray/base/ctor] is `'row-major'` (C-style) or `'column-major'` (Fortran-style).