diff --git a/lib/node_modules/@stdlib/math/base/special/csignum/README.md b/lib/node_modules/@stdlib/math/base/special/csignum/README.md index c9d259752cf4..61b0a5b9516b 100644 --- a/lib/node_modules/@stdlib/math/base/special/csignum/README.md +++ b/lib/node_modules/@stdlib/math/base/special/csignum/README.md @@ -72,6 +72,55 @@ v = csignum( new Complex128( NaN, NaN ) ); // returns [ NaN, NaN ] ``` +#### csignum.assign( re, im, out, strideOut, offsetOut ) + +Evaluates the [signum][signum] function of a double-precision complex floating-point number and assigns results to a provided output array. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var out = new Float64Array( 2 ); +var v = csignum.assign( 3.0, -4.0, out, 1, 0 ); +// returns [ 0.6, -0.8 ] + +var bool = ( out === v ); +// returns true +``` + +The function supports the following parameters: + +- **re**: real component. +- **im**: imaginary component. +- **out**: output array. +- **strideOut**: stride length for `out`. +- **offsetOut**: starting index for `out`. + +#### csignum.strided( z, sz, oz, out, so, oo ) + +Evaluates the [signum][signum] function of a double-precision complex floating-point number stored in a real-valued strided array view and assigns results to a provided strided output array. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var z = new Float64Array( [ 3.0, -4.0 ] ); +var out = new Float64Array( 2 ); + +var v = csignum.strided( z, 1, 0, out, 1, 0 ); +// returns [ 0.6, -0.8 ] + +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`. + @@ -93,18 +142,16 @@ v = csignum( new Complex128( NaN, NaN ) ); ```javascript -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var csignum = require( '@stdlib/math/base/special/csignum' ); -var rand = uniform( -50.0, 50.0 ); +// Create an array of random numbers: +var arr = new Complex128Array( uniform( 200, -50.0, 50.0 ) ); -var z; -var i; -for ( i = 0; i < 100; i++ ) { - z = new Complex128( rand(), rand() ); - console.log( 'csignum(%s) = %s', z, csignum( z ) ); -} +// Evaluate the sign of each number in the array: +logEachMap( 'csignum(%s) = %s', arr, csignum ); ``` diff --git a/lib/node_modules/@stdlib/math/base/special/csignum/benchmark/benchmark.assign.js b/lib/node_modules/@stdlib/math/base/special/csignum/benchmark/benchmark.assign.js new file mode 100644 index 000000000000..0319c98c8dfb --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/csignum/benchmark/benchmark.assign.js @@ -0,0 +1,69 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 Float64Array = require( '@stdlib/array/float64' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var assign = require( './../lib' ).assign; + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// MAIN // + +bench( format( '%s:assign', pkg ), 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 Float64Array( 2 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + j = i % N; + out = assign( re[ j ], im[ 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/csignum/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/csignum/benchmark/benchmark.js index 33b7914587d8..3a801938ac66 100644 --- a/lib/node_modules/@stdlib/math/base/special/csignum/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/csignum/benchmark/benchmark.js @@ -21,37 +21,43 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var Complex128Array = require( '@stdlib/array/complex128' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); var pkg = require( './../package.json' ).name; var csignum = require( './../lib' ); +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + // MAIN // bench( pkg, function benchmark( b ) { - var values; + var zbuf; + var z; var y; var i; - values = [ - new Complex128( uniform( -500.0, 500.0 ), uniform( -500.0, 500.0 ) ), - new Complex128( uniform( -500.0, 500.0 ), uniform( -500.0, 500.0 ) ) - ]; + zbuf = uniform( 200, -500.0, 500.0, options ); + z = new Complex128Array( zbuf.buffer ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = csignum( values[ i%values.length ] ); + y = csignum( z.get( i%100 ) ); if ( isnan( real( y ) ) ) { b.fail( 'should not return NaN' ); } } b.toc(); if ( isnan( imag( y ) ) ) { - b.fail( 'should not return not NaN' ); + b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); b.end(); diff --git a/lib/node_modules/@stdlib/math/base/special/csignum/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/csignum/benchmark/benchmark.native.js index f40bbe14cad5..c5e32a91bcab 100644 --- a/lib/node_modules/@stdlib/math/base/special/csignum/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/csignum/benchmark/benchmark.native.js @@ -22,10 +22,11 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var Complex128Array = require( '@stdlib/array/complex128' ); var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); var tryRequire = require( '@stdlib/utils/try-require' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; @@ -37,29 +38,31 @@ var csignum = tryRequire( resolve( __dirname, './../lib/native.js' ) ); var opts = { 'skip': ( csignum instanceof Error ) }; +var options = { + 'dtype': 'float64' +}; // MAIN // bench( format( '%s::native', pkg ), opts, function benchmark( b ) { - var values; + var zbuf; + var z; var y; var i; - values = [ - new Complex128( uniform( -500.0, 500.0 ), uniform( -500.0, 500.0 ) ), - new Complex128( uniform( -500.0, 500.0 ), uniform( -500.0, 500.0 ) ) - ]; + zbuf = uniform( 200, -500.0, 500.0, options ); + z = new Complex128Array( zbuf.buffer ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = csignum( values[ i%values.length ] ); + y = csignum( z.get( i%100 ) ); if ( isnan( real( y ) ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnan( real( y ) ) ) { + if ( isnan( imag( y ) ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); diff --git a/lib/node_modules/@stdlib/math/base/special/csignum/benchmark/benchmark.strided.js b/lib/node_modules/@stdlib/math/base/special/csignum/benchmark/benchmark.strided.js new file mode 100644 index 000000000000..d04b1022d627 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/csignum/benchmark/benchmark.strided.js @@ -0,0 +1,67 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 Float64Array = require( '@stdlib/array/float64' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var strided = require( './../lib' ).strided; + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// MAIN // + +bench( format( '%s:strided', pkg ), 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 Float64Array( 2 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + j = ( i % N ) * 2; + out = 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/csignum/benchmark/julia/benchmark.jl b/lib/node_modules/@stdlib/math/base/special/csignum/benchmark/julia/benchmark.jl index e302c48058e7..93b0f5401c68 100644 --- a/lib/node_modules/@stdlib/math/base/special/csignum/benchmark/julia/benchmark.jl +++ b/lib/node_modules/@stdlib/math/base/special/csignum/benchmark/julia/benchmark.jl @@ -20,7 +20,7 @@ import BenchmarkTools using Printf # Benchmark variables: -name = "signum"; +name = "csignum"; repeats = 3; """ diff --git a/lib/node_modules/@stdlib/math/base/special/csignum/docs/repl.txt b/lib/node_modules/@stdlib/math/base/special/csignum/docs/repl.txt index b5ea32acd77b..760c45a24141 100644 --- a/lib/node_modules/@stdlib/math/base/special/csignum/docs/repl.txt +++ b/lib/node_modules/@stdlib/math/base/special/csignum/docs/repl.txt @@ -18,6 +18,77 @@ > var v = {{alias}}( new {{alias:@stdlib/complex/float64/ctor}}( -4.2, 5.5 ) ) [ -0.6069136033622302, 0.79476781392673 ] + +{{alias}}.assign( re, im, out, strideOut, offsetOut ) + Evaluates the signum function of a double-precision complex floating-point + number and assigns results to a provided output array. + + Parameters + ---------- + re: number + Real component. + + im: number + Imaginary component. + + out: ArrayLikeObject + Output array. + + strideOut: integer + Stride length. + + offsetOut: integer + Starting index. + + Returns + ------- + out: ArrayLikeObject + Output array. + + Examples + -------- + > var out = new {{alias:@stdlib/array/float64}}( 2 ); + > {{alias}}.assign( 3.0, -4.0, out, 1, 0 ) + [ 0.6, -0.8 ] + + +{{alias}}.strided( z, sz, oz, out, so, oo ) + Evaluates the signum function of a double-precision complex floating-point + 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/float64}}( [ 3.0, -4.0 ] ); + > var out = new {{alias:@stdlib/array/float64}}( 2 ); + > {{alias}}.strided( z, 1, 0, out, 1, 0 ) + [ 0.6, -0.8 ] + See Also -------- diff --git a/lib/node_modules/@stdlib/math/base/special/csignum/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/csignum/docs/types/index.d.ts index e8ca6ee173fb..8741ff68c5e8 100644 --- a/lib/node_modules/@stdlib/math/base/special/csignum/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/math/base/special/csignum/docs/types/index.d.ts @@ -21,6 +21,69 @@ /// import { Complex128 } from '@stdlib/types/complex'; +import { Collection, NumericArray } from '@stdlib/types/array'; + +/** +* Interface for evaluating the signum function of a double-precision complex floating-point number. +*/ +interface Csignum { + /** + * Evaluates the signum function of a double-precision complex floating-point number. + * + * @param z - input value + * @returns result + * + * @example + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * + * var v = csignum( new Complex128( -4.2, 5.5 ) ); + * // returns [ -0.6069136033622302, 0.79476781392673 ] + */ + ( z: Complex128 ): Complex128; + + /** + * Evaluates the signum function of a double-precision complex floating-point number and assigns results to a provided output array. + * + * @param re - real component + * @param im - imaginary component + * @param out - output array + * @param strideOut - stride length + * @param offsetOut - starting index + * @returns output array + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var out = new Float64Array( 2 ); + * var v = csignum.assign( 3.0, -4.0, out, 1, 0 ); + * // returns [ 0.6, -0.8 ] + * + * var bool = ( out === v ); + * // returns true + */ + assign>( re: number, im: number, out: T, strideOut: number, offsetOut: number ): T; + + /** + * Evaluates the signum function of a double-precision complex floating-point number stored in a real-valued strided array view 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 Float64Array = require( '@stdlib/array/float64' ); + * + * var z = new Float64Array( [ 3.0, -4.0 ] ); + * + * var out = csignum.strided( z, 1, 0, new Float64Array( 2 ), 1, 0 ); + * // returns [ 0.6, -0.8 ] + */ + strided, U extends NumericArray | Collection>( z: T, strideZ: number, offsetZ: number, out: U, strideOut: number, offsetOut: number ): U; +} /** * Evaluates the signum function of a double-precision complex floating-point number. @@ -33,8 +96,26 @@ import { Complex128 } from '@stdlib/types/complex'; * * var v = csignum( new Complex128( -4.2, 5.5 ) ); * // returns [ -0.6069136033622302, 0.79476781392673 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var out = new Float64Array( 2 ); +* var v = csignum.assign( 3.0, -4.0, out, 1, 0 ); +* // returns [ 0.6, -0.8 ] +* +* var bool = ( out === v ); +* // returns true +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var z = new Float64Array( [ 3.0, -4.0 ] ); +* +* var out = csignum.strided( z, 1, 0, new Float64Array( 2 ), 1, 0 ); +* // returns [ 0.6, -0.8 ] */ -declare function csignum( z: Complex128 ): Complex128; +declare var csignum: Csignum; // EXPORTS // diff --git a/lib/node_modules/@stdlib/math/base/special/csignum/docs/types/test.ts b/lib/node_modules/@stdlib/math/base/special/csignum/docs/types/test.ts index f4f8ac52c6ca..17b96e2d686f 100644 --- a/lib/node_modules/@stdlib/math/base/special/csignum/docs/types/test.ts +++ b/lib/node_modules/@stdlib/math/base/special/csignum/docs/types/test.ts @@ -22,12 +22,14 @@ import csignum = require( './index' ); // TESTS // -// The function returns an array of numbers... +// The function returns a double-precision complex floating-point number... { - csignum( new Complex128( 1.0, 2.0 ) ); // $ExpectType Complex128 + const z = new Complex128( 1.0, 2.0 ); + + csignum( z ); // $ExpectType Complex128 } -// The compiler throws an error if the function is provided a value other than a complex number... +// The compiler throws an error if the function is provided a first argument which is not a complex number... { csignum( true ); // $ExpectError csignum( false ); // $ExpectError @@ -39,7 +41,211 @@ import csignum = require( './index' ); csignum( ( x: number ): number => x ); // $ExpectError } -// The compiler throws an error if the function is provided insufficient arguments... +// The compiler throws an error if the function is provided an unsupported number of arguments... { + const z = new Complex128( 1.0, 2.0 ); + csignum(); // $ExpectError + csignum( z, z ); // $ExpectError + csignum( z, z, z ); // $ExpectError +} + +// Attached to the main export is an `assign` method which returns a collection... +{ + csignum.assign( 1.0, 1.0, new Float64Array( 2 ), 1, 0 ); // $ExpectType Float64Array + csignum.assign( 1.0, 1.0, new Float32Array( 2 ), 1, 0 ); // $ExpectType Float32Array + csignum.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 Float64Array( 2 ); + + csignum.assign( true, 2.0, out, 1, 0 ); // $ExpectError + csignum.assign( false, 2.0, out, 1, 0 ); // $ExpectError + csignum.assign( null, 2.0, out, 1, 0 ); // $ExpectError + csignum.assign( undefined, 2.0, out, 1, 0 ); // $ExpectError + csignum.assign( '5', 2.0, out, 1, 0 ); // $ExpectError + csignum.assign( [], 2.0, out, 1, 0 ); // $ExpectError + csignum.assign( {}, 2.0, out, 1, 0 ); // $ExpectError + csignum.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 Float64Array( 2 ); + + csignum.assign( 1.0, true, out, 1, 0 ); // $ExpectError + csignum.assign( 1.0, false, out, 1, 0 ); // $ExpectError + csignum.assign( 1.0, null, out, 1, 0 ); // $ExpectError + csignum.assign( 1.0, undefined, out, 1, 0 ); // $ExpectError + csignum.assign( 1.0, '5', out, 1, 0 ); // $ExpectError + csignum.assign( 1.0, [], out, 1, 0 ); // $ExpectError + csignum.assign( 1.0, {}, out, 1, 0 ); // $ExpectError + csignum.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... +{ + csignum.assign( 1.0, 2.0, 1, 1, 0 ); // $ExpectError + csignum.assign( 1.0, 2.0, true, 1, 0 ); // $ExpectError + csignum.assign( 1.0, 2.0, false, 1, 0 ); // $ExpectError + csignum.assign( 1.0, 2.0, null, 1, 0 ); // $ExpectError + csignum.assign( 1.0, 2.0, undefined, 1, 0 ); // $ExpectError + csignum.assign( 1.0, 2.0, '5', 1, 0 ); // $ExpectError + csignum.assign( 1.0, 2.0, [ '5' ], 1, 0 ); // $ExpectError + csignum.assign( 1.0, 2.0, {}, 1, 0 ); // $ExpectError + csignum.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 Float64Array( 2 ); + + csignum.assign( 1.0, 2.0, out, true, 0 ); // $ExpectError + csignum.assign( 1.0, 2.0, out, false, 0 ); // $ExpectError + csignum.assign( 1.0, 2.0, out, null, 0 ); // $ExpectError + csignum.assign( 1.0, 2.0, out, undefined, 0 ); // $ExpectError + csignum.assign( 1.0, 2.0, out, '5', 0 ); // $ExpectError + csignum.assign( 1.0, 2.0, out, [], 0 ); // $ExpectError + csignum.assign( 1.0, 2.0, out, {}, 0 ); // $ExpectError + csignum.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 Float64Array( 2 ); + + csignum.assign( 1.0, 2.0, out, 1, true ); // $ExpectError + csignum.assign( 1.0, 2.0, out, 1, false ); // $ExpectError + csignum.assign( 1.0, 2.0, out, 1, null ); // $ExpectError + csignum.assign( 1.0, 2.0, out, 1, undefined ); // $ExpectError + csignum.assign( 1.0, 2.0, out, 1, '5' ); // $ExpectError + csignum.assign( 1.0, 2.0, out, 1, [] ); // $ExpectError + csignum.assign( 1.0, 2.0, out, 1, {} ); // $ExpectError + csignum.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 Float64Array( 2 ); + + csignum.assign(); // $ExpectError + csignum.assign( 1.0 ); // $ExpectError + csignum.assign( 1.0, 2.0 ); // $ExpectError + csignum.assign( 1.0, 2.0, out ); // $ExpectError + csignum.assign( 1.0, 2.0, out, 1 ); // $ExpectError + csignum.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 Float64Array( 2 ); + + csignum.strided( z, 1, 0, new Float64Array( 2 ), 1, 0 ); // $ExpectType Float64Array + csignum.strided( z, 1, 0, new Float32Array( 2 ), 1, 0 ); // $ExpectType Float32Array + csignum.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 out = new Float64Array( 2 ); + + csignum.strided( true, 1, 0, out, 1, 0 ); // $ExpectError + csignum.strided( false, 1, 0, out, 1, 0 ); // $ExpectError + csignum.strided( null, 1, 0, out, 1, 0 ); // $ExpectError + csignum.strided( undefined, 1, 0, out, 1, 0 ); // $ExpectError + csignum.strided( '5', 1, 0, out, 1, 0 ); // $ExpectError + csignum.strided( [ '5' ], 1, 0, out, 1, 0 ); // $ExpectError + csignum.strided( {}, 1, 0, out, 1, 0 ); // $ExpectError + csignum.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 Float64Array( 2 ); + const out = new Float64Array( 2 ); + + csignum.strided( z, true, 0, out, 1, 0 ); // $ExpectError + csignum.strided( z, false, 0, out, 1, 0 ); // $ExpectError + csignum.strided( z, null, 0, out, 1, 0 ); // $ExpectError + csignum.strided( z, undefined, 0, out, 1, 0 ); // $ExpectError + csignum.strided( z, '5', 0, out, 1, 0 ); // $ExpectError + csignum.strided( z, [], 0, out, 1, 0 ); // $ExpectError + csignum.strided( z, {}, 0, out, 1, 0 ); // $ExpectError + csignum.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 Float64Array( 2 ); + const out = new Float64Array( 2 ); + + csignum.strided( z, 1, true, out, 1, 0 ); // $ExpectError + csignum.strided( z, 1, false, out, 1, 0 ); // $ExpectError + csignum.strided( z, 1, null, out, 1, 0 ); // $ExpectError + csignum.strided( z, 1, undefined, out, 1, 0 ); // $ExpectError + csignum.strided( z, 1, '5', out, 1, 0 ); // $ExpectError + csignum.strided( z, 1, [], out, 1, 0 ); // $ExpectError + csignum.strided( z, 1, {}, out, 1, 0 ); // $ExpectError + csignum.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 Float64Array( 2 ); + + csignum.strided( z, 1, 0, 1, 1, 0 ); // $ExpectError + csignum.strided( z, 1, 0, true, 1, 0 ); // $ExpectError + csignum.strided( z, 1, 0, false, 1, 0 ); // $ExpectError + csignum.strided( z, 1, 0, null, 1, 0 ); // $ExpectError + csignum.strided( z, 1, 0, undefined, 1, 0 ); // $ExpectError + csignum.strided( z, 1, 0, '5', 1, 0 ); // $ExpectError + csignum.strided( z, 1, 0, [ '5' ], 1, 0 ); // $ExpectError + csignum.strided( z, 1, 0, {}, 1, 0 ); // $ExpectError + csignum.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 Float64Array( 2 ); + const out = new Float64Array( 2 ); + + csignum.strided( z, 1, 0, out, true, 0 ); // $ExpectError + csignum.strided( z, 1, 0, out, false, 0 ); // $ExpectError + csignum.strided( z, 1, 0, out, null, 0 ); // $ExpectError + csignum.strided( z, 1, 0, out, undefined, 0 ); // $ExpectError + csignum.strided( z, 1, 0, out, '5', 0 ); // $ExpectError + csignum.strided( z, 1, 0, out, [], 0 ); // $ExpectError + csignum.strided( z, 1, 0, out, {}, 0 ); // $ExpectError + csignum.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 Float64Array( 2 ); + const out = new Float64Array( 2 ); + + csignum.strided( z, 1, 0, out, 1, true ); // $ExpectError + csignum.strided( z, 1, 0, out, 1, false ); // $ExpectError + csignum.strided( z, 1, 0, out, 1, null ); // $ExpectError + csignum.strided( z, 1, 0, out, 1, undefined ); // $ExpectError + csignum.strided( z, 1, 0, out, 1, '5' ); // $ExpectError + csignum.strided( z, 1, 0, out, 1, [] ); // $ExpectError + csignum.strided( z, 1, 0, out, 1, {} ); // $ExpectError + csignum.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 Float64Array( 2 ); + const out = new Float64Array( 2 ); + + csignum.strided(); // $ExpectError + csignum.strided( z ); // $ExpectError + csignum.strided( z, 1 ); // $ExpectError + csignum.strided( z, 1, 0 ); // $ExpectError + csignum.strided( z, 1, 0, out ); // $ExpectError + csignum.strided( z, 1, 0, out, 1 ); // $ExpectError + csignum.strided( z, 1, 0, out, 1, 0, {} ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/math/base/special/csignum/examples/index.js b/lib/node_modules/@stdlib/math/base/special/csignum/examples/index.js index 9ec2309764e6..71aa93f2bc5d 100644 --- a/lib/node_modules/@stdlib/math/base/special/csignum/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/csignum/examples/index.js @@ -18,15 +18,13 @@ 'use strict'; -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var csignum = require( './../lib' ); -var rand = uniform( -50.0, 50.0 ); +// Create an array of random numbers: +var arr = new Complex128Array( uniform( 200, -50.0, 50.0 ) ); -var z; -var i; -for ( i = 0; i < 100; i++ ) { - z = new Complex128( rand(), rand() ); - console.log( 'csignum(%s) = %s', z, csignum( z ) ); -} +// Evaluate the sign of each number in the array: +logEachMap( 'csignum(%s) = %s', arr, csignum ); diff --git a/lib/node_modules/@stdlib/math/base/special/csignum/lib/assign.js b/lib/node_modules/@stdlib/math/base/special/csignum/lib/assign.js new file mode 100644 index 000000000000..909103260d8e --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/csignum/lib/assign.js @@ -0,0 +1,61 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 hypot = require( '@stdlib/math/base/special/hypot' ); + + +// MAIN // + +/** +* Evaluates the signum function of a double-precision complex floating-point 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 Float64Array = require( '@stdlib/array/float64' ); +* +* var out = assign( 3.0, -4.0, new Float64Array( 2 ), 1, 0 ); +* // returns [ 0.6, -0.8 ] +*/ +function assign( re, im, out, strideOut, offsetOut ) { + var az; + + az = hypot( re, im ); + if ( az === 0.0 ) { + out[ offsetOut ] = re; + out[ offsetOut+strideOut ] = im; + return out; + } + out[ offsetOut ] = re / az; + out[ offsetOut+strideOut ] = im / az; + return out; +} + + +// EXPORTS // + +module.exports = assign; diff --git a/lib/node_modules/@stdlib/math/base/special/csignum/lib/index.js b/lib/node_modules/@stdlib/math/base/special/csignum/lib/index.js index 2faba32cb5c6..ad251645aa26 100644 --- a/lib/node_modules/@stdlib/math/base/special/csignum/lib/index.js +++ b/lib/node_modules/@stdlib/math/base/special/csignum/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* Evaluate the signum function of a double-precision floating-point complex number. +* Evaluate the signum function of a double-precision complex floating-point number. * * @module @stdlib/math/base/special/csignum * @@ -39,9 +39,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/csignum/lib/main.js b/lib/node_modules/@stdlib/math/base/special/csignum/lib/main.js index 8fb4f63b7b38..b08a32528f8b 100644 --- a/lib/node_modules/@stdlib/math/base/special/csignum/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/csignum/lib/main.js @@ -21,15 +21,21 @@ // MODULES // var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var Float64Array = require( '@stdlib/array/float64' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var cabs = require( '@stdlib/math/base/special/cabs' ); +var assign = require( './assign.js' ); + + +// VARIABLES // + +var out = new Float64Array( 2 ); // MAIN // /** -* Evaluates the signum function of a double-precision floating-point complex number. +* Evaluates the signum function of a double-precision complex floating-point number. * * @param {Complex128} z - complex number * @returns {Complex128} result @@ -47,17 +53,8 @@ var cabs = require( '@stdlib/math/base/special/cabs' ); * // returns [ NaN, NaN ] */ function csignum( z ) { - var re; - var im; - var az; - - az = cabs( z ); - if ( az === 0.0 ) { - return z; - } - re = real( z ) / az; - im = imag( z ) / az; - return new Complex128( re, im ); + assign( real( z ), imag( z ), out, 1, 0 ); + return new Complex128( out[ 0 ], out[ 1 ] ); } diff --git a/lib/node_modules/@stdlib/math/base/special/csignum/lib/native.js b/lib/node_modules/@stdlib/math/base/special/csignum/lib/native.js index 3023dcd68a74..007c086036f7 100644 --- a/lib/node_modules/@stdlib/math/base/special/csignum/lib/native.js +++ b/lib/node_modules/@stdlib/math/base/special/csignum/lib/native.js @@ -27,7 +27,7 @@ var addon = require( './../src/addon.node' ); // MAIN // /** -* Evaluates the signum function of a double-precision floating-point complex number. +* Evaluates the signum function of a double-precision complex floating-point number. * * @private * @param {Complex128} z - complex number diff --git a/lib/node_modules/@stdlib/math/base/special/csignum/lib/strided.js b/lib/node_modules/@stdlib/math/base/special/csignum/lib/strided.js new file mode 100644 index 000000000000..8bac608f3228 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/csignum/lib/strided.js @@ -0,0 +1,54 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 assign = require( './assign.js' ); + + +// MAIN // + +/** +* Evaluates the signum function of a double-precision complex floating-point number stored in a real-valued strided array view and assigns results to a provided strided output array. +* +* @param {Float64Array} 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 Float64Array = require( '@stdlib/array/float64' ); +* +* var z = new Float64Array( [ 3.0, -4.0 ] ); +* +* var out = strided( z, 1, 0, new Float64Array( 2 ), 1, 0 ); +* // returns [ 0.6, -0.8 ] +*/ +function strided( z, strideZ, offsetZ, out, strideOut, offsetOut ) { + return assign( z[ offsetZ ], z[ offsetZ+strideZ ], out, strideOut, offsetOut ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = strided; diff --git a/lib/node_modules/@stdlib/math/base/special/csignum/package.json b/lib/node_modules/@stdlib/math/base/special/csignum/package.json index 71a1b2f44e08..d6fc4f718284 100644 --- a/lib/node_modules/@stdlib/math/base/special/csignum/package.json +++ b/lib/node_modules/@stdlib/math/base/special/csignum/package.json @@ -59,7 +59,10 @@ "signum", "complex", "cmplx", - "number" + "number", + "sign", + "sgn", + "csignum" ], "__stdlib__": { "scaffold": { diff --git a/lib/node_modules/@stdlib/math/base/special/csignum/test/test.assign.js b/lib/node_modules/@stdlib/math/base/special/csignum/test/test.assign.js new file mode 100644 index 000000000000..ce41cac168fd --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/csignum/test/test.assign.js @@ -0,0 +1,180 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isSameFloat64Array = require( '@stdlib/assert/is-same-float64array' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var PINF = require( '@stdlib/constants/float64/pinf' ); +var NINF = require( '@stdlib/constants/float64/ninf' ); +var Float64Array = require( '@stdlib/array/float64' ); +var csignum = require( './../lib/assign.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof csignum, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function evaluates the signum function of a double-precision complex floating-point number', function test( t ) { + var expected; + var out; + var v; + + out = new Float64Array( 2 ); + v = csignum( 3.0, -4.0, out, 1, 0 ); + + expected = new Float64Array( [ 0.6, -0.8 ] ); + + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' ); + + out = new Float64Array( 4 ); + v = csignum( 3.0, -4.0, out, 2, 0 ); + + expected = new Float64Array( [ 0.6, 0.0, -0.8, 0.0 ] ); + + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' ); + + out = new Float64Array( 4 ); + v = csignum( 3.0, -4.0, out, 2, 1 ); + + expected = new Float64Array( [ 0.0, 0.6, 0.0, -0.8 ] ); + + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' ); + + out = new Float64Array( 4 ); + v = csignum( 3.0, -4.0, out, -2, 3 ); + + expected = new Float64Array( [ 0.0, -0.8, 0.0, 0.6 ] ); + + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function evaluates the complex signum function', function test( t ) { + var expected; + var out; + + out = new Float64Array( 2 ); + csignum( 0.0, 2.0, out, 1, 0 ); + + expected = new Float64Array( [ 0.0, 1.0 ] ); + + t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' ); + + out = new Float64Array( 2 ); + csignum( -5.0, 0.0, out, 1, 0 ); + + expected = new Float64Array( [ -1.0, 0.0 ] ); + + t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' ); + + out = new Float64Array( 2 ); + csignum( 6.0, -8.0, out, 1, 0 ); + + expected = new Float64Array( [ 0.6, -0.8 ] ); + + t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' ); + + out = new Float64Array( 2 ); + csignum( 4.0, -0.0, out, 1, 0 ); + + expected = new Float64Array( [ 1.0, -0.0 ] ); + + t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a `NaN` if provided a `NaN`', function test( t ) { + var out; + + out = new Float64Array( 2 ); + csignum( NaN, 3.0, out, 1, 0 ); + t.strictEqual( isnan( out[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnan( out[ 1 ] ), true, 'returns expected value' ); + + out = new Float64Array( 2 ); + csignum( 5.0, NaN, out, 1, 0 ); + t.strictEqual( isnan( out[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnan( out[ 1 ] ), true, 'returns expected value' ); + + out = new Float64Array( 2 ); + csignum( NaN, NaN, out, 1, 0 ); + t.strictEqual( isnan( out[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnan( out[ 1 ] ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `+0` if provided `+0`', function test( t ) { + var expected; + var out; + + out = new Float64Array( 2 ); + csignum( 0.0, 0.0, out, 1, 0 ); + + expected = new Float64Array( [ 0.0, 0.0 ] ); + + t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns `-0` if provided `-0`', function test( t ) { + var expected; + var out; + + out = new Float64Array( 2 ); + csignum( -0.0, -0.0, out, 1, 0 ); + + expected = new Float64Array( [ -0.0, -0.0 ] ); + + t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a `NaN` if provided `infinity`', function test( t ) { + var out; + + out = new Float64Array( 2 ); + csignum( PINF, PINF, out, 1, 0 ); + t.strictEqual( isnan( out[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnan( out[ 1 ] ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a `NaN` if provided `-infinity`', function test( t ) { + var out; + + out = new Float64Array( 2 ); + csignum( NINF, NINF, out, 1, 0 ); + t.strictEqual( isnan( out[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnan( out[ 1 ] ), true, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/csignum/test/test.js b/lib/node_modules/@stdlib/math/base/special/csignum/test/test.js index 8f633ff8cfa8..99972b6c2636 100644 --- a/lib/node_modules/@stdlib/math/base/special/csignum/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/csignum/test/test.js @@ -21,23 +21,10 @@ // MODULES // var tape = require( 'tape' ); -var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); -var PINF = require( '@stdlib/constants/float64/pinf' ); -var NINF = require( '@stdlib/constants/float64/ninf' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); -var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); +var isMethod = require( '@stdlib/assert/is-method' ); var csignum = require( './../lib' ); -// FIXTURES // - -var data = require( './fixtures/julia/data.json' ); - - // TESTS // tape( 'main export is a function', function test( t ) { @@ -46,58 +33,12 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function evaluates the signum function', function test( t ) { - var ere; - var eim; - var re; - var im; - var y; - var i; - - re = data.re; - im = data.im; - ere = data.expected_re; - eim = data.expected_im; - - for ( i = 0; i < re.length; i++ ) { - y = csignum( new Complex128( re[ i ], im[ i ] ) ); - t.strictEqual( isAlmostSameValue( real( y ), ere[ i ], 0 ), true, 'returns expected value' ); - t.strictEqual( isAlmostSameValue( imag( y ), eim[ i ], 0 ), true, 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function returns a `NaN` if provided a `NaN`', function test( t ) { - var val = csignum( new Complex128( NaN, NaN ) ); - t.strictEqual( isnan( real( val ) ), true, 'returns expected value' ); - t.strictEqual( isnan( imag( val ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `+0` if provided `+0`', function test( t ) { - var val = csignum( new Complex128( +0.0, +0.0 ) ); - t.strictEqual( isPositiveZero( real( val ) ), true, 'returns expected value' ); - t.strictEqual( isPositiveZero( imag( val ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `-0` if provided `-0`', function test( t ) { - var val = csignum( new Complex128( -0.0, -0.0 ) ); - t.strictEqual( isNegativeZero( real( val ) ), true, 'returns expected value' ); - t.strictEqual( isNegativeZero( imag( val ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a `NaN` if provided `infinity`', function test( t ) { - var val = csignum( new Complex128( PINF, PINF ) ); - t.strictEqual( isnan( real( val ) ), true, 'returns expected value' ); - t.strictEqual( isnan( imag( val ) ), true, 'returns expected value' ); +tape( 'attached to the main export is an `assign` method', function test( t ) { + t.strictEqual( isMethod( csignum, 'assign' ), true, 'returns expected value' ); t.end(); }); -tape( 'the function returns a `NaN` if provided `-infinity`', function test( t ) { - var val = csignum( new Complex128( NINF, NINF ) ); - t.strictEqual( isnan( real( val ) ), true, 'returns expected value' ); - t.strictEqual( isnan( imag( val ) ), true, 'returns expected value' ); +tape( 'attached to the main export is a `strided` method', function test( t ) { + t.strictEqual( isMethod( csignum, 'strided' ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/csignum/test/test.main.js b/lib/node_modules/@stdlib/math/base/special/csignum/test/test.main.js new file mode 100644 index 000000000000..95254e1d482b --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/csignum/test/test.main.js @@ -0,0 +1,103 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); +var PINF = require( '@stdlib/constants/float64/pinf' ); +var NINF = require( '@stdlib/constants/float64/ninf' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); +var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var csignum = 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 csignum, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function evaluates the signum function', function test( t ) { + var ere; + var eim; + var re; + var im; + var y; + var i; + + re = data.re; + im = data.im; + ere = data.expected_re; + eim = data.expected_im; + + for ( i = 0; i < re.length; i++ ) { + y = csignum( new Complex128( re[ i ], im[ i ] ) ); + t.strictEqual( isAlmostSameValue( real( y ), ere[ i ], 0 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( imag( y ), eim[ i ], 0 ), true, 'returns expected value' ); + } + t.end(); +}); + +tape( 'the function returns a `NaN` if provided a `NaN`', function test( t ) { + var val = csignum( new Complex128( NaN, NaN ) ); + t.strictEqual( isnan( real( val ) ), true, 'returns expected value' ); + t.strictEqual( isnan( imag( val ) ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns `+0` if provided `+0`', function test( t ) { + var val = csignum( new Complex128( +0.0, +0.0 ) ); + t.strictEqual( isPositiveZero( real( val ) ), true, 'returns expected value' ); + t.strictEqual( isPositiveZero( imag( val ) ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns `-0` if provided `-0`', function test( t ) { + var val = csignum( new Complex128( -0.0, -0.0 ) ); + t.strictEqual( isNegativeZero( real( val ) ), true, 'returns expected value' ); + t.strictEqual( isNegativeZero( imag( val ) ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a `NaN` if provided `infinity`', function test( t ) { + var val = csignum( new Complex128( PINF, PINF ) ); + t.strictEqual( isnan( real( val ) ), true, 'returns expected value' ); + t.strictEqual( isnan( imag( val ) ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a `NaN` if provided `-infinity`', function test( t ) { + var val = csignum( new Complex128( NINF, NINF ) ); + t.strictEqual( isnan( real( val ) ), true, 'returns expected value' ); + t.strictEqual( isnan( imag( val ) ), true, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/csignum/test/test.strided.js b/lib/node_modules/@stdlib/math/base/special/csignum/test/test.strided.js new file mode 100644 index 000000000000..74dd2466e1e2 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/csignum/test/test.strided.js @@ -0,0 +1,202 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isSameFloat64Array = require( '@stdlib/assert/is-same-float64array' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var PINF = require( '@stdlib/constants/float64/pinf' ); +var NINF = require( '@stdlib/constants/float64/ninf' ); +var Float64Array = require( '@stdlib/array/float64' ); +var csignum = require( './../lib/strided.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof csignum, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function evaluates the signum function of a double-precision complex floating-point number', function test( t ) { + var expected; + var out; + var z; + var v; + + z = new Float64Array( [ 3.0, -4.0 ] ); + out = new Float64Array( 2 ); + v = csignum( z, 1, 0, out, 1, 0 ); + + expected = new Float64Array( [ 0.6, -0.8 ] ); + + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' ); + + z = new Float64Array( [ 3.0, 0.0, -4.0, 0.0 ] ); + out = new Float64Array( 4 ); + v = csignum( z, 2, 0, out, 2, 0 ); + + expected = new Float64Array( [ 0.6, 0.0, -0.8, 0.0 ] ); + + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' ); + + z = new Float64Array( [ 0.0, 3.0, 0.0, -4.0 ] ); + out = new Float64Array( 4 ); + v = csignum( z, 2, 1, out, 2, 1 ); + + expected = new Float64Array( [ 0.0, 0.6, 0.0, -0.8 ] ); + + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' ); + + z = new Float64Array( [ -4.0, 3.0 ] ); + out = new Float64Array( 4 ); + v = csignum( z, -1, 1, out, -2, 3 ); + + expected = new Float64Array( [ 0.0, -0.8, 0.0, 0.6 ] ); + + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function evaluates the complex signum function', function test( t ) { + var expected; + var out; + var z; + + z = new Float64Array( [ 0.0, 2.0 ] ); + out = new Float64Array( 2 ); + csignum( z, 1, 0, out, 1, 0 ); + + expected = new Float64Array( [ 0.0, 1.0 ] ); + + t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' ); + + z = new Float64Array( [ -5.0, 0.0 ] ); + out = new Float64Array( 2 ); + csignum( z, 1, 0, out, 1, 0 ); + + expected = new Float64Array( [ -1.0, 0.0 ] ); + + t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' ); + + z = new Float64Array( [ 6.0, -8.0 ] ); + out = new Float64Array( 2 ); + csignum( z, 1, 0, out, 1, 0 ); + + expected = new Float64Array( [ 0.6, -0.8 ] ); + + t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' ); + + z = new Float64Array( [ 4.0, -0.0 ] ); + out = new Float64Array( 2 ); + csignum( z, 1, 0, out, 1, 0 ); + + expected = new Float64Array( [ 1.0, -0.0 ] ); + + t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a `NaN` if provided a `NaN`', function test( t ) { + var out; + var z; + + z = new Float64Array( [ NaN, 3.0 ] ); + out = new Float64Array( 2 ); + csignum( z, 1, 0, out, 1, 0 ); + t.strictEqual( isnan( out[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnan( out[ 1 ] ), true, 'returns expected value' ); + + z = new Float64Array( [ 5.0, NaN ] ); + out = new Float64Array( 2 ); + csignum( z, 1, 0, out, 1, 0 ); + t.strictEqual( isnan( out[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnan( out[ 1 ] ), true, 'returns expected value' ); + + z = new Float64Array( [ NaN, NaN ] ); + out = new Float64Array( 2 ); + csignum( z, 1, 0, out, 1, 0 ); + t.strictEqual( isnan( out[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnan( out[ 1 ] ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `+0` if provided `+0`', function test( t ) { + var expected; + var out; + var z; + + z = new Float64Array( [ 0.0, 0.0 ] ); + out = new Float64Array( 2 ); + csignum( z, 1, 0, out, 1, 0 ); + + expected = new Float64Array( [ 0.0, 0.0 ] ); + + t.strictEqual( isSameFloat64Array( 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; + + z = new Float64Array( [ -0.0, -0.0 ] ); + out = new Float64Array( 2 ); + csignum( z, 1, 0, out, 1, 0 ); + + expected = new Float64Array( [ -0.0, -0.0 ] ); + + t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a `NaN` if provided `infinity`', function test( t ) { + var out; + var z; + + z = new Float64Array( [ PINF, PINF ] ); + out = new Float64Array( 2 ); + csignum( z, 1, 0, out, 1, 0 ); + t.strictEqual( isnan( out[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnan( out[ 1 ] ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a `NaN` if provided `-infinity`', function test( t ) { + var out; + var z; + + z = new Float64Array( [ NINF, NINF ] ); + out = new Float64Array( 2 ); + csignum( z, 1, 0, out, 1, 0 ); + t.strictEqual( isnan( out[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnan( out[ 1 ] ), true, 'returns expected value' ); + t.end(); +}); 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 12945ce666f2..0d85ee29837e 100644 --- a/lib/node_modules/@stdlib/math/base/special/csignumf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/csignumf/README.md @@ -61,6 +61,7 @@ Evaluates the [signum][signum] function of a single-precision complex floating-p ```javascript var Complex64 = require( '@stdlib/complex/float32/ctor' ); + var v = csignumf( new Complex64( -4.2, 5.5 ) ); // returns [ ~-0.607, ~0.795 ] @@ -71,6 +72,55 @@ v = csignumf( new Complex64( NaN, NaN ) ); // returns [ NaN, NaN ] ``` +#### csignumf.assign( re, im, out, strideOut, offsetOut ) + +Evaluates the [signum][signum] function of a single-precision complex floating-point number and assigns results to a provided output array. + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var out = new Float32Array( 2 ); +var v = csignumf.assign( 3.0, -4.0, out, 1, 0 ); +// returns [ ~0.6, ~-0.8 ] + +var bool = ( out === v ); +// returns true +``` + +The function supports the following parameters: + +- **re**: real component. +- **im**: imaginary component. +- **out**: output array. +- **strideOut**: stride length for `out`. +- **offsetOut**: starting index for `out`. + +#### csignumf.strided( z, sz, oz, out, so, oo ) + +Evaluates the [signum][signum] function of a single-precision complex floating-point number stored in a real-valued strided array view and assigns results to a provided strided output array. + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var z = new Float32Array( [ 3.0, -4.0 ] ); +var out = new Float32Array( 2 ); + +var v = csignumf.strided( z, 1, 0, out, 1, 0 ); +// returns [ ~0.6, ~-0.8 ] + +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`. + @@ -92,18 +142,18 @@ v = csignumf( new Complex64( NaN, NaN ) ); ```javascript -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var csignumf = require( '@stdlib/math/base/special/csignumf' ); -var rand = uniform( -50.0, 50.0 ); +// Create an array of random numbers: +var arr = new Complex64Array( uniform( 200, -50.0, 50.0, { + 'dtype': 'float32' +})); -var z; -var i; -for ( i = 0; i < 100; i++ ) { - z = new Complex64( rand(), rand() ); - console.log( 'csignumf(%s) = %s', z, csignumf( z ) ); -} +// Evaluate the sign of each number in the array: +logEachMap( 'csignumf(%s) = %s', arr, csignumf ); ``` 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..53a7c26922da --- /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) 2026 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 format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var assign = require( './../lib' ).assign; + + +// VARIABLES // + +var options = { + 'dtype': 'float32' +}; + + +// MAIN // + +bench( format( '%s:assign', pkg ), 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 = 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.js b/lib/node_modules/@stdlib/math/base/special/csignumf/benchmark/benchmark.js index fcd762cfa274..692a5986aeee 100644 --- a/lib/node_modules/@stdlib/math/base/special/csignumf/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/csignumf/benchmark/benchmark.js @@ -21,37 +21,43 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex64Array = require( '@stdlib/array/complex64' ); var real = require( '@stdlib/complex/float32/real' ); var imag = require( '@stdlib/complex/float32/imag' ); var pkg = require( './../package.json' ).name; var csignumf = require( './../lib' ); +// VARIABLES // + +var options = { + 'dtype': 'float32' +}; + + // MAIN // bench( pkg, function benchmark( b ) { - var values; + var zbuf; + var z; var y; var i; - values = [ - new Complex64( uniform( -500.0, 500.0 ), uniform( -500.0, 500.0 ) ), - new Complex64( uniform( -500.0, 500.0 ), uniform( -500.0, 500.0 ) ) - ]; + zbuf = uniform( 200, -500.0, 500.0, options ); + z = new Complex64Array( zbuf.buffer ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = csignumf( values[ i%values.length ] ); + y = csignumf( z.get( i%100 ) ); if ( isnanf( real( y ) ) ) { b.fail( 'should not return NaN' ); } } b.toc(); if ( isnanf( imag( y ) ) ) { - b.fail( 'should not return not NaN' ); + 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.native.js b/lib/node_modules/@stdlib/math/base/special/csignumf/benchmark/benchmark.native.js index 6a4f5e5e2311..84e0b73c487b 100644 --- a/lib/node_modules/@stdlib/math/base/special/csignumf/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/csignumf/benchmark/benchmark.native.js @@ -22,10 +22,11 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex64Array = require( '@stdlib/array/complex64' ); var real = require( '@stdlib/complex/float32/real' ); +var imag = require( '@stdlib/complex/float32/imag' ); var tryRequire = require( '@stdlib/utils/try-require' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; @@ -37,29 +38,31 @@ var csignumf = tryRequire( resolve( __dirname, './../lib/native.js' ) ); var opts = { 'skip': ( csignumf instanceof Error ) }; +var options = { + 'dtype': 'float32' +}; // MAIN // bench( format( '%s::native', pkg ), opts, function benchmark( b ) { - var values; + var zbuf; + var z; var y; var i; - values = [ - new Complex64( uniform( -500.0, 500.0 ), uniform( -500.0, 500.0 ) ), - new Complex64( uniform( -500.0, 500.0 ), uniform( -500.0, 500.0 ) ) - ]; + zbuf = uniform( 200, -500.0, 500.0, options ); + z = new Complex64Array( zbuf.buffer ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = csignumf( values[ i%values.length ] ); + y = csignumf( z.get( i%100 ) ); if ( isnanf( real( y ) ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnanf( real( y ) ) ) { + if ( isnanf( imag( y ) ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); 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..ff94b2fd0918 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/csignumf/benchmark/benchmark.strided.js @@ -0,0 +1,67 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var strided = require( './../lib' ).strided; + + +// VARIABLES // + +var options = { + 'dtype': 'float32' +}; + + +// MAIN // + +bench( format( '%s:strided', pkg ), 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 = strided( z, 1, 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/julia/benchmark.jl b/lib/node_modules/@stdlib/math/base/special/csignumf/benchmark/julia/benchmark.jl index c1064e0d6ed2..ac30829dfd8e 100644 --- a/lib/node_modules/@stdlib/math/base/special/csignumf/benchmark/julia/benchmark.jl +++ b/lib/node_modules/@stdlib/math/base/special/csignumf/benchmark/julia/benchmark.jl @@ -20,7 +20,7 @@ import BenchmarkTools using Printf # Benchmark variables: -name = "signumf"; +name = "csignumf"; repeats = 3; """ 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 14d03ebda893..47468d887097 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 @@ -18,6 +18,77 @@ > var v = {{alias}}( new {{alias:@stdlib/complex/float32/ctor}}( -4.2, 5.5 ) ) [ ~-0.607, ~0.795 ] + +{{alias}}.assign( re, im, out, strideOut, offsetOut ) + Evaluates the signum function of a single-precision complex floating-point + number and assigns results to a provided output array. + + Parameters + ---------- + re: number + Real component. + + im: number + Imaginary component. + + 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( 3.0, -4.0, out, 1, 0 ) + [ ~0.6, ~-0.8 ] + + +{{alias}}.strided( z, sz, oz, out, so, oo ) + Evaluates the signum function of a single-precision complex floating-point + 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}}( [ 3.0, -4.0 ] ); + > var out = new {{alias:@stdlib/array/float32}}( 2 ); + > {{alias}}.strided( z, 1, 0, out, 1, 0 ) + [ ~0.6, ~-0.8 ] + 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 90bd61291698..595aacd63643 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,69 @@ /// import { Complex64 } from '@stdlib/types/complex'; +import { Collection, NumericArray } from '@stdlib/types/array'; + +/** +* Interface for evaluating the signum function of a single-precision complex floating-point number. +*/ +interface Csignumf { + /** + * Evaluates the signum function of a single-precision complex floating-point number. + * + * @param z - input value + * @returns result + * + * @example + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * + * var v = csignumf( new Complex64( -4.2, 5.5 ) ); + * // returns [ ~-0.607, ~0.795 ] + */ + ( z: Complex64 ): Complex64; + + /** + * Evaluates the signum function of a single-precision complex floating-point number and assigns results to a provided output array. + * + * @param re - real component + * @param im - imaginary component + * @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( 3.0, -4.0, out, 1, 0 ); + * // returns [ ~0.6, ~-0.8 ] + * + * var bool = ( out === v ); + * // returns true + */ + assign>( re: number, im: number, out: T, strideOut: number, offsetOut: number ): T; + + /** + * Evaluates the signum function of a single-precision complex floating-point number stored in a real-valued strided array view 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( [ 3.0, -4.0 ] ); + * + * var out = csignumf.strided( z, 1, 0, new Float32Array( 2 ), 1, 0 ); + * // returns [ ~0.6, ~-0.8 ] + */ + 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. @@ -33,8 +96,26 @@ import { Complex64 } from '@stdlib/types/complex'; * * var v = csignumf( new Complex64( -4.2, 5.5 ) ); * // returns [ ~-0.607, ~0.795 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var out = new Float32Array( 2 ); +* var v = csignumf.assign( 3.0, -4.0, out, 1, 0 ); +* // returns [ ~0.6, ~-0.8 ] +* +* var bool = ( out === v ); +* // returns true +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var z = new Float32Array( [ 3.0, -4.0 ] ); +* +* var out = csignumf.strided( z, 1, 0, new Float32Array( 2 ), 1, 0 ); +* // returns [ ~0.6, ~-0.8 ] */ -declare function csignumf( z: Complex64 ): Complex64; +declare var 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..883f5d477c6a 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 @@ -22,12 +22,14 @@ import csignumf = require( './index' ); // TESTS // -// The function returns an array of numbers... +// The function returns a single-precision complex floating-point number... { - csignumf( new Complex64( 1.0, 2.0 ) ); // $ExpectType Complex64 + const z = new Complex64( 1.0, 2.0 ); + + csignumf( z ); // $ExpectType Complex64 } -// The compiler throws an error if the function is provided a value other than a complex number... +// The compiler throws an error if the function is provided a first argument which is not a complex number... { csignumf( true ); // $ExpectError csignumf( false ); // $ExpectError @@ -39,7 +41,211 @@ import csignumf = require( './index' ); csignumf( ( x: number ): number => x ); // $ExpectError } -// The compiler throws an error if the function is provided insufficient arguments... +// The compiler throws an error if the function is provided an unsupported number of arguments... { + const z = new Complex64( 1.0, 2.0 ); + csignumf(); // $ExpectError + csignumf( z, z ); // $ExpectError + csignumf( z, z, z ); // $ExpectError +} + +// Attached to the main export is an `assign` method which returns a collection... +{ + csignumf.assign( 1.0, 1.0, new Float32Array( 2 ), 1, 0 ); // $ExpectType Float32Array + csignumf.assign( 1.0, 1.0, new Float64Array( 2 ), 1, 0 ); // $ExpectType Float64Array + 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 Float32Array( 2 ), 1, 0 ); // $ExpectType Float32Array + csignumf.strided( z, 1, 0, new Float64Array( 2 ), 1, 0 ); // $ExpectType Float64Array + 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 out = new Float32Array( 2 ); + + 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( 2 ); + + 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, [], 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( 2 ); + + 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, [], 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, 1, 1, 0 ); // $ExpectError + 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( 2 ); + + 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, [], 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( 2 ); + + 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, [] ); // $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( 2 ); + + 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/examples/index.js b/lib/node_modules/@stdlib/math/base/special/csignumf/examples/index.js index 92be2f0d5111..7f76f0c02834 100644 --- a/lib/node_modules/@stdlib/math/base/special/csignumf/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/csignumf/examples/index.js @@ -18,15 +18,15 @@ 'use strict'; -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var csignumf = require( './../lib' ); -var rand = uniform( -50.0, 50.0 ); +// Create an array of random numbers: +var arr = new Complex64Array( uniform( 200, -50.0, 50.0, { + 'dtype': 'float32' +})); -var z; -var i; -for ( i = 0; i < 100; i++ ) { - z = new Complex64( rand(), rand() ); - console.log( 'csignumf(%s) = %s', z, csignumf( z ) ); -} +// Evaluate the sign of each number in the array: +logEachMap( 'csignumf(%s) = %s', arr, csignumf ); 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..10a44bef6135 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/csignumf/lib/assign.js @@ -0,0 +1,62 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 hypotf = require( '@stdlib/math/base/special/hypotf' ); +var f32 = require( '@stdlib/number/float64/base/to-float32' ); + + +// MAIN // + +/** +* Evaluates the signum function of a single-precision complex floating-point 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( 3.0, -4.0, new Float32Array( 2 ), 1, 0 ); +* // returns [ ~0.6, ~-0.8 ] +*/ +function assign( re, im, out, strideOut, offsetOut ) { + var az; + + az = hypotf( re, im ); + if ( az === 0.0 ) { + out[ offsetOut ] = re; + out[ offsetOut+strideOut ] = im; + return out; + } + out[ offsetOut ] = f32( re / az ); + out[ offsetOut+strideOut ] = f32( im / az ); + 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 fe7882c8607e..8a81de91b5bb 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 @@ -19,7 +19,7 @@ 'use strict'; /** -* Evaluate the signum function of a single-precision floating-point complex number. +* Evaluate the signum function of a single-precision complex floating-point number. * * @module @stdlib/math/base/special/csignumf * @@ -39,9 +39,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/main.js b/lib/node_modules/@stdlib/math/base/special/csignumf/lib/main.js index 6621bc7e1f34..24076151defc 100644 --- a/lib/node_modules/@stdlib/math/base/special/csignumf/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/csignumf/lib/main.js @@ -21,16 +21,21 @@ // MODULES // var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var Float32Array = require( '@stdlib/array/float32' ); var real = require( '@stdlib/complex/float32/real' ); var imag = require( '@stdlib/complex/float32/imag' ); -var cabsf = require( '@stdlib/math/base/special/cabsf' ); +var assign = require( './assign.js' ); + + +// VARIABLES // + +var out = new Float32Array( 2 ); // MAIN // /** -* Evaluates the signum function of a single-precision floating-point complex number. +* Evaluates the signum function of a single-precision complex floating-point number. * * @param {Complex64} z - complex number * @returns {Complex64} result @@ -48,17 +53,8 @@ var cabsf = require( '@stdlib/math/base/special/cabsf' ); * // returns [ NaN, NaN ] */ function csignumf( z ) { - var re; - var im; - var az; - - az = cabsf( z ); - if ( az === 0.0 ) { - return z; - } - re = float64ToFloat32( real( z ) / az ); - im = float64ToFloat32( imag( z ) / az ); - return new Complex64( re, im ); + assign( real( z ), imag( z ), out, 1, 0 ); + return new Complex64( out[ 0 ], out[ 1 ] ); } diff --git a/lib/node_modules/@stdlib/math/base/special/csignumf/lib/native.js b/lib/node_modules/@stdlib/math/base/special/csignumf/lib/native.js index bab63d9c7e57..39c144950671 100644 --- a/lib/node_modules/@stdlib/math/base/special/csignumf/lib/native.js +++ b/lib/node_modules/@stdlib/math/base/special/csignumf/lib/native.js @@ -27,7 +27,7 @@ var addon = require( './../src/addon.node' ); // MAIN // /** -* Evaluates the signum function of a single-precision floating-point complex number. +* Evaluates the signum function of a single-precision complex floating-point number. * * @private * @param {Complex64} z - complex number 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..ed247251b3d4 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/csignumf/lib/strided.js @@ -0,0 +1,54 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 assign = require( './assign.js' ); + + +// MAIN // + +/** +* Evaluates the signum function of a single-precision complex floating-point 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( [ 3.0, -4.0 ] ); +* +* var out = strided( z, 1, 0, new Float32Array( 2 ), 1, 0 ); +* // returns [ ~0.6, ~-0.8 ] +*/ +function strided( z, strideZ, offsetZ, out, strideOut, offsetOut ) { + return assign( z[ offsetZ ], z[ offsetZ+strideZ ], out, strideOut, offsetOut ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = strided; diff --git a/lib/node_modules/@stdlib/math/base/special/csignumf/package.json b/lib/node_modules/@stdlib/math/base/special/csignumf/package.json index c58405a53d88..c19cb8102421 100644 --- a/lib/node_modules/@stdlib/math/base/special/csignumf/package.json +++ b/lib/node_modules/@stdlib/math/base/special/csignumf/package.json @@ -59,7 +59,10 @@ "signumf", "complex", "cmplx", - "number" + "number", + "sign", + "sgn", + "csignumf" ], "__stdlib__": { "scaffold": { @@ -188,7 +191,6 @@ }, "keywords": [ "csignum", - "signum", "sign", "sgn", "complex", diff --git a/lib/node_modules/@stdlib/math/base/special/csignumf/src/main.c b/lib/node_modules/@stdlib/math/base/special/csignumf/src/main.c index a60bef26518d..3bae2c38bde4 100644 --- a/lib/node_modules/@stdlib/math/base/special/csignumf/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/csignumf/src/main.c @@ -52,5 +52,7 @@ stdlib_complex64_t stdlib_base_csignumf( const stdlib_complex64_t z ) { return z; } stdlib_complex64_reim( z, &re, &im ); - return stdlib_complex64( re/az, im/az ); + re = re / az; + im = im / az; + return stdlib_complex64( re, im ); } 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..65a5f45045c6 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/csignumf/test/test.assign.js @@ -0,0 +1,180 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isSameFloat32Array = require( '@stdlib/assert/is-same-float32array' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var PINF = require( '@stdlib/constants/float32/pinf' ); +var NINF = require( '@stdlib/constants/float32/ninf' ); +var Float32Array = require( '@stdlib/array/float32' ); +var csignumf = require( './../lib/assign.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof csignumf, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function evaluates the signum function of a single-precision complex floating-point number', function test( t ) { + var expected; + var out; + var v; + + out = new Float32Array( 2 ); + v = csignumf( 3.0, -4.0, out, 1, 0 ); + + expected = new Float32Array( [ 0.6, -0.8 ] ); + + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + out = new Float32Array( 4 ); + v = csignumf( 3.0, -4.0, out, 2, 0 ); + + expected = new Float32Array( [ 0.6, 0.0, -0.8, 0.0 ] ); + + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + out = new Float32Array( 4 ); + v = csignumf( 3.0, -4.0, out, 2, 1 ); + + expected = new Float32Array( [ 0.0, 0.6, 0.0, -0.8 ] ); + + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + out = new Float32Array( 4 ); + v = csignumf( 3.0, -4.0, out, -2, 3 ); + + expected = new Float32Array( [ 0.0, -0.8, 0.0, 0.6 ] ); + + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function evaluates the complex signum function', function test( t ) { + var expected; + var out; + + out = new Float32Array( 2 ); + csignumf( 0.0, 2.0, out, 1, 0 ); + + expected = new Float32Array( [ 0.0, 1.0 ] ); + + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + out = new Float32Array( 2 ); + csignumf( -5.0, 0.0, out, 1, 0 ); + + expected = new Float32Array( [ -1.0, 0.0 ] ); + + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + out = new Float32Array( 2 ); + csignumf( 6.0, -8.0, out, 1, 0 ); + + expected = new Float32Array( [ 0.6, -0.8 ] ); + + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + out = new Float32Array( 2 ); + csignumf( 4.0, -0.0, out, 1, 0 ); + + expected = new Float32Array( [ 1.0, -0.0 ] ); + + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a `NaN` if provided a `NaN`', function test( t ) { + var out; + + out = new Float32Array( 2 ); + csignumf( NaN, 3.0, out, 1, 0 ); + t.strictEqual( isnanf( out[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnanf( out[ 1 ] ), true, 'returns expected value' ); + + out = new Float32Array( 2 ); + csignumf( 5.0, NaN, out, 1, 0 ); + t.strictEqual( isnanf( out[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnanf( out[ 1 ] ), true, 'returns expected value' ); + + out = new Float32Array( 2 ); + csignumf( NaN, NaN, out, 1, 0 ); + t.strictEqual( isnanf( out[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnanf( out[ 1 ] ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `+0` if provided `+0`', function test( t ) { + var expected; + var out; + + out = new Float32Array( 2 ); + csignumf( 0.0, 0.0, out, 1, 0 ); + + expected = new Float32Array( [ 0.0, 0.0 ] ); + + 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; + + out = new Float32Array( 2 ); + csignumf( -0.0, -0.0, out, 1, 0 ); + + expected = new Float32Array( [ -0.0, -0.0 ] ); + + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a `NaN` if provided `infinity`', function test( t ) { + var out; + + out = new Float32Array( 2 ); + csignumf( PINF, PINF, out, 1, 0 ); + t.strictEqual( isnanf( out[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnanf( out[ 1 ] ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a `NaN` if provided `-infinity`', function test( t ) { + var out; + + out = new Float32Array( 2 ); + csignumf( NINF, NINF, out, 1, 0 ); + t.strictEqual( isnanf( out[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnanf( out[ 1 ] ), 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 b0508ab9606b..c8d88bd25ca3 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 @@ -21,23 +21,10 @@ // MODULES // var tape = require( 'tape' ); -var isAlmostSameValue = require( '@stdlib/number/float32/base/assert/is-almost-same-value' ); -var PINF = require( '@stdlib/constants/float32/pinf' ); -var NINF = require( '@stdlib/constants/float32/ninf' ); -var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); -var isNegativeZerof = require( '@stdlib/math/base/assert/is-negative-zerof' ); -var isPositiveZerof = require( '@stdlib/math/base/assert/is-positive-zerof' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var real = require( '@stdlib/complex/float32/real' ); -var imag = require( '@stdlib/complex/float32/imag' ); +var isMethod = require( '@stdlib/assert/is-method' ); var csignumf = require( './../lib' ); -// FIXTURES // - -var data = require( './fixtures/julia/data.json' ); - - // TESTS // tape( 'main export is a function', function test( t ) { @@ -46,58 +33,12 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function evaluates the signum function', function test( t ) { - var ere; - var eim; - var re; - var im; - var y; - var i; - - re = data.re; - im = data.im; - ere = data.expected_re; - eim = data.expected_im; - - for ( i = 0; i < re.length; i++ ) { - y = csignumf( new Complex64( re[ i ], im[ i ] ) ); - t.strictEqual( isAlmostSameValue( real( y ), ere[ i ], 1 ), true, 'returns expected value' ); - t.strictEqual( isAlmostSameValue( imag( y ), eim[ i ], 1 ), true, 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function returns a `NaN` if provided a `NaN`', function test( t ) { - var val = csignumf( new Complex64( NaN, NaN ) ); - t.strictEqual( isnanf( real( val ) ), true, 'returns expected value' ); - t.strictEqual( isnanf( imag( val ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `+0` if provided `+0`', function test( t ) { - var val = csignumf( new Complex64( +0.0, +0.0 ) ); - t.strictEqual( isPositiveZerof( real( val ) ), true, 'returns expected value' ); - t.strictEqual( isPositiveZerof( imag( val ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `-0` if provided `-0`', function test( t ) { - var val = csignumf( new Complex64( -0.0, -0.0 ) ); - t.strictEqual( isNegativeZerof( real( val ) ), true, 'returns expected value' ); - t.strictEqual( isNegativeZerof( imag( val ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a `NaN` if provided `infinity`', function test( t ) { - var val = csignumf( new Complex64( PINF, PINF ) ); - t.strictEqual( isnanf( real( val ) ), true, 'returns expected value' ); - t.strictEqual( isnanf( imag( val ) ), true, 'returns expected value' ); +tape( 'attached to the main export is an `assign` method', function test( t ) { + t.strictEqual( isMethod( csignumf, 'assign' ), true, 'returns expected value' ); t.end(); }); -tape( 'the function returns a `NaN` if provided `-infinity`', function test( t ) { - var val = csignumf( new Complex64( NINF, NINF ) ); - t.strictEqual( isnanf( real( val ) ), true, 'returns expected value' ); - t.strictEqual( isnanf( imag( val ) ), true, 'returns expected value' ); +tape( 'attached to the main export is a `strided` method', function test( t ) { + t.strictEqual( isMethod( csignumf, 'strided' ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/csignumf/test/test.main.js b/lib/node_modules/@stdlib/math/base/special/csignumf/test/test.main.js new file mode 100644 index 000000000000..20de921e1a9c --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/csignumf/test/test.main.js @@ -0,0 +1,103 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isAlmostSameValue = require( '@stdlib/number/float32/base/assert/is-almost-same-value' ); +var PINF = require( '@stdlib/constants/float32/pinf' ); +var NINF = require( '@stdlib/constants/float32/ninf' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var isNegativeZerof = require( '@stdlib/math/base/assert/is-negative-zerof' ); +var isPositiveZerof = require( '@stdlib/math/base/assert/is-positive-zerof' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var real = require( '@stdlib/complex/float32/real' ); +var imag = require( '@stdlib/complex/float32/imag' ); +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, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function evaluates the signum function', function test( t ) { + var ere; + var eim; + var re; + var im; + var y; + var i; + + re = data.re; + im = data.im; + ere = data.expected_re; + eim = data.expected_im; + + for ( i = 0; i < re.length; i++ ) { + y = csignumf( new Complex64( re[ i ], im[ i ] ) ); + t.strictEqual( isAlmostSameValue( real( y ), ere[ i ], 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( imag( y ), eim[ i ], 1 ), true, 'returns expected value' ); + } + t.end(); +}); + +tape( 'the function returns a `NaN` if provided a `NaN`', function test( t ) { + var val = csignumf( new Complex64( NaN, NaN ) ); + t.strictEqual( isnanf( real( val ) ), true, 'returns expected value' ); + t.strictEqual( isnanf( imag( val ) ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns `+0` if provided `+0`', function test( t ) { + var val = csignumf( new Complex64( +0.0, +0.0 ) ); + t.strictEqual( isPositiveZerof( real( val ) ), true, 'returns expected value' ); + t.strictEqual( isPositiveZerof( imag( val ) ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns `-0` if provided `-0`', function test( t ) { + var val = csignumf( new Complex64( -0.0, -0.0 ) ); + t.strictEqual( isNegativeZerof( real( val ) ), true, 'returns expected value' ); + t.strictEqual( isNegativeZerof( imag( val ) ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a `NaN` if provided `infinity`', function test( t ) { + var val = csignumf( new Complex64( PINF, PINF ) ); + t.strictEqual( isnanf( real( val ) ), true, 'returns expected value' ); + t.strictEqual( isnanf( imag( val ) ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a `NaN` if provided `-infinity`', function test( t ) { + var val = csignumf( new Complex64( NINF, NINF ) ); + t.strictEqual( isnanf( real( val ) ), true, 'returns expected value' ); + t.strictEqual( isnanf( imag( val ) ), true, 'returns expected value' ); + t.end(); +}); 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..85d0596b147f --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/csignumf/test/test.strided.js @@ -0,0 +1,202 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isSameFloat32Array = require( '@stdlib/assert/is-same-float32array' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var PINF = require( '@stdlib/constants/float32/pinf' ); +var NINF = require( '@stdlib/constants/float32/ninf' ); +var Float32Array = require( '@stdlib/array/float32' ); +var csignumf = require( './../lib/strided.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof csignumf, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function evaluates the signum function of a single-precision complex floating-point number', function test( t ) { + var expected; + var out; + var z; + var v; + + z = new Float32Array( [ 3.0, -4.0 ] ); + out = new Float32Array( 2 ); + v = csignumf( z, 1, 0, out, 1, 0 ); + + expected = new Float32Array( [ 0.6, -0.8 ] ); + + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + z = new Float32Array( [ 3.0, 0.0, -4.0, 0.0 ] ); + out = new Float32Array( 4 ); + v = csignumf( z, 2, 0, out, 2, 0 ); + + expected = new Float32Array( [ 0.6, 0.0, -0.8, 0.0 ] ); + + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + z = new Float32Array( [ 0.0, 3.0, 0.0, -4.0 ] ); + out = new Float32Array( 4 ); + v = csignumf( z, 2, 1, out, 2, 1 ); + + expected = new Float32Array( [ 0.0, 0.6, 0.0, -0.8 ] ); + + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + z = new Float32Array( [ -4.0, 3.0 ] ); + out = new Float32Array( 4 ); + v = csignumf( z, -1, 1, out, -2, 3 ); + + expected = new Float32Array( [ 0.0, -0.8, 0.0, 0.6 ] ); + + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function evaluates the complex signum function', function test( t ) { + var expected; + var out; + var z; + + z = new Float32Array( [ 0.0, 2.0 ] ); + out = new Float32Array( 2 ); + csignumf( z, 1, 0, out, 1, 0 ); + + expected = new Float32Array( [ 0.0, 1.0 ] ); + + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + z = new Float32Array( [ -5.0, 0.0 ] ); + out = new Float32Array( 2 ); + csignumf( z, 1, 0, out, 1, 0 ); + + expected = new Float32Array( [ -1.0, 0.0 ] ); + + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + z = new Float32Array( [ 6.0, -8.0 ] ); + out = new Float32Array( 2 ); + csignumf( z, 1, 0, out, 1, 0 ); + + expected = new Float32Array( [ 0.6, -0.8 ] ); + + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + z = new Float32Array( [ 4.0, -0.0 ] ); + out = new Float32Array( 2 ); + csignumf( z, 1, 0, out, 1, 0 ); + + expected = new Float32Array( [ 1.0, -0.0 ] ); + + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a `NaN` if provided a `NaN`', function test( t ) { + var out; + var z; + + z = new Float32Array( [ NaN, 3.0 ] ); + out = new Float32Array( 2 ); + csignumf( z, 1, 0, out, 1, 0 ); + t.strictEqual( isnanf( out[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnanf( out[ 1 ] ), true, 'returns expected value' ); + + z = new Float32Array( [ 5.0, NaN ] ); + out = new Float32Array( 2 ); + csignumf( z, 1, 0, out, 1, 0 ); + t.strictEqual( isnanf( out[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnanf( out[ 1 ] ), true, 'returns expected value' ); + + z = new Float32Array( [ NaN, NaN ] ); + out = new Float32Array( 2 ); + csignumf( z, 1, 0, out, 1, 0 ); + t.strictEqual( isnanf( out[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnanf( out[ 1 ] ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `+0` if provided `+0`', function test( t ) { + var expected; + var out; + var z; + + z = new Float32Array( [ 0.0, 0.0 ] ); + out = new Float32Array( 2 ); + csignumf( z, 1, 0, out, 1, 0 ); + + expected = new Float32Array( [ 0.0, 0.0 ] ); + + 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; + + z = new Float32Array( [ -0.0, -0.0 ] ); + out = new Float32Array( 2 ); + csignumf( z, 1, 0, out, 1, 0 ); + + expected = new Float32Array( [ -0.0, -0.0 ] ); + + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a `NaN` if provided `infinity`', function test( t ) { + var out; + var z; + + z = new Float32Array( [ PINF, PINF ] ); + out = new Float32Array( 2 ); + csignumf( z, 1, 0, out, 1, 0 ); + t.strictEqual( isnanf( out[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnanf( out[ 1 ] ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a `NaN` if provided `-infinity`', function test( t ) { + var out; + var z; + + z = new Float32Array( [ NINF, NINF ] ); + out = new Float32Array( 2 ); + csignumf( z, 1, 0, out, 1, 0 ); + t.strictEqual( isnanf( out[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnanf( out[ 1 ] ), true, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/special/data/unary.json b/lib/node_modules/@stdlib/math/special/data/unary.json index bf839ebe1c2c..0215c5d3c3e2 100644 --- a/lib/node_modules/@stdlib/math/special/data/unary.json +++ b/lib/node_modules/@stdlib/math/special/data/unary.json @@ -10061,7 +10061,7 @@ "base_alias": "cfloor", "alias": "cfloorf", "pkg_desc": "round each component of a single-precision complex floating-point number toward negative infinity", - "desc": "rounds each component a single-precision complex floating-point number toward negative infinity", + "desc": "rounds each component of a single-precision complex floating-point number toward negative infinity", "short_desc": "", "parameters": [ { @@ -10196,7 +10196,7 @@ "base_alias": "cfloor", "alias": "cfloor", "pkg_desc": "round each component of a double-precision complex floating-point number toward negative infinity", - "desc": "rounds each component a double-precision complex floating-point number toward negative infinity", + "desc": "rounds each component of a double-precision complex floating-point number toward negative infinity", "short_desc": "", "parameters": [ { @@ -15514,7 +15514,6 @@ }, "keywords": [ "csignum", - "signum", "sign", "sgn", "complex",