From c1b09181190149466c3772bc684b75c37fb89fcb Mon Sep 17 00:00:00 2001 From: Gururaj Gurram Date: Wed, 25 Dec 2024 14:18:19 +0530 Subject: [PATCH 01/34] feat: add C implementation for blas/base/zaxpy --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- .../@stdlib/blas/base/zaxpy/README.md | 109 +++ .../base/zaxpy/benchmark/benchmark.native.js | 120 ++++ .../benchmark/benchmark.ndarray.native.js | 119 ++++ .../blas/base/zaxpy/benchmark/c/Makefile | 146 ++++ .../base/zaxpy/benchmark/c/benchmark.length.c | 156 +++++ .../base/zaxpy/benchmark/fortran/Makefile | 141 ++++ .../benchmark/fortran/benchmark.length.f | 223 ++++++ .../@stdlib/blas/base/zaxpy/binding.gyp | 265 ++++++++ .../blas/base/zaxpy/examples/c/Makefile | 146 ++++ .../blas/base/zaxpy/examples/c/example.c | 45 ++ .../@stdlib/blas/base/zaxpy/include.gypi | 70 ++ .../zaxpy/include/stdlib/blas/base/zaxpy.h | 44 ++ .../include/stdlib/blas/base/zaxpy_cblas.h | 44 ++ .../include/stdlib/blas/base/zaxpy_fortran.h | 43 ++ .../@stdlib/blas/base/zaxpy/lib/native.js | 35 + .../blas/base/zaxpy/lib/ndarray.native.js | 76 +++ .../blas/base/zaxpy/lib/zaxpy.native.js | 71 ++ .../@stdlib/blas/base/zaxpy/manifest.json | 452 +++++++++++++ .../@stdlib/blas/base/zaxpy/package.json | 4 + .../@stdlib/blas/base/zaxpy/src/Makefile | 70 ++ .../@stdlib/blas/base/zaxpy/src/addon.c | 47 ++ .../@stdlib/blas/base/zaxpy/src/zaxpy.c | 53 ++ .../@stdlib/blas/base/zaxpy/src/zaxpy.f | 95 +++ .../@stdlib/blas/base/zaxpy/src/zaxpy_cblas.c | 36 + .../@stdlib/blas/base/zaxpy/src/zaxpy_f.c | 36 + .../base/zaxpy/test/test.ndarray.native.js | 632 ++++++++++++++++++ .../blas/base/zaxpy/test/test.zaxpy.native.js | 547 +++++++++++++++ 27 files changed, 3825 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/benchmark.ndarray.native.js 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/benchmark/fortran/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/fortran/benchmark.length.f 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/include/stdlib/blas/base/zaxpy_fortran.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.f 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_f.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 a1dafcfe789c..b91bb831b153 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/README.md +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/README.md @@ -229,6 +229,115 @@ logEach( '(%s)*(%s) + (%s) = %s', za, zx, zyc, zy ); + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/blas/base/zaxpy.h" +``` + +#### c_zaxpy( N, za, \*ZX, strideX, \*ZY, strideY ) + +Scales values from `ZX` by `za` and adds the result to `ZY`. + +```c +#include "stdlib/complex/float64/ctor.h" + +double zx[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 }; +double zy[] = { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 }; +const stdlib_complex128_t za = stdlib_complex128( 2.0, 2.0 ); + +c_zaxpy( 3, za, (void *)zx, 1, (void *)zy, 1 ); +``` + +The function accepts the following arguments: + +- **N**: `[in] CBLAS_INT` number of indexed elements. +- **za**: `[in] stdlib_complex128_t` scalar constant. +- **ZX**: `[in] void*` first input array. +- **strideX**: `[in] CBLAS_INT` index increment for `ZX`. +- **ZY**: `[inout] void*` second input array. +- **strideY**: `[in] CBLAS_INT` index increment for `ZY`. + +```c +void c_zaxpy( const CBLAS_INT N, const stdlib_complex128_t za, void *ZX, const CBLAS_INT strideX, void *ZY, const CBLAS_INT strideY ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/blas/base/zaxpy.h" +#include "stdlib/complex/float64/ctor.h" +#include + +int main( void ) { + // Create strided arrays: + double zx[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; + double zy[] = { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 }; + + // Create a complex scalar: + const stdlib_complex128_t za = 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; + + // Copy elements: + c_zaxpy( N, za, (void *)zx, strideX, (void *)zy, strideY ); + + // Print the result: + for ( int i = 0; i < N; i += 2 ) { + printf( "zaxpy[ %i ] = %f + %fj\n", i, zy[ i*2 ], zy[ (i*2)+1 ] ); + } +} +``` + +
+ + + +
+ + + @@ -186,7 +140,8 @@ var im = imag( z ); ## Notes -- If `N <= 0`, both functions return `zy` unchanged. +- 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]. @@ -212,17 +167,25 @@ function rand() { return new Complex128( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) ); } -var zx = filledarrayBy( 10, 'complex128', rand ); -var zy = filledarrayBy( 10, 'complex128', rand ); -var zyc = zcopy( zy.length, zy, 1, zeros( zy.length, 'complex128' ), 1 ); +var x = filledarrayBy( 10, 'complex128', rand ); +var y = filledarrayBy( 10, 'complex128', rand ); +var yc = zcopy( y.length, y, 1, zeros( y.length, 'complex128' ), 1 ); + +var alpha = new Complex128( 2.0, 2.0 ); -var za = 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 ); -// Scale values from `zx` by `za` and add the result to `zy`: -zaxpy( zx.length, za, zx, 1, zy, 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', za, zx, zyc, zy ); +logEach( '(%s)*(%s) + (%s) = %s', alpha, x, yc, y ); ``` @@ -252,34 +215,63 @@ logEach( '(%s)*(%s) + (%s) = %s', za, zx, zyc, zy ); ### Usage ```c -#include "stdlib/blas/base/zaxpy.h" +#include "stdlib/blas/base/caxpy.h" +``` + +#### c_caxpy( 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_caxpy( 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_caxpy( const CBLAS_INT N, const stdlib_complex128_t alpha, const void *x, const CBLAS_INT strideX, void *y, const CBLAS_INT strideY ); ``` -#### c_zaxpy( N, za, \*ZX, strideX, \*ZY, strideY ) +#### c_caxpy_ndarray( N, alpha, \*X, strideX, offsetX, \*Y, strideY, offsetY ) -Scales values from `ZX` by `za` and adds the result to `ZY`. +Scales values from `X` by `alpha` and adds the result to `Y` using alternative indexing semantics. ```c -#include "stdlib/complex/float64/ctor.h" +#include "stdlib/complex/float32/ctor.h" -double zx[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 }; -double zy[] = { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 }; -const stdlib_complex128_t za = stdlib_complex128( 2.0, 2.0 ); +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( 3, za, (void *)zx, 1, (void *)zy, 1 ); +c_caxpy_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. -- **za**: `[in] stdlib_complex128_t` scalar constant. -- **ZX**: `[in] void*` first input array. -- **strideX**: `[in] CBLAS_INT` index increment for `ZX`. -- **ZY**: `[inout] void*` second input array. -- **strideY**: `[in] CBLAS_INT` index increment for `ZY`. +- **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( const CBLAS_INT N, const stdlib_complex128_t za, void *ZX, const CBLAS_INT strideX, void *ZY, const CBLAS_INT strideY ); +void c_caxpy_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 ); ``` @@ -301,17 +293,17 @@ void c_zaxpy( const CBLAS_INT N, const stdlib_complex128_t za, void *ZX, const C ### Examples ```c -#include "stdlib/blas/base/zaxpy.h" -#include "stdlib/complex/float64/ctor.h" +#include "stdlib/blas/base/caxpy.h" +#include "stdlib/complex/float32/ctor.h" #include int main( void ) { // Create strided arrays: - double zx[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; - double zy[] = { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 }; + 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 za = stdlib_complex128( 2.0, 2.0 ); + const stdlib_complex128_t alpha = stdlib_complex128( 2.0, 2.0 ); // Specify the number of elements: const int N = 4; @@ -320,12 +312,20 @@ int main( void ) { const int strideX = 1; const int strideY = 1; - // Copy elements: - c_zaxpy( N, za, (void *)zx, strideX, (void *)zy, strideY ); + // 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 ] = %f + %fj\n", i, zy[ i*2 ], zy[ (i*2)+1 ] ); + printf( "zaxpy[ %i ] = %lf + %lfj\n", i, y[ i * 2 ], y[ ( i * 2 ) + 1 ] ); } } ``` @@ -352,7 +352,7 @@ int main( void ) { [blas]: http://www.netlib.org/blas -[zaxpy]: https://www.netlib.org/lapack/explore-html/d5/d4b/group__axpy_ga0b7bac1f4d42514074a48f14f5f9caa0.html#ga0b7bac1f4d42514074a48f14f5f9caa0 +[zaxpy]: https://www.netlib.org/lapack/explore-html/d5/d4b/group__axpy_gaf603daa00d5c723d0e409d9b2d011bf4.html [mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray From fb78c05f4b79505ba7acaead413f8410a17280fe Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Sun, 6 Jul 2025 11:39:14 +0530 Subject: [PATCH 20/34] chore: improve early returning checks --- 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: passed - 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: missing_dependencies - 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 --- --- .../@stdlib/blas/base/zaxpy/lib/ndarray.native.js | 4 ++++ lib/node_modules/@stdlib/blas/base/zaxpy/lib/zaxpy.js | 4 ++++ lib/node_modules/@stdlib/blas/base/zaxpy/lib/zaxpy.native.js | 4 ++++ lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy_ndarray.c | 5 +---- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/zaxpy/lib/ndarray.native.js index 935539f7bfe5..5c064954390d 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/lib/ndarray.native.js @@ -21,6 +21,7 @@ // MODULES // var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); +var dcabs1 = require( '@stdlib/blas/base/dcabs1' ); var addon = require( './../src/addon.node' ); @@ -53,6 +54,9 @@ var addon = require( './../src/addon.node' ); function zaxpy( N, alpha, x, strideX, offsetX, y, strideY, offsetY ) { var viewX = reinterpret( x, 0 ); var viewY = reinterpret( y, 0 ); + if ( N <= 0 || dcabs1( alpha ) === 0.0 ) { + return y; + } addon.ndarray( N, alpha, viewX, strideX, offsetX, viewY, strideY, offsetY ); return y; } diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/lib/zaxpy.js b/lib/node_modules/@stdlib/blas/base/zaxpy/lib/zaxpy.js index b68f04f1470e..7393e4406e04 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/lib/zaxpy.js +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/lib/zaxpy.js @@ -21,6 +21,7 @@ // MODULES // var stride2offset = require( '@stdlib/strided/base/stride2offset' ); +var dcabs1 = require( '@stdlib/blas/base/dcabs1' ); var ndarray = require( './ndarray.js' ); @@ -51,6 +52,9 @@ var ndarray = require( './ndarray.js' ); function zaxpy( N, alpha, x, strideX, y, strideY ) { var ix = stride2offset( N, strideX ); var iy = stride2offset( N, strideY ); + if ( N <= 0 || dcabs1( alpha ) === 0.0 ) { + return y; + } return ndarray( N, alpha, x, strideX, ix, y, strideY, iy ); } diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/lib/zaxpy.native.js b/lib/node_modules/@stdlib/blas/base/zaxpy/lib/zaxpy.native.js index a1958ee249c0..3f8a0ffe234d 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/lib/zaxpy.native.js +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/lib/zaxpy.native.js @@ -21,6 +21,7 @@ // MODULES // var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); +var dcabs1 = require( '@stdlib/blas/base/dcabs1' ); var addon = require( './../src/addon.node' ); @@ -51,6 +52,9 @@ var addon = require( './../src/addon.node' ); function zaxpy( N, alpha, x, strideX, y, strideY ) { var viewX = reinterpret( x, 0 ); var viewY = reinterpret( y, 0 ); + if ( N <= 0 || dcabs1( alpha ) === 0.0 ) { + return y; + } addon( N, alpha, viewX, strideX, viewY, strideY ); return y; } diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy_ndarray.c b/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy_ndarray.c index c6930ea1db61..e8500db39615 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy_ndarray.c +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy_ndarray.c @@ -43,10 +43,7 @@ void API_SUFFIX(c_zaxpy_ndarray)( const CBLAS_INT N, const stdlib_complex128_t a int64_t is2; int64_t i; - if ( N <= 0 ) { - return; - } - if ( c_scabs1( alpha ) == 0.0 ) { + if ( N <= 0 || c_scabs1( alpha ) == 0.0 ) { return; } stdlib_complex128_t *ip1 = (stdlib_complex128_t *)X; From 33796e86f1544b664ec26158a969b6be965e7a9d Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Sun, 6 Jul 2025 11:39:56 +0530 Subject: [PATCH 21/34] chore: add ndarray support --- 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 --- --- .../base/zaxpy/include/stdlib/blas/base/zaxpy.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/include/stdlib/blas/base/zaxpy.h b/lib/node_modules/@stdlib/blas/base/zaxpy/include/stdlib/blas/base/zaxpy.h index a7714a8a9c6c..6078ee099564 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/include/stdlib/blas/base/zaxpy.h +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/include/stdlib/blas/base/zaxpy.h @@ -19,11 +19,11 @@ /** * Header file containing function declarations for the C interface to the BLAS Level 1 routine `zaxpy`. */ -#ifndef ZAXPY_H -#define ZAXPY_H +#ifndef CAXPY_H +#define CAXPY_H #include "stdlib/blas/base/shared.h" -#include "stdlib/complex/float64/ctor.h" +#include "stdlib/complex/float32/ctor.h" /* * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. @@ -33,12 +33,17 @@ extern "C" { #endif /** -* Scale a double-precision complex floating-point vector by a double-precision complex floating-point constant and add the result to a double-precision complex floating-point vector. +* Scales a double-precision complex floating-point vector by a double-precision complex floating-point constant and adds the result to a double-precision complex floating-point vector. */ -void API_SUFFIX(c_zaxpy)( const CBLAS_INT N, const stdlib_complex128_t alpha, void *X, const CBLAS_INT strideX, void *Y, const CBLAS_INT strideY ); +void API_SUFFIX(c_zaxpy)( const CBLAS_INT N, const stdlib_complex128_t alpha, const void *X, const CBLAS_INT strideX, void *Y, const CBLAS_INT strideY ); + +/** +* Scales a double-precision complex floating-point vector by a double-precision complex floating-point constant and adds the result to a double-precision complex floating-point vector using alternative indexing semantics. +*/ +void API_SUFFIX(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 ); #ifdef __cplusplus } #endif -#endif // !ZAXPY_H +#endif // !CAXPY_H From 33b9c7656d526b6296aee3669bb4731a339e16db Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Sun, 6 Jul 2025 06:11:07 +0000 Subject: [PATCH 22/34] chore: update copyright years --- .../@stdlib/blas/base/zaxpy/benchmark/benchmark.native.js | 2 +- .../blas/base/zaxpy/benchmark/benchmark.ndarray.native.js | 2 +- lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/c/Makefile | 2 +- .../@stdlib/blas/base/zaxpy/benchmark/c/benchmark.length.c | 2 +- .../@stdlib/blas/base/zaxpy/benchmark/fortran/Makefile | 2 +- .../blas/base/zaxpy/benchmark/fortran/benchmark.length.f | 2 +- lib/node_modules/@stdlib/blas/base/zaxpy/binding.gyp | 2 +- lib/node_modules/@stdlib/blas/base/zaxpy/examples/c/Makefile | 2 +- lib/node_modules/@stdlib/blas/base/zaxpy/examples/c/example.c | 2 +- lib/node_modules/@stdlib/blas/base/zaxpy/include.gypi | 2 +- .../@stdlib/blas/base/zaxpy/include/stdlib/blas/base/zaxpy.h | 2 +- .../blas/base/zaxpy/include/stdlib/blas/base/zaxpy_cblas.h | 2 +- .../blas/base/zaxpy/include/stdlib/blas/base/zaxpy_fortran.h | 2 +- lib/node_modules/@stdlib/blas/base/zaxpy/lib/native.js | 2 +- lib/node_modules/@stdlib/blas/base/zaxpy/lib/ndarray.native.js | 2 +- lib/node_modules/@stdlib/blas/base/zaxpy/lib/zaxpy.native.js | 2 +- lib/node_modules/@stdlib/blas/base/zaxpy/src/Makefile | 2 +- lib/node_modules/@stdlib/blas/base/zaxpy/src/addon.c | 2 +- lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy.c | 2 +- lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy.f | 2 +- lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy_cblas.c | 2 +- lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy_f.c | 2 +- lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy_ndarray.c | 2 +- .../@stdlib/blas/base/zaxpy/test/test.ndarray.native.js | 2 +- .../@stdlib/blas/base/zaxpy/test/test.zaxpy.native.js | 2 +- 25 files changed, 25 insertions(+), 25 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/benchmark.native.js index 06bcaad5061b..2e3d66e7fde7 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/benchmark.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/benchmark.ndarray.native.js index 8425045d0c71..2e290d9ec4f1 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/benchmark.ndarray.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/c/Makefile b/lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/c/Makefile index 9f97140e7cb0..cce2c865d7ad 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/c/Makefile +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/c/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/c/benchmark.length.c index 9b5e403a5f62..1c9a6733f285 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/c/benchmark.length.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/fortran/Makefile b/lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/fortran/Makefile index 28b70ff7f607..36a601a08f3a 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/fortran/Makefile +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/fortran/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/fortran/benchmark.length.f b/lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/fortran/benchmark.length.f index 9685d5e8719f..7c0484a8e740 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/fortran/benchmark.length.f +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/fortran/benchmark.length.f @@ -1,7 +1,7 @@ !> ! @license Apache-2.0 ! -! Copyright (c) 2024 The Stdlib Authors. +! Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/binding.gyp b/lib/node_modules/@stdlib/blas/base/zaxpy/binding.gyp index 02a2799da097..08de71a2020e 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/binding.gyp +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/binding.gyp @@ -1,6 +1,6 @@ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/examples/c/Makefile b/lib/node_modules/@stdlib/blas/base/zaxpy/examples/c/Makefile index 6aed70daf167..25ced822f96a 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/examples/c/Makefile +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/examples/c/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/zaxpy/examples/c/example.c index 7b1068963161..6504bec699f0 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/examples/c/example.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/include.gypi b/lib/node_modules/@stdlib/blas/base/zaxpy/include.gypi index 497aeca15320..4217944b5d20 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/include.gypi +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/include.gypi @@ -1,6 +1,6 @@ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/include/stdlib/blas/base/zaxpy.h b/lib/node_modules/@stdlib/blas/base/zaxpy/include/stdlib/blas/base/zaxpy.h index 6078ee099564..67677e5417cf 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/include/stdlib/blas/base/zaxpy.h +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/include/stdlib/blas/base/zaxpy.h @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/include/stdlib/blas/base/zaxpy_cblas.h b/lib/node_modules/@stdlib/blas/base/zaxpy/include/stdlib/blas/base/zaxpy_cblas.h index d967374353cc..ae3429a56762 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/include/stdlib/blas/base/zaxpy_cblas.h +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/include/stdlib/blas/base/zaxpy_cblas.h @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/include/stdlib/blas/base/zaxpy_fortran.h b/lib/node_modules/@stdlib/blas/base/zaxpy/include/stdlib/blas/base/zaxpy_fortran.h index 6a194893fdc4..b3d7cd20327e 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/include/stdlib/blas/base/zaxpy_fortran.h +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/include/stdlib/blas/base/zaxpy_fortran.h @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/lib/native.js b/lib/node_modules/@stdlib/blas/base/zaxpy/lib/native.js index 459cb11405d0..a7ee4da8bb25 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/lib/native.js +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/lib/native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/zaxpy/lib/ndarray.native.js index 5c064954390d..0ffae68c927b 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/lib/ndarray.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/lib/zaxpy.native.js b/lib/node_modules/@stdlib/blas/base/zaxpy/lib/zaxpy.native.js index 3f8a0ffe234d..0822b87595c6 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/lib/zaxpy.native.js +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/lib/zaxpy.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/src/Makefile b/lib/node_modules/@stdlib/blas/base/zaxpy/src/Makefile index bcf18aa46655..7733b6180cb4 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/src/Makefile +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/src/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/src/addon.c b/lib/node_modules/@stdlib/blas/base/zaxpy/src/addon.c index 40a2bc7d5865..0d9c471d0bf6 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/src/addon.c +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/src/addon.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy.c b/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy.c index 7f84b9f720d2..036b6f02c33d 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy.c +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy.f b/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy.f index aa5bc30e6d7f..3b3720dbb032 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy.f +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy.f @@ -1,7 +1,7 @@ !> ! @license Apache-2.0 ! -! Copyright (c) 2024 The Stdlib Authors. +! Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy_cblas.c b/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy_cblas.c index 6130b73c5073..ee724a7a1b0c 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy_cblas.c +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy_cblas.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy_f.c b/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy_f.c index 6c35116de093..94434984dbaa 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy_f.c +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy_f.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy_ndarray.c b/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy_ndarray.c index e8500db39615..e6c84bcff6f6 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy_ndarray.c +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy_ndarray.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/zaxpy/test/test.ndarray.native.js index 30ed176cffc0..ba261653d9ae 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/test/test.ndarray.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/test/test.zaxpy.native.js b/lib/node_modules/@stdlib/blas/base/zaxpy/test/test.zaxpy.native.js index 0aa860dc5905..dd984a212f63 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/test/test.zaxpy.native.js +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/test/test.zaxpy.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 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. From 2d26a8caa9384eeccab357d0caec40f7dc264865 Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Sun, 6 Jul 2025 11:58:34 +0530 Subject: [PATCH 23/34] chore: add appropriate header files Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- .../@stdlib/blas/base/zaxpy/include/stdlib/blas/base/zaxpy.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/include/stdlib/blas/base/zaxpy.h b/lib/node_modules/@stdlib/blas/base/zaxpy/include/stdlib/blas/base/zaxpy.h index 67677e5417cf..0f8b8676d85e 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/include/stdlib/blas/base/zaxpy.h +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/include/stdlib/blas/base/zaxpy.h @@ -23,7 +23,7 @@ #define CAXPY_H #include "stdlib/blas/base/shared.h" -#include "stdlib/complex/float32/ctor.h" +#include "stdlib/complex/float64/ctor.h" /* * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. From 84598e351b6ef206a0fddebf24dfeb44866a15ff Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Sun, 6 Jul 2025 13:04:54 +0530 Subject: [PATCH 24/34] refactor: improve ndarray implementation and update manifest.json --- 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: missing_dependencies - 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 --- --- .../@stdlib/blas/base/zaxpy/manifest.json | 144 ++++++++++++------ .../blas/base/zaxpy/src/zaxpy_ndarray.c | 5 +- 2 files changed, 96 insertions(+), 53 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/manifest.json b/lib/node_modules/@stdlib/blas/base/zaxpy/manifest.json index 85f6b21318c7..1a1828492584 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/manifest.json @@ -58,7 +58,8 @@ "blas": "", "wasm": false, "src": [ - "./src/zaxpy.c" + "./src/zaxpy.c", + "./src/zaxpy_ndarray.c" ], "include": [ "./include" @@ -67,9 +68,11 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/complex/float64/base/mul", - "@stdlib/complex/float64/base/add", - "@stdlib/complex/float64/ctor" + "@stdlib/blas/base/scabs1", + "@stdlib/complex/float64/base/mul-add", + "@stdlib/complex/float64/ctor", + "@stdlib/strided/base/stride2offset", + "@stdlib/strided/base/stride2offset" ] }, { @@ -78,7 +81,8 @@ "blas": "", "wasm": false, "src": [ - "./src/zaxpy.c" + "./src/zaxpy.c", + "./src/zaxpy_ndarray.c" ], "include": [ "./include" @@ -87,9 +91,10 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/complex/float64/base/mul", - "@stdlib/complex/float64/base/add", - "@stdlib/complex/float64/ctor" + "@stdlib/blas/base/scabs1", + "@stdlib/complex/float64/base/mul-add", + "@stdlib/complex/float64/ctor", + "@stdlib/strided/base/stride2offset" ] }, @@ -99,7 +104,8 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/zaxpy_cblas.c" + "./src/zaxpy_cblas.c", + "./src/zaxpy_ndarray.c" ], "include": [ "./include" @@ -116,7 +122,9 @@ "@stdlib/napi/argv-int64", "@stdlib/napi/argv-strided-complex128array", "@stdlib/napi/argv-complex128", - "@stdlib/complex/float64/ctor" + "@stdlib/complex/float64/ctor", + "@stdlib/blas/base/scabs1", + "@stdlib/complex/float64/base/mul-add" ] }, { @@ -125,7 +133,8 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/zaxpy_cblas.c" + "./src/zaxpy_cblas.c", + "./src/zaxpy_ndarray.c" ], "include": [ "./include" @@ -137,7 +146,9 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/complex/float32/ctor" + "@stdlib/complex/float32/ctor", + "@stdlib/blas/base/scabs1", + "@stdlib/complex/float64/base/mul-add" ] }, { @@ -146,7 +157,8 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/zaxpy_cblas.c" + "./src/zaxpy_cblas.c", + "./src/zaxpy_ndarray.c" ], "include": [ "./include" @@ -158,7 +170,9 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/complex/float32/ctor" + "@stdlib/complex/float32/ctor", + "@stdlib/blas/base/scabs1", + "@stdlib/complex/float64/base/mul-add" ] }, @@ -192,7 +206,8 @@ "blas": "", "wasm": false, "src": [ - "./src/zaxpy.c" + "./src/zaxpy.c", + "./src/zaxpy_ndarray.c" ], "include": [ "./include" @@ -201,9 +216,10 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/complex/float64/base/mul", - "@stdlib/complex/float64/base/add", - "@stdlib/complex/float64/ctor" + "@stdlib/blas/base/scabs1", + "@stdlib/complex/float64/base/mul-add", + "@stdlib/complex/float64/ctor", + "@stdlib/strided/base/stride2offset" ] }, { @@ -212,7 +228,8 @@ "blas": "", "wasm": false, "src": [ - "./src/zaxpy.c" + "./src/zaxpy.c", + "./src/zaxpy_ndarray.c" ], "include": [ "./include" @@ -221,9 +238,10 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/complex/float64/base/mul", - "@stdlib/complex/float64/base/add", - "@stdlib/complex/float64/ctor" + "@stdlib/blas/base/scabs1", + "@stdlib/complex/float64/base/mul-add", + "@stdlib/complex/float64/ctor", + "@stdlib/strided/base/stride2offset" ] }, @@ -233,7 +251,8 @@ "blas": "apple_accelerate_framework", "wasm": false, "src": [ - "./src/zaxpy_cblas.c" + "./src/zaxpy_cblas.c", + "./src/zaxpy_ndarray.c" ], "include": [ "./include" @@ -249,7 +268,9 @@ "@stdlib/napi/argv-int64", "@stdlib/napi/argv-strided-complex128array", "@stdlib/napi/argv-complex128", - "@stdlib/complex/float64/ctor" + "@stdlib/complex/float64/ctor", + "@stdlib/blas/base/scabs1", + "@stdlib/complex/float64/base/mul-add" ] }, { @@ -258,7 +279,8 @@ "blas": "apple_accelerate_framework", "wasm": false, "src": [ - "./src/zaxpy_cblas.c" + "./src/zaxpy_cblas.c", + "./src/zaxpy_ndarray.c" ], "include": [ "./include" @@ -269,7 +291,9 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/complex/float64/ctor" + "@stdlib/complex/float64/ctor", + "@stdlib/blas/base/scabs1", + "@stdlib/complex/float64/base/mul-add" ] }, { @@ -278,7 +302,8 @@ "blas": "apple_accelerate_framework", "wasm": false, "src": [ - "./src/zaxpy_cblas.c" + "./src/zaxpy_cblas.c", + "./src/zaxpy_ndarray.c" ], "include": [ "./include" @@ -289,7 +314,9 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/complex/float64/ctor" + "@stdlib/complex/float64/ctor", + "@stdlib/blas/base/scabs1", + "@stdlib/complex/float64/base/mul-add" ] }, @@ -299,7 +326,8 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/zaxpy_cblas.c" + "./src/zaxpy_cblas.c", + "./src/zaxpy_ndarray.c" ], "include": [ "./include" @@ -316,7 +344,9 @@ "@stdlib/napi/argv-int64", "@stdlib/napi/argv-strided-complex128array", "@stdlib/napi/argv-complex128", - "@stdlib/complex/float64/ctor" + "@stdlib/complex/float64/ctor", + "@stdlib/blas/base/scabs1", + "@stdlib/complex/float64/base/mul-add" ] }, { @@ -325,7 +355,8 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/zaxpy_cblas.c" + "./src/zaxpy_cblas.c", + "./src/zaxpy_ndarray.c" ], "include": [ "./include" @@ -337,7 +368,9 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/complex/float64/ctor" + "@stdlib/complex/float64/ctor", + "@stdlib/blas/base/scabs1", + "@stdlib/complex/float64/base/mul-add" ] }, { @@ -346,7 +379,8 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/zaxpy_cblas.c" + "./src/zaxpy_cblas.c", + "./src/zaxpy_ndarray.c" ], "include": [ "./include" @@ -358,7 +392,9 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/complex/float64/ctor" + "@stdlib/complex/float64/ctor", + "@stdlib/blas/base/scabs1", + "@stdlib/complex/float64/base/mul-add" ] }, @@ -368,7 +404,8 @@ "blas": "", "wasm": false, "src": [ - "./src/zaxpy.c" + "./src/zaxpy.c", + "./src/zaxpy_ndarray.c" ], "include": [ "./include" @@ -383,8 +420,9 @@ "@stdlib/napi/argv-strided-complex128array", "@stdlib/napi/argv-complex128", "@stdlib/complex/float64/ctor", - "@stdlib/complex/float64/base/mul", - "@stdlib/complex/float64/base/add" + "@stdlib/blas/base/scabs1", + "@stdlib/complex/float64/base/mul-add", + "@stdlib/strided/base/stride2offset" ] }, { @@ -393,7 +431,8 @@ "blas": "", "wasm": false, "src": [ - "./src/zaxpy.c" + "./src/zaxpy.c", + "./src/zaxpy_ndarray.c" ], "include": [ "./include" @@ -402,9 +441,10 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/complex/float64/base/mul", - "@stdlib/complex/float64/base/add", - "@stdlib/complex/float64/ctor" + "@stdlib/blas/base/scabs1", + "@stdlib/complex/float64/base/mul-add", + "@stdlib/complex/float64/ctor", + "@stdlib/strided/base/stride2offset" ] }, { @@ -413,7 +453,8 @@ "blas": "", "wasm": false, "src": [ - "./src/zaxpy.c" + "./src/zaxpy.c", + "./src/zaxpy_ndarray.c" ], "include": [ "./include" @@ -422,9 +463,10 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/complex/float64/base/mul", - "@stdlib/complex/float64/base/add", - "@stdlib/complex/float64/ctor" + "@stdlib/blas/base/scabs1", + "@stdlib/complex/float64/base/mul-add", + "@stdlib/complex/float64/ctor", + "@stdlib/strided/base/stride2offset" ] }, @@ -434,7 +476,8 @@ "blas": "", "wasm": true, "src": [ - "./src/zaxpy.c" + "./src/zaxpy.c", + "./src/zaxpy_ndarray.c" ], "include": [ "./include" @@ -443,10 +486,11 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/complex/float64/base/mul", - "@stdlib/complex/float64/base/add", - "@stdlib/complex/float64/ctor" + "@stdlib/blas/base/scabs1", + "@stdlib/complex/float64/base/mul-add", + "@stdlib/complex/float64/ctor", + "@stdlib/strided/base/stride2offset" ] } ] -} \ No newline at end of file +} diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy_ndarray.c b/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy_ndarray.c index e6c84bcff6f6..ab29adb16af5 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy_ndarray.c +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy_ndarray.c @@ -20,8 +20,7 @@ #include "stdlib/blas/base/scabs1.h" #include "stdlib/blas/base/shared.h" #include "stdlib/complex/float64/ctor.h" -#include "stdlib/complex/float64/base/add.h" -#include "stdlib/complex/float64/base/mul.h" +#include "stdlib/complex/float64/base/mul_add.h" #include /** @@ -55,7 +54,7 @@ void API_SUFFIX(c_zaxpy_ndarray)( const CBLAS_INT N, const stdlib_complex128_t a for ( i = 0; i < N; i++, ip1 += is1, ip2 += is2 ) { x = *ip1; y = *ip2; - *ip2 = stdlib_base_complex128_add( stdlib_base_complex128_mul( alpha, x ), y ); + *ip2 = stdlib_base_complex128_muladd( alpha, x, y ); } return; } From 2bd731df7951cfaa35564c641686983b32bac25b Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Sun, 6 Jul 2025 13:14:21 +0530 Subject: [PATCH 25/34] fix: chore scabs1 to dcabs1 --- 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: missing_dependencies - 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 --- --- .../@stdlib/blas/base/zaxpy/manifest.json | 34 +++++++++---------- .../blas/base/zaxpy/src/zaxpy_ndarray.c | 4 +-- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/manifest.json b/lib/node_modules/@stdlib/blas/base/zaxpy/manifest.json index 1a1828492584..da91e1cfc14b 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/manifest.json @@ -68,7 +68,7 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/blas/base/scabs1", + "@stdlib/blas/base/dcabs1", "@stdlib/complex/float64/base/mul-add", "@stdlib/complex/float64/ctor", "@stdlib/strided/base/stride2offset", @@ -91,7 +91,7 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/blas/base/scabs1", + "@stdlib/blas/base/dcabs1", "@stdlib/complex/float64/base/mul-add", "@stdlib/complex/float64/ctor", "@stdlib/strided/base/stride2offset" @@ -123,7 +123,7 @@ "@stdlib/napi/argv-strided-complex128array", "@stdlib/napi/argv-complex128", "@stdlib/complex/float64/ctor", - "@stdlib/blas/base/scabs1", + "@stdlib/blas/base/dcabs1", "@stdlib/complex/float64/base/mul-add" ] }, @@ -147,7 +147,7 @@ "dependencies": [ "@stdlib/blas/base/shared", "@stdlib/complex/float32/ctor", - "@stdlib/blas/base/scabs1", + "@stdlib/blas/base/dcabs1", "@stdlib/complex/float64/base/mul-add" ] }, @@ -171,7 +171,7 @@ "dependencies": [ "@stdlib/blas/base/shared", "@stdlib/complex/float32/ctor", - "@stdlib/blas/base/scabs1", + "@stdlib/blas/base/dcabs1", "@stdlib/complex/float64/base/mul-add" ] }, @@ -216,7 +216,7 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/blas/base/scabs1", + "@stdlib/blas/base/dcabs1", "@stdlib/complex/float64/base/mul-add", "@stdlib/complex/float64/ctor", "@stdlib/strided/base/stride2offset" @@ -238,7 +238,7 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/blas/base/scabs1", + "@stdlib/blas/base/dcabs1", "@stdlib/complex/float64/base/mul-add", "@stdlib/complex/float64/ctor", "@stdlib/strided/base/stride2offset" @@ -269,7 +269,7 @@ "@stdlib/napi/argv-strided-complex128array", "@stdlib/napi/argv-complex128", "@stdlib/complex/float64/ctor", - "@stdlib/blas/base/scabs1", + "@stdlib/blas/base/dcabs1", "@stdlib/complex/float64/base/mul-add" ] }, @@ -292,7 +292,7 @@ "dependencies": [ "@stdlib/blas/base/shared", "@stdlib/complex/float64/ctor", - "@stdlib/blas/base/scabs1", + "@stdlib/blas/base/dcabs1", "@stdlib/complex/float64/base/mul-add" ] }, @@ -315,7 +315,7 @@ "dependencies": [ "@stdlib/blas/base/shared", "@stdlib/complex/float64/ctor", - "@stdlib/blas/base/scabs1", + "@stdlib/blas/base/dcabs1", "@stdlib/complex/float64/base/mul-add" ] }, @@ -345,7 +345,7 @@ "@stdlib/napi/argv-strided-complex128array", "@stdlib/napi/argv-complex128", "@stdlib/complex/float64/ctor", - "@stdlib/blas/base/scabs1", + "@stdlib/blas/base/dcabs1", "@stdlib/complex/float64/base/mul-add" ] }, @@ -369,7 +369,7 @@ "dependencies": [ "@stdlib/blas/base/shared", "@stdlib/complex/float64/ctor", - "@stdlib/blas/base/scabs1", + "@stdlib/blas/base/dcabs1", "@stdlib/complex/float64/base/mul-add" ] }, @@ -393,7 +393,7 @@ "dependencies": [ "@stdlib/blas/base/shared", "@stdlib/complex/float64/ctor", - "@stdlib/blas/base/scabs1", + "@stdlib/blas/base/dcabs1", "@stdlib/complex/float64/base/mul-add" ] }, @@ -420,7 +420,7 @@ "@stdlib/napi/argv-strided-complex128array", "@stdlib/napi/argv-complex128", "@stdlib/complex/float64/ctor", - "@stdlib/blas/base/scabs1", + "@stdlib/blas/base/dcabs1", "@stdlib/complex/float64/base/mul-add", "@stdlib/strided/base/stride2offset" ] @@ -441,7 +441,7 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/blas/base/scabs1", + "@stdlib/blas/base/dcabs1", "@stdlib/complex/float64/base/mul-add", "@stdlib/complex/float64/ctor", "@stdlib/strided/base/stride2offset" @@ -463,7 +463,7 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/blas/base/scabs1", + "@stdlib/blas/base/dcabs1", "@stdlib/complex/float64/base/mul-add", "@stdlib/complex/float64/ctor", "@stdlib/strided/base/stride2offset" @@ -486,7 +486,7 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/blas/base/scabs1", + "@stdlib/blas/base/dcabs1", "@stdlib/complex/float64/base/mul-add", "@stdlib/complex/float64/ctor", "@stdlib/strided/base/stride2offset" diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy_ndarray.c b/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy_ndarray.c index ab29adb16af5..88719f25d75f 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy_ndarray.c +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy_ndarray.c @@ -17,7 +17,7 @@ */ #include "stdlib/blas/base/zaxpy.h" -#include "stdlib/blas/base/scabs1.h" +#include "stdlib/blas/base/dcabs1.h" #include "stdlib/blas/base/shared.h" #include "stdlib/complex/float64/ctor.h" #include "stdlib/complex/float64/base/mul_add.h" @@ -42,7 +42,7 @@ void API_SUFFIX(c_zaxpy_ndarray)( const CBLAS_INT N, const stdlib_complex128_t a int64_t is2; int64_t i; - if ( N <= 0 || c_scabs1( alpha ) == 0.0 ) { + if ( N <= 0 || c_dcabs1( alpha ) == 0.0 ) { return; } stdlib_complex128_t *ip1 = (stdlib_complex128_t *)X; From 7584e80f7b61acbfb28480048242f675feaf5042 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Sun, 6 Jul 2025 13:52:07 +0530 Subject: [PATCH 26/34] chore: update fortran files --- 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: missing_dependencies - 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 --- --- lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy_f.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy_f.c b/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy_f.c index 94434984dbaa..45f3c719bd78 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy_f.c +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy_f.c @@ -33,4 +33,5 @@ */ void API_SUFFIX(c_zaxpy)( const CBLAS_INT N, const stdlib_complex128_t alpha, void *X, const CBLAS_INT strideX, void *Y, const CBLAS_INT strideY ) { zaxpy( &N, &alpha, X, &strideX, Y, &strideY ); + return; } From 556c18b9c9ab738cf4585bd16f3c2af232797a06 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Sun, 6 Jul 2025 14:01:30 +0530 Subject: [PATCH 27/34] chore: update repl output --- 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: passed - 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 --- --- lib/node_modules/@stdlib/blas/base/zaxpy/docs/repl.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/zaxpy/docs/repl.txt index 94dedb7f4295..7d4db2046b8e 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/docs/repl.txt @@ -119,7 +119,7 @@ > x = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); > y = new {{alias:@stdlib/array/complex128}}( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); > {{alias}}.ndarray( 2, alpha, x, 1, 1, y, 1, 1 ) - [ -1.0, 23.0, -1.0, 7.0, 1.0, 1.0 ] + [ 1.0, 1.0, -1.0, 15.0, -1.0, 23.0 ] See Also -------- From 6c2d9426b00c094a72190584d4127d54732ea44f Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Sun, 6 Jul 2025 14:49:41 +0530 Subject: [PATCH 28/34] chore: add appropriate line endings --- 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 --- --- .../blas/base/zaxpy/benchmark/fortran/benchmark.length.f | 2 +- lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy.f | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/fortran/benchmark.length.f b/lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/fortran/benchmark.length.f index 7c0484a8e740..0cb86e59bfd9 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/fortran/benchmark.length.f +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/fortran/benchmark.length.f @@ -220,4 +220,4 @@ subroutine main() end do call print_summary( count, count ) end subroutine main -end program bench \ No newline at end of file +end program bench diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy.f b/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy.f index 3b3720dbb032..dcca86ee5710 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy.f +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy.f @@ -93,4 +93,4 @@ subroutine zaxpy( N, alpha, x, strideX, y, strideY ) end do end if return -end subroutine zaxpy \ No newline at end of file +end subroutine zaxpy From e46946668d7d0dd17e6be2f9cd56e11b54f4d5af Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Sun, 6 Jul 2025 14:55:21 +0530 Subject: [PATCH 29/34] fix: change parameter declaration --- 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: missing_dependencies - 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 --- --- lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy_f.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy_f.c b/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy_f.c index 45f3c719bd78..e9c8b282f16d 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy_f.c +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/src/zaxpy_f.c @@ -31,7 +31,7 @@ * @param Y second input array * @param strideY Y stride length */ -void API_SUFFIX(c_zaxpy)( const CBLAS_INT N, const stdlib_complex128_t alpha, void *X, const CBLAS_INT strideX, void *Y, const CBLAS_INT strideY ) { +void API_SUFFIX(c_zaxpy)( const CBLAS_INT N, const stdlib_complex128_t alpha, const void *X, const CBLAS_INT strideX, void *Y, const CBLAS_INT strideY ) { zaxpy( &N, &alpha, X, &strideX, Y, &strideY ); return; } From d9e366025df354a5b2b507fdd79e2836d21ffe3e Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Sun, 6 Jul 2025 15:27:47 +0530 Subject: [PATCH 30/34] fix: change parameter declaration --- 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 --- --- .../blas/base/zaxpy/include/stdlib/blas/base/zaxpy_fortran.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/include/stdlib/blas/base/zaxpy_fortran.h b/lib/node_modules/@stdlib/blas/base/zaxpy/include/stdlib/blas/base/zaxpy_fortran.h index b3d7cd20327e..92c30d3b14ff 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/include/stdlib/blas/base/zaxpy_fortran.h +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/include/stdlib/blas/base/zaxpy_fortran.h @@ -34,7 +34,7 @@ extern "C" { /** * Scale a double-precision complex floating-point vector by a double-precision complex floating-point constant and add the result to a double-precision complex floating-point vector. */ -void zaxpy( const CBLAS_INT *, const stdlib_complex128_t *, void *, const CBLAS_INT *, void *, const CBLAS_INT * ); +void zaxpy( const CBLAS_INT *, const stdlib_complex128_t *, const void *, const CBLAS_INT *, void *, const CBLAS_INT * ); #ifdef __cplusplus } From 02afa53800231c2a3c200f5541a88cc69d0a9355 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Sun, 6 Jul 2025 15:44:17 +0530 Subject: [PATCH 31/34] fix: update Makefile --- 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 --- --- .../@stdlib/blas/base/zaxpy/benchmark/fortran/Makefile | 2 +- lib/node_modules/@stdlib/blas/base/zaxpy/manifest.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/fortran/Makefile b/lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/fortran/Makefile index 36a601a08f3a..a41fcbd68bb6 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/fortran/Makefile +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/fortran/Makefile @@ -78,7 +78,7 @@ endif INCLUDE ?= # List of Fortran source files: -SOURCE_FILES ?= ../../src/zscal.f +SOURCE_FILES ?= ../../src/zaxpy.f # List of Fortran targets: f_targets := benchmark.length.out diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/manifest.json b/lib/node_modules/@stdlib/blas/base/zaxpy/manifest.json index da91e1cfc14b..c741174205e5 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/manifest.json @@ -71,7 +71,6 @@ "@stdlib/blas/base/dcabs1", "@stdlib/complex/float64/base/mul-add", "@stdlib/complex/float64/ctor", - "@stdlib/strided/base/stride2offset", "@stdlib/strided/base/stride2offset" ] }, From 0e9372fec6582c0b8622a3035ef1f3343ff5048a Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Sun, 6 Jul 2025 16:31:54 +0530 Subject: [PATCH 32/34] bench: add correct file paths --- 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: passed - 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 --- --- .../blas/base/zaxpy/benchmark/benchmark.ndarray.native.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/benchmark.ndarray.native.js index 2e290d9ec4f1..e329c5cc1f8c 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/benchmark/benchmark.ndarray.native.js @@ -34,7 +34,7 @@ var pkg = require( './../package.json' ).name; // VARIABLES // -var zaxpy = tryRequire( resolve( __dirname, './../lib/zaxpy.native.js' ) ); +var zaxpy = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); var opts = { 'skip': ( zaxpy instanceof Error ) }; From e6a5aefdeac3827c7651f46c3c4021ca70c5719b Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Wed, 9 Jul 2025 09:33:04 +0530 Subject: [PATCH 33/34] fix: revert stats/base changes --- .../@stdlib/stats/base/nanrange-by/README.md | 40 +-- .../base/nanrange-by/benchmark/benchmark.js | 31 +-- .../benchmark/benchmark.ndarray.js | 29 +-- .../stats/base/nanrange-by/docs/repl.txt | 36 +-- .../base/nanrange-by/docs/types/index.d.ts | 25 +- .../stats/base/nanrange-by/docs/types/test.ts | 9 +- .../stats/base/nanrange-by/examples/index.js | 12 +- .../stats/base/nanrange-by/lib/index.js | 9 +- .../stats/base/nanrange-by/lib/main.js | 27 +- .../stats/base/nanrange-by/lib/nanrange_by.js | 100 ++++++++ .../stats/base/nanrange-by/lib/ndarray.js | 27 +- .../base/nanrange-by/test/test.nanrange_by.js | 233 ++++++++++++++++++ .../base/nanrange-by/test/test.ndarray.js | 187 +------------- .../stats/base/range-by/lib/accessors.js | 6 +- .../@stdlib/stats/base/stdevtk/README.md | 46 ++-- .../stats/base/stdevtk/benchmark/benchmark.js | 17 +- .../stdevtk/benchmark/benchmark.ndarray.js | 17 +- .../@stdlib/stats/base/stdevtk/docs/repl.txt | 36 +-- .../stats/base/stdevtk/docs/types/index.d.ts | 19 +- .../stats/base/stdevtk/docs/types/test.ts | 3 - .../stats/base/stdevtk/examples/index.js | 14 +- .../@stdlib/stats/base/stdevtk/lib/ndarray.js | 13 +- .../@stdlib/stats/base/stdevtk/lib/stdevtk.js | 10 +- .../stats/base/stdevtk/test/test.ndarray.js | 169 +------------ .../stats/base/stdevtk/test/test.stdevtk.js | 173 +------------ .../@stdlib/stats/base/stdevwd/README.md | 46 ++-- .../stats/base/stdevwd/benchmark/benchmark.js | 19 +- .../stdevwd/benchmark/benchmark.ndarray.js | 17 +- .../@stdlib/stats/base/stdevwd/docs/repl.txt | 36 +-- .../stats/base/stdevwd/docs/types/index.d.ts | 19 +- .../stats/base/stdevwd/docs/types/test.ts | 3 - .../stats/base/stdevwd/examples/index.js | 14 +- .../@stdlib/stats/base/stdevwd/lib/index.js | 4 +- .../@stdlib/stats/base/stdevwd/lib/ndarray.js | 13 +- .../@stdlib/stats/base/stdevwd/lib/stdevwd.js | 10 +- .../stats/base/stdevwd/test/test.ndarray.js | 169 +------------ .../stats/base/stdevwd/test/test.stdevwd.js | 207 ++++++++++++++++ 37 files changed, 874 insertions(+), 971 deletions(-) create mode 100644 lib/node_modules/@stdlib/stats/base/nanrange-by/lib/nanrange_by.js create mode 100644 lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.nanrange_by.js create mode 100644 lib/node_modules/@stdlib/stats/base/stdevwd/test/test.stdevwd.js diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/README.md b/lib/node_modules/@stdlib/stats/base/nanrange-by/README.md index cb63285bcc88..ce74ee3181e2 100644 --- a/lib/node_modules/@stdlib/stats/base/nanrange-by/README.md +++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/README.md @@ -38,9 +38,9 @@ The [**range**][range] is defined as the difference between the maximum and mini var nanrangeBy = require( '@stdlib/stats/base/nanrange-by' ); ``` -#### nanrangeBy( N, x, strideX, clbk\[, thisArg] ) +#### nanrangeBy( N, x, stride, clbk\[, thisArg] ) -Computes the [range][range] of a strided array via a callback function, ignoring `NaN` values. +Calculates the [range][range] of strided array `x` via a callback function, ignoring `NaN` values. ```javascript function accessor( v ) { @@ -57,7 +57,7 @@ The function has the following parameters: - **N**: number of indexed elements. - **x**: input [`Array`][mdn-array], [`typed array`][mdn-typed-array], or an array-like object (excluding strings and functions). -- **strideX**: stride length. +- **stride**: index increment. - **clbk**: callback function. - **thisArg**: execution context (_optional_). @@ -89,16 +89,19 @@ var cnt = context.count; // returns 10 ``` -The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to access every other element +The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to access every other element ```javascript +var floor = require( '@stdlib/math/base/special/floor' ); + function accessor( v ) { return v * 2.0; } var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0, NaN, NaN ]; +var N = floor( x.length / 2 ); -var v = nanrangeBy( 5, x, 2, accessor ); +var v = nanrangeBy( N, x, 2, accessor ); // returns 12.0 ``` @@ -106,6 +109,7 @@ Note that indexing is relative to the first index. To introduce an offset, use [ ```javascript var Float64Array = require( '@stdlib/array/float64' ); +var floor = require( '@stdlib/math/base/special/floor' ); function accessor( v ) { return v * 2.0; @@ -116,15 +120,16 @@ var x0 = new Float64Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); // Create an offset view... var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var N = floor( x0.length/2 ); // Access every other element... -var v = nanrangeBy( 3, x1, 2, accessor ); +var v = nanrangeBy( N, x1, 2, accessor ); // returns 8.0 ``` -#### nanrangeBy.ndarray( N, x, strideX, offsetX, clbk\[, thisArg] ) +#### nanrangeBy.ndarray( N, x, stride, offset, clbk\[, thisArg] ) -Computes the [range][range] of a strided array via a callback function, ignoring `NaN` values and using alternative indexing semantics. +Calculates the [range][range] of strided array `x` via a callback function, ignoring `NaN` values and using alternative indexing semantics. ```javascript function accessor( v ) { @@ -139,9 +144,9 @@ var v = nanrangeBy.ndarray( x.length, x, 1, 0, accessor ); The function has the following additional parameters: -- **offsetX**: starting index. +- **offset**: 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 access only the last three elements of `x` +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 access only the last three elements of `x` ```javascript function accessor( v ) { @@ -166,7 +171,6 @@ var v = nanrangeBy.ndarray( 3, x, 1, x.length-3, accessor ); - A provided callback function should return a numeric value. - If a provided callback function returns `NaN`, the value is ignored. - If a provided callback function does not return any value (or equivalently, explicitly returns `undefined`), the value is ignored. -- Both functions support array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array/base/accessor`][@stdlib/array/base/accessor]). - When possible, prefer using [`dnanrange`][@stdlib/stats/strided/dnanrange], [`snanrange`][@stdlib/stats/strided/snanrange], and/or [`nanrange`][@stdlib/stats/base/nanrange], as, depending on the environment, these interfaces are likely to be significantly more performant. @@ -180,23 +184,23 @@ var v = nanrangeBy.ndarray( 3, x, 1, x.length-3, accessor ); ```javascript -var uniform = require( '@stdlib/random/base/uniform' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var randu = require( '@stdlib/random/base/randu' ); var filledarrayBy = require( '@stdlib/array/filled-by' ); -var bernoulli = require( '@stdlib/random/base/bernoulli' ); var nanrangeBy = require( '@stdlib/stats/base/nanrange-by' ); -function rand() { - if ( bernoulli( 0.8 ) < 0.2 ) { +function fill() { + if ( randu() < 0.2 ) { return NaN; } - return uniform( -50.0, 50.0 ); + return discreteUniform( -50, 50 ); } function accessor( v ) { return v * 2.0; } -var x = filledarrayBy( 10, 'float64', rand ); +var x = filledarrayBy( 10, 'float64', fill ); console.log( x ); var v = nanrangeBy( x.length, x, 1, accessor ); @@ -236,8 +240,6 @@ console.log( v ); [mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray -[@stdlib/array/base/accessor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor - [@stdlib/stats/strided/dnanrange]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/strided/dnanrange diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/benchmark/benchmark.js index 3931e4e384cf..497323944104 100644 --- a/lib/node_modules/@stdlib/stats/base/nanrange-by/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/benchmark/benchmark.js @@ -21,13 +21,11 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ); -var filledarrayBy = require( '@stdlib/array/filled-by' ); -var bernoulli = require( '@stdlib/random/base/bernoulli' ); +var randu = require( '@stdlib/random/base/randu' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); var pkg = require( './../package.json' ).name; -var nanrangeBy = require( './../lib/main.js' ); +var nanrangeBy = require( './../lib/nanrange_by.js' ); // FUNCTIONS // @@ -43,19 +41,6 @@ function accessor( value ) { return value * 2.0; } -/** -* Returns a random number. -* -* @private -* @returns {number} random number -*/ -function rand() { - if ( bernoulli( 0.8 ) < 1 ) { - return NaN; - } - return uniform( -50.0, 50.0 ); -} - /** * Create a benchmark function. * @@ -64,7 +49,17 @@ function rand() { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x = filledarrayBy( len, 'generic', rand ); + var x; + var i; + + x = []; + for ( i = 0; i < len; i++ ) { + if ( randu() < 0.2 ) { + x.push( NaN ); + } else { + x.push( ( randu()*20.0 ) - 10.0 ); + } + } return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/benchmark/benchmark.ndarray.js index cec2b32c4fa0..8b8c84d3bdb2 100644 --- a/lib/node_modules/@stdlib/stats/base/nanrange-by/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/benchmark/benchmark.ndarray.js @@ -21,9 +21,7 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ); -var filledarrayBy = require( '@stdlib/array/filled-by' ); -var bernoulli = require( '@stdlib/random/base/bernoulli' ); +var randu = require( '@stdlib/random/base/randu' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); var pkg = require( './../package.json' ).name; @@ -43,19 +41,6 @@ function accessor( value ) { return value * 2.0; } -/** -* Returns a random number. -* -* @private -* @returns {number} random number -*/ -function rand() { - if ( bernoulli( 0.8 ) < 1 ) { - return NaN; - } - return uniform( -50.0, 50.0 ); -} - /** * Create a benchmark function. * @@ -64,7 +49,17 @@ function rand() { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x = filledarrayBy( len, 'generic', rand ); + var x; + var i; + + x = []; + for ( i = 0; i < len; i++ ) { + if ( randu() < 0.2 ) { + x.push( NaN ); + } else { + x.push( ( randu()*20.0 ) - 10.0 ); + } + } return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/repl.txt index 3425fd2e6bcf..306a3a977dd2 100644 --- a/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/repl.txt @@ -1,10 +1,10 @@ -{{alias}}( N, x, strideX, clbk[, thisArg] ) - Computes the range of a strided array via a callback function, ignoring +{{alias}}( N, x, stride, clbk[, thisArg] ) + Calculates the range of a strided array via a callback function, ignoring `NaN` values. - The `N` and stride parameters determine which elements in the strided array - are accessed at runtime. + The `N` and `stride` parameters determine which elements in `x` are accessed + at runtime. Indexing is relative to the first index. To introduce an offset, use typed array views. @@ -34,8 +34,8 @@ Input array/collection. If provided an object, the object must be array- like (excluding strings and functions). - strideX: integer - Stride length. + stride: integer + Index increment for `x`. clbk: Function Callback function. @@ -56,24 +56,25 @@ > {{alias}}( x.length, x, 1, accessor ) 18.0 - // Using `N` and stride parameters: + // Using `N` and `stride` parameters: > x = [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0, 1.0 ]; - > {{alias}}( 4, x, 2, accessor ) + > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); + > {{alias}}( N, x, 2, accessor ) 14.0 // Using view offsets: > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); - > {{alias}}( 3, x1, 2, accessor ) + > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); + > {{alias}}( N, x1, 2, accessor ) 8.0 - -{{alias}}.ndarray( N, x, strideX, offsetX, clbk[, thisArg] ) +{{alias}}.ndarray( N, x, stride, offset, clbk[, thisArg] ) Calculates the range of a strided array via a callback function, ignoring `NaN` values and using alternative indexing semantics. While typed array views mandate a view offset based on the underlying - buffer, the offset parameter supports indexing semantics based on a + buffer, the `offset` parameter supports indexing semantics based on a starting index. Parameters @@ -85,11 +86,11 @@ Input array/collection. If provided an object, the object must be array- like (excluding strings and functions). - strideX: integer - Stride length. + stride: integer + Index increment for `x`. - offsetX: integer - Starting index. + offset: integer + Starting index of `x`. clbk: Function Callback function. @@ -112,7 +113,8 @@ // Using an index offset: > x = [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ]; - > {{alias}}.ndarray( 3, x, 2, 1, accessor ) + > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); + > {{alias}}.ndarray( N, x, 2, 1, accessor ) 8.0 See Also diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/types/index.d.ts index caa6d2312b59..502636524eb1 100644 --- a/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/types/index.d.ts @@ -20,12 +20,7 @@ /// -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Input array. -*/ -type InputArray = Collection | AccessorArrayLike; +import { Collection } from '@stdlib/types/array'; /** * Returns an accessed value. @@ -88,7 +83,7 @@ type Callback = Nullary | Unary | Binary | Ternary | */ interface Routine { /** - * Computes the range of a strided array via a callback function, ignoring `NaN` values. + * Calculates the range of a strided array via a callback function, ignoring `NaN` values. * * ## Notes * @@ -107,7 +102,7 @@ interface Routine { * * @param N - number of indexed elements * @param x - input array - * @param strideX - stride length + * @param stride - stride length * @param clbk - callback * @param thisArg - execution context * @returns range @@ -122,10 +117,10 @@ interface Routine { * var v = nanrangeBy( x.length, x, 1, accessor ); * // returns 18.0 */ - ( N: number, x: InputArray, strideX: number, clbk: Callback, thisArg?: ThisParameterType> ): number; + ( N: number, x: Collection, stride: number, clbk: Callback, thisArg?: ThisParameterType> ): number; /** - * Computes the range of a strided array via a callback function, ignoring `NaN` values and using alternative indexing semantics. + * Calculates the range of a strided array via a callback function, ignoring `NaN` values and using alternative indexing semantics. * * ## Notes * @@ -144,8 +139,8 @@ interface Routine { * * @param N - number of indexed elements * @param x - input array - * @param strideX - stride length - * @param offsetX - starting index + * @param stride - stride length + * @param offset - starting index * @param clbk - callback * @param thisArg - execution context * @returns range @@ -160,11 +155,11 @@ interface Routine { * var v = nanrangeBy.ndarray( x.length, x, 1, 0, accessor ); * // returns 18.0 */ - ndarray( N: number, x: InputArray, strideX: number, offsetX: number, clbk: Callback, thisArg?: ThisParameterType> ): number; + ndarray( N: number, x: Collection, stride: number, offset: number, clbk: Callback, thisArg?: ThisParameterType> ): number; } /** -* Computes the range of a strided array via a callback function, ignoring `NaN` values. +* Calculates the range of a strided array via a callback function, ignoring `NaN` values. * * ## Notes * @@ -183,7 +178,7 @@ interface Routine { * * @param N - number of indexed elements * @param x - input array -* @param strideX - stride length +* @param stride - stride length * @param clbk - callback * @param thisArg - execution context * @returns range diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/types/test.ts b/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/types/test.ts index 309fa8677c85..076af8773ea2 100644 --- a/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/types/test.ts +++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/types/test.ts @@ -16,7 +16,6 @@ * limitations under the License. */ -import AccessorArray = require( '@stdlib/array/base/accessor' ); import nanrangeBy = require( './index' ); const accessor = (): number => { @@ -31,10 +30,7 @@ const accessor = (): number => { const x = new Float64Array( 10 ); nanrangeBy( x.length, x, 1, accessor ); // $ExpectType number - nanrangeBy( x.length, new AccessorArray( x ), 1, accessor ); // $ExpectType number - nanrangeBy( x.length, x, 1, accessor, {} ); // $ExpectType number - nanrangeBy( x.length, new AccessorArray( x ), 1, accessor, {} ); // $ExpectType number } // The compiler throws an error if the function is provided a first argument which is not a number... @@ -74,7 +70,7 @@ const accessor = (): number => { nanrangeBy( x.length, x, undefined, accessor ); // $ExpectError nanrangeBy( x.length, x, [], accessor ); // $ExpectError nanrangeBy( x.length, x, {}, accessor ); // $ExpectError - nanrangeBy( x.length, x, ( x: number ): number => x, accessor ); // $ExpectError + nanrangeBy( x.length, x, ( x: number, accessor ): number => x, accessor ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not a function... @@ -106,10 +102,7 @@ const accessor = (): number => { const x = new Float64Array( 10 ); nanrangeBy.ndarray( x.length, x, 1, 0, accessor ); // $ExpectType number - nanrangeBy.ndarray( x.length, new AccessorArray( x ), 1, 0, accessor ); // $ExpectType number - nanrangeBy.ndarray( x.length, x, 1, 0, accessor, {} ); // $ExpectType number - nanrangeBy.ndarray( x.length, new AccessorArray( x ), 1, 0, accessor, {} ); // $ExpectType number } // The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/examples/index.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/examples/index.js index 6f2b6c34b546..8aaaf469c7a4 100644 --- a/lib/node_modules/@stdlib/stats/base/nanrange-by/examples/index.js +++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/examples/index.js @@ -18,23 +18,23 @@ 'use strict'; -var uniform = require( '@stdlib/random/base/uniform' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var randu = require( '@stdlib/random/base/randu' ); var filledarrayBy = require( '@stdlib/array/filled-by' ); -var bernoulli = require( '@stdlib/random/base/bernoulli' ); var nanrangeBy = require( './../lib' ); -function rand() { - if ( bernoulli( 0.8 ) < 0.2 ) { +function fill() { + if ( randu() < 0.2 ) { return NaN; } - return uniform( -50.0, 50.0 ); + return discreteUniform( -50, 50 ); } function accessor( v ) { return v * 2.0; } -var x = filledarrayBy( 10, 'float64', rand ); +var x = filledarrayBy( 10, 'float64', fill ); console.log( x ); var v = nanrangeBy( x.length, x, 1, accessor ); diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/index.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/index.js index 3ae440117e2e..dfc81b840c2f 100644 --- a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/index.js +++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* Compute the range of a strided array via a callback function and ignoring `NaN` values. +* Calculate the range of a strided array via a callback function and ignoring `NaN` values. * * @module @stdlib/stats/base/nanrange-by * @@ -50,14 +50,7 @@ // MODULES // -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); var main = require( './main.js' ); -var ndarray = require( './ndarray.js' ); - - -// MAIN // - -setReadOnly( main, 'ndarray', ndarray ); // EXPORTS // diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/main.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/main.js index e25596b0f392..806353376607 100644 --- a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/main.js +++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/main.js @@ -20,35 +20,14 @@ // MODULES // -var stride2offset = require( '@stdlib/strided/base/stride2offset' ); +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var nanrangeBy = require( './nanrange_by.js' ); var ndarray = require( './ndarray.js' ); // MAIN // -/** -* Computes the range of a strided array via a callback function, ignoring `NaN` values. -* -* @param {PositiveInteger} N - number of indexed elements -* @param {Collection} x - input array -* @param {integer} strideX - index increment -* @param {Callback} clbk - callback -* @param {*} [thisArg] - execution context -* @returns {number} range -* -* @example -* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, NaN, 0.0, -1.0, -3.0 ]; -* -* function accessor( v ) { -* return v * 2.0; -* } -* -* var v = nanrangeBy( x.length, x, 1, accessor ); -* // returns 18.0 -*/ -function nanrangeBy( N, x, strideX, clbk, thisArg ) { - return ndarray( N, x, strideX, stride2offset( N, strideX ), clbk, thisArg ); -} +setReadOnly( nanrangeBy, 'ndarray', ndarray ); // EXPORTS // diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/nanrange_by.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/nanrange_by.js new file mode 100644 index 000000000000..b7b9dd146f9f --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/nanrange_by.js @@ -0,0 +1,100 @@ +/** +* @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 isnan = require( '@stdlib/math/base/assert/is-nan' ); + + +// MAIN // + +/** +* Calculates the range of a strided array via a callback function, ignoring `NaN` values. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {Collection} x - input array/collection +* @param {integer} stride - index increment +* @param {Callback} clbk - callback +* @param {*} [thisArg] - execution context +* @returns {number} range +* +* @example +* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, NaN, 0.0, -1.0, -3.0 ]; +* +* function accessor( v ) { +* return v * 2.0; +* } +* +* var v = nanrangeBy( x.length, x, 1, accessor ); +* // returns 18.0 +*/ +function nanrangeBy( N, x, stride, clbk, thisArg ) { + var max; + var min; + var ix; + var v; + var i; + + if ( N <= 0 ) { + return NaN; + } + if ( N === 1 || stride === 0 ) { + v = clbk.call( thisArg, x[ 0 ], 0, 0, x ); + if ( v === void 0 || isnan( v ) ) { + return NaN; + } + return 0.0; + } + if ( stride < 0 ) { + ix = (1-N) * stride; + } else { + ix = 0; + } + for ( i = 0; i < N; i++ ) { + min = clbk.call( thisArg, x[ ix ], i, ix, x ); + if ( min === min && min !== void 0 ) { + break; + } + ix += stride; + } + if ( i === N ) { + return NaN; + } + max = min; + i += 1; + for ( i; i < N; i++ ) { + ix += stride; + v = clbk.call( thisArg, x[ ix ], i, ix, x ); + if ( v === void 0 || isnan( v ) ) { + continue; + } + if ( v < min ) { + min = v; + } else if ( v > max ) { + max = v; + } + } + return max - min; +} + + +// EXPORTS // + +module.exports = nanrangeBy; diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/ndarray.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/ndarray.js index 1d517958bcd8..8d7bcbae67df 100644 --- a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/ndarray.js @@ -21,19 +21,17 @@ // MODULES // var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -var accessors = require( './accessors.js' ); // MAIN // /** -* Computes the range of a strided array via a callback function, ignoring `NaN` values. +* Calculates the range of a strided array via a callback function, ignoring `NaN` values. * * @param {PositiveInteger} N - number of indexed elements -* @param {Collection} x - input array -* @param {integer} strideX - stride length -* @param {NonNegativeInteger} offsetX - starting index +* @param {Collection} x - input array/collection +* @param {integer} stride - index increment +* @param {NonNegativeInteger} offset - starting index * @param {Callback} clbk - callback * @param {*} [thisArg] - execution context * @returns {number} range @@ -48,35 +46,30 @@ var accessors = require( './accessors.js' ); * var v = nanrangeBy( x.length, x, 1, 0, accessor ); * // returns 18.0 */ -function nanrangeBy( N, x, strideX, offsetX, clbk, thisArg ) { +function nanrangeBy( N, x, stride, offset, clbk, thisArg ) { var max; var min; var ix; - var o; var v; var i; if ( N <= 0 ) { return NaN; } - o = arraylike2object( x ); - if ( o.accessorProtocol ) { - return accessors( N, o, strideX, offsetX, clbk, thisArg ); - } - if ( N === 1 || strideX === 0 ) { - v = clbk.call( thisArg, x[ offsetX ], 0, offsetX, x ); + if ( N === 1 || stride === 0 ) { + v = clbk.call( thisArg, x[ 0 ], 0, 0, x ); if ( v === void 0 || isnan( v ) ) { return NaN; } return 0.0; } - ix = offsetX; + ix = offset; for ( i = 0; i < N; i++ ) { min = clbk.call( thisArg, x[ ix ], i, ix, x ); if ( min === min && min !== void 0 ) { break; } - ix += strideX; + ix += stride; } if ( i === N ) { return NaN; @@ -84,7 +77,7 @@ function nanrangeBy( N, x, strideX, offsetX, clbk, thisArg ) { max = min; i += 1; for ( i; i < N; i++ ) { - ix += strideX; + ix += stride; v = clbk.call( thisArg, x[ ix ], i, ix, x ); if ( v === void 0 || isnan( v ) ) { continue; diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.nanrange_by.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.nanrange_by.js new file mode 100644 index 000000000000..ce1e4d8fe3ed --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.nanrange_by.js @@ -0,0 +1,233 @@ +/** +* @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 floor = require( '@stdlib/math/base/special/floor' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); +var Float64Array = require( '@stdlib/array/float64' ); +var nanrangeBy = require( './../lib/nanrange_by.js' ); + + +// FUNCTIONS // + +function accessor( v ) { + if ( v === void 0 ) { + return; + } + return v * 2.0; +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof nanrangeBy, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 5', function test( t ) { + t.strictEqual( nanrangeBy.length, 5, 'has expected arity' ); + t.end(); +}); + +tape( 'the function calculates the range of a strided array via a callback function, ignoring NaN values', function test( t ) { + var x; + var v; + + x = [ 1.0, -2.0, -4.0, NaN, 5.0, 0.0, NaN, 3.0 ]; + v = nanrangeBy( x.length, x, 1, accessor ); + t.strictEqual( v, 18.0, 'returns expected value' ); + + x = [ -4.0, NaN, -5.0 ]; + v = nanrangeBy( x.length, x, 1, accessor ); + t.strictEqual( v, 2.0, 'returns expected value' ); + + x = [ -0.0, 0.0, NaN, -0.0 ]; + v = nanrangeBy( x.length, x, 1, accessor ); + t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); + + x = [ NaN ]; + v = nanrangeBy( x.length, x, 1, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + x = [ NaN, NaN ]; + v = nanrangeBy( x.length, x, 1, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + x = new Array( 5 ); // sparse array + v = nanrangeBy( x.length, x, 1, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + x = new Array( 5 ); // sparse array + x[ 2 ] = 1.0; + v = nanrangeBy( x.length, x, 1, accessor ); + t.strictEqual( v, 0.0, '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 = nanrangeBy( 0, x, 1, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + v = nanrangeBy( -1, x, 1, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an `N` parameter equal to `1`, the function returns `0`', function test( t ) { + var x; + var v; + + x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; + + v = nanrangeBy( 1, x, 1, accessor ); + t.strictEqual( v, 0.0, 'returns expected value' ); + + x = new Array( 1 ); // sparse array + v = nanrangeBy( 1, x, 1, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a `stride` parameter', function test( t ) { + var N; + 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, + NaN, // 4 + NaN + ]; + + N = floor( x.length / 2 ); + v = nanrangeBy( N, x, 2, accessor ); + + t.strictEqual( v, 12.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a negative `stride` parameter', function test( t ) { + var N; + var x; + var v; + + x = [ + NaN, // 4 + NaN, + 1.0, // 3 + 2.0, + 2.0, // 2 + -7.0, + -2.0, // 1 + 3.0, + 4.0, // 0 + 2.0 + ]; + + N = floor( x.length / 2 ); + v = nanrangeBy( N, x, -2, accessor ); + + t.strictEqual( v, 12.0, '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 = nanrangeBy( x.length, x, 0, accessor ); + t.strictEqual( v, 0.0, 'returns expected value' ); + + x = new Array( 1 ); // sparse array + v = nanrangeBy( 1, x, 0, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var x0; + var x1; + var N; + 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, + NaN, // 4 + NaN + ]); + + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + N = floor(x1.length / 2); + + v = nanrangeBy( N, x1, 2, accessor ); + t.strictEqual( v, 12.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports providing a callback execution context', function test( t ) { + var ctx; + var x; + + x = [ 1.0, 2.0, 3.0, NaN, 4.0, 5.0 ]; + ctx = { + 'count': 0 + }; + nanrangeBy( x.length, x, 1, accessor, ctx ); + + t.strictEqual( ctx.count, x.length, 'returns expected value' ); + t.end(); + + function accessor( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return v * 2.0; + } +}); diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.ndarray.js index e56dff487a70..33f6c629025d 100644 --- a/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.ndarray.js @@ -21,7 +21,7 @@ // MODULES // var tape = require( 'tape' ); -var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); var nanrangeBy = require( './../lib/ndarray.js' ); @@ -74,11 +74,11 @@ tape( 'the function calculates the range of a strided array via a callback funct v = nanrangeBy( x.length, x, 1, 0, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); - x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array + x = new Array( 5 ); // sparse array v = nanrangeBy( x.length, x, 1, 0, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); - x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array + x = new Array( 5 ); // sparse array x[ 2 ] = 1.0; v = nanrangeBy( x.length, x, 1, 0, accessor ); t.strictEqual( v, 0.0, 'returns expected value' ); @@ -86,42 +86,6 @@ tape( 'the function calculates the range of a strided array via a callback funct t.end(); }); -tape( 'the function calculates the range of a strided array via a callback function, ignoring NaN values (accessors)', function test( t ) { - var x; - var v; - - x = [ 1.0, -2.0, -4.0, NaN, 5.0, 0.0, NaN, 3.0 ]; - v = nanrangeBy( x.length, toAccessorArray( x ), 1, 0, accessor ); - t.strictEqual( v, 18.0, 'returns expected value' ); - - x = [ -4.0, NaN, -5.0 ]; - v = nanrangeBy( x.length, toAccessorArray( x ), 1, 0, accessor ); - t.strictEqual( v, 2.0, 'returns expected value' ); - - x = [ -0.0, 0.0, NaN, -0.0 ]; - v = nanrangeBy( x.length, toAccessorArray( x ), 1, 0, accessor ); - t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); - - x = [ NaN ]; - v = nanrangeBy( x.length, toAccessorArray( x ), 1, 0, accessor ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - x = [ NaN, NaN ]; - v = nanrangeBy( x.length, toAccessorArray( x ), 1, 0, accessor ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array - v = nanrangeBy( x.length, toAccessorArray( x ), 1, 0, accessor ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array - x[ 2 ] = 1.0; - v = nanrangeBy( x.length, toAccessorArray( x ), 1, 0, accessor ); - t.strictEqual( v, 0.0, '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; @@ -137,21 +101,6 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu 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 = nanrangeBy( 0, toAccessorArray( x ), 1, 0, accessor ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - v = nanrangeBy( -1, toAccessorArray( x ), 1, 0, accessor ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - t.end(); -}); - tape( 'if provided an `N` parameter equal to `1`, the function returns `0`', function test( t ) { var x; var v; @@ -161,30 +110,15 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns `0`', fun v = nanrangeBy( 1, x, 1, 0, accessor ); t.strictEqual( v, 0.0, 'returns expected value' ); - x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array + x = new Array( 1 ); // sparse array v = nanrangeBy( 1, x, 1, 0, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); t.end(); }); -tape( 'if provided an `N` parameter equal to `1`, the function returns `0` (accessors)', function test( t ) { - var x; - var v; - - x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; - - v = nanrangeBy( 1, toAccessorArray( x ), 1, 0, accessor ); - t.strictEqual( v, 0.0, 'returns expected value' ); - - x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array - v = nanrangeBy( 1, toAccessorArray( x ), 1, 0, accessor ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - t.end(); -}); - tape( 'the function supports a `stride` parameter', function test( t ) { + var N; var x; var v; @@ -201,36 +135,15 @@ tape( 'the function supports a `stride` parameter', function test( t ) { NaN ]; - v = nanrangeBy( 5, x, 2, 0, accessor ); - - t.strictEqual( v, 12.0, '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, - NaN, // 4 - NaN - ]; - - v = nanrangeBy( 5, toAccessorArray( x ), 2, 0, accessor ); + N = floor( x.length / 2 ); + v = nanrangeBy( N, x, 2, 0, accessor ); t.strictEqual( v, 12.0, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', function test( t ) { + var N; var x; var v; @@ -247,30 +160,8 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) 2.0 ]; - v = nanrangeBy( 5, x, -2, 8, accessor ); - - t.strictEqual( v, 12.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports a negative `stride` parameter (accessors)', function test( t ) { - var x; - var v; - - x = [ - NaN, // 4 - NaN, - 1.0, // 3 - 2.0, - 2.0, // 2 - -7.0, - -2.0, // 1 - 3.0, - 4.0, // 0 - 2.0 - ]; - - v = nanrangeBy( 5, toAccessorArray( x ), -2, 8, accessor ); + N = floor( x.length / 2 ); + v = nanrangeBy( N, x, -2, 8, accessor ); t.strictEqual( v, 12.0, 'returns expected value' ); t.end(); @@ -285,29 +176,13 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`', v = nanrangeBy( x.length, x, 0, 0, accessor ); t.strictEqual( v, 0.0, 'returns expected value' ); - x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array + x = new Array( 1 ); // sparse array v = nanrangeBy( 1, x, 0, 0, accessor ); t.strictEqual( isnan( v ), true, '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 = nanrangeBy( x.length, toAccessorArray( x ), 0, 0, accessor ); - t.strictEqual( v, 0.0, 'returns expected value' ); - - x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array - v = nanrangeBy( 1, toAccessorArray( x ), 0, 0, accessor ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - t.end(); -}); - tape( 'the function supports an offset parameter', function test( t ) { var x; var v; @@ -329,27 +204,6 @@ tape( 'the function supports an offset parameter', function test( t ) { t.end(); }); -tape( 'the function supports an offset parameter (accessors)', function test( t ) { - var x; - var v; - - x = [ - 1.0, - -2.0, // 0 - 3.0, - 4.0, // 1 - 5.0, - -6.0, // 2 - NaN, - NaN // 3 - ]; - - v = nanrangeBy( 4, toAccessorArray( x ), 2, 1, accessor ); - t.strictEqual( v, 20.0, 'returns expected value' ); - - t.end(); -}); - tape( 'the function supports providing a callback execution context', function test( t ) { var ctx; var x; @@ -368,22 +222,3 @@ tape( 'the function supports providing a callback execution context', function t return v * 2.0; } }); - -tape( 'the function supports providing a callback execution context (accessors)', function test( t ) { - var ctx; - var x; - - x = [ 1.0, 2.0, 3.0, NaN, 4.0, 5.0 ]; - ctx = { - 'count': 0 - }; - nanrangeBy( x.length, toAccessorArray( x ), 1, 0, accessor, ctx ); - - t.strictEqual( ctx.count, x.length, 'returns expected value' ); - t.end(); - - function accessor( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * 2.0; - } -}); diff --git a/lib/node_modules/@stdlib/stats/base/range-by/lib/accessors.js b/lib/node_modules/@stdlib/stats/base/range-by/lib/accessors.js index 85bfabd0bb72..d9f95e3aa0d6 100644 --- a/lib/node_modules/@stdlib/stats/base/range-by/lib/accessors.js +++ b/lib/node_modules/@stdlib/stats/base/range-by/lib/accessors.js @@ -67,7 +67,7 @@ function rangeBy( N, x, strideX, offsetX, clbk, thisArg) { get = x.accessors[ 0 ]; if ( N === 1 || strideX === 0 ) { - v = clbk.call( thisArg, get( xbuf, offsetX ), 0, offsetX, xbuf ); + v = clbk.call( thisArg, get( xbuf, offsetX ), 0, offsetX, x ); if ( v === void 0 || isnan( v ) ) { return NaN; } @@ -75,7 +75,7 @@ function rangeBy( N, x, strideX, offsetX, clbk, thisArg) { } ix = offsetX; for ( i = 0; i < N; i++ ) { - min = clbk.call( thisArg, get( xbuf, ix ), i, ix, xbuf ); + min = clbk.call( thisArg, get( xbuf, ix ), i, ix, x ); if ( min !== void 0 ) { break; } @@ -88,7 +88,7 @@ function rangeBy( N, x, strideX, offsetX, clbk, thisArg) { i += 1; for ( i; i < N; i++ ) { ix += strideX; - v = clbk.call( thisArg, get( xbuf, ix ), i, ix, xbuf ); + v = clbk.call( thisArg, get( xbuf, ix ), i, ix, x ); if ( v === void 0 ) { continue; } diff --git a/lib/node_modules/@stdlib/stats/base/stdevtk/README.md b/lib/node_modules/@stdlib/stats/base/stdevtk/README.md index 6938a102f913..0e59c49720c7 100644 --- a/lib/node_modules/@stdlib/stats/base/stdevtk/README.md +++ b/lib/node_modules/@stdlib/stats/base/stdevtk/README.md @@ -98,9 +98,9 @@ The use of the term `n-1` is commonly referred to as Bessel's correction. Note, var stdevtk = require( '@stdlib/stats/base/stdevtk' ); ``` -#### stdevtk( N, correction, x, strideX ) +#### stdevtk( N, correction, x, stride ) -Computes the [standard deviation][standard-deviation] of a strided array using a one-pass textbook algorithm. +Computes the [standard deviation][standard-deviation] of a strided array `x` using a one-pass textbook algorithm. ```javascript var x = [ 1.0, -2.0, 2.0 ]; @@ -114,14 +114,17 @@ The function has the following parameters: - **N**: number of indexed elements. - **correction**: degrees of freedom adjustment. Setting this parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the [standard deviation][standard-deviation] according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the [standard deviation][standard-deviation] of a population, setting this parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the corrected sample [standard deviation][standard-deviation], setting this parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction). - **x**: input [`Array`][mdn-array] or [`typed array`][mdn-typed-array]. -- **strideX**: stride length for `x`. +- **stride**: index increment for `x`. -The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute the [standard deviation][standard-deviation] of every other element in `x`, +The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to compute the [standard deviation][standard-deviation] of every other element in `x`, ```javascript +var floor = require( '@stdlib/math/base/special/floor' ); + var x = [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0 ]; +var N = floor( x.length / 2 ); -var v = stdevtk( 4, 1, x, 2 ); +var v = stdevtk( N, 1, x, 2 ); // returns 2.5 ``` @@ -131,15 +134,18 @@ Note that indexing is relative to the first index. To introduce an offset, use [ ```javascript var Float64Array = require( '@stdlib/array/float64' ); +var floor = require( '@stdlib/math/base/special/floor' ); var x0 = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element -var v = stdevtk( 4, 1, x1, 2 ); +var N = floor( x0.length / 2 ); + +var v = stdevtk( N, 1, x1, 2 ); // returns 2.5 ``` -#### stdevtk.ndarray( N, correction, x, strideX, offsetX ) +#### stdevtk.ndarray( N, correction, x, stride, offset ) Computes the [standard deviation][standard-deviation] of a strided array using a one-pass textbook algorithm and alternative indexing semantics. @@ -152,14 +158,17 @@ var v = stdevtk.ndarray( x.length, 1, x, 1, 0 ); The function has the following additional parameters: -- **offsetX**: starting index for `x`. +- **offset**: starting index for `x`. -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 calculate the [standard deviation][standard-deviation] for every other element in `x` starting from the second element +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 calculate the [standard deviation][standard-deviation] for every other value in `x` starting from the second value ```javascript +var floor = require( '@stdlib/math/base/special/floor' ); + var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ]; +var N = floor( x.length / 2 ); -var v = stdevtk.ndarray( 4, 1, x, 2, 1 ); +var v = stdevtk.ndarray( N, 1, x, 2, 1 ); // returns 2.5 ``` @@ -173,7 +182,6 @@ var v = stdevtk.ndarray( 4, 1, x, 2, 1 ); - If `N <= 0`, both functions return `NaN`. - If `N - c` is less than or equal to `0` (where `c` corresponds to the provided degrees of freedom adjustment), both functions return `NaN`. -- Both functions support array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array/base/accessor`][@stdlib/array/base/accessor]). - Some caution should be exercised when using the one-pass textbook algorithm. Literature overwhelmingly discourages the algorithm's use for two reasons: 1) the lack of safeguards against underflow and overflow and 2) the risk of catastrophic cancellation when subtracting the two sums if the sums are large and the variance small. These concerns have merit; however, the one-pass textbook algorithm should not be dismissed outright. For data distributions with a moderately large standard deviation to mean ratio (i.e., **coefficient of variation**), the one-pass textbook algorithm may be acceptable, especially when performance is paramount and some precision loss is acceptable (including a risk of computing a negative variance due to floating-point rounding errors!). In short, no single "best" algorithm for computing the standard deviation exists. The "best" algorithm depends on the underlying data distribution, your performance requirements, and your minimum precision requirements. When evaluating which algorithm to use, consider the relative pros and cons, and choose the algorithm which best serves your needs. - Depending on the environment, the typed versions ([`dstdevtk`][@stdlib/stats/strided/dstdevtk], [`sstdevtk`][@stdlib/stats/strided/sstdevtk], etc.) are likely to be significantly more performant. @@ -188,12 +196,18 @@ var v = stdevtk.ndarray( 4, 1, x, 2, 1 ); ```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var randu = require( '@stdlib/random/base/randu' ); +var round = require( '@stdlib/math/base/special/round' ); +var Float64Array = require( '@stdlib/array/float64' ); var stdevtk = require( '@stdlib/stats/base/stdevtk' ); -var x = discreteUniform( 10, -50, 50, { - 'dtype': 'float64' -}); +var x; +var i; + +x = new Float64Array( 10 ); +for ( i = 0; i < x.length; i++ ) { + x[ i ] = round( (randu()*100.0) - 50.0 ); +} console.log( x ); var v = stdevtk( x.length, 1, x, 1 ); @@ -244,8 +258,6 @@ console.log( v ); [mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray -[@stdlib/array/base/accessor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor - [@ling:1974a]: https://doi.org/10.2307/2286154 diff --git a/lib/node_modules/@stdlib/stats/base/stdevtk/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/stdevtk/benchmark/benchmark.js index 2e1903c37627..79becfb3cb76 100644 --- a/lib/node_modules/@stdlib/stats/base/stdevtk/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/stdevtk/benchmark/benchmark.js @@ -21,20 +21,13 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/array/uniform' ); +var randu = require( '@stdlib/random/base/randu' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); var pkg = require( './../package.json' ).name; var stdevtk = require( './../lib/stdevtk.js' ); -// VARIABLES // - -var options = { - 'dtype': 'generic' -}; - - // FUNCTIONS // /** @@ -45,7 +38,13 @@ var options = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x = uniform( len, -10, 10, options ); + var x; + var i; + + x = []; + for ( i = 0; i < len; i++ ) { + x.push( ( randu()*20.0 ) - 10.0 ); + } return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/stdevtk/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/base/stdevtk/benchmark/benchmark.ndarray.js index 78dd1cda8b58..650b6dbb7e04 100644 --- a/lib/node_modules/@stdlib/stats/base/stdevtk/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/stdevtk/benchmark/benchmark.ndarray.js @@ -21,20 +21,13 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/array/uniform' ); +var randu = require( '@stdlib/random/base/randu' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); var pkg = require( './../package.json' ).name; var stdevtk = require( './../lib/ndarray.js' ); -// VARIABLES // - -var options = { - 'dtype': 'generic' -}; - - // FUNCTIONS // /** @@ -45,7 +38,13 @@ var options = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x = uniform( len, -10, 10, options ); + var x; + var i; + + x = []; + for ( i = 0; i < len; i++ ) { + x.push( ( randu()*20.0 ) - 10.0 ); + } return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/stdevtk/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/stdevtk/docs/repl.txt index e6c3c0df8536..86088980cd3f 100644 --- a/lib/node_modules/@stdlib/stats/base/stdevtk/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/stdevtk/docs/repl.txt @@ -1,10 +1,10 @@ -{{alias}}( N, correction, x, strideX ) +{{alias}}( N, correction, x, stride ) Computes the standard deviation of a strided array using a one-pass textbook algorithm. - The `N` and stride parameters determine which elements in the strided array - are accessed at runtime. + The `N` and `stride` parameters determine which elements in `x` are accessed + at runtime. Indexing is relative to the first index. To introduce an offset, use a typed array view. @@ -31,8 +31,8 @@ x: Array|TypedArray Input array. - strideX: integer - Stride length. + stride: integer + Index increment. Returns ------- @@ -46,24 +46,27 @@ > {{alias}}( x.length, 1, x, 1 ) ~2.0817 - // Using `N` and stride parameters: + // Using `N` and `stride` parameters: > x = [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ]; - > {{alias}}( 3, 1, x, 2 ) + > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); + > var stride = 2; + > {{alias}}( N, 1, x, stride ) ~2.0817 // Using view offsets: > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] ); > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); - > {{alias}}( 3, 1, x1, 2 ) + > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); + > stride = 2; + > {{alias}}( N, 1, x1, stride ) ~2.0817 - -{{alias}}.ndarray( N, correction, x, strideX, offsetX ) +{{alias}}.ndarray( N, correction, x, stride, offset ) Computes the standard deviation of a strided array using a one-pass textbook algorithm and alternative indexing semantics. While typed array views mandate a view offset based on the underlying - buffer, the offset parameter supports indexing semantics based on a + buffer, the `offset` parameter supports indexing semantics based on a starting index. Parameters @@ -86,10 +89,10 @@ x: Array|TypedArray Input array. - strideX: integer - Stride length. + stride: integer + Index increment. - offsetX: integer + offset: integer Starting index. Returns @@ -105,8 +108,9 @@ ~2.0817 // Using offset parameter: - > x = [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ]; - > {{alias}}.ndarray( 3, 1, x, 2, 1 ) + > var x = [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ]; + > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); + > {{alias}}.ndarray( N, 1, x, 2, 1 ) ~2.0817 See Also diff --git a/lib/node_modules/@stdlib/stats/base/stdevtk/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/stdevtk/docs/types/index.d.ts index b6c4e80db65d..2fe3bd7e76a3 100644 --- a/lib/node_modules/@stdlib/stats/base/stdevtk/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/base/stdevtk/docs/types/index.d.ts @@ -20,12 +20,7 @@ /// -import { NumericArray, Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Input array. -*/ -type InputArray = NumericArray | Collection | AccessorArrayLike; +import { NumericArray } from '@stdlib/types/array'; /** * Interface describing `stdevtk`. @@ -37,7 +32,7 @@ interface Routine { * @param N - number of indexed elements * @param correction - degrees of freedom adjustment * @param x - input array - * @param strideX - stride length + * @param stride - stride length * @returns standard deviation * * @example @@ -46,7 +41,7 @@ interface Routine { * var v = stdevtk( x.length, 1, x, 1 ); * // returns ~2.0817 */ - ( N: number, correction: number, x: InputArray, strideX: number ): number; + ( N: number, correction: number, x: NumericArray, stride: number ): number; /** * Computes the standard deviation of a strided array using a one-pass textbook algorithm and alternative indexing semantics. @@ -54,8 +49,8 @@ interface Routine { * @param N - number of indexed elements * @param correction - degrees of freedom adjustment * @param x - input array - * @param strideX - stride length - * @param offsetX - starting index + * @param stride - stride length + * @param offset - starting index * @returns standard deviation * * @example @@ -64,7 +59,7 @@ interface Routine { * var v = stdevtk.ndarray( x.length, 1, x, 1, 0 ); * // returns ~2.0817 */ - ndarray( N: number, correction: number, x: InputArray, strideX: number, offsetX: number ): number; + ndarray( N: number, correction: number, x: NumericArray, stride: number, offset: number ): number; } /** @@ -73,7 +68,7 @@ interface Routine { * @param N - number of indexed elements * @param correction - degrees of freedom adjustment * @param x - input array -* @param strideX - stride length +* @param stride - stride length * @returns standard deviation * * @example diff --git a/lib/node_modules/@stdlib/stats/base/stdevtk/docs/types/test.ts b/lib/node_modules/@stdlib/stats/base/stdevtk/docs/types/test.ts index 986a15560347..2d4f6d658130 100644 --- a/lib/node_modules/@stdlib/stats/base/stdevtk/docs/types/test.ts +++ b/lib/node_modules/@stdlib/stats/base/stdevtk/docs/types/test.ts @@ -16,7 +16,6 @@ * limitations under the License. */ -import AccessorArray = require( '@stdlib/array/base/accessor' ); import stdevtk = require( './index' ); @@ -27,7 +26,6 @@ import stdevtk = require( './index' ); const x = new Float64Array( 10 ); stdevtk( x.length, 1, x, 1 ); // $ExpectType number - stdevtk( x.length, 1, new AccessorArray( x ), 1 ); // $ExpectType number } // The compiler throws an error if the function is provided a first argument which is not a number... @@ -103,7 +101,6 @@ import stdevtk = require( './index' ); const x = new Float64Array( 10 ); stdevtk.ndarray( x.length, 1, x, 1, 0 ); // $ExpectType number - stdevtk.ndarray( x.length, 1, new AccessorArray( x ), 1, 0 ); // $ExpectType number } // The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... diff --git a/lib/node_modules/@stdlib/stats/base/stdevtk/examples/index.js b/lib/node_modules/@stdlib/stats/base/stdevtk/examples/index.js index da580e627f03..38701368fe61 100644 --- a/lib/node_modules/@stdlib/stats/base/stdevtk/examples/index.js +++ b/lib/node_modules/@stdlib/stats/base/stdevtk/examples/index.js @@ -18,12 +18,18 @@ 'use strict'; -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var randu = require( '@stdlib/random/base/randu' ); +var round = require( '@stdlib/math/base/special/round' ); +var Float64Array = require( '@stdlib/array/float64' ); var stdevtk = require( './../lib' ); -var x = discreteUniform( 10, -50, 50, { - 'dtype': 'float64' -}); +var x; +var i; + +x = new Float64Array( 10 ); +for ( i = 0; i < x.length; i++ ) { + x[ i ] = round( (randu()*100.0) - 50.0 ); +} console.log( x ); var v = stdevtk( x.length, 1, x, 1 ); diff --git a/lib/node_modules/@stdlib/stats/base/stdevtk/lib/ndarray.js b/lib/node_modules/@stdlib/stats/base/stdevtk/lib/ndarray.js index c04f982c1599..5cb715873769 100644 --- a/lib/node_modules/@stdlib/stats/base/stdevtk/lib/ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/stdevtk/lib/ndarray.js @@ -32,18 +32,21 @@ var sqrt = require( '@stdlib/math/base/special/sqrt' ); * @param {PositiveInteger} N - number of indexed elements * @param {number} correction - degrees of freedom adjustment * @param {NumericArray} x - input array -* @param {integer} strideX - stride length -* @param {NonNegativeInteger} offsetX - starting index +* @param {integer} stride - stride length +* @param {NonNegativeInteger} offset - starting index * @returns {number} standard deviation * * @example +* var floor = require( '@stdlib/math/base/special/floor' ); +* * var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ]; +* var N = floor( x.length / 2 ); * -* var v = stdevtk( 4, 1, x, 2, 1 ); +* var v = stdevtk( N, 1, x, 2, 1 ); * // returns 2.5 */ -function stdevtk( N, correction, x, strideX, offsetX ) { - return sqrt( variancetk( N, correction, x, strideX, offsetX ) ); +function stdevtk( N, correction, x, stride, offset ) { + return sqrt( variancetk( N, correction, x, stride, offset ) ); } diff --git a/lib/node_modules/@stdlib/stats/base/stdevtk/lib/stdevtk.js b/lib/node_modules/@stdlib/stats/base/stdevtk/lib/stdevtk.js index 1996cbc367f6..1a06a7e809d5 100644 --- a/lib/node_modules/@stdlib/stats/base/stdevtk/lib/stdevtk.js +++ b/lib/node_modules/@stdlib/stats/base/stdevtk/lib/stdevtk.js @@ -20,8 +20,8 @@ // MODULES // -var stride2offset = require( '@stdlib/strided/base/stride2offset' ); -var ndarray = require( './ndarray.js' ); +var variancetk = require( '@stdlib/stats/strided/variancetk' ); +var sqrt = require( '@stdlib/math/base/special/sqrt' ); // MAIN // @@ -32,7 +32,7 @@ var ndarray = require( './ndarray.js' ); * @param {PositiveInteger} N - number of indexed elements * @param {number} correction - degrees of freedom adjustment * @param {NumericArray} x - input array -* @param {integer} strideX - stride length +* @param {integer} stride - stride length * @returns {number} standard deviation * * @example @@ -41,8 +41,8 @@ var ndarray = require( './ndarray.js' ); * var v = stdevtk( x.length, 1, x, 1 ); * // returns ~2.0817 */ -function stdevtk( N, correction, x, strideX ) { - return ndarray( N, correction, x, strideX, stride2offset( N, strideX ) ); +function stdevtk( N, correction, x, stride ) { + return sqrt( variancetk( N, correction, x, stride ) ); } diff --git a/lib/node_modules/@stdlib/stats/base/stdevtk/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/stdevtk/test/test.ndarray.js index 94a864ec748e..4164fa0da840 100644 --- a/lib/node_modules/@stdlib/stats/base/stdevtk/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/stdevtk/test/test.ndarray.js @@ -21,9 +21,9 @@ // MODULES // var tape = require( 'tape' ); +var floor = require( '@stdlib/math/base/special/floor' ); var sqrt = require( '@stdlib/math/base/special/sqrt' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); var stdevtk = require( './../lib/ndarray.js' ); @@ -59,25 +59,6 @@ tape( 'the function calculates the population standard deviation of a strided ar 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 = stdevtk( x.length, 0, toAccessorArray( x ), 1, 0 ); - t.strictEqual( v, sqrt( 53.5/x.length ), 'returns expected value' ); - - x = [ -4.0, -4.0 ]; - v = stdevtk( x.length, 0, toAccessorArray( x ), 1, 0 ); - t.strictEqual( v, 0.0, 'returns expected value' ); - - x = [ NaN, 4.0 ]; - v = stdevtk( x.length, 0, toAccessorArray( x ), 1, 0 ); - 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; @@ -97,25 +78,6 @@ tape( 'the function calculates the sample standard deviation of a strided array' 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 = stdevtk( x.length, 1, toAccessorArray( x ), 1, 0 ); - t.strictEqual( v, sqrt( 53.5/(x.length-1) ), 'returns expected value' ); - - x = [ -4.0, -4.0 ]; - v = stdevtk( x.length, 1, toAccessorArray( x ), 1, 0 ); - t.strictEqual( v, 0.0, 'returns expected value' ); - - x = [ NaN, 4.0 ]; - v = stdevtk( x.length, 1, toAccessorArray( x ), 1, 0 ); - 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; @@ -131,21 +93,6 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu 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 = stdevtk( 0, 1, toAccessorArray( x ), 1, 0 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - v = stdevtk( -1, 1, toAccessorArray( x ), 1, 0 ); - 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; @@ -158,18 +105,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns a populat 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 = stdevtk( 1, 0, toAccessorArray( x ), 1, 0 ); - 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; @@ -185,22 +120,8 @@ tape( 'if provided a `correction` parameter yielding `N-correction` less than or 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 = stdevtk( x.length, x.length, toAccessorArray( x ), 1, 0 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - v = stdevtk( x.length, x.length+1, toAccessorArray( x ), 1, 0 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - t.end(); -}); - tape( 'the function supports a `stride` parameter', function test( t ) { + var N; var x; var v; @@ -215,34 +136,15 @@ tape( 'the function supports a `stride` parameter', function test( t ) { 2.0 ]; - v = stdevtk( 4, 1, x, 2, 0 ); - - 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 = stdevtk( 4, 1, toAccessorArray( x ), 2, 0 ); + N = floor( x.length / 2 ); + v = stdevtk( N, 1, x, 2, 0 ); t.strictEqual( v, 2.5, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', function test( t ) { + var N; var x; var v; @@ -257,28 +159,8 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) 2.0 ]; - v = stdevtk( 4, 1, x, -2, 6 ); - - 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 = stdevtk( 4, 1, toAccessorArray( x ), -2, 6 ); + N = floor( x.length / 2 ); + v = stdevtk( N, 1, x, -2, 6 ); t.strictEqual( v, 2.5, 'returns expected value' ); t.end(); @@ -296,19 +178,8 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`', 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 = stdevtk( x.length, 1, toAccessorArray( x ), 0, 0 ); - t.strictEqual( v, 0.0, 'returns expected value' ); - - t.end(); -}); - tape( 'the function supports an `offset` parameter', function test( t ) { + var N; var x; var v; @@ -322,29 +193,9 @@ tape( 'the function supports an `offset` parameter', function test( t ) { 3.0, 4.0 // 3 ]; + N = floor( x.length / 2 ); - v = stdevtk( 4, 1, x, 2, 1 ); - t.strictEqual( v, 2.5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports an `offset` parameter (accessors)', function test( t ) { - var x; - var v; - - x = [ - 2.0, - 1.0, // 0 - 2.0, - -2.0, // 1 - -2.0, - 2.0, // 2 - 3.0, - 4.0 // 3 - ]; - - v = stdevtk( 4, 1, toAccessorArray( x ), 2, 1 ); + v = stdevtk( N, 1, x, 2, 1 ); t.strictEqual( v, 2.5, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/stats/base/stdevtk/test/test.stdevtk.js b/lib/node_modules/@stdlib/stats/base/stdevtk/test/test.stdevtk.js index 9c430ae508e4..24287634d6e4 100644 --- a/lib/node_modules/@stdlib/stats/base/stdevtk/test/test.stdevtk.js +++ b/lib/node_modules/@stdlib/stats/base/stdevtk/test/test.stdevtk.js @@ -21,10 +21,10 @@ // MODULES // var tape = require( 'tape' ); +var floor = require( '@stdlib/math/base/special/floor' ); 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 stdevtk = require( './../lib/stdevtk.js' ); @@ -60,25 +60,6 @@ tape( 'the function calculates the population standard deviation of a strided ar 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 = stdevtk( x.length, 0, toAccessorArray( x ), 1 ); - t.strictEqual( v, sqrt( 53.5/x.length ), 'returns expected value' ); - - x = [ -4.0, -4.0 ]; - v = stdevtk( x.length, 0, toAccessorArray( x ), 1 ); - t.strictEqual( v, 0.0, 'returns expected value' ); - - x = [ NaN, 4.0 ]; - v = stdevtk( 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; @@ -98,25 +79,6 @@ tape( 'the function calculates the sample standard deviation of a strided array' 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 = stdevtk( x.length, 1, toAccessorArray( x ), 1 ); - t.strictEqual( v, sqrt( 53.5/(x.length-1) ), 'returns expected value' ); - - x = [ -4.0, -4.0 ]; - v = stdevtk( x.length, 1, toAccessorArray( x ), 1 ); - t.strictEqual( v, 0.0, 'returns expected value' ); - - x = [ NaN, 4.0 ]; - v = stdevtk( 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; @@ -132,21 +94,6 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu 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 = stdevtk( 0, 1, toAccessorArray( x ), 1 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - v = stdevtk( -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; @@ -159,18 +106,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns a populat 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 = stdevtk( 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; @@ -186,22 +121,8 @@ tape( 'if provided a `correction` parameter yielding `N-correction` less than or 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 = stdevtk( x.length, x.length, toAccessorArray( x ), 1 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - v = stdevtk( 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 N; var x; var v; @@ -216,34 +137,15 @@ tape( 'the function supports a `stride` parameter', function test( t ) { 2.0 ]; - v = stdevtk( 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 = stdevtk( 4, 1, toAccessorArray( x ), 2 ); + N = floor( x.length / 2 ); + v = stdevtk( N, 1, x, 2 ); t.strictEqual( v, 2.5, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', function test( t ) { + var N; var x; var v; @@ -258,28 +160,8 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) 2.0 ]; - v = stdevtk( 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 = stdevtk( 4, 1, toAccessorArray( x ), -2 ); + N = floor( x.length / 2 ); + v = stdevtk( N, 1, x, -2 ); t.strictEqual( v, 2.5, 'returns expected value' ); t.end(); @@ -297,21 +179,10 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`', 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 = stdevtk( 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 N; var v; x0 = new Float64Array([ @@ -327,33 +198,9 @@ tape( 'the function supports view offsets', function test( t ) { ]); x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + N = floor(x1.length / 2); - v = stdevtk( 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 = stdevtk( 4, 1, toAccessorArray( x1 ), 2 ); + v = stdevtk( N, 1, x1, 2 ); t.strictEqual( v, 2.5, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/stats/base/stdevwd/README.md b/lib/node_modules/@stdlib/stats/base/stdevwd/README.md index a87eb8f7fdf7..dacfdb543972 100644 --- a/lib/node_modules/@stdlib/stats/base/stdevwd/README.md +++ b/lib/node_modules/@stdlib/stats/base/stdevwd/README.md @@ -98,9 +98,9 @@ The use of the term `n-1` is commonly referred to as Bessel's correction. Note, var stdevwd = require( '@stdlib/stats/base/stdevwd' ); ``` -#### stdevwd( N, correction, x, strideX ) +#### stdevwd( N, correction, x, stride ) -Computes the [standard deviation][standard-deviation] of a strided array using Welford's algorithm. +Computes the [standard deviation][standard-deviation] of a strided array `x` using Welford's algorithm. ```javascript var x = [ 1.0, -2.0, 2.0 ]; @@ -114,14 +114,17 @@ The function has the following parameters: - **N**: number of indexed elements. - **correction**: degrees of freedom adjustment. Setting this parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the [standard deviation][standard-deviation] according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the [standard deviation][standard-deviation] of a population, setting this parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the corrected sample [standard deviation][standard-deviation], setting this parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction). - **x**: input [`Array`][mdn-array] or [`typed array`][mdn-typed-array]. -- **strideX**: stride length for `x`. +- **stride**: index increment for `x`. -The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute the [standard deviation][standard-deviation] of every other element in `x`, +The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to compute the [standard deviation][standard-deviation] of every other element in `x`, ```javascript +var floor = require( '@stdlib/math/base/special/floor' ); + var x = [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0 ]; +var N = floor( x.length / 2 ); -var v = stdevwd( 4, 1, x, 2 ); +var v = stdevwd( N, 1, x, 2 ); // returns 2.5 ``` @@ -131,15 +134,18 @@ Note that indexing is relative to the first index. To introduce an offset, use [ ```javascript var Float64Array = require( '@stdlib/array/float64' ); +var floor = require( '@stdlib/math/base/special/floor' ); var x0 = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element -var v = stdevwd( 4, 1, x1, 2 ); +var N = floor( x0.length / 2 ); + +var v = stdevwd( N, 1, x1, 2 ); // returns 2.5 ``` -#### stdevwd.ndarray( N, correction, x, strideX, offsetX ) +#### stdevwd.ndarray( N, correction, x, stride, offset ) Computes the [standard deviation][standard-deviation] of a strided array using Welford's algorithm and alternative indexing semantics. @@ -152,14 +158,17 @@ var v = stdevwd.ndarray( x.length, 1, x, 1, 0 ); The function has the following additional parameters: -- **offsetX**: starting index for `x`. +- **offset**: starting index for `x`. -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 calculate the [standard deviation][standard-deviation] for every other element in the strided array starting from the second element +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 calculate the [standard deviation][standard-deviation] for every other value in `x` starting from the second value ```javascript +var floor = require( '@stdlib/math/base/special/floor' ); + var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ]; +var N = floor( x.length / 2 ); -var v = stdevwd.ndarray( 4, 1, x, 2, 1 ); +var v = stdevwd.ndarray( N, 1, x, 2, 1 ); // returns 2.5 ``` @@ -173,7 +182,6 @@ var v = stdevwd.ndarray( 4, 1, x, 2, 1 ); - If `N <= 0`, both functions return `NaN`. - If `N - c` is less than or equal to `0` (where `c` corresponds to the provided degrees of freedom adjustment), both functions return `NaN`. -- Both functions support array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array/base/accessor`][@stdlib/array/base/accessor]). - Depending on the environment, the typed versions ([`dstdevwd`][@stdlib/stats/strided/dstdevwd], [`sstdevwd`][@stdlib/stats/base/sstdevwd], etc.) are likely to be significantly more performant. @@ -187,12 +195,18 @@ var v = stdevwd.ndarray( 4, 1, x, 2, 1 ); ```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var randu = require( '@stdlib/random/base/randu' ); +var round = require( '@stdlib/math/base/special/round' ); +var Float64Array = require( '@stdlib/array/float64' ); var stdevwd = require( '@stdlib/stats/base/stdevwd' ); -var x = discreteUniform( 10, -50, 50, { - 'dtype': 'float64' -}); +var x; +var i; + +x = new Float64Array( 10 ); +for ( i = 0; i < x.length; i++ ) { + x[ i ] = round( (randu()*100.0) - 50.0 ); +} console.log( x ); var v = stdevwd( x.length, 1, x, 1 ); @@ -244,8 +258,6 @@ console.log( v ); [mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray -[@stdlib/array/base/accessor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor - [@welford:1962a]: https://doi.org/10.1080/00401706.1962.10490022 [@vanreeken:1968a]: https://doi.org/10.1145/362929.362961 diff --git a/lib/node_modules/@stdlib/stats/base/stdevwd/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/stdevwd/benchmark/benchmark.js index 1dce7798ef99..73ebd0677e56 100644 --- a/lib/node_modules/@stdlib/stats/base/stdevwd/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/stdevwd/benchmark/benchmark.js @@ -21,18 +21,11 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/array/uniform' ); +var randu = require( '@stdlib/random/base/randu' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); var pkg = require( './../package.json' ).name; -var stdevwd = require( './../lib/main.js' ); - - -// VARIABLES // - -var options = { - 'dtype': 'generic' -}; +var stdevwd = require( './../lib/stdevwd.js' ); // FUNCTIONS // @@ -45,7 +38,13 @@ var options = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x = uniform( len, -10, 10, options ); + var x; + var i; + + x = []; + for ( i = 0; i < len; i++ ) { + x.push( ( randu()*20.0 ) - 10.0 ); + } return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/stdevwd/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/base/stdevwd/benchmark/benchmark.ndarray.js index a35722b0a1a0..040cda910a37 100644 --- a/lib/node_modules/@stdlib/stats/base/stdevwd/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/stdevwd/benchmark/benchmark.ndarray.js @@ -21,20 +21,13 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/array/uniform' ); +var randu = require( '@stdlib/random/base/randu' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); var pkg = require( './../package.json' ).name; var stdevwd = require( './../lib/ndarray.js' ); -// VARIABLES // - -var options = { - 'dtype': 'generic' -}; - - // FUNCTIONS // /** @@ -45,7 +38,13 @@ var options = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x = uniform( len, -10, 10, options ); + var x; + var i; + + x = []; + for ( i = 0; i < len; i++ ) { + x.push( ( randu()*20.0 ) - 10.0 ); + } return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/stdevwd/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/stdevwd/docs/repl.txt index 8bc6ec26f103..97e16cd66337 100644 --- a/lib/node_modules/@stdlib/stats/base/stdevwd/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/stdevwd/docs/repl.txt @@ -1,10 +1,10 @@ -{{alias}}( N, correction, x, strideX ) +{{alias}}( N, correction, x, stride ) Computes the standard deviation of a strided array using Welford's algorithm. - The `N` and stride parameters determine which elements in the strided array - are accessed at runtime. + The `N` and `stride` parameters determine which elements in `x` are accessed + at runtime. Indexing is relative to the first index. To introduce an offset, use a typed array view. @@ -31,8 +31,8 @@ x: Array|TypedArray Input array. - strideX: integer - Stride length. + stride: integer + Index increment. Returns ------- @@ -46,24 +46,27 @@ > {{alias}}( x.length, 1, x, 1 ) ~2.0817 - // Using `N` and stride parameters: + // Using `N` and `stride` parameters: > x = [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ]; - > {{alias}}( 3, 1, x, 2 ) + > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); + > var stride = 2; + > {{alias}}( N, 1, x, stride ) ~2.0817 // Using view offsets: > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] ); > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); - > {{alias}}( 3, 1, x1, 2 ) + > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); + > stride = 2; + > {{alias}}( N, 1, x1, stride ) ~2.0817 - -{{alias}}.ndarray( N, correction, x, strideX, offsetX ) +{{alias}}.ndarray( N, correction, x, stride, offset ) Computes the standard deviation of a strided array using Welford's algorithm and alternative indexing semantics. While typed array views mandate a view offset based on the underlying - buffer, the offset parameter supports indexing semantics based on a + buffer, the `offset` parameter supports indexing semantics based on a starting index. Parameters @@ -86,10 +89,10 @@ x: Array|TypedArray Input array. - strideX: integer - Stride length. + stride: integer + Index increment. - offsetX: integer + offset: integer Starting index. Returns @@ -105,8 +108,9 @@ ~2.0817 // Using offset parameter: - > x = [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ]; - > {{alias}}.ndarray( 3, 1, x, 2, 1 ) + > var x = [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ]; + > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); + > {{alias}}.ndarray( N, 1, x, 2, 1 ) ~2.0817 See Also diff --git a/lib/node_modules/@stdlib/stats/base/stdevwd/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/stdevwd/docs/types/index.d.ts index 74822c77fe45..5d2ae57995a1 100644 --- a/lib/node_modules/@stdlib/stats/base/stdevwd/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/base/stdevwd/docs/types/index.d.ts @@ -20,12 +20,7 @@ /// -import { NumericArray, Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Input array. -*/ -type InputArray = NumericArray | Collection | AccessorArrayLike; +import { NumericArray } from '@stdlib/types/array'; /** * Interface describing `stdevwd`. @@ -37,7 +32,7 @@ interface Routine { * @param N - number of indexed elements * @param correction - degrees of freedom adjustment * @param x - input array - * @param strideX - stride length + * @param stride - stride length * @returns standard deviation * * @example @@ -46,7 +41,7 @@ interface Routine { * var v = stdevwd( x.length, 1, x, 1 ); * // returns ~2.0817 */ - ( N: number, correction: number, x: InputArray, strideX: number ): number; + ( N: number, correction: number, x: NumericArray, stride: number ): number; /** * Computes the standard deviation of a strided array using Welford's algorithm and alternative indexing semantics. @@ -54,8 +49,8 @@ interface Routine { * @param N - number of indexed elements * @param correction - degrees of freedom adjustment * @param x - input array - * @param strideX - stride length - * @param offsetX - starting index + * @param stride - stride length + * @param offset - starting index * @returns standard deviation * * @example @@ -64,7 +59,7 @@ interface Routine { * var v = stdevwd.ndarray( x.length, 1, x, 1, 0 ); * // returns ~2.0817 */ - ndarray( N: number, correction: number, x: InputArray, strideX: number, offsetX: number ): number; + ndarray( N: number, correction: number, x: NumericArray, stride: number, offset: number ): number; } /** @@ -73,7 +68,7 @@ interface Routine { * @param N - number of indexed elements * @param correction - degrees of freedom adjustment * @param x - input array -* @param strideX - stride length +* @param stride - stride length * @returns standard deviation * * @example diff --git a/lib/node_modules/@stdlib/stats/base/stdevwd/docs/types/test.ts b/lib/node_modules/@stdlib/stats/base/stdevwd/docs/types/test.ts index f4d526b751ab..2af2b66461f1 100644 --- a/lib/node_modules/@stdlib/stats/base/stdevwd/docs/types/test.ts +++ b/lib/node_modules/@stdlib/stats/base/stdevwd/docs/types/test.ts @@ -16,7 +16,6 @@ * limitations under the License. */ -import AccessorArray = require( '@stdlib/array/base/accessor' ); import stdevwd = require( './index' ); @@ -27,7 +26,6 @@ import stdevwd = require( './index' ); const x = new Float64Array( 10 ); stdevwd( x.length, 1, x, 1 ); // $ExpectType number - stdevwd( x.length, 1, new AccessorArray( x ), 1 ); // $ExpectType number } // The compiler throws an error if the function is provided a first argument which is not a number... @@ -103,7 +101,6 @@ import stdevwd = require( './index' ); const x = new Float64Array( 10 ); stdevwd.ndarray( x.length, 1, x, 1, 0 ); // $ExpectType number - stdevwd.ndarray( x.length, 1, new AccessorArray( x ), 1, 0 ); // $ExpectType number } // The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... diff --git a/lib/node_modules/@stdlib/stats/base/stdevwd/examples/index.js b/lib/node_modules/@stdlib/stats/base/stdevwd/examples/index.js index 1e15a9bef0e2..02ea6cb7e1a2 100644 --- a/lib/node_modules/@stdlib/stats/base/stdevwd/examples/index.js +++ b/lib/node_modules/@stdlib/stats/base/stdevwd/examples/index.js @@ -18,12 +18,18 @@ 'use strict'; -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var randu = require( '@stdlib/random/base/randu' ); +var round = require( '@stdlib/math/base/special/round' ); +var Float64Array = require( '@stdlib/array/float64' ); var stdevwd = require( './../lib' ); -var x = discreteUniform( 10, -50, 50, { - 'dtype': 'float64' -}); +var x; +var i; + +x = new Float64Array( 10 ); +for ( i = 0; i < x.length; i++ ) { + x[ i ] = round( (randu()*100.0) - 50.0 ); +} console.log( x ); var v = stdevwd( x.length, 1, x, 1 ); diff --git a/lib/node_modules/@stdlib/stats/base/stdevwd/lib/index.js b/lib/node_modules/@stdlib/stats/base/stdevwd/lib/index.js index 0c8641bb089a..3d31b99ba6a7 100644 --- a/lib/node_modules/@stdlib/stats/base/stdevwd/lib/index.js +++ b/lib/node_modules/@stdlib/stats/base/stdevwd/lib/index.js @@ -32,11 +32,13 @@ * // returns ~2.0817 * * @example +* var floor = require( '@stdlib/math/base/special/floor' ); * var stdevwd = require( '@stdlib/stats/base/stdevwd' ); * * var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ]; +* var N = floor( x.length / 2 ); * -* var v = stdevwd.ndarray( 4, 1, x, 2, 1 ); +* var v = stdevwd.ndarray( N, 1, x, 2, 1 ); * // returns 2.5 */ diff --git a/lib/node_modules/@stdlib/stats/base/stdevwd/lib/ndarray.js b/lib/node_modules/@stdlib/stats/base/stdevwd/lib/ndarray.js index c279156b14b0..f31809bdc91f 100644 --- a/lib/node_modules/@stdlib/stats/base/stdevwd/lib/ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/stdevwd/lib/ndarray.js @@ -37,18 +37,21 @@ var sqrt = require( '@stdlib/math/base/special/sqrt' ); * @param {PositiveInteger} N - number of indexed elements * @param {number} correction - degrees of freedom adjustment * @param {NumericArray} x - input array -* @param {integer} strideX - stride length -* @param {NonNegativeInteger} offsetX - starting index +* @param {integer} stride - stride length +* @param {NonNegativeInteger} offset - starting index * @returns {number} standard deviation * * @example +* var floor = require( '@stdlib/math/base/special/floor' ); +* * var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ]; +* var N = floor( x.length / 2 ); * -* var v = stdevwd( 4, 1, x, 2, 1 ); +* var v = stdevwd( N, 1, x, 2, 1 ); * // returns 2.5 */ -function stdevwd( N, correction, x, strideX, offsetX ) { - return sqrt( variancewd( N, correction, x, strideX, offsetX ) ); +function stdevwd( N, correction, x, stride, offset ) { + return sqrt( variancewd( N, correction, x, stride, offset ) ); } diff --git a/lib/node_modules/@stdlib/stats/base/stdevwd/lib/stdevwd.js b/lib/node_modules/@stdlib/stats/base/stdevwd/lib/stdevwd.js index 91c2e166ae6f..326eaf7f016d 100644 --- a/lib/node_modules/@stdlib/stats/base/stdevwd/lib/stdevwd.js +++ b/lib/node_modules/@stdlib/stats/base/stdevwd/lib/stdevwd.js @@ -20,8 +20,8 @@ // MODULES // -var stride2offset = require( '@stdlib/strided/base/stride2offset' ); -var ndarray = require( './ndarray.js' ); +var variancewd = require( '@stdlib/stats/strided/variancewd' ); +var sqrt = require( '@stdlib/math/base/special/sqrt' ); // MAIN // @@ -37,7 +37,7 @@ var ndarray = require( './ndarray.js' ); * @param {PositiveInteger} N - number of indexed elements * @param {number} correction - degrees of freedom adjustment * @param {NumericArray} x - input array -* @param {integer} strideX - stride length +* @param {integer} stride - stride length * @returns {number} standard deviation * * @example @@ -46,8 +46,8 @@ var ndarray = require( './ndarray.js' ); * var v = stdevwd( x.length, 1, x, 1 ); * // returns ~2.0817 */ -function stdevwd( N, correction, x, strideX ) { - return ndarray( N, correction, x, strideX, stride2offset( N, strideX ) ); +function stdevwd( N, correction, x, stride ) { + return sqrt( variancewd( N, correction, x, stride ) ); } diff --git a/lib/node_modules/@stdlib/stats/base/stdevwd/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/stdevwd/test/test.ndarray.js index 18ee231bed15..0b5022acab72 100644 --- a/lib/node_modules/@stdlib/stats/base/stdevwd/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/stdevwd/test/test.ndarray.js @@ -21,9 +21,9 @@ // MODULES // var tape = require( 'tape' ); +var floor = require( '@stdlib/math/base/special/floor' ); var sqrt = require( '@stdlib/math/base/special/sqrt' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); var stdevwd = require( './../lib/ndarray.js' ); @@ -59,25 +59,6 @@ tape( 'the function calculates the population standard deviation of a strided ar 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, 0 ); - t.strictEqual( v, sqrt( 53.5/x.length ), 'returns expected value' ); - - x = [ -4.0, -4.0 ]; - v = stdevwd( x.length, 0, toAccessorArray( x ), 1, 0 ); - t.strictEqual( v, 0.0, 'returns expected value' ); - - x = [ NaN, 4.0 ]; - v = stdevwd( x.length, 0, toAccessorArray( x ), 1, 0 ); - 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; @@ -97,25 +78,6 @@ tape( 'the function calculates the sample standard deviation of a strided array' 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, 0 ); - 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, 0 ); - t.strictEqual( v, 0.0, 'returns expected value' ); - - x = [ NaN, 4.0 ]; - v = stdevwd( x.length, 1, toAccessorArray( x ), 1, 0 ); - 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; @@ -131,21 +93,6 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu 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, 0 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - v = stdevwd( -1, 1, toAccessorArray( x ), 1, 0 ); - 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; @@ -158,18 +105,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns a populat 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, 0 ); - 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; @@ -185,22 +120,8 @@ tape( 'if provided a `correction` parameter yielding `N-correction` less than or 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, 0 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - v = stdevwd( x.length, x.length+1, toAccessorArray( x ), 1, 0 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - t.end(); -}); - tape( 'the function supports a `stride` parameter', function test( t ) { + var N; var x; var v; @@ -215,34 +136,15 @@ tape( 'the function supports a `stride` parameter', function test( t ) { 2.0 ]; - v = stdevwd( 4, 1, x, 2, 0 ); - - 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, 0 ); + N = floor( x.length / 2 ); + v = stdevwd( N, 1, x, 2, 0 ); t.strictEqual( v, 2.5, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', function test( t ) { + var N; var x; var v; @@ -257,28 +159,8 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) 2.0 ]; - v = stdevwd( 4, 1, x, -2, 6 ); - - 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, 6 ); + N = floor( x.length / 2 ); + v = stdevwd( N, 1, x, -2, 6 ); t.strictEqual( v, 2.5, 'returns expected value' ); t.end(); @@ -296,19 +178,8 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`', 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, 0 ); - t.strictEqual( v, 0.0, 'returns expected value' ); - - t.end(); -}); - tape( 'the function supports an `offset` parameter', function test( t ) { + var N; var x; var v; @@ -322,29 +193,9 @@ tape( 'the function supports an `offset` parameter', function test( t ) { 3.0, 4.0 // 3 ]; + N = floor( x.length / 2 ); - v = stdevwd( 4, 1, x, 2, 1 ); - t.strictEqual( v, 2.5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports an `offset` parameter (accessors)', function test( t ) { - var x; - var v; - - x = [ - 2.0, - 1.0, // 0 - 2.0, - -2.0, // 1 - -2.0, - 2.0, // 2 - 3.0, - 4.0 // 3 - ]; - - v = stdevwd( 4, 1, toAccessorArray( x ), 2, 1 ); + v = stdevwd( N, 1, x, 2, 1 ); t.strictEqual( v, 2.5, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/stats/base/stdevwd/test/test.stdevwd.js b/lib/node_modules/@stdlib/stats/base/stdevwd/test/test.stdevwd.js new file mode 100644 index 000000000000..dcf840ce4032 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/stdevwd/test/test.stdevwd.js @@ -0,0 +1,207 @@ +/** +* @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 floor = require( '@stdlib/math/base/special/floor' ); +var sqrt = require( '@stdlib/math/base/special/sqrt' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var Float64Array = require( '@stdlib/array/float64' ); +var stdevwd = require( './../lib/stdevwd.js' ); + + +// 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 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( '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 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 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( 'the function supports a `stride` parameter', function test( t ) { + var N; + 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 + ]; + + N = floor( x.length / 2 ); + v = stdevwd( N, 1, x, 2 ); + + t.strictEqual( v, 2.5, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a negative `stride` parameter', function test( t ) { + var N; + 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 + ]; + + N = floor( x.length / 2 ); + v = stdevwd( N, 1, 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( 'the function supports view offsets', function test( t ) { + var x0; + var x1; + var N; + 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 + N = floor(x1.length / 2); + + v = stdevwd( N, 1, x1, 2 ); + t.strictEqual( v, 2.5, 'returns expected value' ); + + t.end(); +}); From 6a5b0905b528e0ad1258ed34d6c6e158e63baca3 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Wed, 9 Jul 2025 10:37:50 +0530 Subject: [PATCH 34/34] chore: revert unintended changes in stats/base --- lib/node_modules/@stdlib/stats/base/README.md | 16 +- .../stats/base/dists/bradford/cdf/README.md | 6 +- .../cdf/benchmark/benchmark.native.js | 19 +- .../bradford/cdf/benchmark/c/benchmark.c | 11 +- .../base/dists/bradford/cdf/docs/repl.txt | 4 +- .../dists/bradford/cdf/docs/types/index.d.ts | 6 +- .../base/dists/bradford/cdf/lib/factory.js | 9 +- .../base/dists/bradford/cdf/lib/index.js | 6 +- .../stats/base/dists/bradford/cdf/lib/main.js | 6 +- .../dists/bradford/cdf/test/test.native.js | 34 ++-- .../bradford/entropy/benchmark/c/benchmark.c | 11 +- .../base/dists/bradford/entropy/lib/main.js | 5 +- .../base/dists/bradford/entropy/src/main.c | 5 +- .../bradford/entropy/test/test.native.js | 52 ++++-- .../mean/benchmark/benchmark.native.js | 16 +- .../bradford/mean/benchmark/c/benchmark.c | 11 +- .../base/dists/bradford/mean/docs/repl.txt | 4 +- .../base/dists/bradford/mean/lib/main.js | 5 +- .../stats/base/dists/bradford/mean/src/main.c | 5 +- .../base/dists/bradford/mean/test/test.js | 4 +- .../bradford/mode/benchmark/c/benchmark.c | 11 +- .../base/dists/bradford/mode/lib/main.js | 5 +- .../base/dists/bradford/mode/lib/native.js | 4 +- .../stats/base/dists/bradford/mode/src/main.c | 5 +- .../dists/bradford/mode/test/test.native.js | 40 ++-- .../pdf/benchmark/benchmark.native.js | 19 +- .../bradford/pdf/benchmark/c/benchmark.c | 11 +- .../base/dists/bradford/pdf/lib/factory.js | 10 +- .../stats/base/dists/bradford/pdf/lib/main.js | 7 +- .../stats/base/dists/bradford/pdf/src/main.c | 8 +- .../quantile/benchmark/benchmark.native.js | 19 +- .../bradford/quantile/benchmark/c/benchmark.c | 11 +- .../dists/bradford/quantile/lib/factory.js | 11 +- .../base/dists/bradford/quantile/lib/main.js | 8 +- .../bradford/quantile/test/test.native.js | 2 +- .../bradford/stdev/benchmark/c/benchmark.c | 11 +- .../base/dists/bradford/stdev/lib/main.js | 5 +- .../base/dists/bradford/stdev/lib/native.js | 4 +- .../base/dists/bradford/stdev/src/main.c | 7 +- .../dists/chi/entropy/test/test.native.js | 2 +- .../chisquare/kurtosis/test/test.native.js | 2 +- .../dists/cosine/mean/test/test.native.js | 2 +- .../stdev/test/test.native.js | 2 +- .../exponential/entropy/test/test.native.js | 2 +- .../geometric/kurtosis/test/test.native.js | 2 +- .../base/dists/kumaraswamy/quantile/README.md | 23 +-- .../kumaraswamy/quantile/examples/index.js | 18 +- .../dists/laplace/mean/test/test.native.js | 2 +- .../kurtosis/test/test.native.js | 2 +- .../variance/test/test.native.js | 2 +- .../dists/planck/entropy/test/test.native.js | 2 +- .../stats/base/dists/poisson/cdf/README.md | 55 +++--- .../dists/poisson/cdf/benchmark/benchmark.js | 40 ++-- .../poisson/cdf/benchmark/benchmark.native.js | 14 +- .../base/dists/poisson/cdf/examples/index.js | 19 +- .../stats/base/dists/poisson/cdf/lib/main.js | 5 +- .../stats/base/dists/poisson/cdf/src/main.c | 5 +- .../base/dists/uniform/entropy/test/test.js | 2 +- .../@stdlib/stats/base/docs/types/index.d.ts | 138 -------------- .../@stdlib/stats/base/lib/index.js | 36 ---- .../stats/base/ndarray/drange/README.md | 116 ++++++++++++ .../ndarray/drange/benchmark/benchmark.js | 102 +++++++++++ .../stats/base/ndarray/drange/docs/repl.txt | 32 ++++ .../base/ndarray/drange/docs/types/index.d.ts | 46 +++++ .../base/ndarray/drange/docs/types/test.ts | 57 ++++++ .../base/ndarray/drange/examples/index.js | 33 ++++ .../stats/base/ndarray/drange/lib/index.js | 45 +++++ .../stats/base/ndarray/drange/lib/main.js | 56 ++++++ .../stats/base/ndarray/drange/package.json | 71 +++++++ .../stats/base/ndarray/drange/test/test.js | 173 ++++++++++++++++++ .../stats/base/ndarray/range/README.md | 115 ++++++++++++ .../base/ndarray/range/benchmark/benchmark.js | 102 +++++++++++ .../stats/base/ndarray/range/docs/repl.txt | 31 ++++ .../base/ndarray/range/docs/types/index.d.ts | 45 +++++ .../base/ndarray/range/docs/types/test.ts | 57 ++++++ .../base/ndarray/range/examples/index.js | 33 ++++ .../stats/base/ndarray/range/lib/index.js | 44 +++++ .../stats/base/ndarray/range/lib/main.js | 55 ++++++ .../stats/base/ndarray/range/package.json | 69 +++++++ .../stats/base/ndarray/range/test/test.js | 172 +++++++++++++++++ .../stats/base/ndarray/srange/README.md | 116 ++++++++++++ .../ndarray/srange/benchmark/benchmark.js | 102 +++++++++++ .../stats/base/ndarray/srange/docs/repl.txt | 32 ++++ .../base/ndarray/srange/docs/types/index.d.ts | 46 +++++ .../base/ndarray/srange/docs/types/test.ts | 57 ++++++ .../base/ndarray/srange/examples/index.js | 33 ++++ .../stats/base/ndarray/srange/lib/index.js | 45 +++++ .../stats/base/ndarray/srange/lib/main.js | 56 ++++++ .../stats/base/ndarray/srange/package.json | 71 +++++++ .../stats/base/ndarray/srange/test/test.js | 173 ++++++++++++++++++ .../@stdlib/stats/base/stdevtk/README.md | 46 ++--- .../stats/base/stdevtk/benchmark/benchmark.js | 17 +- .../stdevtk/benchmark/benchmark.ndarray.js | 17 +- .../@stdlib/stats/base/stdevtk/docs/repl.txt | 36 ++-- .../stats/base/stdevtk/docs/types/index.d.ts | 19 +- .../stats/base/stdevtk/docs/types/test.ts | 3 + .../stats/base/stdevtk/examples/index.js | 14 +- .../@stdlib/stats/base/stdevtk/lib/ndarray.js | 13 +- .../@stdlib/stats/base/stdevtk/lib/stdevtk.js | 10 +- .../stats/base/stdevtk/test/test.ndarray.js | 169 ++++++++++++++++- .../stats/base/stdevtk/test/test.stdevtk.js | 173 +++++++++++++++++- .../@stdlib/stats/base/stdevwd/README.md | 46 ++--- .../stats/base/stdevwd/benchmark/benchmark.js | 19 +- .../stdevwd/benchmark/benchmark.ndarray.js | 17 +- .../@stdlib/stats/base/stdevwd/docs/repl.txt | 36 ++-- .../stats/base/stdevwd/docs/types/index.d.ts | 19 +- .../stats/base/stdevwd/docs/types/test.ts | 3 + .../stats/base/stdevwd/examples/index.js | 14 +- .../@stdlib/stats/base/stdevwd/lib/index.js | 4 +- .../@stdlib/stats/base/stdevwd/lib/ndarray.js | 13 +- .../@stdlib/stats/base/stdevwd/lib/stdevwd.js | 10 +- .../stats/base/stdevwd/test/test.ndarray.js | 169 ++++++++++++++++- 112 files changed, 3080 insertions(+), 780 deletions(-) create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/drange/README.md create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/drange/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/drange/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/drange/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/drange/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/drange/examples/index.js create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/drange/lib/index.js create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/drange/lib/main.js create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/drange/package.json create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/drange/test/test.js create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/range/README.md create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/range/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/range/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/range/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/range/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/range/examples/index.js create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/range/lib/index.js create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/range/lib/main.js create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/range/package.json create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/range/test/test.js create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/srange/README.md create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/srange/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/srange/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/srange/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/srange/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/srange/examples/index.js create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/srange/lib/index.js create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/srange/lib/main.js create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/srange/package.json create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/srange/test/test.js diff --git a/lib/node_modules/@stdlib/stats/base/README.md b/lib/node_modules/@stdlib/stats/base/README.md index 232aeb473b93..839ada64ff2b 100644 --- a/lib/node_modules/@stdlib/stats/base/README.md +++ b/lib/node_modules/@stdlib/stats/base/README.md @@ -64,8 +64,8 @@ The namespace contains the following statistical functions: - [`nanmskmax( N, x, strideX, mask, strideMask )`][@stdlib/stats/strided/nanmskmax]: calculate the maximum value of a strided array according to a mask, ignoring `NaN` values. - [`nanmskmin( N, x, strideX, mask, strideMask )`][@stdlib/stats/strided/nanmskmin]: calculate the minimum value of a strided array according to a mask, ignoring `NaN` values. - [`nanmskrange( N, x, strideX, mask, strideMask )`][@stdlib/stats/strided/nanmskrange]: calculate the range of a strided array according to a mask, ignoring `NaN` values. -- [`nanrangeBy( N, x, stride, clbk[, thisArg] )`][@stdlib/stats/base/nanrange-by]: calculate the range of a strided array via a callback function, ignoring `NaN` values. -- [`nanrange( N, x, strideX )`][@stdlib/stats/base/nanrange]: calculate the range of a strided array, ignoring `NaN` values. +- [`nanrangeBy( N, x, stride, clbk[, thisArg] )`][@stdlib/stats/strided/nanrange-by]: calculate the range of a strided array via a callback function, ignoring `NaN` values. +- [`nanrange( N, x, strideX )`][@stdlib/stats/strided/nanrange]: calculate the range of a strided array, ignoring `NaN` values. - [`nanstdev( N, correction, x, strideX )`][@stdlib/stats/base/nanstdev]: calculate the standard deviation of a strided array ignoring `NaN` values. - [`nanstdevch( N, correction, x, stride )`][@stdlib/stats/base/nanstdevch]: calculate the standard deviation of a strided array ignoring `NaN` values and using a one-pass trial mean algorithm. - [`nanstdevpn( N, correction, x, strideX )`][@stdlib/stats/base/nanstdevpn]: calculate the standard deviation of a strided array ignoring `NaN` values and using a two-pass algorithm. @@ -79,8 +79,8 @@ The namespace contains the following statistical functions: - [`nanvariancewd( N, correction, x, strideX )`][@stdlib/stats/base/nanvariancewd]: calculate the variance of a strided array ignoring `NaN` values and using Welford's algorithm. - [`nanvarianceyc( N, correction, x, strideX )`][@stdlib/stats/base/nanvarianceyc]: calculate the variance of a strided array ignoring `NaN` values and using a one-pass algorithm proposed by Youngs and Cramer. - [`ndarray`][@stdlib/stats/base/ndarray]: base ndarray statistical functions. -- [`rangeBy( N, x, stride, clbk[, thisArg] )`][@stdlib/stats/base/range-by]: calculate the range of a strided array via a callback function. -- [`range( N, x, strideX )`][@stdlib/stats/base/range]: calculate the range of a strided array. +- [`rangeBy( N, x, stride, clbk[, thisArg] )`][@stdlib/stats/strided/range-by]: calculate the range of a strided array via a callback function. +- [`range( N, x, strideX )`][@stdlib/stats/strided/range]: calculate the range of a strided array. - [`sdsnanmean( N, x, stride )`][@stdlib/stats/base/sdsnanmean]: calculate the arithmetic mean of a single-precision floating-point strided array, ignoring `NaN` values and using extended accumulation. - [`sdsnanmeanors( N, x, stride )`][@stdlib/stats/base/sdsnanmeanors]: calculate the arithmetic mean of a single-precision floating-point strided array, ignoring `NaN` values and using ordinary recursive summation with extended accumulation. - [`smeankbn( N, x, stride )`][@stdlib/stats/strided/smeankbn]: calculate the arithmetic mean of a single-precision floating-point strided array using an improved Kahan–Babuška algorithm. @@ -177,9 +177,9 @@ console.log( objectKeys( ns ) ); [@stdlib/stats/strided/nanmskrange]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/strided/nanmskrange -[@stdlib/stats/base/nanrange-by]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/nanrange-by +[@stdlib/stats/strided/nanrange-by]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/strided/nanrange-by -[@stdlib/stats/base/nanrange]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/nanrange +[@stdlib/stats/strided/nanrange]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/strided/nanrange [@stdlib/stats/base/nanstdev]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/nanstdev @@ -207,9 +207,9 @@ console.log( objectKeys( ns ) ); [@stdlib/stats/base/ndarray]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/ndarray -[@stdlib/stats/base/range-by]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/range-by +[@stdlib/stats/strided/range-by]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/strided/range-by -[@stdlib/stats/base/range]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/range +[@stdlib/stats/strided/range]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/strided/range [@stdlib/stats/base/sdsnanmean]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/sdsnanmean diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/cdf/README.md b/lib/node_modules/@stdlib/stats/base/dists/bradford/cdf/README.md index b67273c5abfd..a4140a7fe208 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bradford/cdf/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/cdf/README.md @@ -99,11 +99,11 @@ y = cdf( 0.5, -5.0 ); Returns a function for evaluating the [CDF][cdf] of a [Bradford][bradford-distribution] distribution with shape parameter `c`. ```javascript -var myPDF = cdf.factory( 5.0 ); -var y = myPDF( 0.5 ); +var myCDF = cdf.factory( 5.0 ); +var y = myCDF( 0.5 ); // returns ~0.699 -y = myPDF( 1.0 ); +y = myCDF( 1.0 ); // returns 1.0 ``` diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/cdf/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/bradford/cdf/benchmark/benchmark.native.js index 1f2eb0980f0c..2184bc03bc99 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bradford/cdf/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/cdf/benchmark/benchmark.native.js @@ -22,8 +22,7 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array/float64' ); -var uniform = require( '@stdlib/random/base/uniform' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -40,23 +39,21 @@ var opts = { // MAIN // bench( pkg+'::native', opts, function benchmark( b ) { - var len; + var opts; var x; var c; var y; var i; - len = 100; - x = new Float64Array( len ); - c = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - x[ i ] = uniform( 0.0, 1.0 ); - c[ i ] = uniform( 0.1, 10.0 ); - } + opts = { + 'dtype': 'float64' + }; + x = uniform( 100, 0.0, 1.0, opts ); + c = uniform( 100, 0.1, 10.0, opts ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = cdf( x[ i % len ], c[ i % len ] ); + y = cdf( x[ i % x.length ], c[ i % c.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/cdf/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/stats/base/dists/bradford/cdf/benchmark/c/benchmark.c index 55fc86571330..782f3a396e54 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bradford/cdf/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/cdf/benchmark/c/benchmark.c @@ -100,13 +100,10 @@ static double benchmark( void ) { double y; int i; - // Generate test data: for ( i = 0; i < 100; i++ ) { x[ i ] = random_uniform( 0.0, 1.0 ); c[ i ] = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 10.0 ); } - - // Run the benchmark: t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { y = stdlib_base_dists_bradford_cdf( x[ i % 100 ], c[ i % 100 ] ); @@ -127,21 +124,17 @@ static double benchmark( void ) { */ int main( void ) { double elapsed; - int count; int i; // Use the current time to seed the pseudorandom number generator: srand( time( NULL ) ); print_version(); - count = 0; for ( i = 0; i < REPEATS; i++ ) { - count += 1; printf( "# c::%s\n", NAME ); elapsed = benchmark(); - printf( "ok %d benchmark finished\n", count ); print_results( elapsed ); - printf( "\n" ); + printf( "ok %d benchmark finished\n", i+1 ); } - print_summary( count, count ); + print_summary( REPEATS, REPEATS ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/cdf/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/dists/bradford/cdf/docs/repl.txt index 40ba4eb7bf4f..5c69f386d98f 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bradford/cdf/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/cdf/docs/repl.txt @@ -45,8 +45,8 @@ {{alias}}.factory( c ) - Returns a function for evaluating the cumulative distribution function - (CDF) of a Bradford distribution with shape parameter `c`. + Returns a function for evaluating the cumulative distribution function (CDF) + of a Bradford distribution with shape parameter `c`. Parameters ---------- diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/cdf/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/dists/bradford/cdf/docs/types/index.d.ts index 049e7babd208..35fb3aadcb40 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bradford/cdf/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/cdf/docs/types/index.d.ts @@ -87,11 +87,11 @@ interface CDF { * @returns CDF * * @example - * var mypdf = cdf.factory( 5.0 ); - * var y = mypdf( 0.5 ); + * var mycdf = cdf.factory( 5.0 ); + * var y = mycdf( 0.5 ); * // returns ~0.699 * - * y = mypdf( 1.0 ); + * y = mycdf( 1.0 ); * // returns 1.0 */ factory( c: number ): Unary; diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/cdf/lib/factory.js b/lib/node_modules/@stdlib/stats/base/dists/bradford/cdf/lib/factory.js index 648fa752d921..ec2ee407da36 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bradford/cdf/lib/factory.js +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/cdf/lib/factory.js @@ -42,10 +42,7 @@ var log1p = require( '@stdlib/math/base/special/log1p' ); * // returns 1.0 */ function factory( c ) { - if ( - isnan( c ) || - c <= 0.0 - ) { + if ( isnan( c ) || c <= 0.0 ) { return constantFunction( NaN ); } return cdf; @@ -62,9 +59,7 @@ function factory( c ) { * // returns */ function cdf( x ) { - if ( - isnan( x ) - ) { + if ( isnan( x ) ) { return NaN; } if ( x <= 0.0 ) { diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/cdf/lib/index.js b/lib/node_modules/@stdlib/stats/base/dists/bradford/cdf/lib/index.js index dfc2916567ef..f9d00916bd6a 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bradford/cdf/lib/index.js +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/cdf/lib/index.js @@ -29,11 +29,11 @@ * var y = cdf( 0.5, 5.0 ); * // returns ~0.699 * -* var myPDF = cdf.factory( 5.0 ); -* y = myPDF( 0.5 ); +* var myCDF = cdf.factory( 5.0 ); +* y = myCDF( 0.5 ); * // returns ~0.699 * -* y = myPDF( 1.0 ); +* y = myCDF( 1.0 ); * // returns 1.0 */ diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/cdf/lib/main.js b/lib/node_modules/@stdlib/stats/base/dists/bradford/cdf/lib/main.js index 66802a2d1dba..f3b647b7cedc 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bradford/cdf/lib/main.js +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/cdf/lib/main.js @@ -70,11 +70,7 @@ var log1p = require( '@stdlib/math/base/special/log1p' ); * // returns NaN */ function cdf( x, c ) { - if ( - isnan( c ) || - isnan( x ) || - c <= 0.0 - ) { + if ( isnan( c ) || isnan( x ) || c <= 0.0 ) { return NaN; } if ( x <= 0.0 ) { diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/cdf/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/bradford/cdf/test/test.native.js index d42e86961b2b..8f42f6cd57b7 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bradford/cdf/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/cdf/test/test.native.js @@ -80,32 +80,38 @@ tape( 'if provided `c <= 0`, the function returns `NaN`', opts, function test( t t.end(); }); -tape( 'if provided `x <= 0` and a valid `c`, the function returns `0`', opts, function test( t ) { +tape( 'if provided a number greater than or equal to one for `x` and a finite `c`, the function returns `1`', opts, function test( t ) { var y; - y = cdf( 0.0, 1.0 ); - t.equal( y, 0.0, 'returns expected value' ); + y = cdf( PINF, 0.5 ); + t.equal( y, 1.0, 'returns expected value' ); - y = cdf( -0.5, 1.0 ); - t.equal( y, 0.0, 'returns expected value' ); + y = cdf( 100.0, 0.5 ); + t.equal( y, 1.0, 'returns expected value' ); - y = cdf( NINF, 1.0 ); - t.equal( y, 0.0, 'returns expected value' ); + y = cdf( 10.0, 0.5 ); + t.equal( y, 1.0, 'returns expected value' ); + + y = cdf( 1.0, 0.5 ); + t.equal( y, 1.0, 'returns expected value' ); t.end(); }); -tape( 'if provided `x >= 1` and a valid `c`, the function returns `1`', opts, function test( t ) { +tape( 'if provided a number less than or equal to zero for `x` and a finite `c`, the function returns `0`', opts, function test( t ) { var y; - y = cdf( 1.0, 1.0 ); - t.equal( y, 1.0, 'returns expected value' ); + y = cdf( NINF, 0.5 ); + t.equal( y, 0.0, 'returns expected value' ); - y = cdf( 2.0, 1.0 ); - t.equal( y, 1.0, 'returns expected value' ); + y = cdf( -100.0, 0.5 ); + t.equal( y, 0.0, 'returns expected value' ); - y = cdf( PINF, 1.0 ); - t.equal( y, 1.0, 'returns expected value' ); + y = cdf( -1.0, 0.5 ); + t.equal( y, 0.0, 'returns expected value' ); + + y = cdf( 0.0, 0.5 ); + t.equal( y, 0.0, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/entropy/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/stats/base/dists/bradford/entropy/benchmark/c/benchmark.c index b67a9eb1cfa6..2e3fa4acdf1e 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bradford/entropy/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/entropy/benchmark/c/benchmark.c @@ -99,12 +99,9 @@ static double benchmark( void ) { double y; int i; - // Generate test data: for ( i = 0; i < 100; i++ ) { c[ i ] = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 10.0 ); } - - // Run the benchmark: t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { y = stdlib_base_dists_bradford_entropy( c[ i % 100 ] ); @@ -125,21 +122,17 @@ static double benchmark( void ) { */ int main( void ) { double elapsed; - int count; int i; // Use the current time to seed the pseudorandom number generator: srand( time( NULL ) ); print_version(); - count = 0; for ( i = 0; i < REPEATS; i++ ) { - count += 1; printf( "# c::%s\n", NAME ); elapsed = benchmark(); - printf( "ok %d benchmark finished\n", count ); print_results( elapsed ); - printf( "\n" ); + printf( "ok %d benchmark finished\n", i+1 ); } - print_summary( count, count ); + print_summary( REPEATS, REPEATS ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/entropy/lib/main.js b/lib/node_modules/@stdlib/stats/base/dists/bradford/entropy/lib/main.js index 8bb6ada8f0c8..68b6f4ed2597 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bradford/entropy/lib/main.js +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/entropy/lib/main.js @@ -58,10 +58,7 @@ var ln = require( '@stdlib/math/base/special/ln' ); */ function entropy( c ) { var k; - if ( - isnan( c ) || - c <= 0.0 - ) { + if ( isnan( c ) || c <= 0.0 ) { return NaN; } k = ln( 1.0 + c ); diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/entropy/src/main.c b/lib/node_modules/@stdlib/stats/base/dists/bradford/entropy/src/main.c index 66173059aa59..4a5b93cfe82f 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bradford/entropy/src/main.c +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/entropy/src/main.c @@ -32,10 +32,7 @@ */ double stdlib_base_dists_bradford_entropy( const double c ) { double k; - if ( - stdlib_base_is_nan( c ) || - c <= 0.0 - ) { + if ( stdlib_base_is_nan( c ) || c <= 0.0 ) { return 0.0/0.0; // NaN } k = stdlib_base_ln( 1.0 + c ); diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/entropy/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/bradford/entropy/test/test.native.js index 7093993ebead..7c0add73a454 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bradford/entropy/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/entropy/test/test.native.js @@ -24,6 +24,7 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var abs = require( '@stdlib/math/base/special/abs' ); +var NINF = require( '@stdlib/constants/float64/ninf' ); var EPS = require( '@stdlib/constants/float64/eps' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -38,7 +39,8 @@ var opts = { // FIXTURES // -var data = require( './fixtures/python/small_c.json' ); +var smallC = require( './fixtures/python/small_c.json' ); +var largeC = require( './fixtures/python/large_c.json' ); // TESTS // @@ -55,35 +57,61 @@ tape( 'the function returns `NaN` if provided `NaN`', opts, function test( t ) { t.end(); }); -tape( 'the function returns `NaN` if provided a shape parameter which is not positive', opts, function test( t ) { - var y; +tape( 'if provided `c <= 0`, the function returns `NaN`', opts, function test( t ) { + var v; - y = entropy( 0.0 ); - t.equal( isnan( y ), true, 'returns expected value' ); + v = entropy( 0.0 ); + t.equal( isnan( v ), true, 'returns expected value' ); - y = entropy( -1.0 ); - t.equal( isnan( y ), true, 'returns expected value' ); + v = entropy( -1.0 ); + t.equal( isnan( v ), true, 'returns expected value' ); + + v = entropy( NINF ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); -tape( 'the function returns the differential entropy of a Bradford distribution', opts, function test( t ) { +tape( 'the function returns the differential entropy of a Bradford distribution given small parameter `c`', opts, function test( t ) { var expected; var delta; var tol; + var i; var c; var y; + + expected = smallC.expected; + c = smallC.c; + for ( i = 0; i < expected.length; i++ ) { + y = entropy( c[i] ); + if ( y === expected[i] ) { + t.equal( y, expected[i], 'c: '+c[i]+', y: '+y+', expected: '+expected[i] ); + } else { + delta = abs( y - expected[ i ] ); + tol = 1523.0 * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. c: '+c[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' ); + } + } + t.end(); +}); + +tape( 'the function returns the differential entropy of a Bradford distribution given large parameter `c`', opts, function test( t ) { + var expected; + var delta; + var tol; var i; + var c; + var y; - expected = data.expected; - c = data.c; - for ( i = 0; i < c.length; i++ ) { + expected = largeC.expected; + c = largeC.c; + for ( i = 0; i < expected.length; i++ ) { y = entropy( c[i] ); if ( y === expected[i] ) { t.equal( y, expected[i], 'c: '+c[i]+', y: '+y+', expected: '+expected[i] ); } else { delta = abs( y - expected[ i ] ); - tol = 990.0 * EPS * abs( expected[ i ] ); + tol = 45.0 * EPS * abs( expected[ i ] ); t.ok( delta <= tol, 'within tolerance. c: '+c[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' ); } } diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/mean/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/bradford/mean/benchmark/benchmark.native.js index 5bd635f40150..24ad2b0ada49 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bradford/mean/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/mean/benchmark/benchmark.native.js @@ -22,8 +22,7 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array/float64' ); -var uniform = require( '@stdlib/random/base/uniform' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -40,20 +39,19 @@ var opts = { // MAIN // bench( pkg+'::native', opts, function benchmark( b ) { - var len; + var opts; var c; var y; var i; - len = 100; - c = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - c[ i ] = uniform( 0.1, 10.0 ); - } + opts = { + 'dtype': 'float64' + }; + c = uniform( 100, 0.1, 10.0, opts ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = mean( c[ i % len ] ); + y = mean( c[ i % c.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/mean/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/stats/base/dists/bradford/mean/benchmark/c/benchmark.c index 5928279dbeb6..18f23d137044 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bradford/mean/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/mean/benchmark/c/benchmark.c @@ -99,12 +99,9 @@ static double benchmark( void ) { double y; int i; - // Generate test data: for ( i = 0; i < 100; i++ ) { c[ i ] = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 10.0 ); } - - // Run the benchmark: t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { y = stdlib_base_dists_bradford_mean( c[ i % 100 ] ); @@ -125,21 +122,17 @@ static double benchmark( void ) { */ int main( void ) { double elapsed; - int count; int i; // Use the current time to seed the pseudorandom number generator: srand( time( NULL ) ); print_version(); - count = 0; for ( i = 0; i < REPEATS; i++ ) { - count += 1; printf( "# c::%s\n", NAME ); elapsed = benchmark(); - printf( "ok %d benchmark finished\n", count ); print_results( elapsed ); - printf( "\n" ); + printf( "ok %d benchmark finished\n", i+1 ); } - print_summary( count, count ); + print_summary( REPEATS, REPEATS ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/mean/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/dists/bradford/mean/docs/repl.txt index 63ea829ce2c1..0bd4f2e7b0c4 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bradford/mean/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/mean/docs/repl.txt @@ -1,7 +1,7 @@ {{alias}}( c ) - Returns the expected value of a Bradford distribution with shape - parameter `c`. + Returns the expected value of a Bradford distribution with shape parameter + `c`. If `c <= 0`, the function returns `NaN`. diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/mean/lib/main.js b/lib/node_modules/@stdlib/stats/base/dists/bradford/mean/lib/main.js index a4089c28d464..94869ff8b944 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bradford/mean/lib/main.js +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/mean/lib/main.js @@ -58,10 +58,7 @@ var ln = require( '@stdlib/math/base/special/ln' ); */ function mean( c ) { var k; - if ( - isnan( c ) || - c <= 0.0 - ) { + if ( isnan( c ) || c <= 0.0 ) { return NaN; } k = ln( 1.0 + c ); diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/mean/src/main.c b/lib/node_modules/@stdlib/stats/base/dists/bradford/mean/src/main.c index e2e28712e8ea..db51bcddd72d 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bradford/mean/src/main.c +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/mean/src/main.c @@ -32,10 +32,7 @@ */ double stdlib_base_dists_bradford_mean( const double c ) { double k; - if ( - stdlib_base_is_nan( c ) || - c <= 0.0 - ) { + if ( stdlib_base_is_nan( c ) || c <= 0.0 ) { return 0.0/0.0; // NaN } k = stdlib_base_ln( 1.0 + c ); diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/mean/test/test.js b/lib/node_modules/@stdlib/stats/base/dists/bradford/mean/test/test.js index ddee526e35f9..3e8cf878f48e 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bradford/mean/test/test.js +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/mean/test/test.js @@ -41,7 +41,7 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'if provided `NaN` for `c`, the function returns `NaN`', function test( t ) { +tape( 'if provided `NaN`, the function returns `NaN`', function test( t ) { var v = mean( NaN ); t.equal( isnan( v ), true, 'returns expected value' ); t.end(); @@ -62,7 +62,7 @@ tape( 'if provided `c <= 0`, the function returns `NaN`', function test( t ) { t.end(); }); -tape( 'the function returns the mean of a Bradford distribution', function test( t ) { +tape( 'the function returns the expected value of a Bradford distribution', function test( t ) { var expected; var delta; var tol; diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/benchmark/c/benchmark.c index 16a7c136ee98..b359ab0fe848 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/benchmark/c/benchmark.c @@ -99,12 +99,9 @@ static double benchmark( void ) { double y; int i; - // Generate test data: for ( i = 0; i < 100; i++ ) { c[ i ] = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 10.0 ); } - - // Run the benchmark: t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { y = stdlib_base_dists_bradford_mode( c[ i % 100 ] ); @@ -125,21 +122,17 @@ static double benchmark( void ) { */ int main( void ) { double elapsed; - int count; int i; // Use the current time to seed the pseudorandom number generator: srand( time( NULL ) ); print_version(); - count = 0; for ( i = 0; i < REPEATS; i++ ) { - count += 1; printf( "# c::%s\n", NAME ); elapsed = benchmark(); - printf( "ok %d benchmark finished\n", count ); print_results( elapsed ); - printf( "\n" ); + printf( "ok %d benchmark finished\n", i+1 ); } - print_summary( count, count ); + print_summary( REPEATS, REPEATS ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/lib/main.js b/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/lib/main.js index 797e533b6c5b..21f7862e946e 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/lib/main.js +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/lib/main.js @@ -56,10 +56,7 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); * // returns NaN */ function mode( c ) { - if ( - isnan( c ) || - c <= 0.0 - ) { + if ( isnan( c ) || c <= 0.0 ) { return NaN; } return 0.0; diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/lib/native.js b/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/lib/native.js index 21e0c7fcc27d..d67b26a188f5 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/lib/native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/lib/native.js @@ -56,7 +56,9 @@ var addon = require( './../src/addon.node' ); * var v = mode( NaN ); * // returns NaN */ -var mode = addon; +function mode( c ) { + return addon( c ); +} // EXPORTS // diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/src/main.c b/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/src/main.c index ea13b7cecb84..6a56097313b0 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/src/main.c +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/src/main.c @@ -30,10 +30,7 @@ * // returns 0.0 */ double stdlib_base_dists_bradford_mode( const double c ) { - if ( - stdlib_base_is_nan( c ) || - c <= 0.0 - ) { + if ( stdlib_base_is_nan( c ) || c <= 0.0 ) { return 0.0/0.0; // NaN } return 0.0; diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/test/test.native.js index 48342c84dab5..0e2796a3a62e 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/test/test.native.js @@ -23,7 +23,7 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var PINF = require( '@stdlib/constants/float64/pinf' ); +var uniform = require( '@stdlib/random/array/uniform' ); var NINF = require( '@stdlib/constants/float64/ninf' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -46,45 +46,35 @@ tape( 'main export is a function', opts, function test( t ) { tape( 'if provided `NaN` for `c`, the function returns `NaN`', opts, function test( t ) { var v = mode( NaN ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); -tape( 'if provided a nonpositive `c`, the function returns `NaN`', opts, function test( t ) { +tape( 'if provided `c <= 0`, the function returns `NaN`', opts, function test( t ) { var v; v = mode( 0.0 ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); v = mode( -1.0 ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); v = mode( NINF ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); -tape( 'the function returns the mode of a Bradford distribution', opts, function test( t ) { - var v; - - v = mode( 0.1 ); - t.equal( v, 0.0, 'returns 0.0' ); - - v = mode( 0.5 ); - t.equal( v, 0.0, 'returns 0.0' ); - - v = mode( 1.0 ); - t.equal( v, 0.0, 'returns 0.0' ); - - v = mode( 10.0 ); - t.equal( v, 0.0, 'returns 0.0' ); - - v = mode( 100.0 ); - t.equal( v, 0.0, 'returns 0.0' ); +tape( 'the function returns `0.0` as the mode of a Bradford distribution', opts, function test( t ) { + var c; + var i; + var y; - v = mode( PINF ); - t.equal( v, 0.0, 'returns 0.0' ); + c = uniform( 10, 0.1, 10.0 ); + for ( i = 0; i < c.length; i++ ) { + y = mode( c[ i ] ); + t.equal( y, 0.0, 'returns expected value' ); + } t.end(); }); diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/pdf/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/bradford/pdf/benchmark/benchmark.native.js index 959aa759d91e..5323952f5943 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bradford/pdf/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/pdf/benchmark/benchmark.native.js @@ -22,8 +22,7 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array/float64' ); -var uniform = require( '@stdlib/random/base/uniform' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -40,23 +39,21 @@ var opts = { // MAIN // bench( pkg+'::native', opts, function benchmark( b ) { - var len; + var opts; var x; var c; var y; var i; - len = 100; - x = new Float64Array( len ); - c = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - x[ i ] = uniform( 0.0, 1.0 ); - c[ i ] = uniform( 0.1, 10.0 ); - } + opts = { + 'dtype': 'float64' + }; + x = uniform( 100, 0.0, 1.0, opts ); + c = uniform( 100, 0.1, 10.0, opts ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = pdf( x[ i % len ], c[ i % len ] ); + y = pdf( x[ i % x.length ], c[ i % c.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/pdf/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/stats/base/dists/bradford/pdf/benchmark/c/benchmark.c index 6ca09fc46c66..5a0593924400 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bradford/pdf/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/pdf/benchmark/c/benchmark.c @@ -100,13 +100,10 @@ static double benchmark( void ) { double y; int i; - // Generate test data: for ( i = 0; i < 100; i++ ) { x[ i ] = random_uniform( 0.0, 1.0 ); c[ i ] = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 10.0 ); } - - // Run the benchmark: t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { y = stdlib_base_dists_bradford_pdf( x[ i % 100 ], c[ i % 100 ] ); @@ -127,21 +124,17 @@ static double benchmark( void ) { */ int main( void ) { double elapsed; - int count; int i; // Use the current time to seed the pseudorandom number generator: srand( time( NULL ) ); print_version(); - count = 0; for ( i = 0; i < REPEATS; i++ ) { - count += 1; printf( "# c::%s\n", NAME ); elapsed = benchmark(); - printf( "ok %d benchmark finished\n", count ); print_results( elapsed ); - printf( "\n" ); + printf( "ok %d benchmark finished\n", i+1 ); } - print_summary( count, count ); + print_summary( REPEATS, REPEATS ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/pdf/lib/factory.js b/lib/node_modules/@stdlib/stats/base/dists/bradford/pdf/lib/factory.js index 58006b001abb..85bceef9c331 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bradford/pdf/lib/factory.js +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/pdf/lib/factory.js @@ -43,10 +43,7 @@ var log1p = require( '@stdlib/math/base/special/log1p' ); */ function factory( c ) { var k; - if ( - isnan( c ) || - c <= 0.0 - ) { + if ( isnan( c ) || c <= 0.0 ) { return constantFunction( NaN ); } k = log1p( c ); @@ -64,13 +61,10 @@ function factory( c ) { * // returns */ function pdf( x ) { - if ( - isnan( x ) - ) { + if ( isnan( x ) ) { return NaN; } if ( x < 0.0 || x > 1.0 ) { - // Support of the Bradford distribution: [0,1] return 0.0; } return c / ( ( 1.0 + ( c*x ) ) * k ); diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/pdf/lib/main.js b/lib/node_modules/@stdlib/stats/base/dists/bradford/pdf/lib/main.js index debecb8de99c..2d3c70da09b7 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bradford/pdf/lib/main.js +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/pdf/lib/main.js @@ -71,15 +71,10 @@ var log1p = require( '@stdlib/math/base/special/log1p' ); */ function pdf( x, c ) { var k; - if ( - isnan( c ) || - isnan( x ) || - c <= 0.0 - ) { + if ( isnan( c ) || isnan( x ) || c <= 0.0 ) { return NaN; } if ( x < 0.0 || x > 1.0 ) { - // Support of the Bradford distribution: [0,1] return 0.0; } k = log1p( c ); diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/pdf/src/main.c b/lib/node_modules/@stdlib/stats/base/dists/bradford/pdf/src/main.c index 073b2117a9ec..0944fa4dfad1 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bradford/pdf/src/main.c +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/pdf/src/main.c @@ -33,16 +33,10 @@ */ double stdlib_base_dists_bradford_pdf( const double x, const double c ) { double k; - - if ( - stdlib_base_is_nan( x ) || - stdlib_base_is_nan( c ) || - c <= 0.0 - ) { + if ( stdlib_base_is_nan( x ) || stdlib_base_is_nan( c ) || c <= 0.0 ) { return 0.0/0.0; // NaN } if ( x < 0.0 || x > 1.0 ) { - // Support of the Bradford distribution: [0,1] return 0.0; } k = stdlib_base_log1p( c ); diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/quantile/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/bradford/quantile/benchmark/benchmark.native.js index 9d47715071a2..2c50ec4090b6 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bradford/quantile/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/quantile/benchmark/benchmark.native.js @@ -22,8 +22,7 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array/float64' ); -var uniform = require( '@stdlib/random/base/uniform' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -40,23 +39,21 @@ var opts = { // MAIN // bench( pkg+'::native', opts, function benchmark( b ) { - var len; + var opts; var p; var c; var y; var i; - len = 100; - p = new Float64Array( len ); - c = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - p[ i ] = uniform( 0.0, 1.0 ); - c[ i ] = uniform( 0.1, 10.0 ); - } + opts = { + 'dtype': 'float64' + }; + p = uniform( 100, 0.0, 1.0, opts ); + c = uniform( 100, 0.1, 10.0, opts ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = quantile( p[ i % len ], c[ i % len ] ); + y = quantile( p[ i % p.length ], c[ i % c.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/quantile/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/stats/base/dists/bradford/quantile/benchmark/c/benchmark.c index 2fcb94b3de4d..7879e9f1376c 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bradford/quantile/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/quantile/benchmark/c/benchmark.c @@ -100,13 +100,10 @@ static double benchmark( void ) { double y; int i; - // Generate test data: for ( i = 0; i < 100; i++ ) { p[ i ] = random_uniform( 0.0, 1.0 ); c[ i ] = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 10.0 ); } - - // Run the benchmark: t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { y = stdlib_base_dists_bradford_quantile( p[ i % 100 ], c[ i % 100 ] ); @@ -127,21 +124,17 @@ static double benchmark( void ) { */ int main( void ) { double elapsed; - int count; int i; // Use the current time to seed the pseudorandom number generator: srand( time( NULL ) ); print_version(); - count = 0; for ( i = 0; i < REPEATS; i++ ) { - count += 1; printf( "# c::%s\n", NAME ); elapsed = benchmark(); - printf( "ok %d benchmark finished\n", count ); print_results( elapsed ); - printf( "\n" ); + printf( "ok %d benchmark finished\n", i+1 ); } - print_summary( count, count ); + print_summary( REPEATS, REPEATS ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/quantile/lib/factory.js b/lib/node_modules/@stdlib/stats/base/dists/bradford/quantile/lib/factory.js index 07e45fd9bd84..68348e73f331 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bradford/quantile/lib/factory.js +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/quantile/lib/factory.js @@ -46,10 +46,7 @@ var log1p = require( '@stdlib/math/base/special/log1p' ); * // returns 1.0 */ function factory( c ) { - if ( - isnan( c ) || - c <= 0.0 - ) { + if ( isnan( c ) || c <= 0.0 ) { return constantFunction( NaN ); } return quantile; @@ -66,11 +63,7 @@ function factory( c ) { * // returns */ function quantile( p ) { - if ( - isnan( p ) || - p < 0.0 || - p > 1.0 - ) { + if ( isnan( p ) || p < 0.0 || p > 1.0 ) { return NaN; } return expm1( p * log1p( c ) ) / c; diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/quantile/lib/main.js b/lib/node_modules/@stdlib/stats/base/dists/bradford/quantile/lib/main.js index 74f033d9b3d3..9ca3f0067e15 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bradford/quantile/lib/main.js +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/quantile/lib/main.js @@ -67,13 +67,7 @@ var log1p = require( '@stdlib/math/base/special/log1p' ); * // returns NaN */ function quantile( p, c ) { - if ( - isnan( c ) || - isnan( p ) || - c <= 0.0 || - p < 0.0 || - p > 1.0 - ) { + if ( isnan( c ) || isnan( p ) || c <= 0.0 || p < 0.0 || p > 1.0 ) { return NaN; } return expm1( p * log1p( c ) ) / c; diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/quantile/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/bradford/quantile/test/test.native.js index 4929b8d3b57f..a205860f761f 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bradford/quantile/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/quantile/test/test.native.js @@ -80,7 +80,7 @@ tape( 'if provided `c <= 0`, the function returns `NaN`', opts, function test( t t.end(); }); -tape( 'if provided a probability outside [0,1], the function returns `NaN`', opts, function test( t ) { +tape( 'if provided a number outside `[0,1]` for `p` and a valid `c`, the function returns `NaN`', opts, function test( t ) { var y; y = quantile( 2.0, 1.0 ); diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/stdev/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/stats/base/dists/bradford/stdev/benchmark/c/benchmark.c index 2cbc63786b7a..cb742037867d 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bradford/stdev/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/stdev/benchmark/c/benchmark.c @@ -99,12 +99,9 @@ static double benchmark( void ) { double y; int i; - // Generate test data: for ( i = 0; i < 100; i++ ) { c[ i ] = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 10.0 ); } - - // Run the benchmark: t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { y = stdlib_base_dists_bradford_stdev( c[ i % 100 ] ); @@ -125,21 +122,17 @@ static double benchmark( void ) { */ int main( void ) { double elapsed; - int count; int i; // Use the current time to seed the pseudorandom number generator: srand( time( NULL ) ); print_version(); - count = 0; for ( i = 0; i < REPEATS; i++ ) { - count += 1; printf( "# c::%s\n", NAME ); elapsed = benchmark(); - printf( "ok %d benchmark finished\n", count ); print_results( elapsed ); - printf( "\n" ); + printf( "ok %d benchmark finished\n", i+1 ); } - print_summary( count, count ); + print_summary( REPEATS, REPEATS ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/stdev/lib/main.js b/lib/node_modules/@stdlib/stats/base/dists/bradford/stdev/lib/main.js index ceaa668952eb..f93643b6a1da 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bradford/stdev/lib/main.js +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/stdev/lib/main.js @@ -59,10 +59,7 @@ var sqrt = require( '@stdlib/math/base/special/sqrt' ); */ function stdev( c ) { var k; - if ( - isnan( c ) || - c <= 0.0 - ) { + if ( isnan( c ) || c <= 0.0 ) { return NaN; } k = ln( 1.0 + c ); diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/stdev/lib/native.js b/lib/node_modules/@stdlib/stats/base/dists/bradford/stdev/lib/native.js index 294eb47ae0a6..2d9be3e39151 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bradford/stdev/lib/native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/stdev/lib/native.js @@ -56,7 +56,9 @@ var addon = require( './../src/addon.node' ); * var v = stdev( NaN ); * // returns NaN */ -var stdev = addon; +function stdev( c ) { + return addon( c ); +} // EXPORTS // diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/stdev/src/main.c b/lib/node_modules/@stdlib/stats/base/dists/bradford/stdev/src/main.c index 96117ddd543f..2795f6b970ec 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bradford/stdev/src/main.c +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/stdev/src/main.c @@ -33,12 +33,9 @@ */ double stdlib_base_dists_bradford_stdev( const double c ) { double k; - if ( - stdlib_base_is_nan( c ) || - c <= 0.0 - ) { + if ( stdlib_base_is_nan( c ) || c <= 0.0 ) { return 0.0/0.0; // NaN } k = stdlib_base_ln( 1.0 + c ); - return stdlib_base_sqrt( ( ( ( 2.0 + c ) * k ) - ( 2.0 * c ) ) / ( 2.0 * c * k * k ) ); + return stdlib_base_sqrt( ( ( ( 2.0+c ) * k ) - ( 2.0*c ) ) / ( 2.0*c*k*k ) ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/chi/entropy/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/chi/entropy/test/test.native.js index 7e4f00c9cb68..389a41171862 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chi/entropy/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chi/entropy/test/test.native.js @@ -71,7 +71,7 @@ tape( 'if provided a degrees of freedom parameter `k` that is not a positive num t.end(); }); -tape( 'the function returns the entropy of a chi distribution', opts, function test( t ) { +tape( 'the function returns the differential entropy of a chi distribution', opts, function test( t ) { var expected; var delta; var tol; diff --git a/lib/node_modules/@stdlib/stats/base/dists/chisquare/kurtosis/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/chisquare/kurtosis/test/test.native.js index ebd741ff052b..9d4220553b30 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chisquare/kurtosis/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chisquare/kurtosis/test/test.native.js @@ -69,7 +69,7 @@ tape( 'if provided a degrees of freedom parameter `k` that is not a positive num t.end(); }); -tape( 'the function returns the kurtosis of a chi-squared distribution', opts, function test( t ) { +tape( 'the function returns the excess kurtosis of a chi-squared distribution', opts, function test( t ) { var expected; var k; var i; diff --git a/lib/node_modules/@stdlib/stats/base/dists/cosine/mean/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/cosine/mean/test/test.native.js index c47c4c1e8475..6b8ddc5f6791 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/cosine/mean/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/cosine/mean/test/test.native.js @@ -80,7 +80,7 @@ tape( 'if provided `s <= 0.0`, the function returns `NaN`', opts, function test( t.end(); }); -tape( 'the function returns the mean of a cosine distribution', opts, function test( t ) { +tape( 'the function returns the expected value of a raised cosine distribution', opts, function test( t ) { var expected; var mu; var s; diff --git a/lib/node_modules/@stdlib/stats/base/dists/discrete-uniform/stdev/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/discrete-uniform/stdev/test/test.native.js index 2eebadc64ad3..58e11a8d3c58 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/discrete-uniform/stdev/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/discrete-uniform/stdev/test/test.native.js @@ -58,7 +58,7 @@ tape( 'if provided `a > b`, the function returns `NaN`', opts, function test( t t.end(); }); -tape( 'the function returns the stdev of a discrete uniform distribution', opts, function test( t ) { +tape( 'the function returns the standard deviation of a discrete uniform distribution', opts, function test( t ) { var expected; var delta; var tol; diff --git a/lib/node_modules/@stdlib/stats/base/dists/exponential/entropy/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/exponential/entropy/test/test.native.js index 41e82b5531b9..f69a5f8946df 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/exponential/entropy/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/exponential/entropy/test/test.native.js @@ -68,7 +68,7 @@ tape( 'if provided a rate parameter `lambda` that is not a nonnegative number, t t.end(); }); -tape( 'the function returns the entropy of an exponential distribution', opts, function test( t ) { +tape( 'the function returns the differential entropy of an exponential distribution', opts, function test( t ) { var expected; var lambda; var delta; diff --git a/lib/node_modules/@stdlib/stats/base/dists/geometric/kurtosis/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/geometric/kurtosis/test/test.native.js index 3edec486953a..4ed4e5f6b868 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/geometric/kurtosis/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/geometric/kurtosis/test/test.native.js @@ -75,7 +75,7 @@ tape( 'if provided a success probability `p` outside of `[0,1]`, the function re t.end(); }); -tape( 'the function returns the kurtosis of a geometric distribution', opts, function test( t ) { +tape( 'the function returns the excess kurtosis of a geometric distribution', opts, function test( t ) { var expected; var delta; var tol; diff --git a/lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/quantile/README.md b/lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/quantile/README.md index 9a3c96526e98..790ace2f67a7 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/quantile/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/quantile/README.md @@ -141,22 +141,14 @@ y = myQuantile( 0.3 ); ```javascript var uniform = require( '@stdlib/random/array/uniform' ); var EPS = require( '@stdlib/constants/float64/eps' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var quantile = require( '@stdlib/stats/base/dists/kumaraswamy/quantile' ); -var a; -var b; -var p; -var y; -var i; +var p = uniform( 10, 0.0, 1.0 ); +var a = uniform( 10, EPS, 5.0 ); +var b = uniform( 10, EPS, 5.0 ); -p = uniform( 10, 0.0, 1.0 ); -a = uniform( 10, EPS, 5.0 ); -b = uniform( 10, EPS, 5.0 ); - -for ( i = 0; i < p.length; i++ ) { - y = quantile( p[ i ], a[ i ], b[ i ] ); - console.log( 'p: %d, a: %d, b: %d, Q(p;a,b): %d', p[ i ].toFixed( 4 ), a[ i ].toFixed( 4 ), b[ i ].toFixed( 4 ), y.toFixed( 4 ) ); -} +logEachMap( 'p: %0.4f, a: %0.4f, b: %0.4f, Q(p;a,b): %0.4f', p, a, b, quantile ); ``` @@ -191,7 +183,7 @@ for ( i = 0; i < p.length; i++ ) { #### stdlib_base_dists_kumaraswamy_quantile( p, a, b ) -Evaluates the quantile function of a Kumaraswamy's double bounded distribution. +Evaluates the quantile function of a [Kumaraswamy's double bounded][kumaraswamy-distribution] distribution with parameters `a` (first shape parameter) and `b` (second shape parameter). ```c double out = stdlib_base_dists_kumaraswamy_quantile( 0.5, 1.0, 1.0 ); @@ -205,8 +197,7 @@ The function accepts the following arguments: - **b**: `[in] double` second shape parameter. ```c -double stdlib_base_dists_kumaraswamy_quantile( const double p, const -double a, const double b ); +double stdlib_base_dists_kumaraswamy_quantile( const double p, const double a, const double b ); ``` diff --git a/lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/quantile/examples/index.js b/lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/quantile/examples/index.js index af11e2caa9af..667a70687650 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/quantile/examples/index.js +++ b/lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/quantile/examples/index.js @@ -20,19 +20,11 @@ var uniform = require( '@stdlib/random/array/uniform' ); var EPS = require( '@stdlib/constants/float64/eps' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var quantile = require( './../lib' ); -var a; -var b; -var p; -var y; -var i; +var p = uniform( 10, 0.0, 1.0 ); +var a = uniform( 10, EPS, 5.0 ); +var b = uniform( 10, EPS, 5.0 ); -p = uniform( 10, 0.0, 1.0 ); -a = uniform( 10, EPS, 5.0 ); -b = uniform( 10, EPS, 5.0 ); - -for ( i = 0; i < p.length; i++ ) { - y = quantile( p[ i ], a[ i ], b[ i ] ); - console.log( 'p: %d, a: %d, b: %d, Q(p;a,b): %d', p[ i ].toFixed( 4 ), a[ i ].toFixed( 4 ), b[ i ].toFixed( 4 ), y.toFixed( 4 ) ); -} +logEachMap( 'p: %0.4f, a: %0.4f, b: %0.4f, Q(p;a,b): %0.4f', p, a, b, quantile ); diff --git a/lib/node_modules/@stdlib/stats/base/dists/laplace/mean/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/laplace/mean/test/test.native.js index 2c3ad550ecfb..9437df79e258 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/laplace/mean/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/laplace/mean/test/test.native.js @@ -86,7 +86,7 @@ tape( 'if provided a nonpositive `b`, the function returns `NaN`', opts, functio t.end(); }); -tape( 'the function returns the mean of a Laplace distribution', opts, function test( t ) { +tape( 'the function returns the expected value of a Laplace distribution', opts, function test( t ) { var expected; var mu; var b; diff --git a/lib/node_modules/@stdlib/stats/base/dists/negative-binomial/kurtosis/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/negative-binomial/kurtosis/test/test.native.js index e6fe71419d21..9c9b786e649d 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/negative-binomial/kurtosis/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/negative-binomial/kurtosis/test/test.native.js @@ -92,7 +92,7 @@ tape( 'if provided a success probability `p` outside of `[0,1]`, the function re t.end(); }); -tape( 'the function returns the kurtosis of a negative binomial distribution', opts, function test( t ) { +tape( 'the function returns the excess kurtosis of a negative binomial distribution', opts, function test( t ) { var expected; var r; var p; diff --git a/lib/node_modules/@stdlib/stats/base/dists/negative-binomial/variance/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/negative-binomial/variance/test/test.native.js index 24dd0753faca..dbc3fef031e7 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/negative-binomial/variance/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/negative-binomial/variance/test/test.native.js @@ -75,7 +75,7 @@ tape( 'if provided `r <= 0` or `p <= 0` or `p > 1`, the function returns `NaN`', t.end(); }); -tape( 'the function evaluates the variance for a negative binomial distribution', opts, function test( t ) { +tape( 'the function returns the variance of a negative binomial distribution', opts, function test( t ) { var expected; var delta; var tol; diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/entropy/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/planck/entropy/test/test.native.js index b68e051730a8..1c04a206c328 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/planck/entropy/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/entropy/test/test.native.js @@ -67,7 +67,7 @@ tape( 'if provided a shape parameter `lambda` which is nonpositive, the function t.end(); }); -tape( 'the function returns the entropy of a Planck distribution', opts, function test( t ) { +tape( 'the function returns the differential entropy of a Planck distribution', opts, function test( t ) { var expected; var lambda; var delta; diff --git a/lib/node_modules/@stdlib/stats/base/dists/poisson/cdf/README.md b/lib/node_modules/@stdlib/stats/base/dists/poisson/cdf/README.md index 36847244b0af..6c9974e44cfb 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/poisson/cdf/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/poisson/cdf/README.md @@ -115,6 +115,30 @@ y = mycdf( 8.0 ); +
+ +## Examples + + + +```javascript +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); +var cdf = require( '@stdlib/stats/base/dists/poisson/cdf' ); + +var opts = { + 'dtype': 'float64' +}; +var lambda = uniform( 10, 0.0, 10.0, opts ); +var x = uniform( 10, 0.0, 10.0, opts ); + +logEachMap( 'x: %0.4f, λ: %0.4f, F(x;λ): %0.4f', x, lambda, cdf ); +``` + +
+ + + * * *
@@ -175,8 +199,8 @@ static double random_uniform( double min, double max ) { } int main( void ) { - double x; double lambda; + double x; double y; int i; @@ -197,35 +221,6 @@ int main( void ) { -* * * - -
- -## Examples - - - -```javascript -var randu = require( '@stdlib/random/base/randu' ); -var cdf = require( '@stdlib/stats/base/dists/poisson/cdf' ); - -var lambda; -var x; -var y; -var i; - -for ( i = 0; i < 10; i++ ) { - x = randu() * 10.0; - lambda = randu() * 10.0; - y = cdf( x, lambda ); - console.log( 'x: %d, λ: %d, F(x;λ): %d', x.toFixed( 4 ), lambda.toFixed( 4 ), y.toFixed( 4 ) ); -} -``` - -
- - -