From f07b52e21a6881fb75c50891c9a8a1dc301fa64f Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Wed, 9 Jul 2025 10:26:08 +0530 Subject: [PATCH 1/4] chore: revert other file changes --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../stats/base/stdevwd/test/test.main.js | 360 ------------------ 1 file changed, 360 deletions(-) delete mode 100644 lib/node_modules/@stdlib/stats/base/stdevwd/test/test.main.js diff --git a/lib/node_modules/@stdlib/stats/base/stdevwd/test/test.main.js b/lib/node_modules/@stdlib/stats/base/stdevwd/test/test.main.js deleted file mode 100644 index f54420c59298..000000000000 --- a/lib/node_modules/@stdlib/stats/base/stdevwd/test/test.main.js +++ /dev/null @@ -1,360 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var sqrt = require( '@stdlib/math/base/special/sqrt' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var Float64Array = require( '@stdlib/array/float64' ); -var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -var stdevwd = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof stdevwd, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function has an arity of 4', function test( t ) { - t.strictEqual( stdevwd.length, 4, 'has expected arity' ); - t.end(); -}); - -tape( 'the function calculates the population standard deviation of a strided array', function test( t ) { - var x; - var v; - - x = [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ]; - v = stdevwd( x.length, 0, x, 1 ); - t.strictEqual( v, sqrt( 53.5/x.length ), 'returns expected value' ); - - x = [ -4.0, -4.0 ]; - v = stdevwd( x.length, 0, x, 1 ); - t.strictEqual( v, 0.0, 'returns expected value' ); - - x = [ NaN, 4.0 ]; - v = stdevwd( x.length, 0, x, 1 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function calculates the population standard deviation of a strided array (accessors)', function test( t ) { - var x; - var v; - - x = [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ]; - v = stdevwd( x.length, 0, toAccessorArray( x ), 1 ); - t.strictEqual( v, sqrt( 53.5/x.length ), 'returns expected value' ); - - x = [ -4.0, -4.0 ]; - v = stdevwd( x.length, 0, toAccessorArray( x ), 1 ); - t.strictEqual( v, 0.0, 'returns expected value' ); - - x = [ NaN, 4.0 ]; - v = stdevwd( x.length, 0, toAccessorArray( x ), 1 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function calculates the sample standard deviation of a strided array', function test( t ) { - var x; - var v; - - x = [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ]; - v = stdevwd( x.length, 1, x, 1 ); - t.strictEqual( v, sqrt( 53.5/(x.length-1) ), 'returns expected value' ); - - x = [ -4.0, -4.0 ]; - v = stdevwd( x.length, 1, x, 1 ); - t.strictEqual( v, 0.0, 'returns expected value' ); - - x = [ NaN, 4.0 ]; - v = stdevwd( x.length, 1, x, 1 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function calculates the sample standard deviation of a strided array (accessors)', function test( t ) { - var x; - var v; - - x = [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ]; - v = stdevwd( x.length, 1, toAccessorArray( x ), 1 ); - t.strictEqual( v, sqrt( 53.5/(x.length-1) ), 'returns expected value' ); - - x = [ -4.0, -4.0 ]; - v = stdevwd( x.length, 1, toAccessorArray( x ), 1 ); - t.strictEqual( v, 0.0, 'returns expected value' ); - - x = [ NaN, 4.0 ]; - v = stdevwd( x.length, 1, toAccessorArray( x ), 1 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN`', function test( t ) { - var x; - var v; - - x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; - - v = stdevwd( 0, 1, x, 1 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - v = stdevwd( -1, 1, x, 1 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN` (accessors)', function test( t ) { - var x; - var v; - - x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; - - v = stdevwd( 0, 1, toAccessorArray( x ), 1 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - v = stdevwd( -1, 1, toAccessorArray( x ), 1 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if provided an `N` parameter equal to `1`, the function returns a population standard deviation of `0`', function test( t ) { - var x; - var v; - - x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; - - v = stdevwd( 1, 0, x, 1 ); - t.strictEqual( v, 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'if provided an `N` parameter equal to `1`, the function returns a population standard deviation of `0` (accessors)', function test( t ) { - var x; - var v; - - x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; - - v = stdevwd( 1, 0, toAccessorArray( x ), 1 ); - t.strictEqual( v, 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'if provided a `correction` parameter yielding `N-correction` less than or equal to `0`, the function returns `NaN`', function test( t ) { - var x; - var v; - - x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; - - v = stdevwd( x.length, x.length, x, 1 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - v = stdevwd( x.length, x.length+1, x, 1 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if provided a `correction` parameter yielding `N-correction` less than or equal to `0`, the function returns `NaN` (accessors)', function test( t ) { - var x; - var v; - - x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; - - v = stdevwd( x.length, x.length, toAccessorArray( x ), 1 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - v = stdevwd( x.length, x.length+1, toAccessorArray( x ), 1 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports a `stride` parameter', function test( t ) { - var x; - var v; - - x = [ - 1.0, // 0 - 2.0, - 2.0, // 1 - -7.0, - -2.0, // 2 - 3.0, - 4.0, // 3 - 2.0 - ]; - - v = stdevwd( 4, 1, x, 2 ); - - t.strictEqual( v, 2.5, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports a `stride` parameter (accessors)', function test( t ) { - var x; - var v; - - x = [ - 1.0, // 0 - 2.0, - 2.0, // 1 - -7.0, - -2.0, // 2 - 3.0, - 4.0, // 3 - 2.0 - ]; - - v = stdevwd( 4, 1, toAccessorArray( x ), 2 ); - - t.strictEqual( v, 2.5, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports a negative `stride` parameter', function test( t ) { - var x; - var v; - - x = [ - 1.0, // 3 - 2.0, - 2.0, // 2 - -7.0, - -2.0, // 1 - 3.0, - 4.0, // 0 - 2.0 - ]; - - v = stdevwd( 4, 1, x, -2 ); - - t.strictEqual( v, 2.5, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports a negative `stride` parameter (accessors)', function test( t ) { - var x; - var v; - - x = [ - 1.0, // 3 - 2.0, - 2.0, // 2 - -7.0, - -2.0, // 1 - 3.0, - 4.0, // 0 - 2.0 - ]; - - v = stdevwd( 4, 1, toAccessorArray( x ), -2 ); - - t.strictEqual( v, 2.5, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`', function test( t ) { - var x; - var v; - - x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; - - v = stdevwd( x.length, 1, x, 0 ); - t.strictEqual( v, 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'if provided a `stride` parameter equal to `0`, the function returns `0` (accessors)', function test( t ) { - var x; - var v; - - x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; - - v = stdevwd( x.length, 1, toAccessorArray( x ), 0 ); - t.strictEqual( v, 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports view offsets', function test( t ) { - var x0; - var x1; - var v; - - x0 = new Float64Array([ - 2.0, - 1.0, // 0 - 2.0, - -2.0, // 1 - -2.0, - 2.0, // 2 - 3.0, - 4.0, // 3 - 6.0 - ]); - - x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element - - v = stdevwd( 4, 1, x1, 2 ); - t.strictEqual( v, 2.5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports view offsets (accessors)', function test( t ) { - var x0; - var x1; - var v; - - x0 = new Float64Array([ - 2.0, - 1.0, // 0 - 2.0, - -2.0, // 1 - -2.0, - 2.0, // 2 - 3.0, - 4.0, // 3 - 6.0 - ]); - - x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element - - v = stdevwd( 4, 1, toAccessorArray( x1 ), 2 ); - t.strictEqual( v, 2.5, 'returns expected value' ); - - t.end(); -}); From 7cfc153586b8f9e0c79a3a9a3638884bc6d657dd Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Wed, 9 Jul 2025 10:41:11 +0530 Subject: [PATCH 2/4] feat: add blas/base/zaxpy --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: passed - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: missing_dependencies - task: lint_c_benchmarks status: missing_dependencies - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/blas/base/zaxpy/README.md | 161 +++- .../blas/base/zaxpy/benchmark/c/Makefile | 146 ++++ .../base/zaxpy/benchmark/c/benchmark.length.c | 204 +++++ .../@stdlib/blas/base/zaxpy/binding.gyp | 265 +++++++ .../blas/base/zaxpy/examples/c/Makefile | 147 ++++ .../blas/base/zaxpy/examples/c/example.c | 54 ++ .../@stdlib/blas/base/zaxpy/include.gypi | 265 +++++++ .../zaxpy/include/stdlib/blas/base/zaxpy.h | 49 ++ .../include/stdlib/blas/base/zaxpy_cblas.h | 44 ++ .../@stdlib/blas/base/zaxpy/lib/native.js | 35 + .../blas/base/zaxpy/lib/ndarray.native.js | 67 ++ .../blas/base/zaxpy/lib/zaxpy.native.js | 65 ++ .../@stdlib/blas/base/zaxpy/manifest.json | 495 +++++++++++++ .../@stdlib/blas/base/zaxpy/package.json | 4 + .../@stdlib/blas/base/zaxpy/src/Makefile | 70 ++ .../@stdlib/blas/base/zaxpy/src/addon.c | 68 ++ .../@stdlib/blas/base/zaxpy/src/zaxpy.c | 38 + .../@stdlib/blas/base/zaxpy/src/zaxpy_cblas.c | 36 + .../blas/base/zaxpy/src/zaxpy_ndarray.c | 60 ++ .../base/zaxpy/test/test.ndarray.native.js | 696 ++++++++++++++++++ .../blas/base/zaxpy/test/test.zaxpy.native.js | 611 +++++++++++++++ 21 files changed, 3577 insertions(+), 3 deletions(-) create mode 100644 lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/c/benchmark.length.c create mode 100644 lib/node_modules/@stdlib/blas/base/zaxpy/binding.gyp create mode 100644 lib/node_modules/@stdlib/blas/base/zaxpy/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/zaxpy/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/blas/base/zaxpy/include.gypi create mode 100644 lib/node_modules/@stdlib/blas/base/zaxpy/include/stdlib/blas/base/zaxpy.h create mode 100644 lib/node_modules/@stdlib/blas/base/zaxpy/include/stdlib/blas/base/zaxpy_cblas.h create mode 100644 lib/node_modules/@stdlib/blas/base/zaxpy/lib/native.js create mode 100644 lib/node_modules/@stdlib/blas/base/zaxpy/lib/ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/zaxpy/lib/zaxpy.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/zaxpy/manifest.json create mode 100644 lib/node_modules/@stdlib/blas/base/zaxpy/src/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/zaxpy/src/addon.c create mode 100644 lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy.c create mode 100644 lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy_cblas.c create mode 100644 lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy_ndarray.c create mode 100644 lib/node_modules/@stdlib/blas/base/zaxpy/test/test.ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/zaxpy/test/test.zaxpy.native.js diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/README.md b/lib/node_modules/@stdlib/blas/base/zaxpy/README.md index 12e11b4a6dd3..220a72046d2f 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/README.md +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/README.md @@ -51,9 +51,9 @@ The function has the following parameters: - **N**: number of indexed elements. - **alpha**: scalar [`Complex128`][@stdlib/complex/float64/ctor] constant. - **x**: first input [`Complex128Array`][@stdlib/array/complex128]. -- **strideX**: index increment for `x`. +- **strideX**: stride length for `x`. - **y**: second input [`Complex128Array`][@stdlib/array/complex128]. -- **strideY**: index increment for `y`. +- **strideY**: stride length for `y`. The `N` and stride parameters determine how values from `x` are scaled by `alpha` and added to `y`. For example, to scale every other value in `x` by `alpha` and add the result to every other value of `y`, @@ -137,6 +137,7 @@ zaxpy.ndarray( 3, alpha, x, 1, 1, y, 1, 1 ); ## Notes - If `N <= 0`, both functions return `y` unchanged. +- If `alpha === 0`, both functions return `y` unchanged. - `zaxpy()` corresponds to the [BLAS][blas] level 1 function [`zaxpy`][zaxpy]. @@ -171,6 +172,14 @@ var alpha = new Complex128( 2.0, 2.0 ); // Scale values from `x` by `alpha` and add the result to `y`: zaxpy( x.length, alpha, x, 1, y, 1 ); +// Print the results: +logEach( '(%s)*(%s) + (%s) = %s', alpha, x, yc, y ); + +yc = zcopy( y.length, y, 1, zeros( y.length, 'complex128' ), 1 ); + +// Scale values from `x` by `alpha` and add the result to `y` using alternative indexing semantics: +zaxpy.ndarray( x.length, alpha, x, 1, 0, y, 1, 0 ); + // Print the results: logEach( '(%s)*(%s) + (%s) = %s', alpha, x, yc, y ); ``` @@ -179,6 +188,152 @@ logEach( '(%s)*(%s) + (%s) = %s', alpha, x, yc, y ); + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/blas/base/zaxpy.h" +``` + +#### c_zaxpy( N, alpha, \*X, strideX, \*Y, strideY ) + +Scales values from `X` by `alpha` and adds the result to `Y`. + +```c +#include "stdlib/complex/float32/ctor.h" + +float x[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; +float y[] = { -1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0, -8.0 }; +const stdlib_complex128_t alpha = stdlib_complex128( 2.0, 2.0 ); + +c_zaxpy( 4, alpha, (void *)x, 1, (void *)y, 1 ); +``` + +The function accepts the following arguments: + +- **N**: `[in] CBLAS_INT` number of indexed elements. +- **alpha**: `[in] stdlib_complex128_t` scalar constant. +- **X**: `[in] void*` input array. +- **strideX**: `[in] CBLAS_INT` stride length for `X`. +- **Y**: `[inout] void*` output array. +- **strideY**: `[in] CBLAS_INT` stride length for `Y`. + +```c +void c_zaxpy( const CBLAS_INT N, const stdlib_complex128_t alpha, const void *x, const CBLAS_INT strideX, void *y, const CBLAS_INT strideY ); +``` + +#### c_zaxpy_ndarray( N, alpha, \*X, strideX, offsetX, \*Y, strideY, offsetY ) + +Scales values from `X` by `alpha` and adds the result to `Y` using alternative indexing semantics. + +```c +#include "stdlib/complex/float32/ctor.h" + +float x[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; +float y[] = { -1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0, -8.0 }; +const stdlib_complex128_t alpha = stdlib_complex128( 2.0, 2.0 ); + +c_zaxpy_ndarray( 4, alpha, (void *)x, 1, 0, (void *)y, 1, 0 ); +``` + +The function accepts the following arguments: + +- **N**: `[in] CBLAS_INT` number of indexed elements. +- **alpha**: `[in] stdlib_complex128_t` scalar constant. +- **X**: `[in] void*` input array. +- **strideX**: `[in] CBLAS_INT` stride length for `X`. +- **offsetX**: `[in] CBLAS_INT` starting index for `X`. +- **Y**: `[inout] void*` output array. +- **strideY**: `[in] CBLAS_INT` stride length for `Y`. +- **offsetY**: `[in] CBLAS_INT` starting index for `Y`. + +```c +void c_zaxpy_ndarray( const CBLAS_INT N, const stdlib_complex128_t alpha, const void *x, const CBLAS_INT strideX, const CBLAS_INT offsetX, void *y, const CBLAS_INT strideY, const CBLAS_INT offsetY ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/blas/base/zaxpy.h" +#include "stdlib/complex/float32/ctor.h" +#include + +int main( void ) { + // Create strided arrays: + double x[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; + double y[] = { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 }; + + // Create a complex scalar: + const stdlib_complex128_t alpha = stdlib_complex128( 2.0, 2.0 ); + + // Specify the number of elements: + const int N = 4; + + // Specify stride lengths: + const int strideX = 1; + const int strideY = 1; + + // Scale values from `x` by `alpha` and add the result to `y`: + c_zaxpy( N, alpha, (void *)x, strideX, (void *)y, strideY ); + + // Print the result: + for ( int i = 0; i < N; i++ ) { + printf( "zaxpy[ %i ] = %lf + %lfj\n", i, y[ i * 2 ], y[ ( i * 2 ) + 1 ] ); + } + + // Scale values from `x` by `alpha` and add the result to `y` using alternative indexing semantics: + c_zaxpy_ndarray( N, alpha, (void *)x, strideX, 0, (void *)y, strideY, 0 ); + + // Print the result: + for ( int i = 0; i < N; i++ ) { + printf( "zaxpy[ %i ] = %lf + %lfj\n", i, y[ i * 2 ], y[ ( i * 2 ) + 1 ] ); + } +} +``` + +
+ + + +
+ + +