From bb46b30b06a65a6d92228b2e21eee1d06ae97f74 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 28 Mar 2023 18:14:59 +0530 Subject: [PATCH 01/15] feat: add binding.gyp --- .../@stdlib/blas/base/srotg/binding.gyp | 265 ++++++++++++++++++ 1 file changed, 265 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/srotg/binding.gyp diff --git a/lib/node_modules/@stdlib/blas/base/srotg/binding.gyp b/lib/node_modules/@stdlib/blas/base/srotg/binding.gyp new file mode 100644 index 000000000000..864d9109e892 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotg/binding.gyp @@ -0,0 +1,265 @@ +# @license Apache-2.0 +# +# Copyright (c) 2018 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# 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 +} From c57a5b1bda17f6f21a16b645774ee27401fcbe65 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 28 Mar 2023 18:15:20 +0530 Subject: [PATCH 02/15] feat: add include.gypi --- .../@stdlib/blas/base/srotg/include.gypi | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/srotg/include.gypi diff --git a/lib/node_modules/@stdlib/blas/base/srotg/include.gypi b/lib/node_modules/@stdlib/blas/base/srotg/include.gypi new file mode 100644 index 000000000000..f8b01bfb52cb --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotg/include.gypi @@ -0,0 +1,70 @@ +# @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. + +# 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)', + ' Date: Tue, 28 Mar 2023 21:00:04 +0530 Subject: [PATCH 03/15] feat: add srotg_cblash.h and srotg.h in include/stdlib/blas/base --- .../srotg/include/stdlib/blas/base/srotg.h | 41 +++++++++++++++++++ .../include/stdlib/blas/base/srotg_cblas.h | 41 +++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/srotg/include/stdlib/blas/base/srotg.h create mode 100644 lib/node_modules/@stdlib/blas/base/srotg/include/stdlib/blas/base/srotg_cblas.h diff --git a/lib/node_modules/@stdlib/blas/base/srotg/include/stdlib/blas/base/srotg.h b/lib/node_modules/@stdlib/blas/base/srotg/include/stdlib/blas/base/srotg.h new file mode 100644 index 000000000000..c9925852047f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotg/include/stdlib/blas/base/srotg.h @@ -0,0 +1,41 @@ +/** +* @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. +*/ + +/** +* Header file containing function declarations for the C interface to the BLAS Level 1 routine `srotg`. +*/ +#ifndef SROTG_H +#define SROTG_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. +*/ +#ifdef __cplusplus +extern "C" { +#endif + +/** +* Interchanges two single-precision floating-point vectors. +*/ +void c_srotg( float *a, float *b, float *c, float *s ); + +#ifdef __cplusplus +} +#endif + +#endif // !SROTG_H diff --git a/lib/node_modules/@stdlib/blas/base/srotg/include/stdlib/blas/base/srotg_cblas.h b/lib/node_modules/@stdlib/blas/base/srotg/include/stdlib/blas/base/srotg_cblas.h new file mode 100644 index 000000000000..bb211ea3e45a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotg/include/stdlib/blas/base/srotg_cblas.h @@ -0,0 +1,41 @@ +/** +* @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. +*/ + +/** +* Header file containing function declarations for the C interface to the CBLAS Level 1 routine `cblas_sswap`. +*/ +#ifndef SROTG_CBLAS_H +#define SROTG_CBLAS_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. +*/ +#ifdef __cplusplus +extern "C" { +#endif + +/** +* Interchanges two single-precision floating-point vectors. +*/ +void cblas_srotg( float* a, float* b, float* c, float* s ); + +#ifdef __cplusplus +} +#endif + +#endif // !SROTG_CBLAS_H From 1f986128036b0ba5235ed9926d5bcf5fbe14bfbc Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 28 Mar 2023 21:11:40 +0530 Subject: [PATCH 04/15] feat: add addon.c, makefile, srotg_cblas.c and srotg.c in src/ --- .../@stdlib/blas/base/srotg/src/Makefile | 70 +++++++++++++++++++ .../@stdlib/blas/base/srotg/src/addon.c | 43 ++++++++++++ .../@stdlib/blas/base/srotg/src/srotg.c | 69 ++++++++++++++++++ .../@stdlib/blas/base/srotg/src/srotg_cblas.c | 32 +++++++++ 4 files changed, 214 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/srotg/src/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/srotg/src/addon.c create mode 100644 lib/node_modules/@stdlib/blas/base/srotg/src/srotg.c create mode 100644 lib/node_modules/@stdlib/blas/base/srotg/src/srotg_cblas.c diff --git a/lib/node_modules/@stdlib/blas/base/srotg/src/Makefile b/lib/node_modules/@stdlib/blas/base/srotg/src/Makefile new file mode 100644 index 000000000000..dd720a3de8f2 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotg/src/Makefile @@ -0,0 +1,70 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2020 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/srotg/src/addon.c b/lib/node_modules/@stdlib/blas/base/srotg/src/addon.c new file mode 100644 index 000000000000..e866660ce5cf --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotg/src/addon.c @@ -0,0 +1,43 @@ +/** +* @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. +*/ + +#include "stdlib/blas/base/srotg.h" +#include "stdlib/napi/export.h" +#include "stdlib/napi/argv.h" +#include "stdlib/napi/argv_float.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, 4 ); + STDLIB_NAPI_ARGV_FLOAT( env, a, argv, 0 ); + STDLIB_NAPI_ARGV_FLOAT( env, b, argv, 1 ); + STDLIB_NAPI_ARGV_FLOAT( env, c, argv, 2 ); + STDLIB_NAPI_ARGV_FLOAT( env, s, argv, 3 ); + c_srotg( &a, &b, &c, &s ); + return NULL; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN( addon ) diff --git a/lib/node_modules/@stdlib/blas/base/srotg/src/srotg.c b/lib/node_modules/@stdlib/blas/base/srotg/src/srotg.c new file mode 100644 index 000000000000..1b3a1e134f82 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotg/src/srotg.c @@ -0,0 +1,69 @@ +/** +* @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. +*/ + +#include "stdlib/blas/base/srotg.h" +#include "stdlib/math/base/special/absf.h" +#include "stdlib/math/base/special/sqrtf.h" +#include "stdlib/math/base/special/abs2f.h" +#include "stdlib/math/base/special/copysignf.h" + +/** +* Constructs a Givens plane rotation. +* +* @param a rotational elimination parameter +* @param b rotational elimination parameter +* @param c cosine of the rotation angle +* @param s sine of the rotation angle +*/ +void c_srotg( float *a, float *b, float *c, float *s ) { + float scale; + float sign; + float aa; + float ab; + float r; + float z; + + aa = stdlib_base_absf( *a ); + ab = stdlib_base_absf( *b ); + if ( aa > ab ) { + sign = stdlib_base_copysignf( 1.0f, *a ); + } else { + sign = stdlib_base_copysignf( 1.0f, *b ); + } + scale = aa + ab; + if ( scale == 0.0 ) { + *c = 1.0f; + *s = 0.0f; + r = 0.0f; + z = 0.0f; + } else { + r = scale * stdlib_base_sqrtf( stdlib_base_abs2f( *a/scale ) + stdlib_base_abs2f( *b/scale ) ); + r = sign * r; + *c = *a / r; + *s = *b / r; + z = 1.0f; + if ( aa > ab ) { + z = *s; + } else if ( *c != 0.0f ) { + z = 1.0f / *c; + } + } + *a = r; + *b = z; + return; +} diff --git a/lib/node_modules/@stdlib/blas/base/srotg/src/srotg_cblas.c b/lib/node_modules/@stdlib/blas/base/srotg/src/srotg_cblas.c new file mode 100644 index 000000000000..e55793979b2f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotg/src/srotg_cblas.c @@ -0,0 +1,32 @@ +/** +* @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. +*/ + +#include "stdlib/blas/base/srotg.h" +#include "stdlib/blas/base/srotg_cblas.h" + +/** +* Constructs a Givens plane rotation. +* +* @param a rotational elimination parameter +* @param b rotational elimination parameter +* @param c cosine of the rotation angle +* @param s sine of the rotation angle +*/ +void c_srotg( float *a, float *b, float *c, float *s ) { + cblas_srotg( a, b, c, s ); +} From a8ed33b4160f741120e77ef9cf913a2c01494f3a Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 28 Mar 2023 22:18:20 +0530 Subject: [PATCH 05/15] feat: add manifest.json --- .../@stdlib/blas/base/srotg/manifest.json | 142 ++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/srotg/manifest.json diff --git a/lib/node_modules/@stdlib/blas/base/srotg/manifest.json b/lib/node_modules/@stdlib/blas/base/srotg/manifest.json new file mode 100644 index 000000000000..5bc7f0a306aa --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotg/manifest.json @@ -0,0 +1,142 @@ +{ + "options": { + "os": "linux", + "blas": "" + }, + "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": [ + { + "os": "linux", + "blas": "", + "src": [ + "./src/srotg.f", + "./src/srotg_f.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-float" + ] + }, + { + "os": "linux", + "blas": "openblas", + "src": [ + "./src/srotg_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-float" + ] + }, + { + "os": "mac", + "blas": "", + "src": [ + "./src/srotg.f", + "./src/srotg_f.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-float" + ] + }, + { + "os": "mac", + "blas": "apple_accelerate_framework", + "src": [ + "./src/srotg_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lblas" + ], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-float" + ] + }, + { + "os": "mac", + "blas": "openblas", + "src": [ + "./src/srotg_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-float" + ] + }, + { + "os": "win", + "blas": "", + "src": [ + "./src/srotg.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-float" + ] + } + ] +} From 73eaacfa123a60d9cde1d4c59bd6df639ea94973 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Thu, 6 Apr 2023 21:04:10 +0530 Subject: [PATCH 06/15] feat: add srotg_fortran.h and correct description --- .../srotg/include/stdlib/blas/base/srotg.h | 2 +- .../include/stdlib/blas/base/srotg_cblas.h | 4 +- .../include/stdlib/blas/base/srotg_fortran.h | 41 +++++++++++++++++++ 3 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 lib/node_modules/@stdlib/blas/base/srotg/include/stdlib/blas/base/srotg_fortran.h diff --git a/lib/node_modules/@stdlib/blas/base/srotg/include/stdlib/blas/base/srotg.h b/lib/node_modules/@stdlib/blas/base/srotg/include/stdlib/blas/base/srotg.h index c9925852047f..deb2e330325f 100644 --- a/lib/node_modules/@stdlib/blas/base/srotg/include/stdlib/blas/base/srotg.h +++ b/lib/node_modules/@stdlib/blas/base/srotg/include/stdlib/blas/base/srotg.h @@ -30,7 +30,7 @@ extern "C" { #endif /** -* Interchanges two single-precision floating-point vectors. +* Constructs a Givens plane rotation. */ void c_srotg( float *a, float *b, float *c, float *s ); diff --git a/lib/node_modules/@stdlib/blas/base/srotg/include/stdlib/blas/base/srotg_cblas.h b/lib/node_modules/@stdlib/blas/base/srotg/include/stdlib/blas/base/srotg_cblas.h index bb211ea3e45a..6f653a2ee326 100644 --- a/lib/node_modules/@stdlib/blas/base/srotg/include/stdlib/blas/base/srotg_cblas.h +++ b/lib/node_modules/@stdlib/blas/base/srotg/include/stdlib/blas/base/srotg_cblas.h @@ -17,7 +17,7 @@ */ /** -* Header file containing function declarations for the C interface to the CBLAS Level 1 routine `cblas_sswap`. +* Header file containing function declarations for the C interface to the CBLAS Level 1 routine `cblas_srotg`. */ #ifndef SROTG_CBLAS_H #define SROTG_CBLAS_H @@ -30,7 +30,7 @@ extern "C" { #endif /** -* Interchanges two single-precision floating-point vectors. +* Constructs a Givens plane rotation. */ void cblas_srotg( float* a, float* b, float* c, float* s ); diff --git a/lib/node_modules/@stdlib/blas/base/srotg/include/stdlib/blas/base/srotg_fortran.h b/lib/node_modules/@stdlib/blas/base/srotg/include/stdlib/blas/base/srotg_fortran.h new file mode 100644 index 000000000000..480beff40d01 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotg/include/stdlib/blas/base/srotg_fortran.h @@ -0,0 +1,41 @@ +/** +* @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. +*/ + +/** +* Header file containing function declarations for the Fortran interface to the BLAS Level 1 routine `srotg`. +*/ +#ifndef SROTG_FORTRAN_H +#define SROTG_FORTRAN_H + +/* +* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C/Fortran compiler (a Fortran compiler must be configured to not attach underscores). +*/ +#ifdef __cplusplus +extern "C" { +#endif + +/** +* Constructs a Givens plane rotation. +*/ +void srotg( float *, float *, float *, float * ); + +#ifdef __cplusplus +} +#endif + +#endif // !SROTG_FORTRAN_H From 0b1d8bcd025ad10687d225463d45fe4ade545df7 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Thu, 6 Apr 2023 21:18:40 +0530 Subject: [PATCH 07/15] feat: add srotg_f.c and srotg.f in src/ --- .../@stdlib/blas/base/srotg/src/srotg.f | 89 +++++++++++++++++++ .../@stdlib/blas/base/srotg/src/srotg_f.c | 32 +++++++ 2 files changed, 121 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/srotg/src/srotg.f create mode 100644 lib/node_modules/@stdlib/blas/base/srotg/src/srotg_f.c diff --git a/lib/node_modules/@stdlib/blas/base/srotg/src/srotg.f b/lib/node_modules/@stdlib/blas/base/srotg/src/srotg.f new file mode 100644 index 000000000000..6c164b0a3200 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotg/src/srotg.f @@ -0,0 +1,89 @@ +!> +! @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. +!< + +!> Constructs a Givens plane rotation. +! +! ## Notes +! +! * Modified version of reference BLAS level1 routine (version 3.7.0). Updated to "free form" Fortran 95. +! +! ## Authors +! +! Edward Anderson +! Lockheed Martin +! +! ## Contributors +! +! Weslley Pereira +! University of Colorado Denver, USA +! +! ## 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 {real} a - rotational elimination parameter +! @param {real} b - rotational elimination parameter +! @param {real} c - cosine of rotation +! @param {real} s - sine of rotation +!< +subroutine srotg(a, b, c, s) + ! .. + ! scalar arguments: + real :: c, s, a, b + ! .. + ! local scalars: + real :: r, roe, scale, z + ! .. + ! intrinsic functions: + intrinsic :: abs, sign, sqrt + ! .. + roe = b + if (abs(a) > abs(b)) then + roe = a + end if + scale = abs(a) + abs(b) + if (scale == 0.0) then + c = 1.0 + s = 0.0 + r = 0.0 + z = 0.0 + else + r = scale * sqrt((a / scale) ** 2 + (b / scale) ** 2) + r = sign(1.0, roe) * r + c = a / r + s = b / r + z = 1.0 + if (abs(a) > abs(b)) then + z = s + end if + if (abs(b) >= abs(a) .AND. c /= 0.0) then + z = 1.0 / c + end if + end if + a = r + b = z + return +end diff --git a/lib/node_modules/@stdlib/blas/base/srotg/src/srotg_f.c b/lib/node_modules/@stdlib/blas/base/srotg/src/srotg_f.c new file mode 100644 index 000000000000..ec8a2d34dfd2 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotg/src/srotg_f.c @@ -0,0 +1,32 @@ +/** +* @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. +*/ + +#include "stdlib/blas/base/srotg.h" +#include "stdlib/blas/base/srotg_fortran.h" + +/** +* Constructs a Givens plane rotation. +* +* @param a rotational elimination parameter +* @param b rotational elimination parameter +* @param c cosine of the rotation angle +* @param s sine of the rotation angle +*/ +void c_srotg( float *a, float *b, float *c, float *s ) { + srotg( a, b, c, s ); +} From 2ae95b598e64541911e9ab326b471c78627e4372 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Thu, 6 Apr 2023 21:35:23 +0530 Subject: [PATCH 08/15] feat: update manifest.json --- .../@stdlib/blas/base/srotg/manifest.json | 36 +++++++++++++++---- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/srotg/manifest.json b/lib/node_modules/@stdlib/blas/base/srotg/manifest.json index 5bc7f0a306aa..31c870d75ec3 100644 --- a/lib/node_modules/@stdlib/blas/base/srotg/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/srotg/manifest.json @@ -41,7 +41,11 @@ "dependencies": [ "@stdlib/napi/export", "@stdlib/napi/argv", - "@stdlib/napi/argv-float" + "@stdlib/napi/argv-float", + "@stdlib/math/base/special/absf", + "@stdlib/math/base/special/sqrtf", + "@stdlib/math/base/special/abs2f", + "@stdlib/math/base/special/copysignf" ] }, { @@ -61,7 +65,11 @@ "dependencies": [ "@stdlib/napi/export", "@stdlib/napi/argv", - "@stdlib/napi/argv-float" + "@stdlib/napi/argv-float", + "@stdlib/math/base/special/absf", + "@stdlib/math/base/special/sqrtf", + "@stdlib/math/base/special/abs2f", + "@stdlib/math/base/special/copysignf" ] }, { @@ -79,7 +87,11 @@ "dependencies": [ "@stdlib/napi/export", "@stdlib/napi/argv", - "@stdlib/napi/argv-float" + "@stdlib/napi/argv-float", + "@stdlib/math/base/special/absf", + "@stdlib/math/base/special/sqrtf", + "@stdlib/math/base/special/abs2f", + "@stdlib/math/base/special/copysignf" ] }, { @@ -98,7 +110,11 @@ "dependencies": [ "@stdlib/napi/export", "@stdlib/napi/argv", - "@stdlib/napi/argv-float" + "@stdlib/napi/argv-float", + "@stdlib/math/base/special/absf", + "@stdlib/math/base/special/sqrtf", + "@stdlib/math/base/special/abs2f", + "@stdlib/math/base/special/copysignf" ] }, { @@ -118,7 +134,11 @@ "dependencies": [ "@stdlib/napi/export", "@stdlib/napi/argv", - "@stdlib/napi/argv-float" + "@stdlib/napi/argv-float", + "@stdlib/math/base/special/absf", + "@stdlib/math/base/special/sqrtf", + "@stdlib/math/base/special/abs2f", + "@stdlib/math/base/special/copysignf" ] }, { @@ -135,7 +155,11 @@ "dependencies": [ "@stdlib/napi/export", "@stdlib/napi/argv", - "@stdlib/napi/argv-float" + "@stdlib/napi/argv-float", + "@stdlib/math/base/special/absf", + "@stdlib/math/base/special/sqrtf", + "@stdlib/math/base/special/abs2f", + "@stdlib/math/base/special/copysignf" ] } ] From 1b83ea620900468a5c35cb61bee79a6fd138308f Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Thu, 6 Apr 2023 21:35:45 +0530 Subject: [PATCH 09/15] feat: update package.json --- lib/node_modules/@stdlib/blas/base/srotg/package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/node_modules/@stdlib/blas/base/srotg/package.json b/lib/node_modules/@stdlib/blas/base/srotg/package.json index b1ede45f37c6..5c535d42ff5e 100644 --- a/lib/node_modules/@stdlib/blas/base/srotg/package.json +++ b/lib/node_modules/@stdlib/blas/base/srotg/package.json @@ -14,11 +14,14 @@ } ], "main": "./lib", + "browser": "./lib/main.js", + "gypfile": true, "directories": { "benchmark": "./benchmark", "doc": "./docs", "example": "./examples", "lib": "./lib", + "src": "./src", "test": "./test" }, "types": "./docs/types", From c0cd7b2da582012448eac66a815eee1178169241 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 11 Apr 2023 10:46:14 +0530 Subject: [PATCH 10/15] feat: add c examples --- .../blas/base/srotg/examples/c/Makefile | 129 ++++++++++++++++++ .../blas/base/srotg/examples/c/example.c | 47 +++++++ 2 files changed, 176 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/srotg/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/srotg/examples/c/example.c diff --git a/lib/node_modules/@stdlib/blas/base/srotg/examples/c/Makefile b/lib/node_modules/@stdlib/blas/base/srotg/examples/c/Makefile new file mode 100644 index 000000000000..6e3498f72166 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotg/examples/c/Makefile @@ -0,0 +1,129 @@ +#/ +# @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. +#/ + +# 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 source files: +c_src := ../../src/srotg.c + +# List of C targets: +c_targets := example.out + + +# RULES # + +#/ +# Compiles C source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code (e.g., `-fPIC`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler +# @param {string} CFLAGS - C compiler flags +# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) -I ../../include -o $@ $(c_src) $< -lm + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/blas/base/srotg/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/srotg/examples/c/example.c new file mode 100644 index 000000000000..9b43ef008de4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotg/examples/c/example.c @@ -0,0 +1,47 @@ +/** +* @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. +*/ + +#include "stdlib/blas/base/srotg.h" +#include + +int main() { + // Create an input array: + float a[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f }; + + // Create an output array: + float b[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f }; + + // Create a cosine array: + float c[] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; + + // Create a sine array: + float s[] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; + + // Create an index variable: + int i; + + // Apply the function: + for ( i = 0; i < 5; i++ ) { + c_srotg( &a[ i ], &b[ i ], &c[ i ], &s[ i ] ); + } + + // Print the results: + for ( i = 0; i < 5; i++ ) { + printf( "a: %f, b: %f, c: %f, s: %f", a[ i ], b[ i ], c[ i ], s[ i ] ); + } +} From 2949154752a719bf1c621931b647c734a84817bc Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 11 Apr 2023 11:06:33 +0530 Subject: [PATCH 11/15] feat: update package.json --- lib/node_modules/@stdlib/blas/base/srotg/package.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/srotg/package.json b/lib/node_modules/@stdlib/blas/base/srotg/package.json index 5c535d42ff5e..eb652797bdc2 100644 --- a/lib/node_modules/@stdlib/blas/base/srotg/package.json +++ b/lib/node_modules/@stdlib/blas/base/srotg/package.json @@ -22,6 +22,7 @@ "example": "./examples", "lib": "./lib", "src": "./src", + "include": "./include", "test": "./test" }, "types": "./docs/types", @@ -72,5 +73,8 @@ "float", "single", "float32array" - ] + ], + "__stdlib__": { + "wasm": false + } } From 7363b11d71c0ab25b78baa43986ee10cc3f1dc0e Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 10 Apr 2023 22:58:20 -0700 Subject: [PATCH 12/15] build: update Makefile --- .../blas/base/srotg/examples/c/Makefile | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/srotg/examples/c/Makefile b/lib/node_modules/@stdlib/blas/base/srotg/examples/c/Makefile index 6e3498f72166..ecaa627e1bca 100644 --- a/lib/node_modules/@stdlib/blas/base/srotg/examples/c/Makefile +++ b/lib/node_modules/@stdlib/blas/base/srotg/examples/c/Makefile @@ -69,8 +69,17 @@ else fPIC ?= -fPIC endif +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + # List of source files: -c_src := ../../src/srotg.c +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 @@ -79,11 +88,15 @@ c_targets := example.out # RULES # #/ -# Compiles C source files. +# Compiles source files. # # @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) # @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code (e.g., `-fPIC`) +# @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 @@ -99,12 +112,16 @@ all: $(c_targets) # Compiles C source files. # # @private -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code +# @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) -I ../../include -o $@ $(c_src) $< -lm + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) #/ # Runs compiled benchmarks. From 9f6e5892fa7811a3c0397ca66f0679592337318a Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 10 Apr 2023 23:03:21 -0700 Subject: [PATCH 13/15] docs: add newline in printed output --- lib/node_modules/@stdlib/blas/base/srotg/examples/c/example.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/srotg/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/srotg/examples/c/example.c index 9b43ef008de4..38d7933c8060 100644 --- a/lib/node_modules/@stdlib/blas/base/srotg/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/base/srotg/examples/c/example.c @@ -42,6 +42,6 @@ int main() { // Print the results: for ( i = 0; i < 5; i++ ) { - printf( "a: %f, b: %f, c: %f, s: %f", a[ i ], b[ i ], c[ i ], s[ i ] ); + printf( "a: %f, b: %f, c: %f, s: %f\n", a[ i ], b[ i ], c[ i ], s[ i ] ); } } From f6719041ad1db04d1b8c40365ba6d53fadfb25c9 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 10 Apr 2023 23:03:46 -0700 Subject: [PATCH 14/15] build: add task configurations --- .../@stdlib/blas/base/srotg/manifest.json | 373 ++++++++++-------- 1 file changed, 209 insertions(+), 164 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/srotg/manifest.json b/lib/node_modules/@stdlib/blas/base/srotg/manifest.json index 31c870d75ec3..bc837732e3be 100644 --- a/lib/node_modules/@stdlib/blas/base/srotg/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/srotg/manifest.json @@ -1,166 +1,211 @@ { - "options": { - "os": "linux", - "blas": "" - }, - "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": [ - { - "os": "linux", - "blas": "", - "src": [ - "./src/srotg.f", - "./src/srotg_f.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/napi/export", - "@stdlib/napi/argv", - "@stdlib/napi/argv-float", - "@stdlib/math/base/special/absf", - "@stdlib/math/base/special/sqrtf", - "@stdlib/math/base/special/abs2f", - "@stdlib/math/base/special/copysignf" - ] - }, - { - "os": "linux", - "blas": "openblas", - "src": [ - "./src/srotg_cblas.c" - ], - "include": [ - "./include" - ], - "libraries": [ - "-lopenblas", - "-lpthread" - ], - "libpath": [], - "dependencies": [ - "@stdlib/napi/export", - "@stdlib/napi/argv", - "@stdlib/napi/argv-float", - "@stdlib/math/base/special/absf", - "@stdlib/math/base/special/sqrtf", - "@stdlib/math/base/special/abs2f", - "@stdlib/math/base/special/copysignf" - ] - }, - { - "os": "mac", - "blas": "", - "src": [ - "./src/srotg.f", - "./src/srotg_f.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/napi/export", - "@stdlib/napi/argv", - "@stdlib/napi/argv-float", - "@stdlib/math/base/special/absf", - "@stdlib/math/base/special/sqrtf", - "@stdlib/math/base/special/abs2f", - "@stdlib/math/base/special/copysignf" - ] - }, - { - "os": "mac", - "blas": "apple_accelerate_framework", - "src": [ - "./src/srotg_cblas.c" - ], - "include": [ - "./include" - ], - "libraries": [ - "-lblas" - ], - "libpath": [], - "dependencies": [ - "@stdlib/napi/export", - "@stdlib/napi/argv", - "@stdlib/napi/argv-float", - "@stdlib/math/base/special/absf", - "@stdlib/math/base/special/sqrtf", - "@stdlib/math/base/special/abs2f", - "@stdlib/math/base/special/copysignf" - ] - }, - { - "os": "mac", - "blas": "openblas", - "src": [ - "./src/srotg_cblas.c" - ], - "include": [ - "./include" - ], - "libraries": [ - "-lopenblas", - "-lpthread" - ], - "libpath": [], - "dependencies": [ - "@stdlib/napi/export", - "@stdlib/napi/argv", - "@stdlib/napi/argv-float", - "@stdlib/math/base/special/absf", - "@stdlib/math/base/special/sqrtf", - "@stdlib/math/base/special/abs2f", - "@stdlib/math/base/special/copysignf" - ] - }, - { - "os": "win", - "blas": "", - "src": [ - "./src/srotg.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/napi/export", - "@stdlib/napi/argv", - "@stdlib/napi/argv-float", - "@stdlib/math/base/special/absf", - "@stdlib/math/base/special/sqrtf", - "@stdlib/math/base/special/abs2f", - "@stdlib/math/base/special/copysignf" - ] - } - ] + "options": { + "task": "", + "os": "linux", + "blas": "" + }, + "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": "", + "src": [ + "./src/srotg.f", + "./src/srotg_f.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-float", + "@stdlib/math/base/special/absf", + "@stdlib/math/base/special/sqrtf", + "@stdlib/math/base/special/abs2f", + "@stdlib/math/base/special/copysignf" + ] + }, + { + "task": "build", + "os": "linux", + "blas": "openblas", + "src": [ + "./src/srotg_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-float", + "@stdlib/math/base/special/absf", + "@stdlib/math/base/special/sqrtf", + "@stdlib/math/base/special/abs2f", + "@stdlib/math/base/special/copysignf" + ] + }, + { + "task": "build", + "os": "mac", + "blas": "", + "src": [ + "./src/srotg.f", + "./src/srotg_f.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-float", + "@stdlib/math/base/special/absf", + "@stdlib/math/base/special/sqrtf", + "@stdlib/math/base/special/abs2f", + "@stdlib/math/base/special/copysignf" + ] + }, + { + "task": "build", + "os": "mac", + "blas": "apple_accelerate_framework", + "src": [ + "./src/srotg_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lblas" + ], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-float", + "@stdlib/math/base/special/absf", + "@stdlib/math/base/special/sqrtf", + "@stdlib/math/base/special/abs2f", + "@stdlib/math/base/special/copysignf" + ] + }, + { + "task": "build", + "os": "mac", + "blas": "openblas", + "src": [ + "./src/srotg_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-float", + "@stdlib/math/base/special/absf", + "@stdlib/math/base/special/sqrtf", + "@stdlib/math/base/special/abs2f", + "@stdlib/math/base/special/copysignf" + ] + }, + { + "task": "build", + "os": "win", + "blas": "", + "src": [ + "./src/srotg.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-float", + "@stdlib/math/base/special/absf", + "@stdlib/math/base/special/sqrtf", + "@stdlib/math/base/special/abs2f", + "@stdlib/math/base/special/copysignf" + ] + }, + { + "task": "examples", + "os": "linux", + "blas": "", + "src": [ + "./src/srotg.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/special/absf", + "@stdlib/math/base/special/sqrtf", + "@stdlib/math/base/special/abs2f", + "@stdlib/math/base/special/copysignf" + ] + }, + { + "task": "benchmark", + "os": "linux", + "blas": "", + "src": [ + "./src/srotg.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/special/absf", + "@stdlib/math/base/special/sqrtf", + "@stdlib/math/base/special/abs2f", + "@stdlib/math/base/special/copysignf" + ] + } + ] } From 13e53deabc494dc0046d3b7a39d84749b17e425a Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 11 Apr 2023 18:21:05 +0530 Subject: [PATCH 15/15] feat: add C benchmarks --- .../blas/base/srotg/benchmark/c/Makefile | 142 +++++++++++++++++ .../blas/base/srotg/benchmark/c/benchmark.c | 144 ++++++++++++++++++ 2 files changed, 286 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/srotg/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/srotg/benchmark/c/benchmark.c diff --git a/lib/node_modules/@stdlib/blas/base/srotg/benchmark/c/Makefile b/lib/node_modules/@stdlib/blas/base/srotg/benchmark/c/Makefile new file mode 100644 index 000000000000..9202fb4f0eee --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotg/benchmark/c/Makefile @@ -0,0 +1,142 @@ +#/ +# @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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := benchmark.out + + +# RULES # + +#/ +# Compiles C source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code (e.g., `-fPIC`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (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/srotg/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/blas/base/srotg/benchmark/c/benchmark.c new file mode 100644 index 000000000000..fee51c90fa10 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotg/benchmark/c/benchmark.c @@ -0,0 +1,144 @@ +/** +* @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. +*/ + +/** +* Benchmark `srotg`. +*/ +#include "stdlib/blas/base/srotg.h" +#include +#include +#include +#include +#include + +#define NAME "srotg" +#define ITERATIONS 10000000 +#define REPEATS 3 +#define MIN 1 +#define MAX 6 + +/** +* Prints the TAP version. +*/ +void print_version() { + 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() { + 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 +*/ +float rand_float() { + int r = rand(); + return (float)r / ( (float)RAND_MAX + 1.0f ); +} + +/** +* Runs a benchmark. +* +* @param iterations number of iterations +* @return elapsed time in seconds +*/ +double benchmark( int iterations ) { + double elapsed; + float a; + float b; + float c; + float s; + double t; + int i; + + t = tic(); + for ( i = 0; i < iterations; i++ ) { + a = ( rand_float() * 10.0f ) - 5.0f; + b = ( rand_float() * 10.0f ) - 5.0f; + c_srotg( &a, &b, &c, &s ); + if ( a != a || b != b || c != c || s != s ) { + printf( "should not return NaN" ); + break; + } + + } + elapsed = tic() - t; + if ( a != a || b != b || c != c || s != s ) { + printf( "should not return NaN" ); + } + return elapsed; +} + +/** +* Main execution sequence. +*/ +int main( void ) { + double elapsed; + int i; + + // Use the current time to seed the random number generator: + srand( time( NULL ) ); + + print_version(); + for ( i = 0; i < REPEATS; i++ ) { + printf( "# c::%s\n", "srotg" ); + elapsed = benchmark( ITERATIONS ); + print_results( ITERATIONS, elapsed ); + printf( "ok %d benchmark finished\n", i+1 ); + } + print_summary( REPEATS, REPEATS ); +}