From 062dc8cdf0343420274c5706ae1b063cb7d836f4 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Fri, 26 Apr 2024 01:50:39 +0530 Subject: [PATCH 01/16] feat: add C / Fortran implementation for dcabs1 --- .../@stdlib/blas/base/dcabs1/README.md | 91 ++++ .../blas/base/dcabs1/benchmark/benchmark.js | 63 +++ .../base/dcabs1/benchmark/benchmark.native.js | 68 +++ .../blas/base/dcabs1/benchmark/c/Makefile | 146 ++++++ .../dcabs1/benchmark/c/benchmark.length.c | 150 ++++++ .../base/dcabs1/benchmark/fortran/Makefile | 141 ++++++ .../benchmark/fortran/benchmark.length.f | 205 +++++++++ .../@stdlib/blas/base/dcabs1/binding.gyp | 265 +++++++++++ .../@stdlib/blas/base/dcabs1/docs/repl.txt | 22 + .../blas/base/dcabs1/docs/types/index.d.ts | 44 ++ .../blas/base/dcabs1/docs/types/test.ts | 45 ++ .../blas/base/dcabs1/examples/c/Makefile | 146 ++++++ .../blas/base/dcabs1/examples/c/example.c | 43 ++ .../blas/base/dcabs1/examples/index.js | 34 ++ .../@stdlib/blas/base/dcabs1/include.gypi | 70 +++ .../dcabs1/include/stdlib/blas/base/dcabs1.h | 44 ++ .../include/stdlib/blas/base/dcabs1_fortran.h | 43 ++ .../include/stdlib/blas/base/dcabs_cblas.h | 43 ++ .../@stdlib/blas/base/dcabs1/lib/index.js | 41 ++ .../@stdlib/blas/base/dcabs1/lib/main.js | 49 ++ .../@stdlib/blas/base/dcabs1/lib/native.js | 47 ++ .../@stdlib/blas/base/dcabs1/manifest.json | 427 ++++++++++++++++++ .../@stdlib/blas/base/dcabs1/package.json | 72 +++ .../@stdlib/blas/base/dcabs1/src/Makefile | 70 +++ .../@stdlib/blas/base/dcabs1/src/addon.c | 42 ++ .../@stdlib/blas/base/dcabs1/src/dcabs1.c | 43 ++ .../@stdlib/blas/base/dcabs1/src/dcabs1.f | 65 +++ .../blas/base/dcabs1/src/dcabs1_cblas.c | 31 ++ .../@stdlib/blas/base/dcabs1/src/dcabs1_f.c | 33 ++ .../@stdlib/blas/base/dcabs1/src/dcabs1sub.f | 41 ++ .../@stdlib/blas/base/dcabs1/test/test.js | 79 ++++ .../blas/base/dcabs1/test/test.native.js | 88 ++++ 32 files changed, 2791 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/dcabs1/README.md create mode 100644 lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/c/benchmark.length.c create mode 100644 lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/fortran/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/fortran/benchmark.length.f create mode 100644 lib/node_modules/@stdlib/blas/base/dcabs1/binding.gyp create mode 100644 lib/node_modules/@stdlib/blas/base/dcabs1/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/base/dcabs1/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/base/dcabs1/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/base/dcabs1/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/dcabs1/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/blas/base/dcabs1/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/dcabs1/include.gypi create mode 100644 lib/node_modules/@stdlib/blas/base/dcabs1/include/stdlib/blas/base/dcabs1.h create mode 100644 lib/node_modules/@stdlib/blas/base/dcabs1/include/stdlib/blas/base/dcabs1_fortran.h create mode 100644 lib/node_modules/@stdlib/blas/base/dcabs1/include/stdlib/blas/base/dcabs_cblas.h create mode 100644 lib/node_modules/@stdlib/blas/base/dcabs1/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/dcabs1/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/base/dcabs1/lib/native.js create mode 100644 lib/node_modules/@stdlib/blas/base/dcabs1/manifest.json create mode 100644 lib/node_modules/@stdlib/blas/base/dcabs1/package.json create mode 100644 lib/node_modules/@stdlib/blas/base/dcabs1/src/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/dcabs1/src/addon.c create mode 100644 lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1.c create mode 100644 lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1.f create mode 100644 lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1_cblas.c create mode 100644 lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1_f.c create mode 100644 lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1sub.f create mode 100644 lib/node_modules/@stdlib/blas/base/dcabs1/test/test.js create mode 100644 lib/node_modules/@stdlib/blas/base/dcabs1/test/test.native.js diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/README.md b/lib/node_modules/@stdlib/blas/base/dcabs1/README.md new file mode 100644 index 000000000000..5f1dc4370233 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/README.md @@ -0,0 +1,91 @@ + + +# dcabs1 + +> Compute the sum of the [absolute value][absolute-value] of the real part and imaginary part of a double-precision [complex][@stdlib/complex/float64] floating-point number. + +
+ +## Usage + +```javascript +var dcabs1 = require( '@stdlib/blas/base/dcabs1' ); +``` + +#### dcabs1( z ) + +Computes the sum of the [absolute value][absolute-value] of the real part and imaginary part of a double-precision [complex][@stdlib/complex/float64] floating-point number. + +```javascript +var Complex128 = require( '@stdlib/complex/float64' ); + +var y = dcabs1( new Complex128( 5.0, 3.0 ) ); +// returns 8.0 +``` + +
+ + + +
+ +## Examples + + + + + +```javascript +var Complex128 = require( '@stdlib/complex/float64' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var dcabs1 = require( '@stdlib/blas/base/dcabs1' ); + +var z; +var i; +for ( i = 0; i < 100; i++ ) { + z = new Complex128( discreteUniform( -50, 50 ), discreteUniform( -50, 50 ) ); + console.log( 'dcabs1(%s) = %d', z.toString(), dcabs1( z ) ); +} +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/benchmark.js new file mode 100644 index 000000000000..78bd625d72bf --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/benchmark.js @@ -0,0 +1,63 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/base/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var Complex128 = require( '@stdlib/complex/float64' ); +var pkg = require( './../package.json' ).name; +var dcabs1 = require( './../lib' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var values; + var y; + var i; + + values = [ + new Complex128( uniform( -500.0, 500.0, options ), uniform( -500.0, 500.0, options ) ), + new Complex128( uniform( -500.0, 500.0, options ), uniform( -500.0, 500.0, options ) ) + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = dcabs1( values[ i%values.length ] ); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/benchmark.native.js new file mode 100644 index 000000000000..025ed38adc33 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/benchmark.native.js @@ -0,0 +1,68 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/base/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var Complex128 = require( '@stdlib/complex/float64' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var dcabs1 = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( dcabs1 instanceof Error ) +}; +var options = { + 'dtype': 'float64' +}; + + +// MAIN // + +bench( pkg+'::native', opts, function benchmark( b ) { + var values; + var y; + var i; + + values = [ + new Complex128( uniform( -500.0, 500.0, options ), uniform( -500.0, 500.0, options ) ), + new Complex128( uniform( -500.0, 500.0, options ), uniform( -500.0, 500.0, options ) ) + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = dcabs1( values[ i%values.length ] ); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/c/Makefile b/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/c/Makefile new file mode 100644 index 000000000000..9f97140e7cb0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2024 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# 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.length.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/blas/base/dcabs1/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/c/benchmark.length.c new file mode 100644 index 000000000000..577a46c9935e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/c/benchmark.length.c @@ -0,0 +1,150 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/** +* Benchmark `dcabs1`. +*/ +#include "stdlib/blas/base/dcabs1.h" +#include "stdlib/complex/float64.h" +#include +#include +#include +#include +#include + +#define NAME "dcabs1" +#define ITERATIONS 10000000 +#define REPEATS 3 +#define MIN 1 +#define MAX 6 + +/** +* Prints the TAP version. +*/ +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 +*/ +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 iterations number of iterations +* @param elapsed elapsed time in seconds +*/ +void print_results( int iterations, 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 +*/ +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 +*/ +double rand_double( void ) { + int r = rand(); + return (double)r / ( (double)RAND_MAX + 1.0 ); +} + +/** +* Runs a benchmark. +* +* @param iterations number of iterations +* @return elapsed time in seconds +*/ +double benchmark( int iterations ) { + stdlib_complex128_t z; + double elapsed; + double t; + double y; + int i; + + z = stdlib_complex128( rand_double()*50.0, rand_double()*50.0 ); + y = 0.0; + t = tic(); + for ( i = 0; i < iterations; i++ ) { + y = c_dcabs1( z ); + if ( y != y ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( y != y ) { + printf( "should not return NaN\n" ); + } + return elapsed; +} + +/** +* Main execution sequence. +*/ +int main( void ) { + double elapsed; + int count; + int iter; + int i; + int j; + + // Use the current time to seed the random number generator: + srand( time( NULL ) ); + + print_version(); + count = 0; + for ( i = MIN; i <= MAX; i++ ) { + iter = ITERATIONS / pow( 10, i-1 ); + for ( j = 0; j < REPEATS; j++ ) { + count += 1; + printf( "# c::%s", NAME ); + elapsed = benchmark( iter ); + print_results( iter, elapsed ); + printf( "ok %d benchmark finished\n", count ); + } + } + print_summary( count, count ); +} diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/fortran/Makefile b/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/fortran/Makefile new file mode 100644 index 000000000000..c4946c7b13fc --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/fortran/Makefile @@ -0,0 +1,141 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2024 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# 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 Fortran source files: +ifdef FORTRAN_COMPILER + FC := $(FORTRAN_COMPILER) +else + FC := gfortran +endif + +# Define the command-line options when compiling Fortran files: +FFLAGS ?= \ + -std=f95 \ + -ffree-form \ + -O3 \ + -Wall \ + -Wextra \ + -Wno-compare-reals \ + -Wimplicit-interface \ + -fno-underscoring \ + -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 ?= + +# List of Fortran source files: +SOURCE_FILES ?= ../../src/dcabs1.f + +# List of Fortran targets: +f_targets := benchmark.length.out + + +# RULES # + +#/ +# Compiles Fortran source files. +# +# @param {string} SOURCE_FILES - list of Fortran source files +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) +# @param {string} [FORTRAN_COMPILER] - Fortran compiler +# @param {string} [FFLAGS] - Fortran compiler flags +# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code +# +# @example +# make +# +# @example +# make all +#/ +all: $(f_targets) + +.PHONY: all + +#/ +# Compiles Fortran source files. +# +# @private +# @param {string} SOURCE_FILES - list of Fortran source files +# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) +# @param {string} FC - Fortran compiler +# @param {string} FFLAGS - Fortran compiler flags +# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code +#/ +$(f_targets): %.out: %.f + $(QUIET) $(FC) $(FFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(f_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/blas/base/dcabs1/benchmark/fortran/benchmark.length.f b/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/fortran/benchmark.length.f new file mode 100644 index 000000000000..b2da15372541 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/fortran/benchmark.length.f @@ -0,0 +1,205 @@ +!> +! @license Apache-2.0 +! +! Copyright (c) 2024 The Stdlib Authors. +! +! Licensed under the Apache License, Version 2.0 (the "License"); +! you may not use this file except in compliance with the License. +! You may obtain a copy of the License at +! +! http://www.apache.org/licenses/LICENSE-2.0 +! +! Unless required by applicable law or agreed to in writing, software +! distributed under the License is distributed on an "AS IS" BASIS, +! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +! See the License for the specific language governing permissions and +! limitations under the License. +!< + +!> Benchmark `dcabs1`. +! +! ## Notes +! +! - Written in "free form" Fortran 95. +! +!< +program bench + implicit none + ! .. + ! Local constants: + character(6), parameter :: name = 'dcabs1' ! if changed, be sure to adjust length + integer, parameter :: iterations = 1000000 + integer, parameter :: repeats = 3 + integer, parameter :: min = 1 + integer, parameter :: max = 6 + ! .. + ! Run the benchmarks: + call main() + ! .. + ! Functions: +contains + ! .. + ! Prints the TAP version. + ! .. + subroutine print_version() + print '(A)', 'TAP version 13' + end subroutine print_version + ! .. + ! Prints the TAP summary. + ! + ! @param {integer} total - total number of tests + ! @param {integer} passing - total number of passing tests + ! .. + subroutine print_summary( total, passing ) + ! .. + ! Scalar arguments: + integer, intent(in) :: total, passing + ! .. + ! Local variables: + character(len=999) :: str, tmp + ! .. + ! Intrinsic functions: + intrinsic adjustl, trim + ! .. + print '(A)', '#' + ! .. + write (str, '(I15)') total ! TAP plan + tmp = adjustl( str ) + print '(A,A)', '1..', trim( tmp ) + ! .. + print '(A,A)', '# total ', trim( tmp ) + ! .. + write (str, '(I15)') passing + tmp = adjustl( str ) + print '(A,A)', '# pass ', trim( tmp ) + ! .. + print '(A)', '#' + print '(A)', '# ok' + end subroutine print_summary + ! .. + ! Prints benchmarks results. + ! + ! @param {integer} iterations - number of iterations + ! @param {double} elapsed - elapsed time in seconds + ! .. + subroutine print_results( iterations, elapsed ) + ! .. + ! Scalar arguments: + double precision, intent(in) :: elapsed + integer, intent(in) :: iterations + ! .. + ! Local variables: + double precision :: rate + character(len=999) :: str, tmp + ! .. + ! Intrinsic functions: + intrinsic dble, adjustl, trim + ! .. + rate = dble( iterations ) / elapsed + ! .. + print '(A)', ' ---' + ! .. + write (str, '(I15)') iterations + tmp = adjustl( str ) + print '(A,A)', ' iterations: ', trim( tmp ) + ! .. + write (str, '(f0.9)') elapsed + tmp = adjustl( str ) + print '(A,A)', ' elapsed: ', trim( tmp ) + ! .. + write( str, '(f0.9)') rate + tmp = adjustl( str ) + print '(A,A)', ' rate: ', trim( tmp ) + ! .. + print '(A)', ' ...' + end subroutine print_results + ! .. + ! Runs a benchmark. + ! + ! @param {integer} iterations - number of iterations + ! @return {double} elapsed time in seconds + ! .. + double precision function benchmark( iterations ) + ! .. + ! External functions: + interface + double precision function dcabs1( z ) + complex(8) :: z + end function dcabs1 + end interface + ! .. + ! Scalar arguments: + integer, intent(in) :: iterations + ! .. + ! Local scalars: + double precision :: elapsed, r1, r2 + real :: t1, t2 + double precision :: y + integer :: i + ! .. + ! Local scalar: + complex(8) :: z + ! .. + ! Intrinsic functions: + intrinsic random_number, cpu_time + ! .. + call random_number( r1 ) + call random_number( r2 ) + z = cmplx( (r1*100.0d0)-50.0d0, (r2*100.0d0)-50.0d0, kind=kind(0.0d0) ) + ! .. + call cpu_time( t1 ) + ! .. + y = 0.0 + do i = 1, iterations + y = dcabs1( z ) + if ( y /= y ) then + print '(A)', 'unexpected result' + exit + end if + end do + ! .. + call cpu_time( t2 ) + ! .. + elapsed = t2 - t1 + ! .. + if ( y /= y ) then + print '(A)', 'unexpected result' + end if + ! .. + benchmark = elapsed + return + end function benchmark + ! .. + ! Main execution sequence. + ! .. + subroutine main() + ! .. + ! Local variables: + character(len=999) :: str, tmp + double precision :: elapsed + integer :: i, j, count, iter + ! .. + ! Intrinsic functions: + intrinsic adjustl, trim + ! .. + call print_version() + count = 0 + do i = min, max + iter = iterations / 10**(i-1) + do j = 1, repeats + count = count + 1 + ! .. + print '(A,A,A,A)', '# fortran::', name + ! .. + elapsed = benchmark( iter ) + ! .. + call print_results( iter, elapsed ) + ! .. + write (str, '(I15)') count + tmp = adjustl( str ) + print '(A,A,A)', 'ok ', trim( tmp ), ' benchmark finished' + end do + end do + call print_summary( count, count ) + end subroutine main +end program bench \ No newline at end of file diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/binding.gyp b/lib/node_modules/@stdlib/blas/base/dcabs1/binding.gyp new file mode 100644 index 000000000000..02a2799da097 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/binding.gyp @@ -0,0 +1,265 @@ +# @license Apache-2.0 +# +# Copyright (c) 2024 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# 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', + + # Fortran compiler (to override -Dfortran_compiler=): + 'fortran_compiler%': 'gfortran', + + # Fortran compiler flags: + 'fflags': [ + # Specify the Fortran standard to which a program is expected to conform: + '-std=f95', + + # Indicate that the layout is free-form source code: + '-ffree-form', + + # Aggressive optimization: + '-O3', + + # Enable commonly used warning options: + '-Wall', + + # Warn if source code contains problematic language features: + '-Wextra', + + # Warn if a procedure is called without an explicit interface: + '-Wimplicit-interface', + + # Do not transform names of entities specified in Fortran source files by appending underscores (i.e., don't mangle names, thus allowing easier usage in C wrappers): + '-fno-underscoring', + + # Warn if source code contains Fortran 95 extensions and C-language constructs: + '-pedantic', + + # Compile but do not link (output is an object file): + '-c', + ], + + # 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 + + # Define custom build actions for particular inputs: + 'rules': [ + { + # Define a rule for processing Fortran files: + 'extension': 'f', + + # Define the pathnames to be used as inputs when performing processing: + 'inputs': [ + # Full path of the current input: + '<(RULE_INPUT_PATH)' + ], + + # Define the outputs produced during processing: + 'outputs': [ + # Store an output object file in a directory for placing intermediate results (only accessible within a single target): + '<(INTERMEDIATE_DIR)/<(RULE_INPUT_ROOT).<(obj)' + ], + + # Define the rule for compiling Fortran based on the host OS: + 'conditions': [ + [ + 'OS=="win"', + + # Rule to compile Fortran on Windows: + { + 'rule_name': 'compile_fortran_windows', + 'message': 'Compiling Fortran file <(RULE_INPUT_PATH) on Windows...', + + 'process_outputs_as_sources': 0, + + # Define the command-line invocation: + 'action': [ + '<(fortran_compiler)', + '<@(fflags)', + '<@(_inputs)', + '-o', + '<@(_outputs)', + ], + }, + + # Rule to compile Fortran on non-Windows: + { + 'rule_name': 'compile_fortran_linux', + 'message': 'Compiling Fortran file <(RULE_INPUT_PATH) on Linux...', + + 'process_outputs_as_sources': 1, + + # Define the command-line invocation: + 'action': [ + '<(fortran_compiler)', + '<@(fflags)', + '-fPIC', # generate platform-independent code + '<@(_inputs)', + '-o', + '<@(_outputs)', + ], + } + ], # end condition (OS=="win") + ], # end conditions + }, # end rule (extension=="f") + ], # end rules + }, # 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/blas/base/dcabs1/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/dcabs1/docs/repl.txt new file mode 100644 index 000000000000..b9d6938beff3 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/docs/repl.txt @@ -0,0 +1,22 @@ + +{{alias}}( z ) + Computes the sum of the absolute value of real and imaginary part of a + double-precision complex floating-point number. + + Parameters + ---------- + z: Complex128 + Complex number. + + Returns + ------- + y: number + Result. + + Examples + -------- + > var y = {{alias}}( new {{alias:@stdlib/complex/float64}}( 5.0, 3.0 ) ) + 8.0 + + See Also + -------- diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/dcabs1/docs/types/index.d.ts new file mode 100644 index 000000000000..28e27ee810bd --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/docs/types/index.d.ts @@ -0,0 +1,44 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +import { Complex128 } from '@stdlib/types/complex'; + +/** +* Computes the sum of the absolute value of the real and imaginary part of a double-precision complex floating-point number. +* +* ## Notes +* +* @param z - complex number +* @returns result +* +* @example +* var Complex128 = require( '@stdlib/complex/float64' ); +* +* var v = dcabs1( new Complex128( 5.0, 3.0 ) ); +* // returns 8.0 +*/ +declare function dcabs1( z: Complex128 ): number; + + +// EXPORTS // + +export = dcabs1; diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/dcabs1/docs/types/test.ts new file mode 100644 index 000000000000..54aac9ed823f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/docs/types/test.ts @@ -0,0 +1,45 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import Complex128 = require( '@stdlib/complex/float64' ); +import dcabs1 = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + dcabs1( new Complex128( 5, 3 ) ); // $ExpectType number +} + +// The compiler throws an error if the function is not provided a complex number... +{ + dcabs1( true ); // $ExpectError + dcabs1( false ); // $ExpectError + dcabs1( null ); // $ExpectError + dcabs1( undefined ); // $ExpectError + dcabs1( '5' ); // $ExpectError + dcabs1( [] ); // $ExpectError + dcabs1( {} ); // $ExpectError + dcabs1( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided insufficient arguments... +{ + dcabs1(); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/examples/c/Makefile b/lib/node_modules/@stdlib/blas/base/dcabs1/examples/c/Makefile new file mode 100644 index 000000000000..6aed70daf167 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/examples/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2024 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# 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/blas/base/dcabs1/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/dcabs1/examples/c/example.c new file mode 100644 index 000000000000..3b1db58b56ce --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/examples/c/example.c @@ -0,0 +1,43 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/blas/base/dcabs1.h" +#include "stdlib/complex/float64.h" +#include "stdlib/complex/reim.h" +#include + +int main( void ) { + const stdlib_complex128_t x[] = { + stdlib_complex128( 3.14, 1.0 ), + stdlib_complex128( -3.14, -1.0 ), + stdlib_complex128( 0.0, 0.0 ), + stdlib_complex128( 0.0/0.0, 0.0/0.0 ) + }; + + stdlib_complex128_t z; + double re; + double im; + double y; + int i; + for ( i = 0; i < 4; i++ ) { + z = x[ i ]; + y = c_dcabs1( z ); + stdlib_reim( z, &re, &im ); + printf( "f(%lf + %lf) = %lf\n", re, im, y ); + } +} diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/examples/index.js b/lib/node_modules/@stdlib/blas/base/dcabs1/examples/index.js new file mode 100644 index 000000000000..6836c47a18ad --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/examples/index.js @@ -0,0 +1,34 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var Complex128 = require( '@stdlib/complex/float64' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var dcabs1 = require( './../lib' ); + +// Create a PRNG to generate uniformly distributed pseudorandom integers: +var rand = discreteUniform( -50, 50 ); + +// Compute the sum of the absolute value of real and imaginary part for a set of complex numbers... +var z; +var i; +for ( i = 0; i < 100; i++ ) { + z = new Complex128( rand(), rand() ); + console.log( 'dcabs1(%s) = %d', z.toString(), dcabs1( z ) ); +} diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/include.gypi b/lib/node_modules/@stdlib/blas/base/dcabs1/include.gypi new file mode 100644 index 000000000000..497aeca15320 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/include.gypi @@ -0,0 +1,70 @@ +# @license Apache-2.0 +# +# Copyright (c) 2024 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A GYP include file for building a Node.js native add-on. +# +# Note that nesting variables is required due to how GYP processes a configuration. Any variables defined within a nested 'variables' section is defined in the outer scope. Thus, conditions in the outer variable scope are free to use these variables without running into "variable undefined" errors. +# +# Main documentation: +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +# +# Variable nesting hacks: +# +# [3]: https://chromium.googlesource.com/external/skia/gyp/+/master/common_variables.gypi +# [4]: https://src.chromium.org/viewvc/chrome/trunk/src/build/common.gypi?revision=127004 +{ + # Define variables to be used throughout the configuration for all targets: + 'variables': { + 'variables': { + # Host BLAS library (to override -Dblas=): + 'blas%': '', + + # Path to BLAS library (to override -Dblas_dir=): + 'blas_dir%': '', + }, # end variables + + # Source directory: + 'src_dir': './src', + + # Include directories: + 'include_dirs': [ + '<@(blas_dir)', + '=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "math.abs", + "blas", + "scalar", + "dcabs1", + "abs", + "absolute", + "magnitude", + "modulus", + "float64", + "complex", + "cmplx", + "number" + ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/src/Makefile b/lib/node_modules/@stdlib/blas/base/dcabs1/src/Makefile new file mode 100644 index 000000000000..bcf18aa46655 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/src/Makefile @@ -0,0 +1,70 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2024 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# 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/blas/base/dcabs1/src/addon.c b/lib/node_modules/@stdlib/blas/base/dcabs1/src/addon.c new file mode 100644 index 000000000000..ca4ca2fcb3cd --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/src/addon.c @@ -0,0 +1,42 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/blas/base/dcabs1.h" +#include "stdlib/napi/export.h" +#include "stdlib/napi/argv.h" +#include "stdlib/napi/argv_complex128.h" +#include "stdlib/napi/create_double.h" +#include + +/** +* Receives JavaScript callback invocation data. +* +* @private +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +static napi_value addon( napi_env env, napi_callback_info info ) { + STDLIB_NAPI_ARGV( env, info, argv, argc, 1 ); + STDLIB_NAPI_ARGV_COMPLEX128( env, z, argv, 0 ); + STDLIB_NAPI_CREATE_DOUBLE( env, c_dcabs1( z ), y ); + + return y; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN( addon ) diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1.c b/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1.c new file mode 100644 index 000000000000..ae9827713c63 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1.c @@ -0,0 +1,43 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/blas/base/dcabs1.h" +#include "stdlib/math/base/special/abs.h" +#include "stdlib/complex/float64.h" +#include "stdlib/complex/reim.h" + +/** +* Computes the sum of the absolute value of the real and imaginary part of a double-precision complex floating-point number. +* +* @param z complex number +* @return result +* +* @example +* #include "stdlib/complex/float64.h" +* +* stdlib_complex128_t z = stdlib_complex128( 5.0, 3.0 ); +* +* double y = c_dcabs1( z ); +* // returns 8.0 +*/ +double c_dcabs1( const stdlib_complex128_t z ) { + double re; + double im; + stdlib_reim( z, &re, &im ); + return stdlib_base_abs( re ) + stdlib_base_abs( im ); +} diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1.f b/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1.f new file mode 100644 index 000000000000..4b58c76ecdc7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1.f @@ -0,0 +1,65 @@ +!> +! @license Apache-2.0 +! +! Copyright (c) 2024 The Stdlib Authors. +! +! Licensed under the Apache License, Version 2.0 (the "License"); +! you may not use this file except in compliance with the License. +! You may obtain a copy of the License at +! +! http://www.apache.org/licenses/LICENSE-2.0 +! +! Unless required by applicable law or agreed to in writing, software +! distributed under the License is distributed on an "AS IS" BASIS, +! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +! See the License for the specific language governing permissions and +! limitations under the License. +!< + +!> Computes the sum of the absolute value of the real and imaginary part of a double-precision complex floating-point number. +! +! ## Notes +! +! * Modified version of reference BLAS level1 routine (version 3.7.0). Updated to "free form" Fortran 95. +! +! ## Authors +! +! * Univ. of Tennessee +! * Univ. of California Berkeley +! * Univ. of Colorado Denver +! * NAG Ltd. +! +! ## History +! +! * Jack Dongarra, linpack, 3/11/78. +! +! - modified 3/93 to return if incx .le. 0. +! - modified 12/3/93, array(1) declarations changed to array(*) +! +! ## License +! +! From : +! +! > The reference BLAS is a freely-available software package. It is available from netlib via anonymous ftp and the World Wide Web. Thus, it can be included in commercial software packages (and has been). We only ask that proper credit be given to the authors. +! > +! > Like all software, it is copyrighted. It is not trademarked, but we do ask the following: +! > +! > * If you modify the source for these routines we ask that you change the name of the routine and comment the changes made to the original. +! > +! > * We will gladly answer any questions regarding the software. If a modification is done, however, it is the responsibility of the person who modified the routine to provide support. +! +! @param {complex} z - complex number +! @returns {double} result +!< +double precision function dcabs1( z ) + implicit none + ! .. + ! Scalar arguments: + complex(8) z + ! .. + ! Intrinsic functions: + intrinsic ABS, DBLE, AIMAG + ! .. + dcabs1 = ABS( DBLE( z ) ) + ABS( AIMAG( z ) ) + return +end function dcabs1 \ No newline at end of file diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1_cblas.c b/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1_cblas.c new file mode 100644 index 000000000000..8e22647b839e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1_cblas.c @@ -0,0 +1,31 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/blas/base/dcabs1.h" +#include "stdlib/blas/base/dcabs1_cblas.h" +#include "stdlib/complex/float64.h" + +/** +* Computes the sum of the absolute value of the real and imaginary part of a double-precision complex floating-point number. +* +* @param z complex number +* @return result +*/ +double c_dcabs1( const stdlib_complex128_t z ) { + return cblas_dcabs1( z ); +} diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1_f.c b/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1_f.c new file mode 100644 index 000000000000..74419718f8aa --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1_f.c @@ -0,0 +1,33 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/blas/base/dcabs1.h" +#include "stdlib/blas/base/dcabs1_fortran.h" +#include "stdlib/complex/float64.h" + +/** +* Computes the sum of the absolute value of the real and imaginary part of a double-precision complex floating-point number. +* +* @param z complex number +* @return result +*/ +double c_dcabs1( const stdlib_complex128_t z ) { + double y; + dcabs1sub( &z, &y ); + return y; +} diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1sub.f b/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1sub.f new file mode 100644 index 000000000000..663c53a88752 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1sub.f @@ -0,0 +1,41 @@ +!> +! @license Apache-2.0 +! +! Copyright (c) 2024 The Stdlib Authors. +! +! Licensed under the Apache License, Version 2.0 (the "License"); +! you may not use this file except in compliance with the License. +! You may obtain a copy of the License at +! +! http://www.apache.org/licenses/LICENSE-2.0 +! +! Unless required by applicable law or agreed to in writing, software +! distributed under the License is distributed on an "AS IS" BASIS, +! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +! See the License for the specific language governing permissions and +! limitations under the License. +!< + +!> Wraps `dcabs1` as a subroutine. +! +! @param {complex} z - complex number +! @param {double} y - result +!< +subroutine dcabs1sub( z, y ) + implicit none + ! .. + ! External functions: + interface + double precision function dcabs1( z ) + complex(8) :: z + end function dcabs1 + end interface + ! .. + ! Scalar arguments: + complex(8) :: z + double precision :: y + ! .. + ! Compute the sum of the absolute values of the real and imaginary part of a double-precision complex number: + y = dcabs1( z ) + return +end subroutine dcabs1sub \ No newline at end of file diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/test/test.js b/lib/node_modules/@stdlib/blas/base/dcabs1/test/test.js new file mode 100644 index 000000000000..731ff086c94a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/test/test.js @@ -0,0 +1,79 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64' ); +var dcabs1 = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dcabs1, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function computes the sum of the absolute value of the real and imaginary part of a complex number', function test( t ) { + var expected; + var delta; + var tol; + var re; + var im; + var y; + var i; + + re = new Float64Array( [ 5.0, -3.0, 0.0, 0.0, 3.0 ] ); + im = new Float64Array( [ 3.0, 4.0, 0.0, -0.0, 0.0 ] ); + expected = new Float64Array( [ 8.0, 7.0, 0.0, 0.0, 3.0 ] ); + + for ( i = 0; i < re.length; i++ ) { + y = dcabs1( new Complex128( re[ i ], im[ i ] ) ); + if ( y === expected[ i ] ) { + t.equal( y, expected[ i ], 're: '+re[i]+'. im: '+im[i]+'. Expected: '+expected[i] ); + } else { + delta = abs( y - expected[i] ); + tol = EPS * abs( expected[i] ); + t.ok( delta <= tol, 'within tolerance. re: '+re[i]+'. im: '+im[i]+' y: '+y+'. Expected: '+expected[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } + t.end(); +}); + +tape( 'if either the real or imaginary component is `NaN`, the function returns `NaN`', function test( t ) { + var v; + + v = dcabs1( new Complex128( NaN, 3.0 ) ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + v = dcabs1( new Complex128( 5.0, NaN ) ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + v = dcabs1( new Complex128( NaN, NaN ) ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/test/test.native.js b/lib/node_modules/@stdlib/blas/base/dcabs1/test/test.native.js new file mode 100644 index 000000000000..6cfc0c887481 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/test/test.native.js @@ -0,0 +1,88 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var dcabs1 = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( dcabs1 instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dcabs1, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function computes the sum of the absolute value of the real and imaginary part of a complex number', opts, function test( t ) { + var expected; + var delta; + var tol; + var re; + var im; + var y; + var i; + + re = new Float64Array( [ 5.0, -3.0, 0.0, 0.0, 3.0 ] ); + im = new Float64Array( [ 3.0, 4.0, 0.0, -0.0, 0.0 ] ); + expected = new Float64Array( [ 8.0, 7.0, 0.0, 0.0, 3.0 ] ); + + for ( i = 0; i < re.length; i++ ) { + y = dcabs1( new Complex128( re[ i ], im[ i ] ) ); + if ( y === expected[ i ] ) { + t.equal( y, expected[ i ], 're: '+re[i]+'. im: '+im[i]+'. Expected: '+expected[i] ); + } else { + delta = abs( y - expected[i] ); + tol = EPS * abs( expected[i] ); + t.ok( delta <= tol, 'within tolerance. re: '+re[i]+'. im: '+im[i]+' y: '+y+'. Expected: '+expected[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } + t.end(); +}); + +tape( 'if either the real or imaginary component is `NaN`, the function returns `NaN`', opts, function test( t ) { + var v; + + v = dcabs1( new Complex128( NaN, 3.0 ) ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + v = dcabs1( new Complex128( 5.0, NaN ) ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + v = dcabs1( new Complex128( NaN, NaN ) ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + t.end(); +}); From 7231c8a681edbc4fa829c4a639dfbe88f21977f0 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Fri, 26 Apr 2024 01:53:42 +0530 Subject: [PATCH 02/16] chore: resolve warnings --- .../@stdlib/blas/base/dcabs1/benchmark/benchmark.js | 4 ++-- .../@stdlib/blas/base/dcabs1/benchmark/benchmark.native.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/benchmark.js index 78bd625d72bf..a182f9d21f0a 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/benchmark.js @@ -43,8 +43,8 @@ bench( pkg, function benchmark( b ) { var i; values = [ - new Complex128( uniform( -500.0, 500.0, options ), uniform( -500.0, 500.0, options ) ), - new Complex128( uniform( -500.0, 500.0, options ), uniform( -500.0, 500.0, options ) ) + new Complex128( uniform( -500.0, 500.0, options ), uniform( -500.0, 500.0, options ) ), // eslint-disable-line max-len + new Complex128( uniform( -500.0, 500.0, options ), uniform( -500.0, 500.0, options ) ) // eslint-disable-line max-len ]; b.tic(); diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/benchmark.native.js index 025ed38adc33..95e422963756 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/benchmark.native.js @@ -48,8 +48,8 @@ bench( pkg+'::native', opts, function benchmark( b ) { var i; values = [ - new Complex128( uniform( -500.0, 500.0, options ), uniform( -500.0, 500.0, options ) ), - new Complex128( uniform( -500.0, 500.0, options ), uniform( -500.0, 500.0, options ) ) + new Complex128( uniform( -500.0, 500.0, options ), uniform( -500.0, 500.0, options ) ), // eslint-disable-line max-len + new Complex128( uniform( -500.0, 500.0, options ), uniform( -500.0, 500.0, options ) ) // eslint-disable-line max-len ]; b.tic(); From cd2dc8b25b298fd9fe450169a82a00e45ca6dc37 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Thu, 6 Jun 2024 15:56:54 +0530 Subject: [PATCH 03/16] chore: apply review changes --- .../@stdlib/blas/base/dcabs1/README.md | 110 ++++++++++++++++-- .../blas/base/dcabs1/benchmark/benchmark.js | 15 +-- .../base/dcabs1/benchmark/benchmark.native.js | 11 +- .../blas/base/dcabs1/benchmark/c/Makefile | 2 +- .../c/{benchmark.length.c => benchmark.c} | 2 +- .../base/dcabs1/benchmark/fortran/Makefile | 2 +- .../{benchmark.length.f => benchmark.f} | 0 .../blas/base/dcabs1/docs/types/index.d.ts | 2 +- .../blas/base/dcabs1/docs/types/test.ts | 2 +- .../blas/base/dcabs1/examples/c/example.c | 16 +-- .../blas/base/dcabs1/examples/index.js | 6 +- .../dcabs1/include/stdlib/blas/base/dcabs1.h | 7 +- .../include/stdlib/blas/base/dcabs1_fortran.h | 4 +- .../include/stdlib/blas/base/dcabs_cblas.h | 4 +- .../@stdlib/blas/base/dcabs1/lib/index.js | 2 +- .../@stdlib/blas/base/dcabs1/manifest.json | 77 +++++++----- .../@stdlib/blas/base/dcabs1/package.json | 5 +- .../@stdlib/blas/base/dcabs1/src/addon.c | 3 +- .../@stdlib/blas/base/dcabs1/src/dcabs1.c | 6 +- .../@stdlib/blas/base/dcabs1/src/dcabs1.f | 2 +- .../blas/base/dcabs1/src/dcabs1_cblas.c | 4 +- .../@stdlib/blas/base/dcabs1/src/dcabs1_f.c | 4 +- .../@stdlib/blas/base/dcabs1/src/dcabs1sub.f | 2 +- .../@stdlib/blas/base/dcabs1/test/test.js | 22 +--- .../blas/base/dcabs1/test/test.native.js | 20 +--- 25 files changed, 204 insertions(+), 126 deletions(-) rename lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/c/{benchmark.length.c => benchmark.c} (98%) rename lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/fortran/{benchmark.length.f => benchmark.f} (100%) diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/README.md b/lib/node_modules/@stdlib/blas/base/dcabs1/README.md index 5f1dc4370233..915655bffb07 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/README.md +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/README.md @@ -20,7 +20,7 @@ limitations under the License. # dcabs1 -> Compute the sum of the [absolute value][absolute-value] of the real part and imaginary part of a double-precision [complex][@stdlib/complex/float64] floating-point number. +> Compute the sum of the [absolute values][absolute-value] of the real part and imaginary components of a double-precision [complex][@stdlib/complex/float64/ctor] floating-point number.
@@ -32,10 +32,10 @@ var dcabs1 = require( '@stdlib/blas/base/dcabs1' ); #### dcabs1( z ) -Computes the sum of the [absolute value][absolute-value] of the real part and imaginary part of a double-precision [complex][@stdlib/complex/float64] floating-point number. +Computes the sum of the [absolute values][absolute-value] of the real part and imaginary components of a double-precision [complex][@stdlib/complex/float64/ctor] floating-point number. ```javascript -var Complex128 = require( '@stdlib/complex/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); var y = dcabs1( new Complex128( 5.0, 3.0 ) ); // returns 8.0 @@ -49,19 +49,17 @@ var y = dcabs1( new Complex128( 5.0, 3.0 ) ); ## Examples - - ```javascript -var Complex128 = require( '@stdlib/complex/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); var dcabs1 = require( '@stdlib/blas/base/dcabs1' ); var z; var i; for ( i = 0; i < 100; i++ ) { - z = new Complex128( discreteUniform( -50, 50 ), discreteUniform( -50, 50 ) ); + z = new Complex128( discreteUniform( -5, 5 ), discreteUniform( -5, 5 ) ); console.log( 'dcabs1(%s) = %d', z.toString(), dcabs1( z ) ); } ``` @@ -70,6 +68,102 @@ for ( i = 0; i < 100; i++ ) { + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/blas/base/dcabs1.h" +``` + +#### c_dcabs1( z ) + +Computes the sum of the [absolute values][absolute-value] of the real and imaginary components of a double-precision [complex][@stdlib/complex/float64/ctor] floating-point number. + +```c +#include "stdlib/complex/float64/ctor.h" + +const stdlib_complex128_t c = stdlib_complex128( 3.14, 1.0 ); + +c_dcabs1( z ); +``` + +The function accepts the following arguments: + +- **z**: `[in] stdlib_complex128_t` complex number. + +```c +void c_dcabs1( const stdlib_complex128_t z ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/blas/base/dcabs1.h" +#include "stdlib/complex/float64/ctor.h" +#include "stdlib/complex/real.h" +#include "stdlib/complex/imag.h" +#include + +int main( void ) { + const stdlib_complex128_t x[] = { + stdlib_complex128( 3.14, 1.0 ), + stdlib_complex128( -3.14, -1.0 ), + stdlib_complex128( 0.0, 0.0 ), + stdlib_complex128( 0.0/0.0, 0.0/0.0 ) + }; + + float y; + int i; + for ( i = 0; i < 4; i++ ) { + y = c_dcabs1( x[ i ] ); + printf( "f(%lf + %lf) = %lf\n", stdlib_real( x[ i ] ), stdlib_imag( x[ i ] ), y ); + } +} +``` + +
+ + + +
+ + + diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/benchmark.js index a182f9d21f0a..bb0b8fdf177e 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/benchmark.js @@ -21,20 +21,13 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var Complex128 = require( '@stdlib/complex/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); var pkg = require( './../package.json' ).name; var dcabs1 = require( './../lib' ); -// VARIABLES // - -var options = { - 'dtype': 'float64' -}; - - // MAIN // bench( pkg, function benchmark( b ) { @@ -43,8 +36,8 @@ bench( pkg, function benchmark( b ) { var i; values = [ - new Complex128( uniform( -500.0, 500.0, options ), uniform( -500.0, 500.0, options ) ), // eslint-disable-line max-len - new Complex128( uniform( -500.0, 500.0, options ), uniform( -500.0, 500.0, options ) ) // eslint-disable-line max-len + new Complex128( discreteUniform( -500.0, 500.0 ), discreteUniform( -500.0, 500.0 ) ), // eslint-disable-line max-len + new Complex128( discreteUniform( -500.0, 500.0 ), discreteUniform( -500.0, 500.0 ) ) // eslint-disable-line max-len ]; b.tic(); diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/benchmark.native.js index 95e422963756..a8657d7ce751 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/benchmark.native.js @@ -22,9 +22,9 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var Complex128 = require( '@stdlib/complex/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -35,9 +35,6 @@ var dcabs1 = tryRequire( resolve( __dirname, './../lib/native.js' ) ); var opts = { 'skip': ( dcabs1 instanceof Error ) }; -var options = { - 'dtype': 'float64' -}; // MAIN // @@ -48,8 +45,8 @@ bench( pkg+'::native', opts, function benchmark( b ) { var i; values = [ - new Complex128( uniform( -500.0, 500.0, options ), uniform( -500.0, 500.0, options ) ), // eslint-disable-line max-len - new Complex128( uniform( -500.0, 500.0, options ), uniform( -500.0, 500.0, options ) ) // eslint-disable-line max-len + new Complex128( discreteUniform( -500.0, 500.0 ), discreteUniform( -500.0, 500.0 ) ), // eslint-disable-line max-len + new Complex128( discreteUniform( -500.0, 500.0 ), discreteUniform( -500.0, 500.0 ) ) // eslint-disable-line max-len ]; b.tic(); diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/c/Makefile b/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/c/Makefile index 9f97140e7cb0..f69e9da2b4d3 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/c/Makefile +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/c/Makefile @@ -82,7 +82,7 @@ LIBRARIES ?= LIBPATH ?= # List of C targets: -c_targets := benchmark.length.out +c_targets := benchmark.out # RULES # diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/c/benchmark.c similarity index 98% rename from lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/c/benchmark.length.c rename to lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/c/benchmark.c index 577a46c9935e..495169ef7779 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/c/benchmark.c @@ -20,7 +20,7 @@ * Benchmark `dcabs1`. */ #include "stdlib/blas/base/dcabs1.h" -#include "stdlib/complex/float64.h" +#include "stdlib/complex/float64/ctor.h" #include #include #include diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/fortran/Makefile b/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/fortran/Makefile index c4946c7b13fc..98440e45d695 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/fortran/Makefile +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/fortran/Makefile @@ -81,7 +81,7 @@ INCLUDE ?= SOURCE_FILES ?= ../../src/dcabs1.f # List of Fortran targets: -f_targets := benchmark.length.out +f_targets := benchmark.out # RULES # diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/fortran/benchmark.length.f b/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/fortran/benchmark.f similarity index 100% rename from lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/fortran/benchmark.length.f rename to lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/fortran/benchmark.f diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/dcabs1/docs/types/index.d.ts index 28e27ee810bd..fbde626cb6cc 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/docs/types/index.d.ts @@ -23,7 +23,7 @@ import { Complex128 } from '@stdlib/types/complex'; /** -* Computes the sum of the absolute value of the real and imaginary part of a double-precision complex floating-point number. +* Computes the sum of the absolute values of the real and imaginary components of a double-precision complex floating-point number. * * ## Notes * diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/dcabs1/docs/types/test.ts index 54aac9ed823f..2119c92f12a2 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/docs/types/test.ts @@ -16,7 +16,7 @@ * limitations under the License. */ -import Complex128 = require( '@stdlib/complex/float64' ); +import Complex128 = require( '@stdlib/complex/float64/ctor' ); import dcabs1 = require( './index' ); diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/dcabs1/examples/c/example.c index 3b1db58b56ce..648e0104444f 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/examples/c/example.c @@ -17,8 +17,9 @@ */ #include "stdlib/blas/base/dcabs1.h" -#include "stdlib/complex/float64.h" -#include "stdlib/complex/reim.h" +#include "stdlib/complex/float64/ctor.h" +#include "stdlib/complex/real.h" +#include "stdlib/complex/imag.h" #include int main( void ) { @@ -29,15 +30,10 @@ int main( void ) { stdlib_complex128( 0.0/0.0, 0.0/0.0 ) }; - stdlib_complex128_t z; - double re; - double im; - double y; + float y; int i; for ( i = 0; i < 4; i++ ) { - z = x[ i ]; - y = c_dcabs1( z ); - stdlib_reim( z, &re, &im ); - printf( "f(%lf + %lf) = %lf\n", re, im, y ); + y = c_dcabs1( x[ i ] ); + printf( "f(%lf + %lf) = %lf\n", stdlib_real( x[ i ] ), stdlib_imag( x[ i ] ), y ); } } diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/examples/index.js b/lib/node_modules/@stdlib/blas/base/dcabs1/examples/index.js index 6836c47a18ad..dc0e9f9a9c0f 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/examples/index.js +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/examples/index.js @@ -18,14 +18,14 @@ 'use strict'; -var Complex128 = require( '@stdlib/complex/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; var dcabs1 = require( './../lib' ); // Create a PRNG to generate uniformly distributed pseudorandom integers: -var rand = discreteUniform( -50, 50 ); +var rand = discreteUniform( -5, 5 ); -// Compute the sum of the absolute value of real and imaginary part for a set of complex numbers... +// Compute the sum of the absolute values of real and imaginary components for a set of complex numbers... var z; var i; for ( i = 0; i < 100; i++ ) { diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/include/stdlib/blas/base/dcabs1.h b/lib/node_modules/@stdlib/blas/base/dcabs1/include/stdlib/blas/base/dcabs1.h index bcc8c1df578b..7d882c846b0e 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/include/stdlib/blas/base/dcabs1.h +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/include/stdlib/blas/base/dcabs1.h @@ -17,12 +17,12 @@ */ /** -* Header file containing function declarations for the C interface to the Level 1 routine `idamax`. +* Header file containing function declarations for the C interface to the Level 1 routine `dcabs1`. */ #ifndef DCABS1_H #define DCABS1_H -#include "stdlib/complex/float64.h" +#include "stdlib/complex/float64/ctor.h" /* * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. @@ -32,7 +32,7 @@ extern "C" { #endif /** -* Computes the sum of the absolute value of the real and imaginary part of a double-precision complex floating-point number. +* Computes the sum of the absolute values of the real and imaginary components of a double-precision complex floating-point number. */ double c_dcabs1( const stdlib_complex128_t z ); @@ -41,4 +41,3 @@ double c_dcabs1( const stdlib_complex128_t z ); #endif #endif // !DCABS1_H - diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/include/stdlib/blas/base/dcabs1_fortran.h b/lib/node_modules/@stdlib/blas/base/dcabs1/include/stdlib/blas/base/dcabs1_fortran.h index 27847e83426c..078343f6ab75 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/include/stdlib/blas/base/dcabs1_fortran.h +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/include/stdlib/blas/base/dcabs1_fortran.h @@ -22,7 +22,7 @@ #ifndef DCABS1_FORTRAN_H #define DCABS1_FORTRAN_H -#include "stdlib/complex/float64.h" +#include "stdlib/complex/float64/ctor.h" /* * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. @@ -32,7 +32,7 @@ extern "C" { #endif /** -* Computes the sum of the absolute value of the real and imaginary part of a double-precision complex floating-point number. +* Computes the sum of the absolute values of the real and imaginary components of a double-precision complex floating-point number. */ void dcabs1sub( const stdlib_complex128_t *, double * ); diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/include/stdlib/blas/base/dcabs_cblas.h b/lib/node_modules/@stdlib/blas/base/dcabs1/include/stdlib/blas/base/dcabs_cblas.h index 5264a7a65005..573b3e79f91b 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/include/stdlib/blas/base/dcabs_cblas.h +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/include/stdlib/blas/base/dcabs_cblas.h @@ -22,7 +22,7 @@ #ifndef DCABS1_CBLAS_H #define DCABS1_CBLAS_H -#include "stdlib/complex/float64.h" +#include "stdlib/complex/float64/ctor.h" /* * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. @@ -32,7 +32,7 @@ extern "C" { #endif /** -* Computes the sum of the absolute value of the real and imaginary part of a double-precision complex floating-point number. +* Computes the sum of the absolute values of the real and imaginary components of a double-precision complex floating-point number. */ double cblas_dcabs1( const stdlib_complex128_t z ); diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/lib/index.js b/lib/node_modules/@stdlib/blas/base/dcabs1/lib/index.js index e9ffc3a9cb6e..b4815ae24f2e 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/lib/index.js +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* Compute the sum of the absolute value of the real and imaginary part of a double-precision complex floating-point number. +* Compute the sum of the absolute values of the real and imaginary components of a double-precision complex floating-point number. * * @module @stdlib/blas/base/dcabs1 * diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/manifest.json b/lib/node_modules/@stdlib/blas/base/dcabs1/manifest.json index c1844665dd57..67943b564dc7 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/manifest.json @@ -46,9 +46,9 @@ "dependencies": [ "@stdlib/napi/export", "@stdlib/napi/argv", + "@stdlib/napi/argv-complex64", "@stdlib/napi/create-double", - "@stdlib/napi/argv-complex128", - "@stdlib/complex/float64", + "@stdlib/complex/float64/ctor", "@stdlib/math/base/special/abs", "@stdlib/complex/reim" ] @@ -68,7 +68,7 @@ "libpath": [], "dependencies": [ "@stdlib/math/base/special/abs", - "@stdlib/complex/float64", + "@stdlib/complex/float64/ctor", "@stdlib/complex/reim" ] }, @@ -87,8 +87,10 @@ "libpath": [], "dependencies": [ "@stdlib/math/base/special/abs", - "@stdlib/complex/float64", - "@stdlib/complex/reim" + "@stdlib/complex/float64/ctor", + "@stdlib/complex/reim", + "@stdlib/complex/real", + "@stdlib/complex/imag" ] }, @@ -111,9 +113,9 @@ "dependencies": [ "@stdlib/napi/export", "@stdlib/napi/argv", + "@stdlib/napi/argv-complex64", "@stdlib/napi/create-double", - "@stdlib/napi/argv-complex128", - "@stdlib/complex/float64", + "@stdlib/complex/float64/ctor", "@stdlib/math/base/special/abs", "@stdlib/complex/reim" ] @@ -134,7 +136,9 @@ "-lpthread" ], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/complex/float64/ctor" + ] }, { "task": "examples", @@ -152,7 +156,10 @@ "-lpthread" ], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/complex/real", + "@stdlib/complex/imag" + ] }, { @@ -173,9 +180,9 @@ "dependencies": [ "@stdlib/napi/export", "@stdlib/napi/argv", + "@stdlib/napi/argv-complex64", "@stdlib/napi/create-double", - "@stdlib/napi/argv-complex128", - "@stdlib/complex/float64", + "@stdlib/complex/float64/ctor", "@stdlib/math/base/special/abs", "@stdlib/complex/reim" ] @@ -195,7 +202,7 @@ "libpath": [], "dependencies": [ "@stdlib/math/base/special/abs", - "@stdlib/complex/float64", + "@stdlib/complex/float64/ctor", "@stdlib/complex/reim" ] }, @@ -214,8 +221,10 @@ "libpath": [], "dependencies": [ "@stdlib/math/base/special/abs", - "@stdlib/complex/float64", - "@stdlib/complex/reim" + "@stdlib/complex/float64/ctor", + "@stdlib/complex/reim", + "@stdlib/complex/real", + "@stdlib/complex/imag" ] }, @@ -237,9 +246,9 @@ "dependencies": [ "@stdlib/napi/export", "@stdlib/napi/argv", + "@stdlib/napi/argv-complex64", "@stdlib/napi/create-double", - "@stdlib/napi/argv-complex128", - "@stdlib/complex/float64", + "@stdlib/complex/float64/ctor", "@stdlib/math/base/special/abs", "@stdlib/complex/reim" ] @@ -259,7 +268,9 @@ "-lblas" ], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/complex/float64/ctor" + ] }, { "task": "examples", @@ -276,7 +287,10 @@ "-lblas" ], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/complex/real", + "@stdlib/complex/imag" + ] }, { @@ -298,9 +312,9 @@ "dependencies": [ "@stdlib/napi/export", "@stdlib/napi/argv", + "@stdlib/napi/argv-complex64", "@stdlib/napi/create-double", - "@stdlib/napi/argv-complex128", - "@stdlib/complex/float64", + "@stdlib/complex/float64/ctor", "@stdlib/math/base/special/abs", "@stdlib/complex/reim" ] @@ -321,7 +335,9 @@ "-lpthread" ], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/complex/float64/ctor" + ] }, { "task": "examples", @@ -339,7 +355,10 @@ "-lpthread" ], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/complex/real", + "@stdlib/complex/imag" + ] }, { @@ -358,9 +377,9 @@ "dependencies": [ "@stdlib/napi/export", "@stdlib/napi/argv", + "@stdlib/napi/argv-complex64", "@stdlib/napi/create-double", - "@stdlib/napi/argv-complex128", - "@stdlib/complex/float64", + "@stdlib/complex/float64/ctor", "@stdlib/math/base/special/abs", "@stdlib/complex/reim" ] @@ -380,7 +399,7 @@ "libpath": [], "dependencies": [ "@stdlib/math/base/special/abs", - "@stdlib/complex/float64", + "@stdlib/complex/float64/ctor", "@stdlib/complex/reim" ] }, @@ -399,8 +418,10 @@ "libpath": [], "dependencies": [ "@stdlib/math/base/special/abs", - "@stdlib/complex/float64", - "@stdlib/complex/reim" + "@stdlib/complex/float64/ctor", + "@stdlib/complex/reim", + "@stdlib/complex/real", + "@stdlib/complex/imag" ] }, @@ -419,7 +440,7 @@ "libpath": [], "dependencies": [ "@stdlib/math/base/special/abs", - "@stdlib/complex/float64", + "@stdlib/complex/float64/ctor", "@stdlib/complex/reim" ] } diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/package.json b/lib/node_modules/@stdlib/blas/base/dcabs1/package.json index afaad737287e..a31242e3cc44 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/package.json +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/blas/base/dcabs1", "version": "0.0.0", - "description": "Compute the sum of the absolute value of the real and imaginary part of a double-precision complex floating-point number.", + "description": "Compute the sum of the absolute values of the real and imaginary components of a double-precision complex floating-point number.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", @@ -56,14 +56,11 @@ "stdmath", "mathematics", "math", - "math.abs", "blas", "scalar", "dcabs1", "abs", "absolute", - "magnitude", - "modulus", "float64", "complex", "cmplx", diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/src/addon.c b/lib/node_modules/@stdlib/blas/base/dcabs1/src/addon.c index ca4ca2fcb3cd..219665700c0c 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/src/addon.c +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/src/addon.c @@ -18,8 +18,8 @@ #include "stdlib/blas/base/dcabs1.h" #include "stdlib/napi/export.h" -#include "stdlib/napi/argv.h" #include "stdlib/napi/argv_complex128.h" +#include "stdlib/napi/argv.h" #include "stdlib/napi/create_double.h" #include @@ -35,7 +35,6 @@ static napi_value addon( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV( env, info, argv, argc, 1 ); STDLIB_NAPI_ARGV_COMPLEX128( env, z, argv, 0 ); STDLIB_NAPI_CREATE_DOUBLE( env, c_dcabs1( z ), y ); - return y; } diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1.c b/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1.c index ae9827713c63..1d5fa76fc1c5 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1.c +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1.c @@ -18,17 +18,17 @@ #include "stdlib/blas/base/dcabs1.h" #include "stdlib/math/base/special/abs.h" -#include "stdlib/complex/float64.h" +#include "stdlib/complex/float64/ctor.h" #include "stdlib/complex/reim.h" /** -* Computes the sum of the absolute value of the real and imaginary part of a double-precision complex floating-point number. +* Computes the sum of the absolute values of the real and imaginary components of a double-precision complex floating-point number. * * @param z complex number * @return result * * @example -* #include "stdlib/complex/float64.h" +* #include "stdlib/complex/float64/ctor.h" * * stdlib_complex128_t z = stdlib_complex128( 5.0, 3.0 ); * diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1.f b/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1.f index 4b58c76ecdc7..fa35da235529 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1.f +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1.f @@ -16,7 +16,7 @@ ! limitations under the License. !< -!> Computes the sum of the absolute value of the real and imaginary part of a double-precision complex floating-point number. +!> Computes the sum of the absolute values of the real and imaginary components of a double-precision complex floating-point number. ! ! ## Notes ! diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1_cblas.c b/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1_cblas.c index 8e22647b839e..ad0f0116239f 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1_cblas.c +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1_cblas.c @@ -18,10 +18,10 @@ #include "stdlib/blas/base/dcabs1.h" #include "stdlib/blas/base/dcabs1_cblas.h" -#include "stdlib/complex/float64.h" +#include "stdlib/complex/float64/ctor.h" /** -* Computes the sum of the absolute value of the real and imaginary part of a double-precision complex floating-point number. +* Computes the sum of the absolute values of the real and imaginary components of a double-precision complex floating-point number. * * @param z complex number * @return result diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1_f.c b/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1_f.c index 74419718f8aa..9c4bdb1a9645 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1_f.c +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1_f.c @@ -18,10 +18,10 @@ #include "stdlib/blas/base/dcabs1.h" #include "stdlib/blas/base/dcabs1_fortran.h" -#include "stdlib/complex/float64.h" +#include "stdlib/complex/float64/ctor.h" /** -* Computes the sum of the absolute value of the real and imaginary part of a double-precision complex floating-point number. +* Computes the sum of the absolute values of the real and imaginary components of a double-precision complex floating-point number. * * @param z complex number * @return result diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1sub.f b/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1sub.f index 663c53a88752..cb225ab84d85 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1sub.f +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1sub.f @@ -35,7 +35,7 @@ end function dcabs1 complex(8) :: z double precision :: y ! .. - ! Compute the sum of the absolute values of the real and imaginary part of a double-precision complex number: + ! Compute the sum of the absolute values of the real and imaginary components of a double-precision complex floating-point number: y = dcabs1( z ) return end subroutine dcabs1sub \ No newline at end of file diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/test/test.js b/lib/node_modules/@stdlib/blas/base/dcabs1/test/test.js index 731ff086c94a..ee3eac83fb0c 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/test/test.js +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/test/test.js @@ -22,10 +22,8 @@ var tape = require( 'tape' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var EPS = require( '@stdlib/constants/float64/eps' ); -var abs = require( '@stdlib/math/base/special/abs' ); var Float64Array = require( '@stdlib/array/float64' ); -var Complex128 = require( '@stdlib/complex/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); var dcabs1 = require( './../lib' ); @@ -37,10 +35,8 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function computes the sum of the absolute value of the real and imaginary part of a complex number', function test( t ) { +tape( 'the function computes the sum of the absolute values of the real and imaginary components of a complex number', function test( t ) { var expected; - var delta; - var tol; var re; var im; var y; @@ -52,13 +48,7 @@ tape( 'the function computes the sum of the absolute value of the real and imagi for ( i = 0; i < re.length; i++ ) { y = dcabs1( new Complex128( re[ i ], im[ i ] ) ); - if ( y === expected[ i ] ) { - t.equal( y, expected[ i ], 're: '+re[i]+'. im: '+im[i]+'. Expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. re: '+re[i]+'. im: '+im[i]+' y: '+y+'. Expected: '+expected[i]+'. delta: '+delta+'. tol: '+tol+'.' ); - } + t.equal( y, expected[ i ], 'returns expected value. re: '+re[ i ]+'. im: '+im[ i ]+'. expected: '+expected[ i ]+'.' ); } t.end(); }); @@ -67,13 +57,13 @@ tape( 'if either the real or imaginary component is `NaN`, the function returns var v; v = dcabs1( new Complex128( NaN, 3.0 ) ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); v = dcabs1( new Complex128( 5.0, NaN ) ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); v = dcabs1( new Complex128( NaN, NaN ) ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/test/test.native.js b/lib/node_modules/@stdlib/blas/base/dcabs1/test/test.native.js index 6cfc0c887481..891c97a43939 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/test/test.native.js +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/test/test.native.js @@ -23,8 +23,6 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var EPS = require( '@stdlib/constants/float64/eps' ); -var abs = require( '@stdlib/math/base/special/abs' ); var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -46,7 +44,7 @@ tape( 'main export is a function', opts, function test( t ) { t.end(); }); -tape( 'the function computes the sum of the absolute value of the real and imaginary part of a complex number', opts, function test( t ) { +tape( 'the function computes the sum of the absolute values of the real and imaginary components of a complex number', opts, function test( t ) { var expected; var delta; var tol; @@ -60,14 +58,8 @@ tape( 'the function computes the sum of the absolute value of the real and imagi expected = new Float64Array( [ 8.0, 7.0, 0.0, 0.0, 3.0 ] ); for ( i = 0; i < re.length; i++ ) { - y = dcabs1( new Complex128( re[ i ], im[ i ] ) ); - if ( y === expected[ i ] ) { - t.equal( y, expected[ i ], 're: '+re[i]+'. im: '+im[i]+'. Expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. re: '+re[i]+'. im: '+im[i]+' y: '+y+'. Expected: '+expected[i]+'. delta: '+delta+'. tol: '+tol+'.' ); - } + y = dcabs1( new Complex64( re[ i ], im[ i ] ) ); + t.equal( y, expected[ i ], 'returns expected value. re: '+re[ i ]+'. im: '+im[ i ]+'. expected: '+expected[ i ]+'.' ); } t.end(); }); @@ -76,13 +68,13 @@ tape( 'if either the real or imaginary component is `NaN`, the function returns var v; v = dcabs1( new Complex128( NaN, 3.0 ) ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); v = dcabs1( new Complex128( 5.0, NaN ) ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); v = dcabs1( new Complex128( NaN, NaN ) ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); t.end(); }); From 77d29acd8067cd1593e0fc25ff86245ef4746af3 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Thu, 6 Jun 2024 16:27:38 +0530 Subject: [PATCH 04/16] chore: apply review changes --- .../@stdlib/blas/base/dcabs1/manifest.json | 12 ++++++------ .../@stdlib/blas/base/dcabs1/test/test.native.js | 4 +--- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/manifest.json b/lib/node_modules/@stdlib/blas/base/dcabs1/manifest.json index 67943b564dc7..ead291448a5c 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/manifest.json @@ -46,7 +46,7 @@ "dependencies": [ "@stdlib/napi/export", "@stdlib/napi/argv", - "@stdlib/napi/argv-complex64", + "@stdlib/napi/argv-complex128", "@stdlib/napi/create-double", "@stdlib/complex/float64/ctor", "@stdlib/math/base/special/abs", @@ -113,7 +113,7 @@ "dependencies": [ "@stdlib/napi/export", "@stdlib/napi/argv", - "@stdlib/napi/argv-complex64", + "@stdlib/napi/argv-complex128", "@stdlib/napi/create-double", "@stdlib/complex/float64/ctor", "@stdlib/math/base/special/abs", @@ -180,7 +180,7 @@ "dependencies": [ "@stdlib/napi/export", "@stdlib/napi/argv", - "@stdlib/napi/argv-complex64", + "@stdlib/napi/argv-complex128", "@stdlib/napi/create-double", "@stdlib/complex/float64/ctor", "@stdlib/math/base/special/abs", @@ -246,7 +246,7 @@ "dependencies": [ "@stdlib/napi/export", "@stdlib/napi/argv", - "@stdlib/napi/argv-complex64", + "@stdlib/napi/argv-complex128", "@stdlib/napi/create-double", "@stdlib/complex/float64/ctor", "@stdlib/math/base/special/abs", @@ -312,7 +312,7 @@ "dependencies": [ "@stdlib/napi/export", "@stdlib/napi/argv", - "@stdlib/napi/argv-complex64", + "@stdlib/napi/argv-complex128", "@stdlib/napi/create-double", "@stdlib/complex/float64/ctor", "@stdlib/math/base/special/abs", @@ -377,7 +377,7 @@ "dependencies": [ "@stdlib/napi/export", "@stdlib/napi/argv", - "@stdlib/napi/argv-complex64", + "@stdlib/napi/argv-complex128", "@stdlib/napi/create-double", "@stdlib/complex/float64/ctor", "@stdlib/math/base/special/abs", diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/test/test.native.js b/lib/node_modules/@stdlib/blas/base/dcabs1/test/test.native.js index 891c97a43939..64ad0b4de6d6 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/test/test.native.js +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/test/test.native.js @@ -46,8 +46,6 @@ tape( 'main export is a function', opts, function test( t ) { tape( 'the function computes the sum of the absolute values of the real and imaginary components of a complex number', opts, function test( t ) { var expected; - var delta; - var tol; var re; var im; var y; @@ -58,7 +56,7 @@ tape( 'the function computes the sum of the absolute values of the real and imag expected = new Float64Array( [ 8.0, 7.0, 0.0, 0.0, 3.0 ] ); for ( i = 0; i < re.length; i++ ) { - y = dcabs1( new Complex64( re[ i ], im[ i ] ) ); + y = dcabs1( new Complex128( re[ i ], im[ i ] ) ); t.equal( y, expected[ i ], 'returns expected value. re: '+re[ i ]+'. im: '+im[ i ]+'. expected: '+expected[ i ]+'.' ); } t.end(); From 43e775233269c533b169405fb5c1d0dcd6f9593e Mon Sep 17 00:00:00 2001 From: aman-095 Date: Thu, 6 Jun 2024 18:09:01 +0530 Subject: [PATCH 05/16] chore: resolve repl file --- lib/node_modules/@stdlib/blas/base/dcabs1/docs/repl.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/dcabs1/docs/repl.txt index b9d6938beff3..41777f36fe73 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/docs/repl.txt @@ -1,7 +1,7 @@ {{alias}}( z ) - Computes the sum of the absolute value of real and imaginary part of a - double-precision complex floating-point number. + Computes the sum of the absolute values of real and imaginary components of + a double-precision complex floating-point number. Parameters ---------- @@ -15,7 +15,7 @@ Examples -------- - > var y = {{alias}}( new {{alias:@stdlib/complex/float64}}( 5.0, 3.0 ) ) + > var y = {{alias}}( new {{alias:@stdlib/complex/float64/ctor}}( 5.0, 3.0 ) ) 8.0 See Also From c75bc8cd99f3c2d9d5239c82b7dd9a96a07a05e7 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Thu, 6 Jun 2024 18:12:19 -0700 Subject: [PATCH 06/16] bench: update declarations --- .../@stdlib/blas/base/dcabs1/benchmark/fortran/benchmark.f | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/fortran/benchmark.f b/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/fortran/benchmark.f index b2da15372541..7827e7a751d6 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/fortran/benchmark.f +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/fortran/benchmark.f @@ -124,7 +124,7 @@ double precision function benchmark( iterations ) ! External functions: interface double precision function dcabs1( z ) - complex(8) :: z + complex(kind=kind(0.0d0)) :: z end function dcabs1 end interface ! .. @@ -138,7 +138,7 @@ end function dcabs1 integer :: i ! .. ! Local scalar: - complex(8) :: z + complex(kind=kind(0.0d0)) :: z ! .. ! Intrinsic functions: intrinsic random_number, cpu_time From c821dcbba5a6e1c8ef86aab851a81da955f1e102 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Thu, 6 Jun 2024 18:14:26 -0700 Subject: [PATCH 07/16] bench: use factory --- .../@stdlib/blas/base/dcabs1/benchmark/benchmark.js | 11 ++++++++--- .../blas/base/dcabs1/benchmark/benchmark.native.js | 7 ++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/benchmark.js index bb0b8fdf177e..bab9e1c63327 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/benchmark.js @@ -21,13 +21,18 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; var isnan = require( '@stdlib/math/base/assert/is-nan' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var pkg = require( './../package.json' ).name; var dcabs1 = require( './../lib' ); +// VARIABLES // + +var rand = discreteUniform( -500.0, 500.0 ); + + // MAIN // bench( pkg, function benchmark( b ) { @@ -36,8 +41,8 @@ bench( pkg, function benchmark( b ) { var i; values = [ - new Complex128( discreteUniform( -500.0, 500.0 ), discreteUniform( -500.0, 500.0 ) ), // eslint-disable-line max-len - new Complex128( discreteUniform( -500.0, 500.0 ), discreteUniform( -500.0, 500.0 ) ) // eslint-disable-line max-len + new Complex128( rand(), rand() ), + new Complex128( rand(), rand() ) ]; b.tic(); diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/benchmark.native.js index a8657d7ce751..9aa8bd307d43 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/benchmark/benchmark.native.js @@ -22,7 +22,7 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; var isnan = require( '@stdlib/math/base/assert/is-nan' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -35,6 +35,7 @@ var dcabs1 = tryRequire( resolve( __dirname, './../lib/native.js' ) ); var opts = { 'skip': ( dcabs1 instanceof Error ) }; +var rand = discreteUniform( -500.0, 500.0 ); // MAIN // @@ -45,8 +46,8 @@ bench( pkg+'::native', opts, function benchmark( b ) { var i; values = [ - new Complex128( discreteUniform( -500.0, 500.0 ), discreteUniform( -500.0, 500.0 ) ), // eslint-disable-line max-len - new Complex128( discreteUniform( -500.0, 500.0 ), discreteUniform( -500.0, 500.0 ) ) // eslint-disable-line max-len + new Complex128( rand(), rand() ), + new Complex128( rand(), rand() ) ]; b.tic(); From c268cfbb486109e7309c922d16bd14ecc2912a60 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Thu, 6 Jun 2024 18:15:09 -0700 Subject: [PATCH 08/16] docs: update example --- .../@stdlib/blas/base/dcabs1/docs/types/index.d.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/dcabs1/docs/types/index.d.ts index fbde626cb6cc..90990a9b2d67 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/docs/types/index.d.ts @@ -25,15 +25,13 @@ import { Complex128 } from '@stdlib/types/complex'; /** * Computes the sum of the absolute values of the real and imaginary components of a double-precision complex floating-point number. * -* ## Notes -* * @param z - complex number * @returns result * * @example * var Complex128 = require( '@stdlib/complex/float64' ); * -* var v = dcabs1( new Complex128( 5.0, 3.0 ) ); +* var v = dcabs1( new Complex128( 5.0, -3.0 ) ); * // returns 8.0 */ declare function dcabs1( z: Complex128 ): number; From 22924719bdf742744b67ad8c4c3d3c538f6df0a8 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Thu, 6 Jun 2024 18:15:30 -0700 Subject: [PATCH 09/16] test: update values --- lib/node_modules/@stdlib/blas/base/dcabs1/docs/types/test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/dcabs1/docs/types/test.ts index 2119c92f12a2..939eae468e58 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/docs/types/test.ts @@ -24,7 +24,7 @@ import dcabs1 = require( './index' ); // The function returns a number... { - dcabs1( new Complex128( 5, 3 ) ); // $ExpectType number + dcabs1( new Complex128( 5.0, 3.0 ) ); // $ExpectType number } // The compiler throws an error if the function is not provided a complex number... From 5a84a8bd236a2d24265b04740814ad6b68f0623a Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Thu, 6 Jun 2024 18:15:57 -0700 Subject: [PATCH 10/16] docs: update example --- lib/node_modules/@stdlib/blas/base/dcabs1/docs/repl.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/dcabs1/docs/repl.txt index 41777f36fe73..79a4944c5d0f 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/docs/repl.txt @@ -15,7 +15,7 @@ Examples -------- - > var y = {{alias}}( new {{alias:@stdlib/complex/float64/ctor}}( 5.0, 3.0 ) ) + > var y = {{alias}}( new {{alias:@stdlib/complex/float64/ctor}}( 5.0, -3.0 ) ) 8.0 See Also From 3b8258165b46cc965fbc067a7b999d88719044c2 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Thu, 6 Jun 2024 18:17:22 -0700 Subject: [PATCH 11/16] docs: fix copy-paste errors --- .../blas/base/dcabs1/include/stdlib/blas/base/dcabs1_fortran.h | 2 +- .../blas/base/dcabs1/include/stdlib/blas/base/dcabs_cblas.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/include/stdlib/blas/base/dcabs1_fortran.h b/lib/node_modules/@stdlib/blas/base/dcabs1/include/stdlib/blas/base/dcabs1_fortran.h index 078343f6ab75..5dbf223e9eb9 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/include/stdlib/blas/base/dcabs1_fortran.h +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/include/stdlib/blas/base/dcabs1_fortran.h @@ -17,7 +17,7 @@ */ /** -* Header file containing function declarations for the Fortran interface to the BLAS Level 1 routine `idamax`. +* Header file containing function declarations for the Fortran interface to the BLAS Level 1 routine `dcabs1`. */ #ifndef DCABS1_FORTRAN_H #define DCABS1_FORTRAN_H diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/include/stdlib/blas/base/dcabs_cblas.h b/lib/node_modules/@stdlib/blas/base/dcabs1/include/stdlib/blas/base/dcabs_cblas.h index 573b3e79f91b..8d2d5b4a547a 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/include/stdlib/blas/base/dcabs_cblas.h +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/include/stdlib/blas/base/dcabs_cblas.h @@ -17,7 +17,7 @@ */ /** -* Header file containing function declarations for the C interface to the CBLAS Level 1 routine `cblas_ccopy`. +* Header file containing function declarations for the C interface to the CBLAS Level 1 routine `cblas_dcabs1`. */ #ifndef DCABS1_CBLAS_H #define DCABS1_CBLAS_H From 979f529bc034421de9bd22ae5b91549ee1fd0790 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Thu, 6 Jun 2024 18:18:22 -0700 Subject: [PATCH 12/16] docs: update examples --- lib/node_modules/@stdlib/blas/base/dcabs1/lib/index.js | 2 +- lib/node_modules/@stdlib/blas/base/dcabs1/lib/main.js | 4 ++-- lib/node_modules/@stdlib/blas/base/dcabs1/lib/native.js | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/lib/index.js b/lib/node_modules/@stdlib/blas/base/dcabs1/lib/index.js index b4815ae24f2e..666b580bdfa6 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/lib/index.js +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/lib/index.js @@ -27,7 +27,7 @@ * var Complex128 = require( '@stdlib/complex/float64' ); * var dcabs1 = require( '@stdlib/blas/base/dcabs1' ); * -* var v = dcabs1( new Complex128( 5.0, 3.0 ) ); +* var v = dcabs1( new Complex128( 5.0, -3.0 ) ); * // returns 8.0 */ diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/lib/main.js b/lib/node_modules/@stdlib/blas/base/dcabs1/lib/main.js index fda570ebf001..3d13bc420b54 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/lib/main.js +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/lib/main.js @@ -31,12 +31,12 @@ var imag = require( '@stdlib/complex/imag' ); * Computes the sum of the absolute value of the real and imaginary part of a double-precision complex floating-point number. * * @param {Complex128} z - complex number -* @returns {number} absolute value +* @returns {number} result * * @example * var Complex128 = require( '@stdlib/complex/float64' ); * -* var v = dcabs1( new Complex128( 5.0, 3.0 ) ); +* var v = dcabs1( new Complex128( 5.0, -3.0 ) ); * // returns 8.0 */ function dcabs1( z ) { diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/lib/native.js b/lib/node_modules/@stdlib/blas/base/dcabs1/lib/native.js index 1de150255dc1..2c1ea8ac02ca 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/lib/native.js +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/lib/native.js @@ -29,12 +29,12 @@ var addon = require( './../src/addon.node' ); * Computes the sum of the absolute value of the real and imaginary part of a double-precision complex floating-point number. * * @param {Complex128} z - complex number -* @returns {number} absolute value +* @returns {number} result * * @example * var Complex128 = require( '@stdlib/complex/float64' ); * -* var v = dcabs1( new Complex128( 5.0, 3.0 ) ); +* var v = dcabs1( new Complex128( 5.0, -3.0 ) ); * // returns 8.0 */ function dcabs1( z ) { From 07dfc5353f54d49432e11d2a0e9e08e9a7b3fad9 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Thu, 6 Jun 2024 18:20:56 -0700 Subject: [PATCH 13/16] fix: use correct intrinsic and update docs --- .../@stdlib/blas/base/dcabs1/src/dcabs1.c | 2 +- .../@stdlib/blas/base/dcabs1/src/dcabs1.f | 13 +++---------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1.c b/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1.c index 1d5fa76fc1c5..e083dea97902 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1.c +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1.c @@ -30,7 +30,7 @@ * @example * #include "stdlib/complex/float64/ctor.h" * -* stdlib_complex128_t z = stdlib_complex128( 5.0, 3.0 ); +* stdlib_complex128_t z = stdlib_complex128( 5.0, -3.0 ); * * double y = c_dcabs1( z ); * // returns 8.0 diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1.f b/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1.f index fa35da235529..d97f069e2e41 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1.f +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1.f @@ -29,13 +29,6 @@ ! * Univ. of Colorado Denver ! * NAG Ltd. ! -! ## History -! -! * Jack Dongarra, linpack, 3/11/78. -! -! - modified 3/93 to return if incx .le. 0. -! - modified 12/3/93, array(1) declarations changed to array(*) -! ! ## License ! ! From : @@ -55,11 +48,11 @@ double precision function dcabs1( z ) implicit none ! .. ! Scalar arguments: - complex(8) z + complex(kind=kind(0.0d0)) :: z ! .. ! Intrinsic functions: - intrinsic ABS, DBLE, AIMAG + intrinsic abs, dble, dimag ! .. - dcabs1 = ABS( DBLE( z ) ) + ABS( AIMAG( z ) ) + dcabs1 = abs( dble( z ) ) + abs( dimag( z ) ) return end function dcabs1 \ No newline at end of file From 470e6d451ffc3eb45329e6bb9b1abf345f81024b Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Thu, 6 Jun 2024 18:22:07 -0700 Subject: [PATCH 14/16] refactor: update declarations --- lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1sub.f | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1sub.f b/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1sub.f index cb225ab84d85..8875fcfc835c 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1sub.f +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1sub.f @@ -27,12 +27,12 @@ subroutine dcabs1sub( z, y ) ! External functions: interface double precision function dcabs1( z ) - complex(8) :: z + complex(kind=kind(0.0d0)) :: z end function dcabs1 end interface ! .. ! Scalar arguments: - complex(8) :: z + complex(kind=kind(0.0d0)) :: z double precision :: y ! .. ! Compute the sum of the absolute values of the real and imaginary components of a double-precision complex floating-point number: From a61ddf00c68aa02be08e9351bd889d7b5fd76e90 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Thu, 6 Jun 2024 18:25:28 -0700 Subject: [PATCH 15/16] build: update configurations and fix docs --- .../@stdlib/blas/base/dcabs1/README.md | 9 ++++---- .../@stdlib/blas/base/dcabs1/manifest.json | 23 +++++++------------ 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/README.md b/lib/node_modules/@stdlib/blas/base/dcabs1/README.md index 915655bffb07..7791db188ff9 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/README.md +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/README.md @@ -37,7 +37,7 @@ Computes the sum of the [absolute values][absolute-value] of the real part and i ```javascript var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var y = dcabs1( new Complex128( 5.0, 3.0 ) ); +var y = dcabs1( new Complex128( 5.0, -3.0 ) ); // returns 8.0 ``` @@ -101,9 +101,10 @@ Computes the sum of the [absolute values][absolute-value] of the real and imagin ```c #include "stdlib/complex/float64/ctor.h" -const stdlib_complex128_t c = stdlib_complex128( 3.14, 1.0 ); +const stdlib_complex128_t c = stdlib_complex128( 5.0, -3.0 ); -c_dcabs1( z ); +double y = c_dcabs1( z ); +// returns 8.0 ``` The function accepts the following arguments: @@ -111,7 +112,7 @@ The function accepts the following arguments: - **z**: `[in] stdlib_complex128_t` complex number. ```c -void c_dcabs1( const stdlib_complex128_t z ); +double c_dcabs1( const stdlib_complex128_t z ); ```
diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/manifest.json b/lib/node_modules/@stdlib/blas/base/dcabs1/manifest.json index ead291448a5c..e8745c59a3b3 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/manifest.json @@ -48,9 +48,7 @@ "@stdlib/napi/argv", "@stdlib/napi/argv-complex128", "@stdlib/napi/create-double", - "@stdlib/complex/float64/ctor", - "@stdlib/math/base/special/abs", - "@stdlib/complex/reim" + "@stdlib/complex/float64/ctor" ] }, { @@ -115,9 +113,7 @@ "@stdlib/napi/argv", "@stdlib/napi/argv-complex128", "@stdlib/napi/create-double", - "@stdlib/complex/float64/ctor", - "@stdlib/math/base/special/abs", - "@stdlib/complex/reim" + "@stdlib/complex/float64/ctor" ] }, { @@ -157,6 +153,7 @@ ], "libpath": [], "dependencies": [ + "@stdlib/complex/float64/ctor", "@stdlib/complex/real", "@stdlib/complex/imag" ] @@ -182,9 +179,7 @@ "@stdlib/napi/argv", "@stdlib/napi/argv-complex128", "@stdlib/napi/create-double", - "@stdlib/complex/float64/ctor", - "@stdlib/math/base/special/abs", - "@stdlib/complex/reim" + "@stdlib/complex/float64/ctor" ] }, { @@ -248,9 +243,7 @@ "@stdlib/napi/argv", "@stdlib/napi/argv-complex128", "@stdlib/napi/create-double", - "@stdlib/complex/float64/ctor", - "@stdlib/math/base/special/abs", - "@stdlib/complex/reim" + "@stdlib/complex/float64/ctor" ] }, { @@ -288,6 +281,7 @@ ], "libpath": [], "dependencies": [ + "@stdlib/complex/float64/ctor", "@stdlib/complex/real", "@stdlib/complex/imag" ] @@ -314,9 +308,7 @@ "@stdlib/napi/argv", "@stdlib/napi/argv-complex128", "@stdlib/napi/create-double", - "@stdlib/complex/float64/ctor", - "@stdlib/math/base/special/abs", - "@stdlib/complex/reim" + "@stdlib/complex/float64/ctor" ] }, { @@ -356,6 +348,7 @@ ], "libpath": [], "dependencies": [ + "@stdlib/complex/float64/ctor", "@stdlib/complex/real", "@stdlib/complex/imag" ] From ddc8f02acbf99fffd47540265bc954c7fd484a3d Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 6 Jun 2024 18:34:09 -0700 Subject: [PATCH 16/16] Apply suggestions from code review Signed-off-by: Athan --- lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1.f | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1.f b/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1.f index d97f069e2e41..8bcb5bcb7c31 100644 --- a/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1.f +++ b/lib/node_modules/@stdlib/blas/base/dcabs1/src/dcabs1.f @@ -51,8 +51,8 @@ double precision function dcabs1( z ) complex(kind=kind(0.0d0)) :: z ! .. ! Intrinsic functions: - intrinsic abs, dble, dimag + intrinsic abs, dble, aimag ! .. - dcabs1 = abs( dble( z ) ) + abs( dimag( z ) ) + dcabs1 = abs( dble( z ) ) + abs( aimag( z ) ) return end function dcabs1 \ No newline at end of file