diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/README.md b/lib/node_modules/@stdlib/blas/base/dzasum/README.md new file mode 100644 index 000000000000..cdbc13ef385e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/README.md @@ -0,0 +1,295 @@ + + +# dzasum + +> Compute the sum of the absolute values of the real and imaginary components of a double-precision complex floating-point vector. + +
+ +## Usage + +```javascript +var dzasum = require( '@stdlib/blas/base/dzasum' ); +``` + +#### dzasum( N, x, strideX ) + +Computes the sum of the absolute values of the real and imaginary components of a double-precision complex floating-point vector. + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); + +var x = new Complex128Array( [ 0.3, 0.1, 0.5, 0.0, 0.0, 0.5, 0.0, 0.2 ] ); + +var out = dzasum( 4, x, 1 ); +// returns ~1.6 +``` + +The function has the following parameters: + +- **N**: number of indexed elements. +- **x**: input [`Complex128Array`][@stdlib/array/complex128]. +- **strideX**: index increment for `x`. + +The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to traverse every other value, + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); + +var x = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); + +var out = dzasum( 2, x, 2 ); +// returns 7.0 +``` + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); + +// Initial array: +var x0 = new Complex128Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); + +// Create an offset view: +var x1 = new Complex128Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +// Compute the sum of absolute values: +var out = dzasum( 2, x1, 1 ); +// returns 18.0 +``` + +#### dzasum.ndarray( N, x, strideX, offset ) + +Computes the sum of the absolute values of the real and imaginary components of a double-precision complex floating-point vector using alternative indexing semantics. + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); + +var x = new Complex128Array( [ 0.3, 0.1, 0.5, 0.0, 0.0, 0.5, 0.0, 0.2 ] ); + +var out = dzasum.ndarray( 4, x, 1, 0 ); +// returns ~1.6 +``` + +The function has the following additional parameters: + +- **offsetX**: starting index. + +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to start from the second index, + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); + +var x = new Complex128Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); + +var out = dzasum.ndarray( 2, x, 1, 1 ); +// returns 18.0 +``` + +
+ + + +
+ +## Notes + +- If `N <= 0`, both functions return `0.0`. +- `dzasum()` corresponds to the [BLAS][blas] level 1 function [`dzasum`][dzasum]. + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var dzasum = require( '@stdlib/blas/base/dzasum' ); + +function rand() { + return new Complex128( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) ); +} + +var x = filledarrayBy( 10, 'complex128', rand ); +console.log( x.toString() ); + +// Compute the sum of the absolute values of real and imaginary components: +var out = dzasum( x.length, x, 1 ); +console.log( out ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/blas/base/dzasum.h" +``` + +#### c_dzasum( N, \*X, strideX ) + +Computes the sum of the absolute values of the real and imaginary components of a double-precision complex floating-point vector. + +```c +const double X[] = { 0.3, 0.1, 0.5, 0.0, 0.0, 0.5, 0.0, 0.2 }; + +double out = c_dzasum( 4, (void *)X, 1 ); +// returns 1.6 +``` + +The function accepts the following arguments: + +- **N**: `[in] CBLAS_INT` number of indexed elements. +- **X**: `[in] void*` input array. +- **strideX**: `[in] CBLAS_INT` index increment for `X`. + +```c +double c_dzasum( const CBLAS_INT N, const void *X, const CBLAS_INT strideX ); +``` + +#### c_dzasum_ndarray( N, \*X, strideX, offsetX ) + +Computes the sum of the absolute values of the real and imaginary components of a double-precision complex floating-point vector using alternative indexing semantics. + +```c +const double X[] = { 0.3, 0.1, 0.5, 0.0, 0.0, 0.5, 0.0, 0.2 }; + +double out = c_dzasum_ndarray( 4, (void *)X, 1, 0 ); +// returns 1.6 +``` + +The function accepts the following arguments: + +- **N**: `[in] CBLAS_INT` number of indexed elements. +- **X**: `[in] void*` input array. +- **strideX**: `[in] CBLAS_INT` index increment for `X`. +- **offsetX**: `[in] CBLAS_INT` starting index for `X`. + +```c +double c_dzasum_ndarray( const CBLAS_INT N, const void *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/blas/base/dzasum.h" +#include + +int main( void ) { + // Create a strided array of interleaved real and imaginary components: + const double X[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; + + // Specify the number of elements: + const int N = 4; + + // Specify stride length: + const int strideX = 1; + + // Compute the sum of the absolute values of real and imaginary components: + double out = c_dzasum( N, (void *)X, strideX ); + + // Print the result: + printf( "out: %f\n", out ); + + // Compute the sum of the absolute values of real and imaginary components using alternative indexing semantics: + out = c_dzasum_ndarray( N, (void *)X, -strideX, N-1 ); + + // Print the result: + printf( "out: %f\n", out ); +} +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.js new file mode 100644 index 000000000000..322fb242f34e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.js @@ -0,0 +1,106 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var dzasum = require( './../lib/dzasum.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var x; + + x = new Complex128Array( uniform( N*2, -100.0, 100.0, options ) ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = dzasum( x.length, x, 1 ); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var N; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + N = pow( 10, i ); + f = createBenchmark( N ); + bench( format( '%s:size=%u', pkg, N ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.native.js new file mode 100644 index 000000000000..07ea33e4139e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.native.js @@ -0,0 +1,111 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var dzasum = tryRequire( resolve( __dirname, './../lib/dzasum.native.js' ) ); +var opts = { + 'skip': ( dzasum instanceof Error ) +}; +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var x; + + x = new Complex128Array( uniform( N*2, -100.0, 100.0, options ) ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = dzasum( x.length, x, 1 ); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var N; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + N = pow( 10, i ); + f = createBenchmark( N ); + bench( format( '%s::native:size=%u', pkg, N ), opts, f); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..07eecc11a3a7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.ndarray.js @@ -0,0 +1,106 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var dzasum = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var x; + + x = new Complex128Array( uniform( N*2, -100.0, 100.0, options ) ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = dzasum( x.length, x, 1, 0 ); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var N; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + N = pow( 10, i ); + f = createBenchmark( N ); + bench( format( '%s:ndarray:size=%u', pkg, N ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.ndarray.native.js new file mode 100644 index 000000000000..5a3d4e279d27 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.ndarray.native.js @@ -0,0 +1,111 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var dzasum = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( dzasum instanceof Error ) +}; +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var x; + + x = new Complex128Array( uniform( N*2, -100.0, 100.0, options ) ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = dzasum( x.length, x, 1, 0 ); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var N; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + N = pow( 10, i ); + f = createBenchmark( N ); + bench( format( '%s:ndarray:native:size=%u', pkg, N ), opts, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/binding.gyp b/lib/node_modules/@stdlib/blas/base/dzasum/binding.gyp new file mode 100644 index 000000000000..60dce9d0b31a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/binding.gyp @@ -0,0 +1,265 @@ +# @license Apache-2.0 +# +# Copyright (c) 2026 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# 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/dzasum/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/dzasum/docs/repl.txt new file mode 100644 index 000000000000..53a6f5a1324b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/docs/repl.txt @@ -0,0 +1,91 @@ + +{{alias}}( N, x, strideX ) + Computes the sum of the absolute values of each element in a + double-precision complex floating-point vector. + + The `N` and `strideX` parameters determine which elements in `x` are used + to compute the sum. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + If `N` is less than or equal to `0`, the function returns `0`. + + Parameters + ---------- + N: integer + Number of indexed elements. + + x: Complex128Array + Input array. + + strideX: integer + Index increment. + + Returns + ------- + out: number + Result. + + Examples + -------- + // Standard usage: + > var x = new {{alias:@stdlib/array/complex128}}( [ -2.0, 1.0, 3.0, -5.0 ]); + > var out = {{alias}}( x.length, x, 1 ) + 11.0 + + // Advanced indexing: + > var x = new {{alias:@stdlib/array/complex128}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0 ] ); + > out = {{alias}}( 2, x, 2 ) + 7.0 + + // Using typed array views: + > var x0 = new {{alias:@stdlib/array/complex128}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); + > var x1 = new {{alias:@stdlib/array/complex128}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > out = {{alias}}( 2, x1, 1 ) + 18.0 + + +{{alias}}.ndarray( N, x, strideX, offsetX ) + Computes the sum of the absolute values of each element in a + double-precision complex floating-point vector using alternative indexing + semantics. + + While typed array views mandate a view offset based on the underlying + buffer, the `offsetX` parameter supports indexing semantics based on a + starting index. + + Parameters + ---------- + N: integer + Number of indexed elements. + + x: Complex128Array + Input array. + + strideX: integer + Index increment. + + offsetX: integer + Starting index. + + Returns + ------- + out: number + Result. + + Examples + -------- + // Standard usage: + > var x = new {{alias:@stdlib/array/complex128}}( [ -2.0, 1.0, 3.0, -5.0 ] ); + > var out = {{alias}}.ndarray( x.length, x, 1, 0 ) + 11.0 + + // Advanced indexing: + > x = new {{alias:@stdlib/array/complex128}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 ] ); + > out = {{alias}}.ndarray( 3, x, -1, x.length-1 ) + 33.0 + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/dzasum/docs/types/index.d.ts new file mode 100644 index 000000000000..f4337831da6a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/docs/types/index.d.ts @@ -0,0 +1,96 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +import { Complex128Array } from '@stdlib/types/array'; + +/** +* Interface describing `dzasum`. +*/ +interface Routine { + /** + * Computes the sum of the absolute values of each element in a double-precision complex floating-point vector. + * + * @param N - number of indexed elements + * @param x - input array + * @param stride - stride length + * @returns sum of absolute values + * + * @example + * var Complex128Array = require( '@stdlib/array/complex128' ); + * + * var x = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); + * + * var sum = dzasum( x.length, x, 1 ); + * // returns 19.0 + */ + ( N: number, x: Complex128Array, stride: number ): number; + + /** + * Computes the sum of the absolute values of each element in a double-precision complex floating-point vector using alternative indexing semantics. + * + * @param N - number of indexed elements + * @param x - input array + * @param stride - stride length + * @param offsetX - starting index + * @returns sum of absolute values + * + * @example + * var Complex128Array = require( '@stdlib/array/complex128' ); + * + * var x = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); + * + * var z = dzasum.ndarray( x.length, x, 1, 0 ); + * // returns 19.0 + */ + ndarray( N: number, x: Complex128Array, stride: number, offsetX: number ): number; +} + +/** +* Computes the sum of the absolute values of each element in a double-precision complex floating-point vector. +* +* @param N - number of indexed elements +* @param x - input array +* @param stride - stride length +* @returns sum of absolute values +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* +* var x = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); +* +* var sum = dzasum( x.length, x, 1 ); +* // returns 19.0 +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* +* var x = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); +* +* var z = dzasum.ndarray( x.length, x, 1, 0 ); +* // returns 19.0 +*/ +declare var dzasum: Routine; + + +// EXPORTS // + +export = dzasum; diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/dzasum/docs/types/test.ts new file mode 100644 index 000000000000..7d25b9f4dfd7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/docs/types/test.ts @@ -0,0 +1,158 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import Complex128Array = require( '@stdlib/array/complex128' ); +import dzasum = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + const x = new Complex128Array( 10 ); + + dzasum( x.length, x, 1 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const x = new Complex128Array( 10 ); + + dzasum( '10', x, 1 ); // $ExpectError + dzasum( true, x, 1 ); // $ExpectError + dzasum( false, x, 1 ); // $ExpectError + dzasum( null, x, 1 ); // $ExpectError + dzasum( undefined, x, 1 ); // $ExpectError + dzasum( [], x, 1 ); // $ExpectError + dzasum( {}, x, 1 ); // $ExpectError + dzasum( ( x: number ): number => x, x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a Complex128Array... +{ + const x = new Complex128Array( 10 ); + + dzasum( x.length, 10, 1 ); // $ExpectError + dzasum( x.length, '10', 1 ); // $ExpectError + dzasum( x.length, true, 1 ); // $ExpectError + dzasum( x.length, false, 1 ); // $ExpectError + dzasum( x.length, null, 1 ); // $ExpectError + dzasum( x.length, undefined, 1 ); // $ExpectError + dzasum( x.length, [], 1 ); // $ExpectError + dzasum( x.length, {}, 1 ); // $ExpectError + dzasum( x.length, ( x: number ): number => x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const x = new Complex128Array( 10 ); + + dzasum( x.length, x, '10' ); // $ExpectError + dzasum( x.length, x, true ); // $ExpectError + dzasum( x.length, x, false ); // $ExpectError + dzasum( x.length, x, null ); // $ExpectError + dzasum( x.length, x, undefined ); // $ExpectError + dzasum( x.length, x, [] ); // $ExpectError + dzasum( x.length, x, {} ); // $ExpectError + dzasum( x.length, x, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = new Complex128Array( 10 ); + + dzasum(); // $ExpectError + dzasum( x.length ); // $ExpectError + dzasum( x.length, x ); // $ExpectError + dzasum( x.length, x, 1, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a number... +{ + const x = new Complex128Array( 10 ); + + dzasum.ndarray( x.length, x, 1, 0 ); // $ExpectType number +} + +// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... +{ + const x = new Complex128Array( 10 ); + + dzasum.ndarray( '10', x, 1, 0 ); // $ExpectError + dzasum.ndarray( true, x, 1, 0 ); // $ExpectError + dzasum.ndarray( false, x, 1, 0 ); // $ExpectError + dzasum.ndarray( null, x, 1, 0 ); // $ExpectError + dzasum.ndarray( undefined, x, 1, 0 ); // $ExpectError + dzasum.ndarray( [], x, 1, 0 ); // $ExpectError + dzasum.ndarray( {}, x, 1, 0 ); // $ExpectError + dzasum.ndarray( ( x: number ): number => x, x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a second argument which is not a Complex128Array... +{ + const x = new Complex128Array( 10 ); + + dzasum.ndarray( x.length, 10, 1, 0 ); // $ExpectError + dzasum.ndarray( x.length, '10', 1, 0 ); // $ExpectError + dzasum.ndarray( x.length, true, 1, 0 ); // $ExpectError + dzasum.ndarray( x.length, false, 1, 0 ); // $ExpectError + dzasum.ndarray( x.length, null, 1, 0 ); // $ExpectError + dzasum.ndarray( x.length, undefined, 1, 0 ); // $ExpectError + dzasum.ndarray( x.length, [], 1, 0 ); // $ExpectError + dzasum.ndarray( x.length, {}, 1, 0 ); // $ExpectError + dzasum.ndarray( x.length, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... +{ + const x = new Complex128Array( 10 ); + + dzasum.ndarray( x.length, x, '10', 0 ); // $ExpectError + dzasum.ndarray( x.length, x, true, 0 ); // $ExpectError + dzasum.ndarray( x.length, x, false, 0 ); // $ExpectError + dzasum.ndarray( x.length, x, null, 0 ); // $ExpectError + dzasum.ndarray( x.length, x, undefined, 0 ); // $ExpectError + dzasum.ndarray( x.length, x, [], 0 ); // $ExpectError + dzasum.ndarray( x.length, x, {}, 0 ); // $ExpectError + dzasum.ndarray( x.length, x, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... +{ + const x = new Complex128Array( 10 ); + + dzasum.ndarray( x.length, x, 1, '10' ); // $ExpectError + dzasum.ndarray( x.length, x, 1, true ); // $ExpectError + dzasum.ndarray( x.length, x, 1, false ); // $ExpectError + dzasum.ndarray( x.length, x, 1, null ); // $ExpectError + dzasum.ndarray( x.length, x, 1, undefined ); // $ExpectError + dzasum.ndarray( x.length, x, 1, [] ); // $ExpectError + dzasum.ndarray( x.length, x, 1, {} ); // $ExpectError + dzasum.ndarray( x.length, x, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const x = new Complex128Array( 10 ); + + dzasum.ndarray(); // $ExpectError + dzasum.ndarray( x.length ); // $ExpectError + dzasum.ndarray( x.length, x ); // $ExpectError + dzasum.ndarray( x.length, x, 1 ); // $ExpectError + dzasum.ndarray( x.length, x, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/examples/c/Makefile b/lib/node_modules/@stdlib/blas/base/dzasum/examples/c/Makefile new file mode 100644 index 000000000000..c8f8e9a1517b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/examples/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2026 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# 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/dzasum/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/dzasum/examples/c/example.c new file mode 100644 index 000000000000..7e03d10fb8bc --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/examples/c/example.c @@ -0,0 +1,43 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/blas/base/dzasum.h" +#include + +int main( void ) { + // Create a strided array of interleaved real and imaginary components: + const double X[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; + + // Specify the number of elements: + const int N = 4; + + // Specify stride length: + const int strideX = 1; + + // Compute the sum of the absolute values of real and imaginary components: + double out = c_dzasum( N, (void *)X, strideX ); + + // Print the result: + printf( "out: %lf\n", out ); + + // Compute the sum of the absolute values of real and imaginary components using alternative indexing semantics: + out = c_dzasum_ndarray( N, (void *)X, -strideX, N-1 ); + + // Print the result: + printf( "out: %lf\n", out ); +} diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/examples/index.js b/lib/node_modules/@stdlib/blas/base/dzasum/examples/index.js new file mode 100644 index 000000000000..2fa386811dc4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/examples/index.js @@ -0,0 +1,40 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var dzasum = require( './../lib' ); + +function rand() { + return new Complex128( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) ); +} + +// Generate random input arrays: +var x = filledarrayBy( 10, 'complex128', rand ); +console.log( x.toString() ); + +// Compute the sum of the absolute values of each element: +var out = dzasum( x.length, x, 1 ); +console.log( out ); + +// Compute the sum of the absolute values of each element using alternative indexing semantics: +out = dzasum.ndarray( x.length, x, 1, 0 ); +console.log( out ); diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/include.gypi b/lib/node_modules/@stdlib/blas/base/dzasum/include.gypi new file mode 100644 index 000000000000..dcb556d250e8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/include.gypi @@ -0,0 +1,70 @@ +# @license Apache-2.0 +# +# Copyright (c) 2026 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A GYP include file for building a Node.js native add-on. +# +# Note that nesting variables is required due to how GYP processes a configuration. Any variables defined within a nested 'variables' section is defined in the outer scope. Thus, conditions in the outer variable scope are free to use these variables without running into "variable undefined" errors. +# +# Main documentation: +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +# +# Variable nesting hacks: +# +# [3]: https://chromium.googlesource.com/external/skia/gyp/+/master/common_variables.gypi +# [4]: https://src.chromium.org/viewvc/chrome/trunk/src/build/common.gypi?revision=127004 +{ + # Define variables to be used throughout the configuration for all targets: + 'variables': { + 'variables': { + # Host BLAS library (to override -Dblas=): + 'blas%': '', + + # Path to BLAS library (to override -Dblas_dir=): + 'blas_dir%': '', + }, # end variables + + # Source directory: + 'src_dir': './src', + + # Include directories: + 'include_dirs': [ + '<@(blas_dir)', + '=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "blas", + "level 1", + "linear", + "algebra", + "subroutines", + "dcabs1", + "absolute", + "value", + "sum", + "l1norm", + "norm", + "taxicab", + "manhattan", + "vector", + "array", + "ndarray", + "double", + "complex128", + "complex128array" + ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/src/Makefile b/lib/node_modules/@stdlib/blas/base/dzasum/src/Makefile new file mode 100644 index 000000000000..2caf905cedbe --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/src/Makefile @@ -0,0 +1,70 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2026 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# 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/dzasum/src/addon.c b/lib/node_modules/@stdlib/blas/base/dzasum/src/addon.c new file mode 100644 index 000000000000..442f479cfead --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/src/addon.c @@ -0,0 +1,61 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/blas/base/dzasum.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/napi/export.h" +#include "stdlib/napi/argv.h" +#include "stdlib/napi/argv_int64.h" +#include "stdlib/napi/argv_strided_complex128array.h" +#include "stdlib/napi/create_double.h" +#include + +/** +* Receives JavaScript callback invocation data. +* +* @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, 3 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 2 ); + STDLIB_NAPI_ARGV_STRIDED_COMPLEX128ARRAY( env, X, N, strideX, argv, 1 ); + STDLIB_NAPI_CREATE_DOUBLE( env, API_SUFFIX(c_dzasum)( N, (void *)X, strideX ), out ); + return out; +} + +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +static napi_value addon_method( napi_env env, napi_callback_info info ) { + STDLIB_NAPI_ARGV( env, info, argv, argc, 4 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 2 ); + STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 3 ); + STDLIB_NAPI_ARGV_STRIDED_COMPLEX128ARRAY( env, X, N, strideX, argv, 1 ); + STDLIB_NAPI_CREATE_DOUBLE( env, API_SUFFIX(c_dzasum_ndarray)( N, (void *)X, strideX, offsetX ), out ); + return out; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method ) diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/src/dzasum.c b/lib/node_modules/@stdlib/blas/base/dzasum/src/dzasum.c new file mode 100644 index 000000000000..3aa53265e4fe --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/src/dzasum.c @@ -0,0 +1,33 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/blas/base/dzasum.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/strided/base/stride2offset.h" + +/** +* Computes the sum of the absolute values of the real and imaginary components of a double-precision complex floating-point vector. +* +* @param N number of indexed elements +* @param X input array +* @param strideX X stride length +*/ +double API_SUFFIX(c_dzasum)( const CBLAS_INT N, const void *X, const CBLAS_INT strideX ) { + CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX ); + return API_SUFFIX(c_dzasum_ndarray)( N, X, strideX, ox ); +} diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/src/dzasum.f b/lib/node_modules/@stdlib/blas/base/dzasum/src/dzasum.f new file mode 100644 index 000000000000..1d9d9f55d211 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/src/dzasum.f @@ -0,0 +1,83 @@ +!> +! @license Apache-2.0 +! +! Copyright (c) 2026 The Stdlib Authors. +! +! Licensed under the Apache License, Version 2.0 (the "License"); +! you may not use this file except in compliance with the License. +! You may obtain a copy of the License at +! +! http://www.apache.org/licenses/LICENSE-2.0 +! +! Unless required by applicable law or agreed to in writing, software +! distributed under the License is distributed on an "AS IS" BASIS, +! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +! See the License for the specific language governing permissions and +! limitations under the License. +!< + +!> Computes the sum of the absolute values of the real and imaginary components of a double-precision complex floating-point vector. +! +! ## Notes +! +! * Modified version of reference BLAS level1 routine (version 3.8.0). Updated to "free form" Fortran 95. +! +! ## Authors +! +! * Edward Anderson, Lockheed Martin +! * Weslley Pereira, University of Colorado Denver, USA +! +! ## History +! +! * Original version written on August 2016. +! +! ## 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 {integer} N - number of indexed elements +! @param {Array} x - array +! @param {integer} strideX - `x` stride length +! @returns {double precision} result +!< +double precision function dzasum( N, x, strideX ) + implicit none + ! .. + ! Scalar arguments: + integer :: N, strideX + ! .. + ! Array arguments: + complex(kind=kind(0.0d0)) :: x( * ) + ! .. + ! Local scalars: + integer :: i, nix + double precision :: stemp + ! .. + ! Intrinsic functions: + intrinsic abs, aimag, dble + ! .. + dzasum = 0.0d0 + stemp = 0.0d0 + ! .. + if ( N <= 0 .or. strideX <= 0 ) return + if( strideX == 1 ) then + do i = 1, N + stemp = stemp + ( abs( dble( x( i ) ) ) + abs( aimag( x( i ) ) ) ) + end do + else + nix = N*strideX + do i = 1, nix, strideX + stemp = stemp + ( abs( dble( x( i ) ) ) + abs( aimag( x( i ) ) ) ) + end do + end if + dzasum = stemp + return +end function dzasum diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/src/dzasum_cblas.c b/lib/node_modules/@stdlib/blas/base/dzasum/src/dzasum_cblas.c new file mode 100644 index 000000000000..1724aab524c9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/src/dzasum_cblas.c @@ -0,0 +1,57 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/blas/base/dzasum.h" +#include "stdlib/blas/base/dzasum_cblas.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/complex/float64/ctor.h" +#include "stdlib/strided/base/min_view_buffer_index.h" + +/** +* Computes the sum of the absolute values of the real and imaginary components of a double-precision complex floating-point vector. +* +* @param N number of indexed elements +* @param X input array +* @param strideX X stride length +*/ +double API_SUFFIX(c_dzasum)( const CBLAS_INT N, const void *X, const CBLAS_INT strideX ) { + CBLAS_INT sx = strideX; + if( sx < 0 ) { + X = (const void *)( (const double *)X + ( (N-1) * (-sx) * 2 ) ); + sx = -sx; + } + return API_SUFFIX(cblas_dzasum)( N, X, sx ); +} + +/** +* Computes the sum of the absolute values of the real and imaginary components of a double-precision complex floating-point vector using alternative indexing semantics. +* +* @param N number of indexed elements +* @param X input array +* @param strideX X stride length +* @param offsetX starting index for X +*/ +double API_SUFFIX(c_dzasum_ndarray)( const CBLAS_INT N, const void *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) { + const stdlib_complex128_t *x = (const stdlib_complex128_t *)X; + CBLAS_INT sx = strideX; + if( sx < 0 ) { + sx = -sx; + } + x += stdlib_strided_min_view_buffer_index( N, strideX, offsetX ); + return API_SUFFIX(cblas_dzasum)( N, (void *)x, sx ); +} diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/src/dzasum_f.c b/lib/node_modules/@stdlib/blas/base/dzasum/src/dzasum_f.c new file mode 100644 index 000000000000..669d8dc870d4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/src/dzasum_f.c @@ -0,0 +1,65 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/blas/base/dzasum.h" +#include "stdlib/blas/base/dzasum_fortran.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/complex/float64/ctor.h" +#include "stdlib/strided/base/min_view_buffer_index.h" + +/** +* Computes the sum of the absolute values of the real and imaginary components of a double-precision complex floating-point vector. +* +* @param N number of indexed elements +* @param X input array +* @param strideX X stride length +* @return result +*/ +double API_SUFFIX(c_dzasum)( const CBLAS_INT N, const void *X, const CBLAS_INT strideX ) { + CBLAS_INT sx; + double out; + + sx = strideX; + if ( sx < 0 ) { + sx = -sx; + } + dzasumsub( &N, X, &sx, &out ); + return out; +} + +/** +* Computes the sum of the absolute values of the real and imaginary components of a double-precision complex floating-point vector using alternative indexing semantics. +* +* @param N number of indexed elements +* @param X input array +* @param strideX X stride length +* @param offsetX starting index for X +* @return result +*/ +double API_SUFFIX(c_dzasum_ndarray)( const CBLAS_INT N, const void *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) { + const stdlib_complex128_t *x = (const stdlib_complex128_t *)X; + CBLAS_INT sx = strideX; + double out; + + x += stdlib_strided_min_view_buffer_index( N, strideX, offsetX ); + if ( sx < 0 ) { + sx = -sx; + } + dzasumsub( &N, (void *)x, &sx, &out ); + return out; +} diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/src/dzasum_ndarray.c b/lib/node_modules/@stdlib/blas/base/dzasum/src/dzasum_ndarray.c new file mode 100644 index 000000000000..9166e3521a80 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/src/dzasum_ndarray.c @@ -0,0 +1,49 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/blas/base/dzasum.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/math/base/special/abs.h" + +/** +* Computes the sum of the absolute values of the real and imaginary components of a double-precision complex floating-point vector using alternative indexing semantics. +* +* @param N number of indexed elements +* @param X input array +* @param strideX X stride length +* @param offsetX starting index for X +*/ +double API_SUFFIX(c_dzasum_ndarray)( const CBLAS_INT N, const void *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) { + const double *x = (const double *)X; + double stemp; + CBLAS_INT sx; + CBLAS_INT ix; + CBLAS_INT i; + + if ( N <= 0 ) { + return 0.0; + } + stemp = 0.0; + sx = strideX * 2; + ix = offsetX * 2; + for( i = 0; i < N; i++ ) { + stemp += stdlib_base_abs( x[ix] ) + stdlib_base_abs( x[ix+1] ); + ix += sx; + } + return stemp; +} diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/src/dzasumsub.f b/lib/node_modules/@stdlib/blas/base/dzasum/src/dzasumsub.f new file mode 100644 index 000000000000..9a129ba549dc --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/src/dzasumsub.f @@ -0,0 +1,46 @@ +!> +! @license Apache-2.0 +! +! Copyright (c) 2026 The Stdlib Authors. +! +! Licensed under the Apache License, Version 2.0 (the "License"); +! you may not use this file except in compliance with the License. +! You may obtain a copy of the License at +! +! http://www.apache.org/licenses/LICENSE-2.0 +! +! Unless required by applicable law or agreed to in writing, software +! distributed under the License is distributed on an "AS IS" BASIS, +! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +! See the License for the specific language governing permissions and +! limitations under the License. +!< + +!> Wraps `dzasum` as a subroutine. +! +! @param {integer} N - number of indexed elements +! @param {Array} x - input array +! @param {integer} strideX - `x` stride length +! @param {double precision} out - output variable reference +!< +subroutine dzasumsub( N, x, strideX, out ) + implicit none + ! .. + ! External functions: + interface + double precision function dzasum( N, x, strideX ) + complex(kind=kind(0.0d0)) :: x(*) + integer :: strideX, N + end function dzasum + end interface + ! .. + ! Scalar arguments: + integer :: strideX, N + double precision :: out + ! .. + ! Array arguments: + complex(kind=kind(0.0d0)) :: x(*) + ! .. + out = dzasum( N, x, strideX ) + return +end subroutine dzasumsub diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/test.f b/lib/node_modules/@stdlib/blas/base/dzasum/test.f new file mode 100644 index 000000000000..e2dd83c8c215 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/test.f @@ -0,0 +1,12 @@ + double precision function dzasum( N, x, strideX ) + implicit none + integer :: N, strideX + complex(kind=kind(0.0d0)) :: x( * ) + integer :: i + double precision :: stemp + intrinsic abs, dble, aimag + stemp = 0.0d0 + stemp = stemp + abs( dble( x( 1 ) ) ) + abs( aimag( x( 1 ) ) ) + dzasum = stemp + return + end function dzasum diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/test/test.dzasum.js b/lib/node_modules/@stdlib/blas/base/dzasum/test/test.dzasum.js new file mode 100644 index 000000000000..e487766c861c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/test/test.dzasum.js @@ -0,0 +1,143 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var dzasum = require( './../lib/dzasum.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dzasum, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 3', function test( t ) { + t.strictEqual( dzasum.length, 3, 'returns expected value' ); + t.end(); +}); + +tape( 'the function computes the sum of absolute values', function test( t ) { + var x; + var y; + + x = new Complex128Array([ + 1.0, + -2.0, + 3.0, + -4.0, + 5.0, + -6.0 + ]); + y = dzasum( x.length, x, 1 ); + + t.strictEqual( y, 21.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `x` stride', function test( t ) { + var x; + var y; + var N; + + x = new Complex128Array([ + 1.0, // 1 + -2.0, // 1 + 3.0, + -4.0, + 5.0, // 2 + -6.0 // 2 + ]); + N = 2; + + y = dzasum( N, x, 2 ); + + t.strictEqual( y, 14.0, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `0`', function test( t ) { + var x; + var y; + + x = new Complex128Array([ + 1.0, // 1 + -2.0, // 1 + 3.0, + -4.0, + 5.0, // 2 + -6.0 // 2 + ]); + y = dzasum( 0, x, 1 ); + + t.strictEqual( y, 0.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride', function test( t ) { + var x; + var y; + var N; + + x = new Complex128Array([ + 1.0, // 2 + -2.0, // 2 + 3.0, + -4.0, + 5.0, // 1 + -6.0 // 1 + ]); + N = 2; + + y = dzasum( N, x, -2 ); + + t.strictEqual( y, 14.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var x0; + var x1; + var y; + var N; + + // Initial array... + x0 = new Complex128Array([ + 1.0, + -2.0, + 3.0, // 1 + -4.0, // 1 + 5.0, // 2 + -6.0 // 2 + ]); + + // Create an offset view... + x1 = new Complex128Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // begin at 2nd element + + N = 2; + y = dzasum( N, x1, 1 ); + + t.strictEqual( y, 18.0, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/test/test.dzasum.native.js b/lib/node_modules/@stdlib/blas/base/dzasum/test/test.dzasum.native.js new file mode 100644 index 000000000000..de47e07ab989 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/test/test.dzasum.native.js @@ -0,0 +1,152 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var dzasum = tryRequire( resolve( __dirname, './../lib/dzasum.native.js' ) ); +var opts = { + 'skip': ( dzasum instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dzasum, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 3', opts, function test( t ) { + t.strictEqual( dzasum.length, 3, 'returns expected value' ); + t.end(); +}); + +tape( 'the function computes the sum of absolute values', opts, function test( t ) { + var x; + var y; + + x = new Complex128Array([ + 1.0, + -2.0, + 3.0, + -4.0, + 5.0, + -6.0 + ]); + y = dzasum( x.length, x, 1 ); + + t.strictEqual( y, 21.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var x; + var y; + var N; + + x = new Complex128Array([ + 1.0, // 1 + -2.0, // 1 + 3.0, + -4.0, + 5.0, // 2 + -6.0 // 2 + ]); + N = 2; + + y = dzasum( N, x, 2 ); + + t.strictEqual( y, 14.0, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `0`', opts, function test( t ) { + var x; + var y; + + x = new Complex128Array([ + 1.0, // 1 + -2.0, // 1 + 3.0, + -4.0, + 5.0, // 2 + -6.0 // 2 + ]); + y = dzasum( 0, x, 1 ); + + t.strictEqual( y, 0.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride', opts, function test( t ) { + var x; + var y; + var N; + + x = new Complex128Array([ + 1.0, // 2 + -2.0, // 2 + 3.0, + -4.0, + 5.0, // 1 + -6.0 // 1 + ]); + N = 2; + + y = dzasum( N, x, -2 ); + + t.strictEqual( y, 14.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports view offsets', opts, function test( t ) { + var x0; + var x1; + var y; + var N; + + // Initial array... + x0 = new Complex128Array([ + 1.0, + -2.0, + 3.0, // 1 + -4.0, // 1 + 5.0, // 2 + -6.0 // 2 + ]); + + // Create an offset view... + x1 = new Complex128Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // begin at 2nd element + + N = 2; + y = dzasum( N, x1, 1 ); + + t.strictEqual( y, 18.0, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/test/test.js b/lib/node_modules/@stdlib/blas/base/dzasum/test/test.js new file mode 100644 index 000000000000..85e3d70d6dc5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/test/test.js @@ -0,0 +1,82 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var proxyquire = require( 'proxyquire' ); +var isBrowser = require( '@stdlib/assert/is-browser' ); +var dzasum = require( './../lib' ); + + +// VARIABLES // + +var opts = { + 'skip': isBrowser +}; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dzasum, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the main export is a method providing an ndarray interface', function test( t ) { + t.strictEqual( typeof dzasum.ndarray, 'function', 'method is a function' ); + t.end(); +}); + +tape( 'if a native implementation is available, the main export is the native implementation', opts, function test( t ) { + var dzasum = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dzasum, mock, 'returns expected value' ); + t.end(); + + function tryRequire() { + return mock; + } + + function mock() { + // Mock... + } +}); + +tape( 'if a native implementation is not available, the main export is a JavaScript implementation', opts, function test( t ) { + var dzasum; + var main; + + main = require( './../lib/dzasum.js' ); + + dzasum = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dzasum, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/dzasum/test/test.ndarray.js new file mode 100644 index 000000000000..11976d4c4fca --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/test/test.ndarray.js @@ -0,0 +1,173 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var dzasum = require( './../lib/ndarray.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dzasum, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 4', function test( t ) { + t.strictEqual( dzasum.length, 4, 'returns expected value' ); + t.end(); +}); + +tape( 'the function computes the sum of absolute values', function test( t ) { + var x; + var y; + + x = new Complex128Array([ + 1.0, + -2.0, + 3.0, + -4.0, + 5.0, + -6.0 + ]); + y = dzasum( x.length, x, 1, 0 ); + + t.strictEqual( y, 21.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `x` stride', function test( t ) { + var x; + var y; + var N; + + x = new Complex128Array([ + 1.0, // 1 + -2.0, // 1 + 3.0, + -4.0, + 5.0, // 2 + -6.0 // 2 + ]); + N = 2; + + y = dzasum( N, x, 2, 0 ); + + t.strictEqual( y, 14.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `x` offset', function test( t ) { + var x; + var y; + var N; + + x = new Complex128Array([ + 1.0, + -2.0, + 3.0, // 1 + -4.0, // 1 + 5.0, // 2 + -6.0 // 2 + ]); + N = 2; + + y = dzasum( N, x, 1, 1 ); + + t.strictEqual( y, 18.0, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `0`', function test( t ) { + var x; + var y; + + x = new Complex128Array([ + 1.0, + -2.0, + 3.0, + -4.0, + 5.0, + -6.0 + ]); + + y = dzasum( -1, x, 1, 0 ); + t.strictEqual( y, 0.0, 'returns expected value' ); + + y = dzasum( 0, x, 1, 0 ); + t.strictEqual( y, 0.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a negative stride', function test( t ) { + var x; + var y; + var N; + + x = new Complex128Array([ + 1.0, // 2 + -2.0, // 2 + 3.0, + -4.0, + 5.0, // 1 + -6.0 // 1 + ]); + N = 2; + + y = dzasum( N, x, -2, x.length-1 ); + + t.strictEqual( y, 14.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying complex access patterns', function test( t ) { + var x; + var y; + var N; + + x = new Complex128Array([ + 0.3, // 4 + 0.1, // 4 + 5.0, + 8.0, + 0.5, // 3 + 0.0, // 3 + 6.0, + 9.0, + 0.0, // 2 + 0.5, // 2 + 8.0, + 3.0, + 0.0, // 1 + 0.2, // 1 + 9.0, + 4.0 + ]); + N = 4; + + y = dzasum( N, x, -2, 6 ); + + t.strictEqual( y, 1.6, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dzasum/test/test.ndarray.native.js new file mode 100644 index 000000000000..cef1cd30f78f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/test/test.ndarray.native.js @@ -0,0 +1,182 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var dzasum = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( dzasum instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dzasum, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 4', opts, function test( t ) { + t.strictEqual( dzasum.length, 4, 'returns expected value' ); + t.end(); +}); + +tape( 'the function computes the sum of absolute values', opts, function test( t ) { + var x; + var y; + + x = new Complex128Array([ + 1.0, + -2.0, + 3.0, + -4.0, + 5.0, + -6.0 + ]); + y = dzasum( x.length, x, 1, 0 ); + + t.strictEqual( y, 21.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var x; + var y; + var N; + + x = new Complex128Array([ + 1.0, // 1 + -2.0, // 1 + 3.0, + -4.0, + 5.0, // 2 + -6.0 // 2 + ]); + N = 2; + + y = dzasum( N, x, 2, 0 ); + + t.strictEqual( y, 14.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `x` offset', opts, function test( t ) { + var x; + var y; + var N; + + x = new Complex128Array([ + 1.0, + -2.0, + 3.0, // 1 + -4.0, // 1 + 5.0, // 2 + -6.0 // 2 + ]); + N = 2; + + y = dzasum( N, x, 1, 1 ); + + t.strictEqual( y, 18.0, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `0`', opts, function test( t ) { + var x; + var y; + + x = new Complex128Array([ + 1.0, + -2.0, + 3.0, + -4.0, + 5.0, + -6.0 + ]); + + y = dzasum( -1, x, 1, 0 ); + t.strictEqual( y, 0.0, 'returns expected value' ); + + y = dzasum( 0, x, 1, 0 ); + t.strictEqual( y, 0.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a negative stride', opts, function test( t ) { + var x; + var y; + var N; + + x = new Complex128Array([ + 1.0, // 2 + -2.0, // 2 + 3.0, + -4.0, + 5.0, // 1 + -6.0 // 1 + ]); + N = 2; + + y = dzasum( N, x, -2, x.length-1 ); + + t.strictEqual( y, 14.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying complex access patterns', opts, function test( t ) { + var x; + var y; + var N; + + x = new Complex128Array([ + 0.3, // 4 + 0.1, // 4 + 5.0, + 8.0, + 0.5, // 3 + 0.0, // 3 + 6.0, + 9.0, + 0.0, // 2 + 0.5, // 2 + 8.0, + 3.0, + 0.0, // 1 + 0.2, // 1 + 9.0, + 4.0 + ]); + N = 4; + + y = dzasum( N, x, -2, 6 ); + + t.strictEqual( y, 1.5999999999999999, 'returns expected value' ); + t.end(); +});