diff --git a/lib/node_modules/@stdlib/complex/float32/base/scale/README.md b/lib/node_modules/@stdlib/complex/float32/base/scale/README.md new file mode 100644 index 000000000000..4d8855a714b1 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/scale/README.md @@ -0,0 +1,271 @@ + + +# scale + +> Scale a single-precision complex floating-point number by a real-valued single-precision floating-point scalar constant. + +
+ +
+ + + +
+ +## Usage + +```javascript +var scale = require( '@stdlib/complex/float32/base/scale' ); +``` + +#### scale( alpha, c ) + +Scales a single-precision complex floating-point number by a real-valued single-precision floating-point scalar constant. + +```javascript +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); + +var c = new Complex64( 5.0, 3.0 ); + +var v = scale( 5.0, c ); +// returns + +var re = realf( v ); +// returns 25.0 + +var im = imagf( v ); +// returns 15.0 +``` + +The function supports the following parameters: + +- **alpha**: real-valued scalar constant. +- **c**: [complex number][@stdlib/complex/float32/ctor]. + +#### scale.assign( alpha, re1, im1, out, strideOut, offsetOut ) + +Scales a single-precision complex floating-point number by a real-valued single-precision floating-point scalar constant and assigns results to a provided output array. + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var out = new Float32Array( 2 ); +var v = scale.assign( 5.0, 5.0, 3.0, out, 1, 0 ); +// returns [ 25.0, 15.0 ] + +var bool = ( out === v ); +// returns true +``` + +The function supports the following parameters: + +- **alpha**: real-valued scalar constant. +- **re**: real component of the complex number. +- **im**: imaginary component of the complex number. +- **out**: output array. +- **strideOut**: stride length for `out`. +- **offsetOut**: starting index for `out`. + +#### scale.strided( alpha, c, sc, oc, out, so, oo ) + +Scales a single-precision complex floating-point number stored in a real-valued strided array view by a real-valued single-precision floating-point scalar constant and assigns results to a provided strided output array. + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var c = new Float32Array( [ 5.0, 3.0 ] ); +var out = new Float32Array( 2 ); + +var v = scale.strided( 5.0, c, 1, 0, out, 1, 0 ); +// returns [ 25.0, 15.0 ] + +var bool = ( out === v ); +// returns true +``` + +The function supports the following parameters: + +- **alpha**: real-valued scalar constant. +- **c**: complex number strided array view. +- **sc**: stride length for `c`. +- **oc**: starting index for `c`. +- **out**: output array. +- **so**: stride length for `out`. +- **oo**: starting index for `out`. + +
+ + + +
+ +## Examples + + + +```javascript +var Complex64Array = require( '@stdlib/array/complex64' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); +var scale = require( '@stdlib/complex/float32/base/scale' ); + +// Generate an array of random values: +var values = new Complex64Array( discreteUniform( 200, -50, 50 ) ); + +// Scale each by a scalar constant: +logEachMap( '%0.1f * (%s) = %s', 5.0, values, scale ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/complex/float32/base/scale.h" +``` + +#### stdlib_base_complex64_scale( alpha, c ) + +Scales a single-precision complex floating-point number by a real-valued single-precision floating-point scalar constant. + +```c +#include "stdlib/complex/float32/ctor.h" +#include "stdlib/complex/float32/real.h" +#include "stdlib/complex/float32/imag.h" + +stdlib_complex64_t c = stdlib_complex64( 5.0f, 3.0f ); + +stdlib_complex64_t out = stdlib_base_complex64_scale( 5.0f, c ); + +float re = stdlib_complex64_real( out ); +// returns 25.0f + +float im = stdlib_complex64_imag( out ); +// returns 15.0f +``` + +The function accepts the following arguments: + +- **alpha**: `[in] float` scalar constant. +- **c**: `[in] stdlib_complex64_t` complex number. + +```c +stdlib_complex64_t stdlib_base_complex64_scale( const float alpha, const stdlib_complex64_t c ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/complex/float32/base/scale.h" +#include "stdlib/complex/float32/ctor.h" +#include "stdlib/complex/float32/reim.h" +#include + +int main( void ) { + const stdlib_complex64_t x[] = { + stdlib_complex64( 3.14f, 1.5f ), + stdlib_complex64( -3.14f, 1.5f ), + stdlib_complex64( 0.0f, -0.0f ), + stdlib_complex64( 0.0f/0.0f, 0.0f/0.0f ) + }; + + stdlib_complex64_t v; + stdlib_complex64_t y; + float re; + float im; + int i; + for ( i = 0; i < 4; i++ ) { + v = x[ i ]; + stdlib_complex64_reim( v, &re, &im ); + printf( "c = %f + %fi\n", re, im ); + + y = stdlib_base_complex64_scale( 5.0f, v ); + stdlib_complex64_reim( y, &re, &im ); + printf( "scale(5.0, c) = %f + %fi\n", re, im ); + } +} +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/complex/float32/base/scale/benchmark/benchmark.assign.js b/lib/node_modules/@stdlib/complex/float32/base/scale/benchmark/benchmark.assign.js new file mode 100644 index 000000000000..53977e19dee8 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/scale/benchmark/benchmark.assign.js @@ -0,0 +1,68 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var Float32Array = require( '@stdlib/array/float32' ); +var pkg = require( './../package.json' ).name; +var scale = require( './../lib' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float32' +}; + + +// MAIN // + +bench( pkg+':assign', function benchmark( b ) { + var out; + var re; + var im; + var N; + var i; + var j; + + N = 100; + re = uniform( N, -500.0, 500.0, options ); + im = uniform( N, -500.0, 500.0, options ); + + out = new Float32Array( 2 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + j = i % N; + out = scale.assign( 5.0, 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/complex/float32/base/scale/benchmark/benchmark.js b/lib/node_modules/@stdlib/complex/float32/base/scale/benchmark/benchmark.js new file mode 100644 index 000000000000..89924ae9f90e --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/scale/benchmark/benchmark.js @@ -0,0 +1,60 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/base/uniform' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var pkg = require( './../package.json' ).name; +var scale = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var values; + var out; + var z; + 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 ) ) + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = values[ i%values.length ]; + out = scale( 5.0, z ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( isnanf( realf( out ) ) || isnanf( imagf( out ) ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/complex/float32/base/scale/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/complex/float32/base/scale/benchmark/benchmark.native.js new file mode 100644 index 000000000000..80907db560ad --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/scale/benchmark/benchmark.native.js @@ -0,0 +1,69 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/base/uniform' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var scale = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( scale instanceof Error ) +}; + + +// MAIN // + +bench( pkg+'::native', opts, function benchmark( b ) { + var values; + var out; + var z; + 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 ) ) + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = values[ i%values.length ]; + out = scale( 5.0, z ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( isnanf( realf( out ) ) || isnanf( imagf( out ) ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/complex/float32/base/scale/benchmark/benchmark.strided.js b/lib/node_modules/@stdlib/complex/float32/base/scale/benchmark/benchmark.strided.js new file mode 100644 index 000000000000..2aefff0efc41 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/scale/benchmark/benchmark.strided.js @@ -0,0 +1,66 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var Float32Array = require( '@stdlib/array/float32' ); +var pkg = require( './../package.json' ).name; +var scale = require( './../lib' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float32' +}; + + +// MAIN // + +bench( pkg+':strided', function benchmark( b ) { + var out; + var z1; + var N; + var i; + var j; + + N = 50; + z1 = 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 = scale.strided( 5.0, z1, 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/complex/float32/base/scale/benchmark/c/Makefile b/lib/node_modules/@stdlib/complex/float32/base/scale/benchmark/c/Makefile new file mode 100644 index 000000000000..85a01e54fdaf --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/scale/benchmark/c/Makefile @@ -0,0 +1,126 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2025 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of C targets: +c_targets := benchmark.out + + +# RULES # + +#/ +# Compiles C source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code (e.g., `-fPIC`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler +# @param {string} CFLAGS - C compiler flags +# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) -o $@ $< -lm + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/complex/float32/base/scale/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/complex/float32/base/scale/benchmark/c/benchmark.c new file mode 100644 index 000000000000..b39656dddd58 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/scale/benchmark/c/benchmark.c @@ -0,0 +1,140 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include +#include +#include +#include +#include + +#define NAME "cscale" +#define ITERATIONS 1000000 +#define REPEATS 3 + +/** +* Prints the TAP version. +*/ +static void print_version( void ) { + printf( "TAP version 13\n" ); +} + +/** +* Prints the TAP summary. +* +* @param total total number of tests +* @param passing total number of passing tests +*/ +static void print_summary( int total, int passing ) { + printf( "#\n" ); + printf( "1..%d\n", total ); // TAP plan + printf( "# total %d\n", total ); + printf( "# pass %d\n", passing ); + printf( "#\n" ); + printf( "# ok\n" ); +} + +/** +* Prints benchmarks results. +* +* @param elapsed elapsed time in seconds +*/ +static void print_results( double elapsed ) { + double rate = (double)ITERATIONS / elapsed; + printf( " ---\n" ); + printf( " iterations: %d\n", ITERATIONS ); + printf( " elapsed: %0.9f\n", elapsed ); + printf( " rate: %0.9f\n", rate ); + printf( " ...\n" ); +} + +/** +* Returns a clock time. +* +* @return clock time +*/ +static double tic( void ) { + struct timeval now; + gettimeofday( &now, NULL ); + return (double)now.tv_sec + (double)now.tv_usec/1.0e6; +} + +/** +* Generates a random number on the interval [0,1). +* +* @return random number +*/ +static float rand_float( void ) { + int r = rand(); + return (float)r / ( (float)RAND_MAX + 1.0f ); +} + +/** +* Runs a benchmark. +* +* @return elapsed time in seconds +*/ +static double benchmark( void ) { + double elapsed; + float re; + float im; + double t; + int i; + + float complex z1; + float complex z2; + + t = tic(); + for ( i = 0; i < ITERATIONS; i++ ) { + re = ( 1000.0f*rand_float() ) - 500.0f; + im = ( 1000.0f*rand_float() ) - 500.0f; + z1 = re + im*I; + + re = creal( z1 ) * 5.0f; + im = cimag( z1 ) * 5.0f; + z2 = re + im*I; + if ( z2 != z2 ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( z2 != z2 ) { + printf( "should not return NaN\n" ); + } + return elapsed; +} + +/** +* Main execution sequence. +*/ +int main( void ) { + double elapsed; + int i; + + // Use the current time to seed the random number generator: + srand( time( NULL ) ); + + print_version(); + for ( i = 0; i < REPEATS; i++ ) { + printf( "# c::%s\n", NAME ); + elapsed = benchmark(); + print_results( elapsed ); + printf( "ok %d benchmark finished\n", i+1 ); + } + print_summary( REPEATS, REPEATS ); +} diff --git a/lib/node_modules/@stdlib/complex/float32/base/scale/benchmark/c/native/Makefile b/lib/node_modules/@stdlib/complex/float32/base/scale/benchmark/c/native/Makefile new file mode 100644 index 000000000000..a4bd7b38fd74 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/scale/benchmark/c/native/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2025 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := benchmark.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/complex/float32/base/scale/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/complex/float32/base/scale/benchmark/c/native/benchmark.c new file mode 100644 index 000000000000..56abbb9a7ee5 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/scale/benchmark/c/native/benchmark.c @@ -0,0 +1,142 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/complex/float32/base/scale.h" +#include "stdlib/complex/float32/ctor.h" +#include "stdlib/complex/float32/reim.h" +#include +#include +#include +#include +#include + +#define NAME "scale" +#define ITERATIONS 1000000 +#define REPEATS 3 + +/** +* Prints the TAP version. +*/ +static void print_version( void ) { + printf( "TAP version 13\n" ); +} + +/** +* Prints the TAP summary. +* +* @param total total number of tests +* @param passing total number of passing tests +*/ +static void print_summary( int total, int passing ) { + printf( "#\n" ); + printf( "1..%d\n", total ); // TAP plan + printf( "# total %d\n", total ); + printf( "# pass %d\n", passing ); + printf( "#\n" ); + printf( "# ok\n" ); +} + +/** +* Prints benchmarks results. +* +* @param elapsed elapsed time in seconds +*/ +static void print_results( double elapsed ) { + double rate = (double)ITERATIONS / elapsed; + printf( " ---\n" ); + printf( " iterations: %d\n", ITERATIONS ); + printf( " elapsed: %0.9f\n", elapsed ); + printf( " rate: %0.9f\n", rate ); + printf( " ...\n" ); +} + +/** +* Returns a clock time. +* +* @return clock time +*/ +static double tic( void ) { + struct timeval now; + gettimeofday( &now, NULL ); + return (double)now.tv_sec + (double)now.tv_usec/1.0e6; +} + +/** +* Generates a random number on the interval [0,1). +* +* @return random number +*/ +static float rand_float( void ) { + int r = rand(); + return (float)r / ( (float)RAND_MAX + 1.0f ); +} + +/** +* Runs a benchmark. +* +* @return elapsed time in seconds +*/ +static double benchmark( void ) { + double elapsed; + float re; + float im; + double t; + int i; + + stdlib_complex64_t z1; + stdlib_complex64_t z2; + + t = tic(); + for ( i = 0; i < ITERATIONS; i++ ) { + re = ( 1000.0f*rand_float() ) - 500.0f; + im = ( 1000.0f*rand_float() ) - 500.0f; + z1 = stdlib_complex64( re, im ); + + z2 = stdlib_base_complex64_scale( 5.0f, z1 ); + stdlib_complex64_reim( z2, &re, &im ); + if ( re != re ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( im != im ) { + printf( "should not return NaN\n" ); + } + return elapsed; +} + +/** +* Main execution sequence. +*/ +int main( void ) { + double elapsed; + int i; + + // Use the current time to seed the random number generator: + srand( time( NULL ) ); + + print_version(); + for ( i = 0; i < REPEATS; i++ ) { + printf( "# c::native::%s\n", NAME ); + elapsed = benchmark(); + print_results( elapsed ); + printf( "ok %d benchmark finished\n", i+1 ); + } + print_summary( REPEATS, REPEATS ); +} diff --git a/lib/node_modules/@stdlib/complex/float32/base/scale/benchmark/julia/REQUIRE b/lib/node_modules/@stdlib/complex/float32/base/scale/benchmark/julia/REQUIRE new file mode 100644 index 000000000000..98645e192e41 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/scale/benchmark/julia/REQUIRE @@ -0,0 +1,2 @@ +julia 1.5 +BenchmarkTools 0.5.0 diff --git a/lib/node_modules/@stdlib/complex/float32/base/scale/benchmark/julia/benchmark.jl b/lib/node_modules/@stdlib/complex/float32/base/scale/benchmark/julia/benchmark.jl new file mode 100755 index 000000000000..64548604f6c8 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/scale/benchmark/julia/benchmark.jl @@ -0,0 +1,144 @@ +#!/usr/bin/env julia +# +# @license Apache-2.0 +# +# Copyright (c) 2025 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import BenchmarkTools +using Printf + +# Benchmark variables: +name = "scale"; +repeats = 3; + +""" + print_version() + +Prints the TAP version. + +# Examples + +``` julia +julia> print_version() +``` +""" +function print_version() + @printf( "TAP version 13\n" ); +end + +""" + print_summary( total, passing ) + +Print the benchmark summary. + +# Arguments + +* `total`: total number of tests +* `passing`: number of passing tests + +# Examples + +``` julia +julia> print_summary( 3, 3 ) +``` +""" +function print_summary( total, passing ) + @printf( "#\n" ); + @printf( "1..%d\n", total ); # TAP plan + @printf( "# total %d\n", total ); + @printf( "# pass %d\n", passing ); + @printf( "#\n" ); + @printf( "# ok\n" ); +end + +""" + print_results( iterations, elapsed ) + +Print benchmark results. + +# Arguments + +* `iterations`: number of iterations +* `elapsed`: elapsed time (in seconds) + +# Examples + +``` julia +julia> print_results( 1000000, 0.131009101868 ) +``` +""" +function print_results( iterations, elapsed ) + rate = iterations / elapsed + + @printf( " ---\n" ); + @printf( " iterations: %d\n", iterations ); + @printf( " elapsed: %0.9f\n", elapsed ); + @printf( " rate: %0.9f\n", rate ); + @printf( " ...\n" ); +end + +""" + benchmark() + +Run a benchmark. + +# Notes + +* Benchmark results are returned as a two-element array: [ iterations, elapsed ]. +* The number of iterations is not the true number of iterations. Instead, an 'iteration' is defined as a 'sample', which is a computed estimate for a single evaluation. +* The elapsed time is in seconds. + +# Examples + +``` julia +julia> out = benchmark(); +``` +""" +function benchmark() + t = BenchmarkTools.@benchmark ComplexF32( (rand()*1000.0)-500.0, (rand()*1000.0)-500.0 ) * 5.0 samples=1e6 + + # Compute the total "elapsed" time and convert from nanoseconds to seconds: + s = sum( t.times ) / 1.0e9; + + # Determine the number of "iterations": + iter = length( t.times ); + + # Return the results: + [ iter, s ]; +end + +""" + main() + +Run benchmarks. + +# Examples + +``` julia +julia> main(); +``` +""" +function main() + print_version(); + for i in 1:repeats + @printf( "# julia::%s\n", name ); + results = benchmark(); + print_results( results[ 1 ], results[ 2 ] ); + @printf( "ok %d benchmark finished\n", i ); + end + print_summary( repeats, repeats ); +end + +main(); diff --git a/lib/node_modules/@stdlib/complex/float32/base/scale/binding.gyp b/lib/node_modules/@stdlib/complex/float32/base/scale/binding.gyp new file mode 100644 index 000000000000..68a1ca11d160 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/scale/binding.gyp @@ -0,0 +1,170 @@ +# @license Apache-2.0 +# +# Copyright (c) 2025 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A `.gyp` file for building a Node.js native add-on. +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # List of files to include in this file: + 'includes': [ + './include.gypi', + ], + + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Target name should match the add-on export name: + 'addon_target_name%': 'addon', + + # Set variables based on the host OS: + 'conditions': [ + [ + 'OS=="win"', + { + # Define the object file suffix: + 'obj': 'obj', + }, + { + # Define the object file suffix: + 'obj': 'o', + } + ], # end condition (OS=="win") + ], # end conditions + }, # end variables + + # Define compile targets: + 'targets': [ + + # Target to generate an add-on: + { + # The target name should match the add-on export name: + 'target_name': '<(addon_target_name)', + + # Define dependencies: + 'dependencies': [], + + # Define directories which contain relevant include headers: + 'include_dirs': [ + # Local include directory: + '<@(include_dirs)', + ], + + # List of source files: + 'sources': [ + '<@(src_files)', + ], + + # Settings which should be applied when a target's object files are used as linker input: + 'link_settings': { + # Define libraries: + 'libraries': [ + '<@(libraries)', + ], + + # Define library directories: + 'library_dirs': [ + '<@(library_dirs)', + ], + }, + + # C/C++ compiler flags: + 'cflags': [ + # Enable commonly used warning options: + '-Wall', + + # Aggressive optimization: + '-O3', + ], + + # C specific compiler flags: + 'cflags_c': [ + # Specify the C standard to which a program is expected to conform: + '-std=c99', + ], + + # C++ specific compiler flags: + 'cflags_cpp': [ + # Specify the C++ standard to which a program is expected to conform: + '-std=c++11', + ], + + # Linker flags: + 'ldflags': [], + + # Apply conditions based on the host OS: + 'conditions': [ + [ + 'OS=="mac"', + { + # Linker flags: + 'ldflags': [ + '-undefined dynamic_lookup', + '-Wl,-no-pie', + '-Wl,-search_paths_first', + ], + }, + ], # end condition (OS=="mac") + [ + 'OS!="win"', + { + # C/C++ flags: + 'cflags': [ + # Generate platform-independent code: + '-fPIC', + ], + }, + ], # end condition (OS!="win") + ], # end conditions + }, # end target <(addon_target_name) + + # Target to copy a generated add-on to a standard location: + { + 'target_name': 'copy_addon', + + # Declare that the output of this target is not linked: + 'type': 'none', + + # Define dependencies: + 'dependencies': [ + # Require that the add-on be generated before building this target: + '<(addon_target_name)', + ], + + # Define a list of actions: + 'actions': [ + { + 'action_name': 'copy_addon', + 'message': 'Copying addon...', + + # Explicitly list the inputs in the command-line invocation below: + 'inputs': [], + + # Declare the expected outputs: + 'outputs': [ + '<(addon_output_dir)/<(addon_target_name).node', + ], + + # Define the command-line invocation: + 'action': [ + 'cp', + '<(PRODUCT_DIR)/<(addon_target_name).node', + '<(addon_output_dir)/<(addon_target_name).node', + ], + }, + ], # end actions + }, # end target copy_addon + ], # end targets +} diff --git a/lib/node_modules/@stdlib/complex/float32/base/scale/docs/repl.txt b/lib/node_modules/@stdlib/complex/float32/base/scale/docs/repl.txt new file mode 100644 index 000000000000..e8f48e326d6a --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/scale/docs/repl.txt @@ -0,0 +1,110 @@ + +{{alias}}( alpha, c ) + Scales a single-precision complex floating-point number by a real-valued + single-precision floating-point scalar constant. + + Parameters + ---------- + alpha: number + Scalar constant. + + c: Complex64 + Complex number. + + Returns + ------- + out: Complex64 + Result. + + Examples + -------- + > var c = new {{alias:@stdlib/complex/float32/ctor}}( 5.0, 3.0 ) + + > var out = {{alias}}( 5.0, c ) + + > var re = {{alias:@stdlib/complex/float32/real}}( out ) + 25.0 + > var im = {{alias:@stdlib/complex/float32/imag}}( out ) + 15.0 + + +{{alias}}.assign( alpha, re, im, out, strideOut, offsetOut ) + Scales a single-precision complex floating-point number by a real-valued + single-precision floating-point scalar constant and assigns results to a + provided output array. + + Parameters + ---------- + alpha: number + Scalar constant. + + re: number + Real component of the complex number. + + im: number + Imaginary component of the complex number. + + out: ArrayLikeObject + Output array. + + strideOut: integer + Stride length. + + offsetOut: integer + Starting index. + + Returns + ------- + out: ArrayLikeObject + Output array. + + Examples + -------- + > var out = new {{alias:@stdlib/array/float32}}( 2 ); + > {{alias}}.assign( 5.0, 5.0, 3.0, out, 1, 0 ) + [ 25.0, 15.0 ] + + +{{alias}}.strided( alpha, c, sc, oc, out, so, oo ) + Scales a single-precision complex floating-point number stored in a real- + valued strided array view by a real-valued single-precision floating-point + scalar constant and assigns results to a provided strided output array. + + Parameters + ---------- + alpha: number + Scalar constant. + + c: ArrayLikeObject + Complex number view. + + sc: integer + Stride length for `c`. + + oc: integer + Starting index for `c`. + + out: ArrayLikeObject + Output array. + + so: integer + Stride length for `out`. + + oo: integer + Starting index for `out`. + + Returns + ------- + out: ArrayLikeObject + Output array. + + Examples + -------- + > var c = new {{alias:@stdlib/array/float32}}( [ 5.0, 3.0 ] ); + > var out = new {{alias:@stdlib/array/float32}}( 2 ); + > {{alias}}.strided( 5.0, c, 1, 0, out, 1, 0 ) + [ 25.0, 15.0 ] + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/complex/float32/base/scale/docs/types/index.d.ts b/lib/node_modules/@stdlib/complex/float32/base/scale/docs/types/index.d.ts new file mode 100644 index 000000000000..de450815b29a --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/scale/docs/types/index.d.ts @@ -0,0 +1,149 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +import { Complex64 } from '@stdlib/types/complex'; +import { Collection, NumericArray } from '@stdlib/types/array'; + +/** +* Interface for scaling a single-precision complex floating-point number. +*/ +interface Scale { + /** + * Scales a single-precision complex floating-point number by a real-valued single-precision floating-point scalar constant. + * + * @param alpha - scalar constant + * @param z - complex number + * @returns result + * + * @example + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * + * var z = new Complex64( 5.0, 3.0 ); + * // returns + * + * var out = scale( 5.0, z ); + * // returns + * + * var re = realf( out ); + * // returns 25.0 + * + * var im = imagf( out ); + * // returns 15.0 + */ + ( alpha: number, z: Complex64 ): Complex64; + + /** + * Scales a single-precision complex floating-point number by a real-valued single-precision floating-point scalar constant and assigns results to a provided output array. + * + * @param alpha - scalar constant + * @param re - real component of the complex number + * @param im - imaginary component of the complex number + * @param out - output array + * @param strideOut - stride length + * @param offsetOut - starting index + * @returns output array + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * + * var out = new Float32Array( 2 ); + * var v = scale.assign( 5.0, 5.0, 3.0, out, 1, 0 ); + * // returns [ 25.0, 15.0 ] + * + * var bool = ( out === v ); + * // returns true + */ + assign>( alpha: number, re: number, im: number, out: T, strideOut: number, offsetOut: number ): T; + + /** + * Scales a single-precision complex floating-point number stored in a real-valued strided array view by a real-valued single-precision floating-point scalar constant and assigns results to a provided strided output array. + * + * @param alpha - scalar constant + * @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( [ 5.0, 3.0 ] ); + * + * var out = scale.strided( 5.0, z, 1, 0, new Float32Array( 2 ), 1, 0 ); + * // returns [ 25.0, 15.0 ] + */ + strided, U extends NumericArray | Collection>( alpha: number, z: T, strideZ: number, offsetZ: number, out: U, strideOut: number, offsetOut: number ): U; +} + +/** +* Scales a single-precision complex floating-point number by a real-valued single-precision floating-point scalar constant. +* +* @param alpha - scalar constant +* @param z - complex number +* @returns result +* +* @example +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* var realf = require( '@stdlib/complex/float32/real' ); +* var imagf = require( '@stdlib/complex/float32/imag' ); +* +* var z = new Complex64( 5.0, 3.0 ); +* // returns +* +* var out = scale( 5.0, z ); +* // returns +* +* var re = realf( out ); +* // returns 25.0 +* +* var im = imagf( out ); +* // returns 15.0 +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var out = new Float32Array( 2 ); +* var v = scale.assign( 5.0, 5.0, 3.0, out, 1, 0 ); +* // returns [ 25.0, 15.0 ] +* +* var bool = ( out === v ); +* // returns true +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var z = new Float32Array( [ 5.0, 3.0 ] ); +* +* var out = scale.strided( 5.0, z, 1, 0, new Float32Array( 2 ), 1, 0 ); +* // returns [ 25.0, 15.0 ] +*/ +declare var scale: Scale; + + +// EXPORTS // + +export = scale; diff --git a/lib/node_modules/@stdlib/complex/float32/base/scale/docs/types/test.ts b/lib/node_modules/@stdlib/complex/float32/base/scale/docs/types/test.ts new file mode 100644 index 000000000000..cfbeecd6b0d7 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/scale/docs/types/test.ts @@ -0,0 +1,296 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import Complex64 = require( '@stdlib/complex/float32/ctor' ); +import scale = require( './index' ); + + +// TESTS // + +// The function returns a complex number... +{ + const z = new Complex64( 1.0, 1.0 ); + + scale( 5.0, z ); // $ExpectType Complex64 +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const z = new Complex64( 1.0, 1.0 ); + + scale( true, z ); // $ExpectError + scale( false, z ); // $ExpectError + scale( null, z ); // $ExpectError + scale( undefined, z ); // $ExpectError + scale( '5', z ); // $ExpectError + scale( [], z ); // $ExpectError + scale( {}, z ); // $ExpectError + scale( ( x: number ): number => x, z ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a complex number... +{ + scale( 5.0, true ); // $ExpectError + scale( 5.0, false ); // $ExpectError + scale( 5.0, null ); // $ExpectError + scale( 5.0, undefined ); // $ExpectError + scale( 5.0, '5' ); // $ExpectError + scale( 5.0, [] ); // $ExpectError + scale( 5.0, {} ); // $ExpectError + scale( 5.0, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const z = new Complex64( 1.0, 1.0 ); + + scale(); // $ExpectError + scale( 5.0 ); // $ExpectError + scale( 5.0, z, z ); // $ExpectError +} + +// Attached to the main export is an `assign` method which returns a collection... +{ + scale.assign( 5.0, 1.0, 1.0, new Float32Array( 2 ), 1, 0 ); // $ExpectType Float32Array + scale.assign( 5.0, 1.0, 1.0, new Float32Array( 2 ), 1, 0 ); // $ExpectType Float32Array + scale.assign( 5.0, 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 ); + + scale.assign( true, 1.0, 2.0, out, 1, 0 ); // $ExpectError + scale.assign( false, 1.0, 2.0, out, 1, 0 ); // $ExpectError + scale.assign( null, 1.0, 2.0, out, 1, 0 ); // $ExpectError + scale.assign( undefined, 1.0, 2.0, out, 1, 0 ); // $ExpectError + scale.assign( '5', 1.0, 2.0, out, 1, 0 ); // $ExpectError + scale.assign( [], 1.0, 2.0, out, 1, 0 ); // $ExpectError + scale.assign( {}, 1.0, 2.0, out, 1, 0 ); // $ExpectError + scale.assign( ( x: number ): number => x, 1.0, 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 ); + + scale.assign( 5.0, true, 2.0, out, 1, 0 ); // $ExpectError + scale.assign( 5.0, false, 2.0, out, 1, 0 ); // $ExpectError + scale.assign( 5.0, null, 2.0, out, 1, 0 ); // $ExpectError + scale.assign( 5.0, undefined, 2.0, out, 1, 0 ); // $ExpectError + scale.assign( 5.0, '5', 2.0, out, 1, 0 ); // $ExpectError + scale.assign( 5.0, [], 2.0, out, 1, 0 ); // $ExpectError + scale.assign( 5.0, {}, 2.0, out, 1, 0 ); // $ExpectError + scale.assign( 5.0, ( x: number ): number => x, 2.0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided a third argument which is not a number... +{ + const out = new Float32Array( 2 ); + + scale.assign( 5.0, 1.0, true, out, 1, 0 ); // $ExpectError + scale.assign( 5.0, 1.0, false, out, 1, 0 ); // $ExpectError + scale.assign( 5.0, 1.0, null, out, 1, 0 ); // $ExpectError + scale.assign( 5.0, 1.0, undefined, out, 1, 0 ); // $ExpectError + scale.assign( 5.0, 1.0, '5', out, 1, 0 ); // $ExpectError + scale.assign( 5.0, 1.0, [], out, 1, 0 ); // $ExpectError + scale.assign( 5.0, 1.0, {}, out, 1, 0 ); // $ExpectError + scale.assign( 5.0, 1.0, ( x: number ): number => x, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided a fourth argument which is not a collection... +{ + scale.assign( 1.0, 2.0, 3.0, 1, 1, 0 ); // $ExpectError + scale.assign( 1.0, 2.0, 3.0, true, 1, 0 ); // $ExpectError + scale.assign( 1.0, 2.0, 3.0, false, 1, 0 ); // $ExpectError + scale.assign( 1.0, 2.0, 3.0, null, 1, 0 ); // $ExpectError + scale.assign( 1.0, 2.0, 3.0, undefined, 1, 0 ); // $ExpectError + scale.assign( 1.0, 2.0, 3.0, '5', 1, 0 ); // $ExpectError + scale.assign( 1.0, 2.0, 3.0, [ '5' ], 1, 0 ); // $ExpectError + scale.assign( 1.0, 2.0, 3.0, {}, 1, 0 ); // $ExpectError + scale.assign( 1.0, 2.0, 3.0, ( x: number ): number => x, 1, 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 ); + + scale.assign( 1.0, 2.0, 3.0, out, true, 0 ); // $ExpectError + scale.assign( 1.0, 2.0, 3.0, out, false, 0 ); // $ExpectError + scale.assign( 1.0, 2.0, 3.0, out, null, 0 ); // $ExpectError + scale.assign( 1.0, 2.0, 3.0, out, undefined, 0 ); // $ExpectError + scale.assign( 1.0, 2.0, 3.0, out, '5', 0 ); // $ExpectError + scale.assign( 1.0, 2.0, 3.0, out, [], 0 ); // $ExpectError + scale.assign( 1.0, 2.0, 3.0, out, {}, 0 ); // $ExpectError + scale.assign( 1.0, 2.0, 3.0, out, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided a sixth argument which is not a number... +{ + const out = new Float32Array( 2 ); + + scale.assign( 1.0, 2.0, 3.0, out, 1, true ); // $ExpectError + scale.assign( 1.0, 2.0, 3.0, out, 1, false ); // $ExpectError + scale.assign( 1.0, 2.0, 3.0, out, 1, null ); // $ExpectError + scale.assign( 1.0, 2.0, 3.0, out, 1, undefined ); // $ExpectError + scale.assign( 1.0, 2.0, 3.0, out, 1, '5' ); // $ExpectError + scale.assign( 1.0, 2.0, 3.0, out, 1, [] ); // $ExpectError + scale.assign( 1.0, 2.0, 3.0, out, 1, {} ); // $ExpectError + scale.assign( 1.0, 2.0, 3.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 ); + + scale.assign(); // $ExpectError + scale.assign( 1.0 ); // $ExpectError + scale.assign( 1.0, 2.0 ); // $ExpectError + scale.assign( 1.0, 2.0, 3.0 ); // $ExpectError + scale.assign( 1.0, 2.0, 3.0, out ); // $ExpectError + scale.assign( 1.0, 2.0, 3.0, out, 1 ); // $ExpectError + scale.assign( 1.0, 2.0, 3.0, out, 1, 0, {} ); // $ExpectError +} + +// Attached to the main export is a `strided` method which returns a collection... +{ + const z1 = new Float32Array( 2 ); + + scale.strided( 5.0, z1, 1, 0, new Float32Array( 2 ), 1, 0 ); // $ExpectType Float32Array + scale.strided( 5.0, z1, 1, 0, new Float32Array( 2 ), 1, 0 ); // $ExpectType Float32Array + scale.strided( 5.0, z1, 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 number... +{ + const z1 = new Float32Array( 2 ); + const out = new Float32Array( z1.length ); + + scale.strided( true, z1, 1, 0, out, 1, 0 ); // $ExpectError + scale.strided( false, z1, 1, 0, out, 1, 0 ); // $ExpectError + scale.strided( null, z1, 1, 0, out, 1, 0 ); // $ExpectError + scale.strided( undefined, z1, 1, 0, out, 1, 0 ); // $ExpectError + scale.strided( '5', z1, 1, 0, out, 1, 0 ); // $ExpectError + scale.strided( [ '5' ], z1, 1, 0, out, 1, 0 ); // $ExpectError + scale.strided( {}, z1, 1, 0, out, 1, 0 ); // $ExpectError + scale.strided( ( x: number ): number => x, z1, 1, 0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `strided` method is provided a second argument which is not a collection... +{ + const z1 = new Float32Array( 2 ); + const out = new Float32Array( z1.length ); + + scale.strided( 5.0, true, 1, 0, out, 1, 0 ); // $ExpectError + scale.strided( 5.0, false, 1, 0, out, 1, 0 ); // $ExpectError + scale.strided( 5.0, null, 1, 0, out, 1, 0 ); // $ExpectError + scale.strided( 5.0, undefined, 1, 0, out, 1, 0 ); // $ExpectError + scale.strided( 5.0, '5', 1, 0, out, 1, 0 ); // $ExpectError + scale.strided( 5.0, [ '5' ], 1, 0, out, 1, 0 ); // $ExpectError + scale.strided( 5.0, {}, 1, 0, out, 1, 0 ); // $ExpectError + scale.strided( 5.0, ( x: number ): number => x, 1, 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 z1 = new Float32Array( 2 ); + const out = new Float32Array( z1.length ); + + scale.strided( 5.0, z1, true, 0, out, 1, 0 ); // $ExpectError + scale.strided( 5.0, z1, false, 0, out, 1, 0 ); // $ExpectError + scale.strided( 5.0, z1, null, 0, out, 1, 0 ); // $ExpectError + scale.strided( 5.0, z1, undefined, 0, out, 1, 0 ); // $ExpectError + scale.strided( 5.0, z1, '5', 0, out, 1, 0 ); // $ExpectError + scale.strided( 5.0, z1, [], 0, out, 1, 0 ); // $ExpectError + scale.strided( 5.0, z1, {}, 0, out, 1, 0 ); // $ExpectError + scale.strided( 5.0, z1, ( x: number ): number => x, 0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `strided` method is provided a fourth argument which is not a number... +{ + const z1 = new Float32Array( 2 ); + const out = new Float32Array( 2 ); + + scale.strided( 5.0, z1, 1, true, out, 1, 0 ); // $ExpectError + scale.strided( 5.0, z1, 1, false, out, 1, 0 ); // $ExpectError + scale.strided( 5.0, z1, 1, null, out, 1, 0 ); // $ExpectError + scale.strided( 5.0, z1, 1, undefined, out, 1, 0 ); // $ExpectError + scale.strided( 5.0, z1, 1, '5', out, 1, 0 ); // $ExpectError + scale.strided( 5.0, z1, 1, [], out, 1, 0 ); // $ExpectError + scale.strided( 5.0, z1, 1, {}, out, 1, 0 ); // $ExpectError + scale.strided( 5.0, z1, 1, ( x: number ): number => x, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `strided` method is provided a fifth argument which is not a collection... +{ + const z1 = new Float32Array( 2 ); + + scale.strided( 5.0, z1, 1, 0, true, 1, 0 ); // $ExpectError + scale.strided( 5.0, z1, 1, 0, false, 1, 0 ); // $ExpectError + scale.strided( 5.0, z1, 1, 0, null, 1, 0 ); // $ExpectError + scale.strided( 5.0, z1, 1, 0, undefined, 1, 0 ); // $ExpectError + scale.strided( 5.0, z1, 1, 0, '5', 1, 0 ); // $ExpectError + scale.strided( 5.0, z1, 1, 0, [ '5' ], 1, 0 ); // $ExpectError + scale.strided( 5.0, z1, 1, 0, {}, 1, 0 ); // $ExpectError + scale.strided( 5.0, z1, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `strided` method is provided a sixth argument which is not a number... +{ + const z1 = new Float32Array( 2 ); + const out = new Float32Array( z1.length ); + + scale.strided( 5.0, z1, 1, 0, out, true, 0 ); // $ExpectError + scale.strided( 5.0, z1, 1, 0, out, false, 0 ); // $ExpectError + scale.strided( 5.0, z1, 1, 0, out, null, 0 ); // $ExpectError + scale.strided( 5.0, z1, 1, 0, out, undefined, 0 ); // $ExpectError + scale.strided( 5.0, z1, 1, 0, out, '5', 0 ); // $ExpectError + scale.strided( 5.0, z1, 1, 0, out, [], 0 ); // $ExpectError + scale.strided( 5.0, z1, 1, 0, out, {}, 0 ); // $ExpectError + scale.strided( 5.0, z1, 1, 0, out, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the `strided` method is provided a seventh argument which is not a number... +{ + const z1 = new Float32Array( 2 ); + const out = new Float32Array( z1.length ); + + scale.strided( 5.0, z1, 1, 0, out, 1, true ); // $ExpectError + scale.strided( 5.0, z1, 1, 0, out, 1, false ); // $ExpectError + scale.strided( 5.0, z1, 1, 0, out, 1, null ); // $ExpectError + scale.strided( 5.0, z1, 1, 0, out, 1, undefined ); // $ExpectError + scale.strided( 5.0, z1, 1, 0, out, 1, '5' ); // $ExpectError + scale.strided( 5.0, z1, 1, 0, out, 1, [] ); // $ExpectError + scale.strided( 5.0, z1, 1, 0, out, 1, {} ); // $ExpectError + scale.strided( 5.0, z1, 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 z1 = new Float32Array( 2 ); + const out = new Float32Array( z1.length ); + + scale.strided(); // $ExpectError + scale.strided( 5.0 ); // $ExpectError + scale.strided( 5.0, z1 ); // $ExpectError + scale.strided( 5.0, z1, 1 ); // $ExpectError + scale.strided( 5.0, z1, 1, 0 ); // $ExpectError + scale.strided( 5.0, z1, 1, 0, out ); // $ExpectError + scale.strided( 5.0, z1, 1, 0, out, 1 ); // $ExpectError + scale.strided( 5.0, z1, 1, 0, out, 1, 0, {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/complex/float32/base/scale/examples/c/Makefile b/lib/node_modules/@stdlib/complex/float32/base/scale/examples/c/Makefile new file mode 100644 index 000000000000..25ced822f96a --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/scale/examples/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2025 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := example.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled examples. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/complex/float32/base/scale/examples/c/example.c b/lib/node_modules/@stdlib/complex/float32/base/scale/examples/c/example.c new file mode 100644 index 000000000000..2cea242cff91 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/scale/examples/c/example.c @@ -0,0 +1,46 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/complex/float32/base/scale.h" +#include "stdlib/complex/float32/ctor.h" +#include "stdlib/complex/float32/reim.h" +#include + +int main( void ) { + const stdlib_complex64_t x[] = { + stdlib_complex64( 3.14f, 1.5f ), + stdlib_complex64( -3.14f, 1.5f ), + stdlib_complex64( 0.0f, -0.0f ), + stdlib_complex64( 0.0f/0.0f, 0.0f/0.0f ) + }; + + stdlib_complex64_t v; + stdlib_complex64_t y; + float re; + float im; + int i; + for ( i = 0; i < 4; i++ ) { + v = x[ i ]; + stdlib_complex64_reim( v, &re, &im ); + printf( "z = %f + %fi\n", re, im ); + + y = stdlib_base_complex64_scale( 5.0f, v ); + stdlib_complex64_reim( y, &re, &im ); + printf( "scale(5.0, z) = %f + %fi\n", re, im ); + } +} diff --git a/lib/node_modules/@stdlib/complex/float32/base/scale/examples/index.js b/lib/node_modules/@stdlib/complex/float32/base/scale/examples/index.js new file mode 100644 index 000000000000..93df811b50c4 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/scale/examples/index.js @@ -0,0 +1,30 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var Complex64Array = require( '@stdlib/array/complex64' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); +var scale = require( './../lib' ); + +// Generate an array of random values: +var values = new Complex64Array( discreteUniform( 200, -50, 50 ) ); + +// Scale each by a scalar constant: +logEachMap( '%0.1f * (%s) = %s', 5.0, values, scale ); diff --git a/lib/node_modules/@stdlib/complex/float32/base/scale/include.gypi b/lib/node_modules/@stdlib/complex/float32/base/scale/include.gypi new file mode 100644 index 000000000000..ecfaf82a3279 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/scale/include.gypi @@ -0,0 +1,53 @@ +# @license Apache-2.0 +# +# Copyright (c) 2025 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A GYP include file for building a Node.js native add-on. +# +# Main documentation: +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Source directory: + 'src_dir': './src', + + # Include directories: + 'include_dirs': [ + '[ 25.0, 15.0 ] +*/ +function assign( alpha, re, im, out, strideOut, offsetOut ) { + out[ offsetOut ] = f32( re * alpha ); + out[ offsetOut+strideOut ] = f32( im * alpha ); + return out; +} + + +// EXPORTS // + +module.exports = assign; diff --git a/lib/node_modules/@stdlib/complex/float32/base/scale/lib/index.js b/lib/node_modules/@stdlib/complex/float32/base/scale/lib/index.js new file mode 100644 index 000000000000..b92a93809d17 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/scale/lib/index.js @@ -0,0 +1,63 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Scale a single-precision complex floating-point number by a real-valued single-precision floating-point scalar constant. +* +* @module @stdlib/complex/float32/base/scale +* +* @example +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* var realf = require( '@stdlib/complex/float32/real' ); +* var imagf = require( '@stdlib/complex/float32/imag' ); +* var scale = require( '@stdlib/complex/float32/base/scale' ); +* +* var z = new Complex64( 5.0, 3.0 ); +* // returns +* +* var out = scale( scalar, z ); +* // returns +* +* var re = realf( out ); +* // returns 25.0 +* +* var im = imagf( out ); +* // returns 15.0 +*/ + +// 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/complex/float32/base/scale/lib/main.js b/lib/node_modules/@stdlib/complex/float32/base/scale/lib/main.js new file mode 100644 index 000000000000..b1a106ae791a --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/scale/lib/main.js @@ -0,0 +1,62 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var f32 = require( '@stdlib/number/float64/base/to-float32' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); + + +// MAIN // + +/** +* Scales a single-precision complex floating-point number by a real-valued single-precision floating-point scalar constant. +* +* @param {number} alpha - scalar constant +* @param {Complex64} z - complex number +* @returns {Complex64} result +* +* @example +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* var realf = require( '@stdlib/complex/float32/real' ); +* var imagf = require( '@stdlib/complex/float32/imag' ); +* +* var z = new Complex64( 5.0, 3.0 ); +* // returns +* +* var out = scale( 5.0, z ); +* // returns +* +* var re = realf( out ); +* // returns 25.0 +* +* var im = imagf( out ); +* // returns 15.0 +*/ +function scale( alpha, z ) { + return new Complex64( f32( realf(z)*alpha ), f32( imagf(z)*alpha ) ); +} + + +// EXPORTS // + +module.exports = scale; diff --git a/lib/node_modules/@stdlib/complex/float32/base/scale/lib/native.js b/lib/node_modules/@stdlib/complex/float32/base/scale/lib/native.js new file mode 100644 index 000000000000..f73cffc9b925 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/scale/lib/native.js @@ -0,0 +1,62 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Scales a single-precision complex floating-point number by a real-valued single-precision floating-point scalar constant. +* +* @private +* @param {number} alpha - scalar constant +* @param {Complex64} z - complex number +* @returns {Complex64} result +* +* @example +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* var realf = require( '@stdlib/complex/float32/real' ); +* var imagf = require( '@stdlib/complex/float32/imag' ); +* +* var z = new Complex64( 5.0, 3.0 ); +* // returns +* +* var out = scale( 5.0, z ); +* // returns +* +* var re = realf( out ); +* // returns 25.0 +* +* var im = imagf( out ); +* // returns 15.0 +*/ +function scale( alpha, z ) { + var v = addon( alpha, z ); + return new Complex64( v.re, v.im ); +} + + +// EXPORTS // + +module.exports = scale; diff --git a/lib/node_modules/@stdlib/complex/float32/base/scale/lib/strided.js b/lib/node_modules/@stdlib/complex/float32/base/scale/lib/strided.js new file mode 100644 index 000000000000..165648d9eef8 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/scale/lib/strided.js @@ -0,0 +1,57 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var f32 = require( '@stdlib/number/float64/base/to-float32' ); + + +// MAIN // + +/** +* Scales a single-precision complex floating-point number stored in a real-valued strided array view by a real-valued single-precision floating-point scalar constant and assigns results to a provided strided output array. +* +* @param {number} alpha - scalar constant +* @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( [ 5.0, 3.0 ] ); +* +* var out = strided( 5.0, z, 1, 0, new Float32Array( 2 ), 1, 0 ); +* // returns [ 25.0, 15.0 ] +*/ +function strided( alpha, z, strideZ, offsetZ, out, strideOut, offsetOut ) { + out[ offsetOut ] = f32( alpha * z[ offsetZ ] ); + out[ offsetOut+strideOut ] = f32( alpha * z[ offsetZ+strideZ ] ); + return out; +} + + +// EXPORTS // + +module.exports = strided; diff --git a/lib/node_modules/@stdlib/complex/float32/base/scale/manifest.json b/lib/node_modules/@stdlib/complex/float32/base/scale/manifest.json new file mode 100644 index 000000000000..c55113261d87 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/scale/manifest.json @@ -0,0 +1,75 @@ +{ + "options": { + "task": "build" + }, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "task": "build", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/napi/binary", + "@stdlib/complex/float32/ctor", + "@stdlib/complex/float32/reim" + ] + }, + { + "task": "benchmark", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/complex/float32/ctor", + "@stdlib/complex/float32/reim" + ] + }, + { + "task": "examples", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/complex/float32/ctor", + "@stdlib/complex/float32/reim" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/complex/float32/base/scale/package.json b/lib/node_modules/@stdlib/complex/float32/base/scale/package.json new file mode 100644 index 000000000000..dddf99ac31ac --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/scale/package.json @@ -0,0 +1,69 @@ +{ + "name": "@stdlib/complex/float32/base/scale", + "version": "0.0.0", + "description": "Scale a single-precision complex floating-point number by a real-valued single-precision floating-point scalar constant.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "gypfile": true, + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "include": "./include", + "lib": "./lib", + "src": "./src", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "mul", + "cmul", + "mult", + "multiply", + "multiplication", + "arithmetic", + "complex", + "cmplx", + "number" + ] +} diff --git a/lib/node_modules/@stdlib/complex/float32/base/scale/src/Makefile b/lib/node_modules/@stdlib/complex/float32/base/scale/src/Makefile new file mode 100644 index 000000000000..7733b6180cb4 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/scale/src/Makefile @@ -0,0 +1,70 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2025 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + + +# RULES # + +#/ +# Removes generated files for building an add-on. +# +# @example +# make clean-addon +#/ +clean-addon: + $(QUIET) -rm -f *.o *.node + +.PHONY: clean-addon + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: clean-addon + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/complex/float32/base/scale/src/addon.c b/lib/node_modules/@stdlib/complex/float32/base/scale/src/addon.c new file mode 100644 index 000000000000..20a4d768be9b --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/scale/src/addon.c @@ -0,0 +1,22 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/complex/float32/base/scale.h" +#include "stdlib/math/base/napi/binary.h" + +STDLIB_MATH_BASE_NAPI_MODULE_FC_C( stdlib_base_complex64_scale ) diff --git a/lib/node_modules/@stdlib/complex/float32/base/scale/src/main.c b/lib/node_modules/@stdlib/complex/float32/base/scale/src/main.c new file mode 100644 index 000000000000..12dc53014fc5 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/scale/src/main.c @@ -0,0 +1,51 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/complex/float32/base/scale.h" +#include "stdlib/complex/float32/ctor.h" +#include "stdlib/complex/float32/reim.h" + +/** +* Scales a single-precision complex floating-point number by a real-valued single-precision floating-point scalar constant. +* +* @param alpha scalar constant +* @param z input value +* @return result +* +* @example +* #include "stdlib/complex/float32/ctor.h" +* #include "stdlib/complex/float32/real.h" +* #include "stdlib/complex/float32/imag.h" +* +* stdlib_complex64_t z = stdlib_complex64( 5.0f, 3.0f ); +* +* stdlib_complex64_t out = stdlib_base_complex64_scale( 5.0f, z ); +* +* float re = stdlib_complex64_real( out ); +* // returns 25.0f +* +* float im = stdlib_complex64_imag( out ); +* // returns 15.0f +*/ +stdlib_complex64_t stdlib_base_complex64_scale( const float alpha, const stdlib_complex64_t z ) { + float re; + float im; + + stdlib_complex64_reim( z, &re, &im ); + return stdlib_complex64( re * alpha, im * alpha ); +} diff --git a/lib/node_modules/@stdlib/complex/float32/base/scale/test/test.assign.js b/lib/node_modules/@stdlib/complex/float32/base/scale/test/test.assign.js new file mode 100644 index 000000000000..6018471a3ccd --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/scale/test/test.assign.js @@ -0,0 +1,111 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isSameFloat32Array = require( '@stdlib/assert/is-same-float32array' ); +var Float32Array = require( '@stdlib/array/float32' ); +var scale = require( './../lib/assign.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof scale, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function scales a complex number', function test( t ) { + var expected; + var out; + var v; + + out = new Float32Array( 2 ); + v = scale( 5.0, 5.0, 3.0, out, 1, 0 ); + + expected = new Float32Array( [ 25.0, 15.0 ] ); + + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + out = new Float32Array( 4 ); + v = scale( 5.0, 5.0, 3.0, out, 2, 0 ); + + expected = new Float32Array( [ 25.0, 0.0, 15.0, 0.0 ] ); + + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + out = new Float32Array( 4 ); + v = scale( 5.0, 5.0, 3.0, out, 2, 1 ); + + expected = new Float32Array( [ 0.0, 25.0, 0.0, 15.0 ] ); + + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + out = new Float32Array( 4 ); + v = scale( 5.0, 5.0, 3.0, out, -2, 3 ); + + expected = new Float32Array( [ 0.0, 15.0, 0.0, 25.0 ] ); + + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if a real or imaginary component is `NaN`, the respective component is `NaN`', function test( t ) { + var expected; + var out; + var v; + + out = new Float32Array( 2 ); + expected = new Float32Array( [ NaN, 15.0 ] ); + + v = scale( 5.0, NaN, 3.0, out, 1, 0 ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + out = new Float32Array( 2 ); + expected = new Float32Array( [ 25.0, NaN ] ); + + v = scale( 5.0, 5.0, NaN, out, 1, 0 ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + out = new Float32Array( 2 ); + expected = new Float32Array( [ NaN, NaN ] ); + + v = scale( 5.0, NaN, NaN, out, 1, 0 ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + out = new Float32Array( 2 ); + expected = new Float32Array( [ NaN, NaN ] ); + + v = scale( NaN, 5.0, 3.0, out, 1, 0 ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/complex/float32/base/scale/test/test.js b/lib/node_modules/@stdlib/complex/float32/base/scale/test/test.js new file mode 100644 index 000000000000..4869937e22c9 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/scale/test/test.js @@ -0,0 +1,46 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isMethod = require( '@stdlib/assert/is-method' ); +var scale = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof scale, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the main export is an `assign` method', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( isMethod( scale, 'assign' ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'attached to the main export is a `strided` method', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( isMethod( scale, 'strided' ), true, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/complex/float32/base/scale/test/test.main.js b/lib/node_modules/@stdlib/complex/float32/base/scale/test/test.main.js new file mode 100644 index 000000000000..4263628fa796 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/scale/test/test.main.js @@ -0,0 +1,82 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var scale = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof scale, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function scales a complex number', function test( t ) { + var c1; + var v; + + c1 = new Complex64( 5.0, 3.0 ); + + v = scale( 5.0, c1 ); + + t.strictEqual( realf( v ), 25.0, 'returns expected value' ); + t.strictEqual( imagf( v ), 15.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'if a real or imaginary component is `NaN`, the respective component is `NaN`', function test( t ) { + var c1; + var v; + + c1 = new Complex64( NaN, 3.0 ); + + v = scale( 5.0, c1 ); + t.strictEqual( isnanf( realf( v ) ), true, 'returns expected value' ); + t.strictEqual( imagf( v ), 15.0, 'returns expected value' ); + + c1 = new Complex64( 5.0, NaN ); + + v = scale( 5.0, c1 ); + t.strictEqual( realf( v ), 25.0, 'returns expected value' ); + t.strictEqual( isnanf( imagf( v ) ), true, 'returns expected value' ); + + c1 = new Complex64( NaN, NaN ); + + v = scale( 5.0, c1 ); + t.strictEqual( isnanf( realf( v ) ), true, 'returns expected value' ); + t.strictEqual( isnanf( imagf( v ) ), true, 'returns expected value' ); + + c1 = new Complex64( 5.0, 3.0 ); + + v = scale( NaN, c1 ); + t.strictEqual( isnanf( realf( v ) ), true, 'returns expected value' ); + t.strictEqual( isnanf( imagf( v ) ), true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/complex/float32/base/scale/test/test.native.js b/lib/node_modules/@stdlib/complex/float32/base/scale/test/test.native.js new file mode 100644 index 000000000000..0534dca8bdd0 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/scale/test/test.native.js @@ -0,0 +1,91 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var scale = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( scale instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof scale, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function scales a complex number', opts, function test( t ) { + var c1; + var v; + + c1 = new Complex64( 5.0, 3.0 ); + + v = scale( 5.0, c1 ); + + t.strictEqual( realf( v ), 25.0, 'returns expected value' ); + t.strictEqual( imagf( v ), 15.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'if a real or imaginary component is `NaN`, the respective component is `NaN`', opts, function test( t ) { + var c1; + var v; + + c1 = new Complex64( NaN, 3.0 ); + + v = scale( 5.0, c1 ); + t.strictEqual( isnanf( realf( v ) ), true, 'returns expected value' ); + t.strictEqual( imagf( v ), 15.0, 'returns expected value' ); + + c1 = new Complex64( 5.0, NaN ); + + v = scale( 5.0, c1 ); + t.strictEqual( realf( v ), 25.0, 'returns expected value' ); + t.strictEqual( isnanf( imagf( v ) ), true, 'returns expected value' ); + + c1 = new Complex64( NaN, NaN ); + + v = scale( 5.0, c1 ); + t.strictEqual( isnanf( realf( v ) ), true, 'returns expected value' ); + t.strictEqual( isnanf( imagf( v ) ), true, 'returns expected value' ); + + c1 = new Complex64( 5.0, 3.0 ); + + v = scale( NaN, c1 ); + t.strictEqual( isnanf( realf( v ) ), true, 'returns expected value' ); + t.strictEqual( isnanf( imagf( v ) ), true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/complex/float32/base/scale/test/test.strided.js b/lib/node_modules/@stdlib/complex/float32/base/scale/test/test.strided.js new file mode 100644 index 000000000000..7828f4b8d568 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/scale/test/test.strided.js @@ -0,0 +1,104 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isSameFloat32Array = require( '@stdlib/assert/is-same-float32array' ); +var Float32Array = require( '@stdlib/array/float32' ); +var scale = require( './../lib/strided.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof scale, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function scales a complex number', function test( t ) { + var expected; + var out; + var c1; + var v; + + c1 = new Float32Array( [ 5.0, 3.0 ] ); + out = new Float32Array( 2 ); + v = scale( 5.0, c1, 1, 0, out, 1, 0 ); + + expected = new Float32Array( [ 25.0, 15.0 ] ); + + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + c1 = new Float32Array( [ 5.0, 0.0, 3.0, 0.0 ] ); + out = new Float32Array( 4 ); + v = scale( 5.0, c1, 2, 0, out, 2, 0 ); + + expected = new Float32Array( [ 25.0, 0.0, 15.0, 0.0 ] ); + + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + c1 = new Float32Array( [ 3.0, 5.0 ] ); + out = new Float32Array( 4 ); + v = scale( 5.0, c1, -1, 1, out, -2, 3 ); + + expected = new Float32Array( [ 0.0, 15.0, 0.0, 25.0 ] ); + + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if a real or imaginary component is `NaN`, the respective component is `NaN`', function test( t ) { + var expected; + var out; + var c1; + var v; + + c1 = new Float32Array( [ NaN, 3.0 ] ); + out = new Float32Array( 2 ); + expected = new Float32Array( [ NaN, 15.0 ] ); + + v = scale( 5.0, c1, 1, 0, out, 1, 0 ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + c1 = new Float32Array( [ 5.0, NaN ] ); + out = new Float32Array( 2 ); + expected = new Float32Array( [ 25.0, NaN ] ); + + v = scale( 5.0, c1, 1, 0, out, 1, 0 ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + c1 = new Float32Array( [ 5.0, 3.0 ] ); + out = new Float32Array( 2 ); + expected = new Float32Array( [ NaN, NaN ] ); + + v = scale( NaN, c1, 1, 0, out, 1, 0 ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat32Array( out, expected ), true, 'returns expected value' ); + + t.end(); +});