diff --git a/lib/node_modules/@stdlib/blas/base/drotg/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/base/drotg/benchmark/benchmark.native.js new file mode 100644 index 000000000000..306036899132 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotg/benchmark/benchmark.native.js @@ -0,0 +1,66 @@ +/** +* @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 discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var drotg = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( drotg instanceof Error ) +}; +var OPTS = { + 'dtype': 'float64' +}; + + +// MAIN // + +bench( pkg+'::native', opts, function benchmark( b ) { + var out; + var x; + var y; + var i; + + x = discreteUniform( 100, -5, 5, OPTS ); + y = discreteUniform( 100, -5, 5, OPTS ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = drotg( x[ i%x.length ], y[ i%y.length ] ); + if ( isnan( out[ i%4 ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( out[ i%4 ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/drotg/benchmark/c/Makefile b/lib/node_modules/@stdlib/blas/base/drotg/benchmark/c/Makefile new file mode 100644 index 000000000000..9f97140e7cb0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotg/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/drotg/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/drotg/benchmark/c/benchmark.length.c new file mode 100644 index 000000000000..41d3ff158bb0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotg/benchmark/c/benchmark.length.c @@ -0,0 +1,151 @@ +/** +* @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/drotg.h" +#include +#include +#include +#include +#include + +#define NAME "drotg" +#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 +* @param len array length +* @return elapsed time in seconds +*/ +double benchmark( int iterations ) { + double elapsed; + double x; + double y; + double c; + double s; + double t; + int i; + + x = ( rand_double()*200.0 ) - 100.0; + y = ( rand_double()*200.0 ) - 100.0; + c = 0.8; + s = 0.6; + t = tic(); + for ( i = 0; i < iterations; i++ ) { + c_drotg( &x, &y, &c, &s ); + 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/drotg/benchmark/fortran/Makefile b/lib/node_modules/@stdlib/blas/base/drotg/benchmark/fortran/Makefile new file mode 100644 index 000000000000..6544ed1723aa --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotg/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/drotg.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/drotg/benchmark/fortran/benchmark.length.f b/lib/node_modules/@stdlib/blas/base/drotg/benchmark/fortran/benchmark.length.f new file mode 100644 index 000000000000..b945c06a51e4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotg/benchmark/fortran/benchmark.length.f @@ -0,0 +1,204 @@ +!> +! @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 `drotg`. +! +! ## Notes +! +! - Written in "free form" Fortran 95. +! +!< +program bench + implicit none + ! .. + ! Local constants: + character(5), parameter :: name = 'drotg' ! 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 + subroutine drotg( da, db, c, s ) + double precision :: c, da, db, s + end subroutine drotg + end interface + ! .. + ! Scalar arguments: + integer, intent(in) :: iterations + ! .. + ! Local scalars: + double precision :: elapsed, r1, r2 + real :: t1, t2 + integer :: i + ! .. + ! Local scalar: + double precision :: da, db + ! .. + ! Intrinsic functions: + intrinsic random_number, cpu_time + ! .. + call random_number( r1 ) + call random_number( r2 ) + da = (r1*100.0d0)-50.0d0 + db = (r2*100.0d0)-50.0d0 + ! .. + call cpu_time( t1 ) + ! .. + do i = 1, iterations + call drotg( da, db, 0.8d0, 0.6d0 ) + if ( db /= db ) then + print '(A)', 'unexpected result' + exit + end if + end do + ! .. + call cpu_time( t2 ) + ! .. + elapsed = t2 - t1 + ! .. + if ( db /= db ) 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/drotg/binding.gyp b/lib/node_modules/@stdlib/blas/base/drotg/binding.gyp new file mode 100644 index 000000000000..02a2799da097 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotg/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/drotg/examples/c/Makefile b/lib/node_modules/@stdlib/blas/base/drotg/examples/c/Makefile new file mode 100644 index 000000000000..6aed70daf167 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotg/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/drotg/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/drotg/examples/c/example.c new file mode 100644 index 000000000000..3fb4f70c4eff --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotg/examples/c/example.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/drotg.h" +#include + +int main( void ) { + double da[] = { 0.3, 0.0, -0.0, 1.0, -1.0, 3.14, -3.14 }; + double db[] = { 0.4, 0.0, -0.0, 1.0, -1.0, 3.14, -3.14 }; + + double c; + double s; + int i; + for ( i = 0; i < 7; i++ ) { + c_drotg( &da[i], &db[i], &c, &s ); + printf( "da: %lf, db: %lf, c: %lf, s: %lf\n", da[i], db[i], c, s ); + } +} diff --git a/lib/node_modules/@stdlib/blas/base/drotg/include.gypi b/lib/node_modules/@stdlib/blas/base/drotg/include.gypi new file mode 100644 index 000000000000..497aeca15320 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotg/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)', + '[ 2.0, 1.0, 0.0, 1.0 ] +*/ +function drotg( a, b ) { + var out = new Float64Array( 4 ); + addon( out, a, b ); + return [ out[ 0 ], out[ 1 ], out[ 2 ], out[ 3 ] ]; +} + + +// EXPORTS // + +module.exports = drotg; diff --git a/lib/node_modules/@stdlib/blas/base/drotg/manifest.json b/lib/node_modules/@stdlib/blas/base/drotg/manifest.json new file mode 100644 index 000000000000..ca496b270c24 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotg/manifest.json @@ -0,0 +1,463 @@ +{ + "options": { + "task": "build", + "os": "linux", + "blas": "", + "wasm": false + }, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "task": "build", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/drotg.f", + "./src/drotg_f.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/math/base/special/copysign", + "@stdlib/math/base/special/sqrt", + "@stdlib/math/base/special/abs", + "@stdlib/math/base/special/abs2" + ] + }, + { + "task": "benchmark", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/drotg.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/math/base/special/copysign", + "@stdlib/math/base/special/sqrt", + "@stdlib/math/base/special/abs", + "@stdlib/math/base/special/abs2" + ] + }, + { + "task": "examples", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/drotg.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/math/base/special/copysign", + "@stdlib/math/base/special/sqrt", + "@stdlib/math/base/special/abs", + "@stdlib/math/base/special/abs2" + ] + }, + + { + "task": "build", + "os": "linux", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/drotg_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/math/base/special/copysign", + "@stdlib/math/base/special/sqrt", + "@stdlib/math/base/special/abs", + "@stdlib/math/base/special/abs2" + ] + }, + { + "task": "benchmark", + "os": "linux", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/drotg_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/math/base/special/copysign", + "@stdlib/math/base/special/sqrt", + "@stdlib/math/base/special/abs", + "@stdlib/math/base/special/abs2" + ] + }, + { + "task": "examples", + "os": "linux", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/drotg_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/math/base/special/copysign", + "@stdlib/math/base/special/sqrt", + "@stdlib/math/base/special/abs", + "@stdlib/math/base/special/abs2" + ] + }, + + { + "task": "build", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/drotg.f", + "./src/drotg_f.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/math/base/special/copysign", + "@stdlib/math/base/special/sqrt", + "@stdlib/math/base/special/abs", + "@stdlib/math/base/special/abs2" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/drotg.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/math/base/special/copysign", + "@stdlib/math/base/special/sqrt", + "@stdlib/math/base/special/abs", + "@stdlib/math/base/special/abs2" + ] + }, + { + "task": "examples", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/drotg.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/math/base/special/copysign", + "@stdlib/math/base/special/sqrt", + "@stdlib/math/base/special/abs", + "@stdlib/math/base/special/abs2" + ] + }, + + { + "task": "build", + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/drotg_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lblas" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/math/base/special/copysign", + "@stdlib/math/base/special/sqrt", + "@stdlib/math/base/special/abs", + "@stdlib/math/base/special/abs2" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/drotg_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lblas" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/math/base/special/copysign", + "@stdlib/math/base/special/sqrt", + "@stdlib/math/base/special/abs", + "@stdlib/math/base/special/abs2" + ] + }, + { + "task": "examples", + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/drotg_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lblas" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/math/base/special/copysign", + "@stdlib/math/base/special/sqrt", + "@stdlib/math/base/special/abs", + "@stdlib/math/base/special/abs2" + ] + }, + + { + "task": "build", + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/drotg_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/math/base/special/copysign", + "@stdlib/math/base/special/sqrt", + "@stdlib/math/base/special/abs", + "@stdlib/math/base/special/abs2" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/drotg_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/math/base/special/copysign", + "@stdlib/math/base/special/sqrt", + "@stdlib/math/base/special/abs", + "@stdlib/math/base/special/abs2" + ] + }, + { + "task": "examples", + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/drotg_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/math/base/special/copysign", + "@stdlib/math/base/special/sqrt", + "@stdlib/math/base/special/abs", + "@stdlib/math/base/special/abs2" + ] + }, + + { + "task": "build", + "os": "win", + "blas": "", + "wasm": false, + "src": [ + "./src/drotg.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/math/base/special/copysign", + "@stdlib/math/base/special/sqrt", + "@stdlib/math/base/special/abs", + "@stdlib/math/base/special/abs2" + ] + }, + { + "task": "benchmark", + "os": "win", + "blas": "", + "wasm": false, + "src": [ + "./src/drotg.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/math/base/special/copysign", + "@stdlib/math/base/special/sqrt", + "@stdlib/math/base/special/abs", + "@stdlib/math/base/special/abs2" + ] + }, + { + "task": "examples", + "os": "win", + "blas": "", + "wasm": false, + "src": [ + "./src/drotg.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/math/base/special/copysign", + "@stdlib/math/base/special/sqrt", + "@stdlib/math/base/special/abs", + "@stdlib/math/base/special/abs2" + ] + }, + + { + "task": "build", + "os": "", + "blas": "", + "wasm": true, + "src": [ + "./src/drotg.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/math/base/special/copysign", + "@stdlib/math/base/special/sqrt", + "@stdlib/math/base/special/abs", + "@stdlib/math/base/special/abs2" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/blas/base/drotg/package.json b/lib/node_modules/@stdlib/blas/base/drotg/package.json index 08b1975ad980..2af94f53f846 100644 --- a/lib/node_modules/@stdlib/blas/base/drotg/package.json +++ b/lib/node_modules/@stdlib/blas/base/drotg/package.json @@ -14,11 +14,15 @@ } ], "main": "./lib", + "browser": "./lib/main.js", + "gypfile": true, "directories": { "benchmark": "./benchmark", "doc": "./docs", "example": "./examples", + "include": "./include", "lib": "./lib", + "src": "./src", "test": "./test" }, "types": "./docs/types", diff --git a/lib/node_modules/@stdlib/blas/base/drotg/src/Makefile b/lib/node_modules/@stdlib/blas/base/drotg/src/Makefile new file mode 100644 index 000000000000..bcf18aa46655 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotg/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/drotg/src/addon.c b/lib/node_modules/@stdlib/blas/base/drotg/src/addon.c new file mode 100644 index 000000000000..de6a3b47a20b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotg/src/addon.c @@ -0,0 +1,132 @@ +/** +* @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/drotg.h" +#include +#include +#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 ) { + napi_status status; + + // Get callback arguments: + size_t argc = 3; + napi_value argv[ 3 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + // Check whether we were provided the correct number of arguments: + if ( argc < 3 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Insufficient arguments." ); + assert( status == napi_ok ); + return NULL; + } + if ( argc > 3 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Too many arguments." ); + assert( status == napi_ok ); + return NULL; + } + + bool res; + status = napi_is_typedarray( env, argv[ 0 ], &res ); + assert( status == napi_ok ); + if ( res == false ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a Float64Array." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype1; + status = napi_typeof( env, argv[ 1 ], &vtype1 ); + assert( status == napi_ok ); + if ( vtype1 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype2; + status = napi_typeof( env, argv[ 2 ], &vtype2 ); + assert( status == napi_ok ); + if ( vtype2 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Third argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_typedarray_type vtype0; + size_t len; + void *Out; + status = napi_get_typedarray_info( env, argv[ 0 ], &vtype0, &len, &Out, NULL, NULL ); + assert( status == napi_ok ); + if ( vtype0 != napi_float64_array ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a Float64Array." ); + assert( status == napi_ok ); + return NULL; + } + if ( len != 4 ) { + status = napi_throw_range_error( env, NULL, "invalid argument. First argument must have 4 elements." ); + assert( status == napi_ok ); + return NULL; + } + + double da; + status = napi_get_value_double( env, argv[ 1 ], &da ); + assert( status == napi_ok ); + + double db; + status = napi_get_value_double( env, argv[ 2 ], &db ); + assert( status == napi_ok ); + + double c; + double s; + c_drotg( &da, &db, &c, &s ); + + double *op = (double *)Out; + op[ 0 ] = da; + op[ 1 ] = db; + op[ 2 ] = c; + op[ 3 ] = s; + + return NULL; +} + +/** +* Initializes a Node-API module. +* +* @private +* @param env environment under which the function is invoked +* @param exports exports object +* @return main export +*/ +static napi_value init( napi_env env, napi_value exports ) { + napi_value fcn; + napi_status status = napi_create_function( env, "exports", NAPI_AUTO_LENGTH, addon, NULL, &fcn ); + assert( status == napi_ok ); + return fcn; +} + +NAPI_MODULE( NODE_GYP_MODULE_NAME, init ) diff --git a/lib/node_modules/@stdlib/blas/base/drotg/src/drotg.c b/lib/node_modules/@stdlib/blas/base/drotg/src/drotg.c new file mode 100644 index 000000000000..6468c48fef03 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotg/src/drotg.c @@ -0,0 +1,71 @@ +/** +* @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/drotg.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/math/base/special/copysign.h" +#include "stdlib/math/base/special/abs2.h" +#include "stdlib/math/base/special/sqrt.h" +#include "stdlib/math/base/special/abs.h" + +/** +* Constructs a Givens plane rotation. +* +* @param a rotational elimination parameter +* @param b rotational elimination parameter +* @param out output array +* @param stride index increment +* @param offset starting index +*/ +void API_SUFFIX(c_drotg)( double* a, double* b, double* c, double* s ) { + double scale; + double sign; + double aa; + double ab; + double r; + double z; + + aa = stdlib_base_abs( *a ); + ab = stdlib_base_abs( *b ); + if ( aa > ab ) { + sign = stdlib_base_copysign( 1.0, *a ); + } else { + sign = stdlib_base_copysign( 1.0, *b ); + } + scale = aa + ab; + if ( scale == 0.0 ) { + *c = 1.0; + *s = 0.0; + r = 0.0; + z = 0.0; + } else { + r = scale * stdlib_base_sqrt( stdlib_base_abs2( *a/scale ) + stdlib_base_abs2( *b/scale ) ); + r *= sign; + *c = *a / r; + *s = *b / r; + z = 1.0; + if ( aa > ab ) { + z = *s; + } else if ( *c != 0.0 ) { + z = 1.0 / *c; + } + } + *a = r; + *b = z; + return; +} diff --git a/lib/node_modules/@stdlib/blas/base/drotg/src/drotg.f b/lib/node_modules/@stdlib/blas/base/drotg/src/drotg.f new file mode 100644 index 000000000000..6586cd3a9a95 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotg/src/drotg.f @@ -0,0 +1,87 @@ +!> +! @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. +!< + +!> Constructs a Givens plane rotation. +! +! ## 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 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 {double} da - rotational elimination parameter +! @param {double} db - rotational elimination parameter +! @param {double} c - cosine of the angle of rotation +! @param {double} s - sine of the angle of rotation +!< +subroutine drotg( da, db, c, s ) + implicit none + ! .. + ! Scalar arguments: + double precision :: c, da, db, s + ! .. + ! Local scalars: + double precision :: r, roe, scale, z + ! .. + ! Intrinsic functions: + intrinsic dabs, dsign, dsqrt + ! .. + roe = db + if (dabs(da) > dabs(db)) roe = da + scale = dabs(da) + dabs(db) + if (scale == 0.0d0) then + c = 1.0d0 + s = 0.0d0 + r = 0.0d0 + z = 0.0d0 + else + r = scale * dsqrt( (da/scale)**2 + (db/scale)**2 ) + r = dsign( 1.0d0, roe ) * r + c = da / r + s = db / r + z = 1.0d0 + if (dabs(da) > dabs(db)) z = s + if (dabs(db) >= dabs(da) .and. c /= 0.0d0) z = 1.0d0 / c + end if + da = r + db = z + return +end subroutine drotg \ No newline at end of file diff --git a/lib/node_modules/@stdlib/blas/base/drotg/src/drotg_cblas.c b/lib/node_modules/@stdlib/blas/base/drotg/src/drotg_cblas.c new file mode 100644 index 000000000000..183bb3123299 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotg/src/drotg_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/drotg.h" +#include "stdlib/blas/base/drotg_cblas.h" +#include "stdlib/blas/base/shared.h" + +/** +* Constructs a Givens plane rotation. +* +* @param a rotational elimination parameter +* @param b rotational elimination parameter +*/ +void API_SUFFIX(c_drotg)( double *a, double *b, double *c, double *s ) { + API_SUFFIX(cblas_drotg)( a, b, c, s ); +} diff --git a/lib/node_modules/@stdlib/blas/base/drotg/src/drotg_f.c b/lib/node_modules/@stdlib/blas/base/drotg/src/drotg_f.c new file mode 100644 index 000000000000..56e842295f63 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotg/src/drotg_f.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/drotg.h" +#include "stdlib/blas/base/drotg_fortran.h" +#include "stdlib/blas/base/shared.h" + +/** +* Constructs a Givens plane rotation. +* +* @param a rotational elimination parameter +* @param b rotational elimination parameter +*/ +void API_SUFFIX(c_drotg)( double *a, double *b, double *c, double *s ) { + drotg( a, b, c, s ); +} diff --git a/lib/node_modules/@stdlib/blas/base/drotg/test/test.native.js b/lib/node_modules/@stdlib/blas/base/drotg/test/test.native.js new file mode 100644 index 000000000000..6d7fbc46c1b6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotg/test/test.native.js @@ -0,0 +1,119 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2023 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 Float64Array = require( '@stdlib/array/float64' ); +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 tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var drotg = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( drotg instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof drotg, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 2', opts, function test( t ) { + t.strictEqual( drotg.length, 2, 'returns expected value' ); + t.end(); +}); + +tape( 'the function computes a Givens plane rotation', opts, function test( t ) { + var expected; + var values; + var delta; + var tol; + var out; + var i; + var j; + var e; + + expected = [ + [ 0.5, 1.0/0.6, 0.6, 0.8 ], + [ 0.5, 0.6, 0.8, 0.6 ], + [ 0.5, -1.0/0.6, -0.6, 0.8 ], + [ -0.5, -0.6, 0.8, -0.6 ], + [ -0.5, 1.0/0.6, 0.6, 0.8 ], + [ 0.0, 0.0, 1.0, 0.0 ], + [ 1.0, 1.0, 0.0, 1.0 ], + [ 1.0, 0.0, 1.0, 0.0 ] + ]; + values = [ + [ 0.3, 0.4 ], + [ 0.4, 0.3 ], + [ -0.3, 0.4 ], + [ -0.4, 0.3 ], + [ -0.3, -0.4 ], + [ 0.0, 0.0 ], + [ 0.0, 1.0 ], + [ 1.0, 0.0 ] + ]; + + for ( i = 0; i < values.length; i++ ) { + e = new Float64Array( expected[i] ); + out = drotg( values[i][0], values[i][1] ); + for ( j = 0; j < out.length; j++ ) { + if ( out[j] === expected[j] ) { + t.strictEqual( out[j], e[j], 'returns expected value' ); + } else { + delta = abs( out[j] - e[j] ); + tol = 1.5 * EPS * abs( e[j] ); + t.ok( delta <= tol, 'within tolerance. out: '+out[j]+'. expected: '+e[j]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } + } + t.end(); +}); + +tape( 'the function returns an array of NaNs if provided a rotational elimination parameter equal to NaN', opts, function test( t ) { + var actual; + var i; + + actual = drotg( NaN, 1.0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( abs( actual[i] ) ), true, 'returns expected value' ); + } + + actual = drotg( 1.0, NaN ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( abs( actual[i] ) ), true, 'returns expected value' ); + } + + actual = drotg( NaN, NaN ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( abs( actual[i] ) ), true, 'returns expected value' ); + } + t.end(); +});