From a12c8cdc1fe6028c016ce61c3e09a628e464eb3c Mon Sep 17 00:00:00 2001 From: Vinit Pandit Date: Mon, 30 Dec 2024 06:22:40 +0000 Subject: [PATCH 01/20] feat: add C ndarray interface and refactor implementation for stats/base/svarianceyc --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: missing_dependencies - task: lint_c_benchmarks status: missing_dependencies - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: passed - task: run_c_examples status: passed - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: passed - task: run_c_benchmarks status: passed - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: passed - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: passed --- --- .../@stdlib/stats/base/svarianceyc/README.md | 151 +++++++++++++++--- .../base/svarianceyc/benchmark/benchmark.js | 16 +- .../svarianceyc/benchmark/benchmark.native.js | 12 +- .../benchmark/benchmark.ndarray.js | 16 +- .../benchmark/benchmark.ndarray.native.js | 12 +- .../benchmark/c/benchmark.length.c | 48 +++++- .../stats/base/svarianceyc/docs/repl.txt | 31 ++-- .../base/svarianceyc/docs/types/index.d.ts | 12 +- .../base/svarianceyc/examples/c/example.c | 9 +- .../stats/base/svarianceyc/examples/index.js | 10 +- .../include/stdlib/stats/base/svarianceyc.h | 9 +- .../stats/base/svarianceyc/lib/index.js | 6 +- .../stats/base/svarianceyc/lib/ndarray.js | 14 +- .../base/svarianceyc/lib/ndarray.native.js | 20 +-- .../stats/base/svarianceyc/lib/svarianceyc.js | 17 +- .../svarianceyc/lib/svarianceyc.native.js | 9 +- .../stats/base/svarianceyc/manifest.json | 42 ++++- .../stats/base/svarianceyc/src/addon.c | 26 ++- .../svarianceyc/src/{svarianceyc.c => main.c} | 61 ++++--- .../base/svarianceyc/test/test.ndarray.js | 13 +- .../svarianceyc/test/test.ndarray.native.js | 13 +- .../base/svarianceyc/test/test.svarianceyc.js | 13 +- .../test/test.svarianceyc.native.js | 13 +- 23 files changed, 372 insertions(+), 201 deletions(-) rename lib/node_modules/@stdlib/stats/base/svarianceyc/src/{svarianceyc.c => main.c} (53%) diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/README.md b/lib/node_modules/@stdlib/stats/base/svarianceyc/README.md index b10f32fc6bbb..68353dba9cf3 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/README.md +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/README.md @@ -98,7 +98,7 @@ The use of the term `n-1` is commonly referred to as Bessel's correction. Note, var svarianceyc = require( '@stdlib/stats/base/svarianceyc' ); ``` -#### svarianceyc( N, correction, x, stride ) +#### svarianceyc( N, correction, x, strideX ) Computes the [variance][variance] of a single-precision floating-point strided array `x` using a one-pass algorithm proposed by Youngs and Cramer. @@ -106,9 +106,8 @@ Computes the [variance][variance] of a single-precision floating-point strided a var Float32Array = require( '@stdlib/array/float32' ); var x = new Float32Array( [ 1.0, -2.0, 2.0 ] ); -var N = x.length; -var v = svarianceyc( N, 1, x, 1 ); +var v = svarianceyc( x.length, 1, x, 1 ); // returns ~4.3333 ``` @@ -117,18 +116,16 @@ 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 [variance][variance] according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the [variance][variance] 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 unbiased sample [variance][variance], 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 [`Float32Array`][@stdlib/array/float32]. -- **stride**: index increment for `x`. +- **strideX**: stride length for `x`. -The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to compute the [variance][variance] of every other element in `x`, +The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute the [variance][variance] of every other element in `x`, ```javascript var Float32Array = require( '@stdlib/array/float32' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x = new Float32Array( [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0 ] ); -var N = floor( x.length / 2 ); -var v = svarianceyc( N, 1, x, 2 ); +var v = svarianceyc( 4, 1, x, 2 ); // returns 6.25 ``` @@ -138,18 +135,15 @@ Note that indexing is relative to the first index. To introduce an offset, use [ ```javascript var Float32Array = require( '@stdlib/array/float32' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x0 = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element -var N = floor( x0.length / 2 ); - -var v = svarianceyc( N, 1, x1, 2 ); +var v = svarianceyc( 4, 1, x1, 2 ); // returns 6.25 ``` -#### svarianceyc.ndarray( N, correction, x, stride, offset ) +#### svarianceyc.ndarray( N, correction, x, strideX, offsetX ) Computes the [variance][variance] of a single-precision floating-point strided array using a one-pass algorithm proposed by Youngs and Cramer and alternative indexing semantics. @@ -157,26 +151,24 @@ Computes the [variance][variance] of a single-precision floating-point strided a var Float32Array = require( '@stdlib/array/float32' ); var x = new Float32Array( [ 1.0, -2.0, 2.0 ] ); -var N = x.length; -var v = svarianceyc.ndarray( N, 1, x, 1, 0 ); +var v = svarianceyc.ndarray( x.length, 1, x, 1, 0 ); // returns ~4.33333 ``` The function has the following additional parameters: -- **offset**: starting index for `x`. +- **offsetX**: 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 [variance][variance] for every other value in `x` starting from the second value +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 [variance][variance] for every other element in `x` starting from the second element ```javascript var Float32Array = require( '@stdlib/array/float32' ); var floor = require( '@stdlib/math/base/special/floor' ); var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); -var N = floor( x.length / 2 ); -var v = svarianceyc.ndarray( N, 1, x, 2, 1 ); +var v = svarianceyc.ndarray( 4, 1, x, 2, 1 ); // returns 6.25 ``` @@ -224,10 +216,131 @@ console.log( v ); + + * * * +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/svarianceyc.h" +``` + +#### stdlib_strided_svarianceyc( N, correction, \*X, strideX ) + +Computes the [variance][variance] of a single-precision floating-point strided array `x` using a one-pass algorithm proposed by Youngs and Cramer. + +```c +const float x[] = { 1.0f, -2.0f, 2.0f }; + +float v = stdlib_strided_svarianceyc( 3, 1, x, 1 ); +// returns ~4.3333f +``` + +The function accepts the following arguments: + +- **N**: `[in] CBLAS_INT` number of indexed elements. +- **correction**: `[in] float` 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 [variance][variance] according to `N-c` where c corresponds to the provided degrees of freedom adjustment. When computing the [variance][variance] 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 unbiased sample [variance][variance], 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**: `[in] float*` input array. +- **strideX**: stride length for `x`. + +The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute the [variance][variance] of every other element in `x`, + +```c +float stdlib_strided_svarianceyc( const CBLAS_INT N, const float correction, const float *X, const CBLAS_INT strideX ); +``` + +#### stdlib_strided_svarianceyc_ndarray( N, correction, \*X, strideX, offsetX ) + +Computes the [variance][variance] of a single-precision floating-point strided array using a one-pass algorithm proposed by Youngs and Cramer and alternative indexing semantics. + +```c +const float x[] = { 1.0f, -2.0f, 2.0f }; + +float v = stdlib_strided_srange_ndarray( 3, 1, x, 1, 0 ); +// returns ~4.33333f +``` + +The function accepts the following arguments: + +- **N**: `[in] CBLAS_INT` number of indexed elements. +- **correction** `[in] float`: 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 [variance][variance] according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the [variance][variance] 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 unbiased sample [variance][variance], 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**: `[in] float*` input array. +- **strideX**: `[in] CBLAS_INT` stride length for `X`. +- **offsetX**: `[in] CBLAS_INT` starting index for `X`. + +```c +float stdlib_strided_svarianceyc_ndarray( const CBLAS_INT N, const float correction, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/stats/base/svarianceyc.h" +#include + +int main( void ) { + // Create a strided array: + const float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f }; + + // Specify the number of elements: + const int N = 4; + + // Specify the stride length: + const int strideX = 2; + + // Compute the variance: + float v = stdlib_strided_svarianceyc( N, 1.0f, x, strideX ); + + // Print the result: + printf( "sample variance: %f\n", v ); +} +``` + +
+ + + +
+ + +
+* * * + ## References - Youngs, Edward A., and Elliot M. Cramer. 1971. "Some Results Relevant to Choice of Sum and Sum-of-Product Algorithms." _Technometrics_ 13 (3): 657–65. doi:[10.1080/00401706.1971.10488826][@youngs:1971a]. diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.js index 4c4b88cace53..42de4b75e183 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.js @@ -21,14 +21,20 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float32Array = require( '@stdlib/array/float32' ); var pkg = require( './../package.json' ).name; var svarianceyc = require( './../lib/svarianceyc.js' ); +// VARIABLES // + +var option = { + 'dtype': 'float32' +}; + + // FUNCTIONS // /** @@ -40,12 +46,8 @@ var svarianceyc = require( './../lib/svarianceyc.js' ); */ function createBenchmark( len ) { var x; - var i; - x = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + x = uniform( len, -10, 10, option ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.native.js index f73c73480731..34f9eecd555e 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.native.js @@ -22,10 +22,9 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float32Array = require( '@stdlib/array/float32' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -36,6 +35,9 @@ var svarianceyc = tryRequire( resolve( __dirname, './../lib/svarianceyc.native.j var opts = { 'skip': ( svarianceyc instanceof Error ) }; +var option = { + 'dtype': 'float32' +}; // FUNCTIONS // @@ -49,12 +51,8 @@ var opts = { */ function createBenchmark( len ) { var x; - var i; - x = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + x = uniform( len, -10, 10, option ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.ndarray.js index ec4a91a25751..f974ddcf93bb 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.ndarray.js @@ -21,14 +21,20 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float32Array = require( '@stdlib/array/float32' ); var pkg = require( './../package.json' ).name; var svarianceyc = require( './../lib/ndarray.js' ); +// VARIABLES // + +var option = { + 'dtype': 'float32' +}; + + // FUNCTIONS // /** @@ -40,12 +46,8 @@ var svarianceyc = require( './../lib/ndarray.js' ); */ function createBenchmark( len ) { var x; - var i; - x = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + x = uniform( len, -10, 10, option ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.ndarray.native.js index 8f9604ba6521..2bdb48c6fc05 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.ndarray.native.js @@ -22,10 +22,9 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float32Array = require( '@stdlib/array/float32' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -36,6 +35,9 @@ var svarianceyc = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) var opts = { 'skip': ( svarianceyc instanceof Error ) }; +var option = { + 'dtype': 'float32' +}; // FUNCTIONS // @@ -49,12 +51,8 @@ var opts = { */ function createBenchmark( len ) { var x; - var i; - x = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + x = uniform( len, -10, 10, option ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/c/benchmark.length.c index ec0cc594aaa0..1d1040fcc849 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/c/benchmark.length.c @@ -94,7 +94,7 @@ static float rand_float( void ) { * @param len array length * @return elapsed time in seconds */ -static double benchmark( int iterations, int len ) { +static double benchmark1( int iterations, int len ) { double elapsed; float x[ len ]; float v; @@ -120,6 +120,39 @@ static double benchmark( int iterations, int len ) { return elapsed; } +/** +* Runs a benchmark. +* +* @param iterations number of iterations +* @param len array length +* @return elapsed time in seconds +*/ +static double benchmark2( int iterations, int len ) { + double elapsed; + float x[ len ]; + float v; + double t; + int i; + + for ( i = 0; i < len; i++ ) { + x[ i ] = ( rand_float() * 20000.0f ) - 10000.0f; + } + v = 0.0f; + t = tic(); + for ( i = 0; i < iterations; i++ ) { + v = stdlib_strided_svarianceyc_ndarray( len, 1.0f, x, 1, 0 ); + if ( v != v ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( v != v ) { + printf( "should not return NaN\n" ); + } + return elapsed; +} + /** * Main execution sequence. */ @@ -142,7 +175,18 @@ int main( void ) { for ( j = 0; j < REPEATS; j++ ) { count += 1; printf( "# c::%s:len=%d\n", NAME, len ); - elapsed = benchmark( iter, len ); + elapsed = benchmark1( iter, len ); + print_results( iter, elapsed ); + printf( "ok %d benchmark finished\n", count ); + } + } + for ( i = MIN; i <= MAX; i++ ) { + len = pow( 10, i ); + iter = ITERATIONS / pow( 10, i-1 ); + for ( j = 0; j < REPEATS; j++ ) { + count += 1; + printf( "# c::%s:ndarray:len=%d\n", NAME, len ); + elapsed = benchmark2( iter, len ); print_results( iter, elapsed ); printf( "ok %d benchmark finished\n", count ); } diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/svarianceyc/docs/repl.txt index c690da3ac3f5..c81ef714e0d3 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/docs/repl.txt @@ -1,10 +1,10 @@ -{{alias}}( N, correction, x, stride ) +{{alias}}( N, correction, x, strideX ) Computes the variance of a single-precision floating-point strided array using a one-pass algorithm proposed by Youngs and Cramer. - The `N` and `stride` parameters determine which elements in `x` are accessed - at runtime. + The `N` and stride parameters determine which elements in the strided array + 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: Float32Array Input array. - stride: integer - Index increment. + strideX: integer + Stride length. Returns ------- @@ -48,20 +48,17 @@ // Using `N` and `stride` parameters: > x = new {{alias:@stdlib/array/float32}}( [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ] ); - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > var stride = 2; - > {{alias}}( N, 1, x, stride ) + > {{alias}}( 3, 1, x, 2 ) ~4.3333 // Using view offsets: > var x0 = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] ); > var x1 = new {{alias:@stdlib/array/float32}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); - > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); - > stride = 2; - > {{alias}}( N, 1, x1, stride ) + > {{alias}}( 3, 1, x1, 2 ) ~4.3333 -{{alias}}.ndarray( N, correction, x, stride, offset ) + +{{alias}}.ndarray( N, correction, x, strideX, offsetX ) Computes the variance of a single-precision floating-point strided array using a one-pass algorithm proposed by Youngs and Cramer and alternative indexing semantics. @@ -90,10 +87,10 @@ x: Float32Array Input array. - stride: integer - Index increment. + strideX: integer + Stride length. - offset: integer + offsetX: integer Starting index. Returns @@ -110,10 +107,8 @@ // Using offset parameter: > var x = new {{alias:@stdlib/array/float32}}( [ 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 ) + > {{alias}}.ndarray( 3, 1, x, 2, 1 ) ~4.3333 See Also -------- - diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/svarianceyc/docs/types/index.d.ts index eb640d094f58..bbc7845b6ac5 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/docs/types/index.d.ts @@ -28,7 +28,7 @@ interface Routine { * @param N - number of indexed elements * @param correction - degrees of freedom adjustment * @param x - input array - * @param stride - stride length + * @param strideX - stride length * @returns variance * * @example @@ -39,7 +39,7 @@ interface Routine { * var v = svarianceyc( x.length, 1, x, 1 ); * // returns ~4.3333 */ - ( N: number, correction: number, x: Float32Array, stride: number ): number; + ( N: number, correction: number, x: Float32Array, strideX: number ): number; /** * Computes the variance of a single-precision floating-point strided array using a one-pass algorithm proposed by Youngs and Cramer and alternative indexing semantics. @@ -47,8 +47,8 @@ interface Routine { * @param N - number of indexed elements * @param correction - degrees of freedom adjustment * @param x - input array - * @param stride - stride length - * @param offset - starting index + * @param strideX - stride length + * @param offsetX - starting index * @returns variance * * @example @@ -59,7 +59,7 @@ interface Routine { * var v = svarianceyc.ndarray( x.length, 1, x, 1, 0 ); * // returns ~4.3333 */ - ndarray( N: number, correction: number, x: Float32Array, stride: number, offset: number ): number; + ndarray( N: number, correction: number, x: Float32Array, strideX: number, offsetX: number ): number; } /** @@ -68,7 +68,7 @@ interface Routine { * @param N - number of indexed elements * @param correction - degrees of freedom adjustment * @param x - input array -* @param stride - stride length +* @param strideX - stride length * @returns variance * * @example diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/svarianceyc/examples/c/example.c index 1d781c4c705b..487730dc1402 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/examples/c/example.c +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/examples/c/example.c @@ -17,21 +17,20 @@ */ #include "stdlib/stats/base/svarianceyc.h" -#include #include int main( void ) { // Create a strided array: - float x[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; + const float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f }; // Specify the number of elements: - int64_t N = 4; + const int N = 4; // Specify the stride length: - int64_t stride = 2; + const int strideX = 2; // Compute the variance: - float v = stdlib_strided_svarianceyc( N, 1.0f, x, stride ); + float v = stdlib_strided_svarianceyc( N, 1.0f, x, strideX ); // Print the result: printf( "sample variance: %f\n", v ); diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/examples/index.js b/lib/node_modules/@stdlib/stats/base/svarianceyc/examples/index.js index 25f0b017410f..6a8becd8deba 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/examples/index.js +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/examples/index.js @@ -18,18 +18,12 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var Float32Array = require( '@stdlib/array/float32' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var svarianceyc = require( './../lib' ); var x; -var i; -x = new Float32Array( 10 ); -for ( i = 0; i < x.length; i++ ) { - x[ i ] = round( (randu()*100.0) - 50.0 ); -} +x = discreteUniform( 10, -50, 50 ); console.log( x ); var v = svarianceyc( x.length, 1, x, 1 ); diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/include/stdlib/stats/base/svarianceyc.h b/lib/node_modules/@stdlib/stats/base/svarianceyc/include/stdlib/stats/base/svarianceyc.h index 031d5f018000..02794063d290 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/include/stdlib/stats/base/svarianceyc.h +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/include/stdlib/stats/base/svarianceyc.h @@ -19,7 +19,7 @@ #ifndef STDLIB_STATS_BASE_SVARIANCEYC_H #define STDLIB_STATS_BASE_SVARIANCEYC_H -#include +#include "stdlib/blas/base/shared.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. @@ -31,7 +31,12 @@ extern "C" { /** * Computes the variance of a single-precision floating-point strided array using a one-pass algorithm proposed by Youngs and Cramer. */ -float stdlib_strided_svarianceyc( const int64_t N, const float correction, const float *X, const int64_t stride ); +float API_SUFFIX(stdlib_strided_svarianceyc)( const CBLAS_INT N, const float correction, const float *X, const CBLAS_INT strideX ); + +/** +* Computes the variance of a single-precision floating-point strided array using a one-pass algorithm proposed by Youngs and Cramer. +*/ +float API_SUFFIX(stdlib_strided_svarianceyc_ndarray)( const CBLAS_INT N, const float correction, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ); #ifdef __cplusplus } diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/lib/index.js b/lib/node_modules/@stdlib/stats/base/svarianceyc/lib/index.js index 0448f6def64f..cdaa30e4f317 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/lib/index.js +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/lib/index.js @@ -28,9 +28,8 @@ * var svarianceyc = require( '@stdlib/stats/base/svarianceyc' ); * * var x = new Float32Array( [ 1.0, -2.0, 2.0 ] ); -* var N = x.length; * -* var v = svarianceyc( N, 1, x, 1 ); +* var v = svarianceyc( x.length, 1, x, 1 ); * // returns ~4.3333 * * @example @@ -39,9 +38,8 @@ * var svarianceyc = require( '@stdlib/stats/base/svarianceyc' ); * * var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); -* var N = floor( x.length / 2 ); * -* var v = svarianceyc.ndarray( N, 1, x, 2, 1 ); +* var v = svarianceyc.ndarray( x.length, 1, x, 2, 1 ); * // returns 6.25 */ diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/lib/ndarray.js b/lib/node_modules/@stdlib/stats/base/svarianceyc/lib/ndarray.js index f2ff0bf51164..a82998f67c41 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/lib/ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/lib/ndarray.js @@ -39,8 +39,8 @@ var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); * @param {PositiveInteger} N - number of indexed elements * @param {number} correction - degrees of freedom adjustment * @param {Float32Array} x - input array -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index +* @param {integer} strideX - stride length +* @param {NonNegativeInteger} offsetX - starting index * @returns {number} variance * * @example @@ -53,7 +53,7 @@ var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); * var v = svarianceyc( N, 1, x, 2, 1 ); * // returns 6.25 */ -function svarianceyc( N, correction, x, stride, offset ) { +function svarianceyc( N, correction, x, strideX, offsetX ) { var sum; var ix; var S; @@ -66,18 +66,18 @@ function svarianceyc( N, correction, x, stride, offset ) { if ( N <= 0 || n <= 0.0 ) { return NaN; } - if ( N === 1 || stride === 0 ) { + if ( N === 1 || strideX === 0 ) { return 0.0; } - sum = x[ offset ]; - ix = offset + stride; + sum = x[ offsetX ]; + ix = offsetX + strideX; S = 0.0; for ( i = 2; i <= N; i++ ) { v = x[ ix ]; sum = float64ToFloat32( sum+v ); d = float64ToFloat32( float64ToFloat32( i*v ) - sum ); S = float64ToFloat32( S + float64ToFloat32( float64ToFloat32( float64ToFloat32( 1.0/(i*(i-1)) ) * d ) * d ) ); // eslint-disable-line max-len - ix += stride; + ix += strideX; } return float64ToFloat32( S/n ); } diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/lib/ndarray.native.js b/lib/node_modules/@stdlib/stats/base/svarianceyc/lib/ndarray.native.js index b2defbd30d7d..bfc7102da52c 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/lib/ndarray.native.js @@ -20,8 +20,7 @@ // MODULES // -var Float32Array = require( '@stdlib/array/float32' ); -var addon = require( './svarianceyc.native.js' ); +var addon = require( './../src/addon.node' ); // MAIN // @@ -32,27 +31,20 @@ var addon = require( './svarianceyc.native.js' ); * @param {PositiveInteger} N - number of indexed elements * @param {number} correction - degrees of freedom adjustment * @param {Float32Array} x - input array -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index +* @param {integer} strideX - stride length +* @param {NonNegativeInteger} offsetX - starting index * @returns {number} variance * * @example * var Float32Array = require( '@stdlib/array/float32' ); -* var floor = require( '@stdlib/math/base/special/floor' ); * * var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); -* var N = floor( x.length / 2 ); * -* var v = svarianceyc( N, 1, x, 2, 1 ); +* var v = svarianceyc( 4, 1, x, 2, 1 ); * // returns 6.25 */ -function svarianceyc( N, correction, x, stride, offset ) { - var view; - if ( stride < 0 ) { - offset += (N-1) * stride; - } - view = new Float32Array( x.buffer, x.byteOffset+(x.BYTES_PER_ELEMENT*offset), x.length-offset ); // eslint-disable-line max-len - return addon( N, correction, view, stride ); +function svarianceyc( N, correction, x, strideX, offsetX ) { + return addon.ndarray( N, correction, x, strideX, offsetX ); } diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/lib/svarianceyc.js b/lib/node_modules/@stdlib/stats/base/svarianceyc/lib/svarianceyc.js index 231ff2d6b467..08b5d1f58fd1 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/lib/svarianceyc.js +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/lib/svarianceyc.js @@ -39,19 +39,18 @@ var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); * @param {PositiveInteger} N - number of indexed elements * @param {number} correction - degrees of freedom adjustment * @param {Float32Array} x - input array -* @param {integer} stride - stride length +* @param {integer} strideX - stride length * @returns {number} variance * * @example * var Float32Array = require( '@stdlib/array/float32' ); * * var x = new Float32Array( [ 1.0, -2.0, 2.0 ] ); -* var N = x.length; * -* var v = svarianceyc( N, 1, x, 1 ); +* var v = svarianceyc( x.length, 1, x, 1 ); * // returns ~4.3333 */ -function svarianceyc( N, correction, x, stride ) { +function svarianceyc( N, correction, x, strideX ) { var sum; var ix; var S; @@ -64,23 +63,23 @@ function svarianceyc( N, correction, x, stride ) { if ( N <= 0 || n <= 0.0 ) { return NaN; } - if ( N === 1 || stride === 0 ) { + if ( N === 1 || strideX === 0 ) { return 0.0; } - if ( stride < 0 ) { - ix = (1-N) * stride; + if ( strideX < 0 ) { + ix = (1-N) * strideX; } else { ix = 0; } sum = x[ ix ]; - ix += stride; + ix += strideX; S = 0.0; for ( i = 2; i <= N; i++ ) { v = x[ ix ]; sum = float64ToFloat32( sum+v ); d = float64ToFloat32( float64ToFloat32( i*v ) - sum ); S = float64ToFloat32( S + float64ToFloat32( float64ToFloat32( float64ToFloat32( 1.0/(i*(i-1)) ) * d ) * d ) ); // eslint-disable-line max-len - ix += stride; + ix += strideX; } return float64ToFloat32( S/n ); } diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/lib/svarianceyc.native.js b/lib/node_modules/@stdlib/stats/base/svarianceyc/lib/svarianceyc.native.js index 7be67f8937d1..fb01afc45cb0 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/lib/svarianceyc.native.js +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/lib/svarianceyc.native.js @@ -31,20 +31,19 @@ var addon = require( './../src/addon.node' ); * @param {PositiveInteger} N - number of indexed elements * @param {number} correction - degrees of freedom adjustment * @param {Float32Array} x - input array -* @param {integer} stride - stride length +* @param {integer} strideX - stride length * @returns {number} variance * * @example * var Float32Array = require( '@stdlib/array/float32' ); * * var x = new Float32Array( [ 1.0, -2.0, 2.0 ] ); -* var N = x.length; * -* var v = svarianceyc( N, 1, x, 1 ); +* var v = svarianceyc( x.length, 1, x, 1 ); * // returns ~4.3333 */ -function svarianceyc( N, correction, x, stride ) { - return addon( N, correction, x, stride ); +function svarianceyc( N, correction, x, strideX ) { + return addon( N, correction, x, strideX ); } diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/manifest.json b/lib/node_modules/@stdlib/stats/base/svarianceyc/manifest.json index 84a0318f76e3..44eefc954631 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/manifest.json +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/manifest.json @@ -1,6 +1,7 @@ { "options": { - "task": "build" + "task": "build", + "wasm": false }, "fields": [ { @@ -27,8 +28,9 @@ "confs": [ { "task": "build", + "wasm": false, "src": [ - "./src/svarianceyc.c" + "./src/main.c" ], "include": [ "./include" @@ -39,6 +41,8 @@ "libpath": [], "dependencies": [ "@stdlib/napi/export", + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", "@stdlib/napi/argv-strided-float32array", @@ -48,8 +52,9 @@ }, { "task": "benchmark", + "wasm": false, "src": [ - "./src/svarianceyc.c" + "./src/main.c" ], "include": [ "./include" @@ -58,12 +63,16 @@ "-lm" ], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" + ] }, { "task": "examples", + "wasm": false, "src": [ - "./src/svarianceyc.c" + "./src/main.c" ], "include": [ "./include" @@ -72,7 +81,28 @@ "-lm" ], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" + ] + }, + { + "task": "", + "wasm": false, + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" + ] } ] } diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/src/addon.c b/lib/node_modules/@stdlib/stats/base/svarianceyc/src/addon.c index f6a7f461b80e..26a46972c4da 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/src/addon.c +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/src/addon.c @@ -36,10 +36,28 @@ static napi_value addon( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV( env, info, argv, argc, 4 ); STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); STDLIB_NAPI_ARGV_FLOAT( env, correction, argv, 1 ); - STDLIB_NAPI_ARGV_INT64( env, stride, argv, 3 ); - STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, stride, argv, 2 ) - STDLIB_NAPI_CREATE_DOUBLE( env, (double)stdlib_strided_svarianceyc( N, correction, X, stride ), v ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 2 ); + STDLIB_NAPI_CREATE_DOUBLE( env, (double)stdlib_strided_svarianceyc( N, correction, X, strideX ), v ); return v; } -STDLIB_NAPI_MODULE_EXPORT_FCN( addon ) +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +static napi_value addon_method( napi_env env, napi_callback_info info ) { + STDLIB_NAPI_ARGV( env, info, argv, argc, 5 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); + STDLIB_NAPI_ARGV_FLOAT( env, correction, argv, 1 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 2 ); + STDLIB_NAPI_ARGV_INT64( env, offesetX, argv, 4 ); + STDLIB_NAPI_CREATE_DOUBLE( env, (double)stdlib_strided_svarianceyc_ndarray( N, correction, X, strideX, offesetX ), v ); + + return v; +} +STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method ) diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/src/svarianceyc.c b/lib/node_modules/@stdlib/stats/base/svarianceyc/src/main.c similarity index 53% rename from lib/node_modules/@stdlib/stats/base/svarianceyc/src/svarianceyc.c rename to lib/node_modules/@stdlib/stats/base/svarianceyc/src/main.c index 0b74c6148e04..fa6e87a31530 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/src/svarianceyc.c +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/src/main.c @@ -17,7 +17,8 @@ */ #include "stdlib/stats/base/svarianceyc.h" -#include +#include "stdlib/blas/base/shared.h" +#include "stdlib/strided/base/stride2offset.h" /** * Computes the variance of a single-precision floating-point strided array using a one-pass algorithm proposed by Youngs and Cramer. @@ -33,33 +34,45 @@ * @param N number of indexed elements * @param correction degrees of freedom adjustment * @param X input array -* @param stride stride length +* @param strideX stride length * @return output value */ -float stdlib_strided_svarianceyc( const int64_t N, const float correction, const float *X, const int64_t stride ) { - int64_t ix; - int64_t i; - double di; - float sum; - double n; - float S; +float API_SUFFIX(stdlib_strided_svarianceyc)( const CBLAS_INT N, const float correction, const float *X, const CBLAS_INT strideX ) { + CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX ); + return API_SUFFIX(stdlib_strided_svarianceyc_ndarray)( N, correction, X, strideX, ox ); +} + + +/** +* Computes the variance of a single-precision floating-point strided array using a one-pass algorithm proposed by Youngs and Cramer using alternative indexing semantics. +* +* @param N number of indexed elements +* @param correction degrees of freedom adjustment +* @param X input array +* @param strideX stride length +* @param offsetX starting index of X +* @return output value +*/ +float API_SUFFIX(stdlib_strided_svarianceyc_ndarray)( const CBLAS_INT N, const float correction, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) { + CBLAS_INT ix; + CBLAS_INT i; + double di; + float sum; + double n; + float S; float v; float d; - n = (double)N - (double)correction; - if ( N <= 0 || n <= 0.0f ) { - return 0.0f / 0.0f; // NaN - } - if ( N == 1 || stride == 0 ) { - return 0.0f; - } - if ( stride < 0 ) { - ix = (1-N) * stride; - } else { - ix = 0; - } - sum = X[ ix ]; - ix += stride; + n = (double)N - (double)correction; + if ( N <= 0 || n <= 0.0f ) { + return 0.0f / 0.0f; // Nan + } + if ( N ==1 || strideX == 0 ) { + return 0.0f; + } + ix = offsetX; + sum = X[ ix ]; + ix += strideX; S = 0.0f; for ( i = 2; i <= N; i++ ) { di = (double)i; @@ -67,7 +80,7 @@ float stdlib_strided_svarianceyc( const int64_t N, const float correction, const sum += v; d = (float)(di*(double)v) - sum; S += (float)(1.0/(di*(di-1.0))) * d * d; - ix += stride; + ix += strideX; } return (double)S / n; } diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/svarianceyc/test/test.ndarray.js index 4744735e1b4f..0ad58b76d89f 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/test/test.ndarray.js @@ -21,7 +21,6 @@ // MODULES // var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); var Float32Array = require( '@stdlib/array/float32' ); @@ -122,7 +121,6 @@ tape( 'if provided a `correction` parameter yielding `N-correction` less than or }); tape( 'the function supports a `stride` parameter', function test( t ) { - var N; var x; var v; @@ -137,15 +135,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) { 2.0 ]); - N = floor( x.length / 2 ); - v = svarianceyc( N, 1, x, 2, 0 ); + v = svarianceyc( 4, 1, x, 2, 0 ); t.strictEqual( v, 6.25, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', function test( t ) { - var N; var x; var v; @@ -160,8 +156,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) 2.0 ]); - N = floor( x.length / 2 ); - v = svarianceyc( N, 1, x, -2, 6 ); + v = svarianceyc( 4, 1, x, -2, 6 ); t.strictEqual( v, 6.25, 'returns expected value' ); t.end(); @@ -180,7 +175,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`', }); tape( 'the function supports an `offset` parameter', function test( t ) { - var N; var x; var v; @@ -194,9 +188,8 @@ tape( 'the function supports an `offset` parameter', function test( t ) { 3.0, 4.0 // 3 ]); - N = floor( x.length / 2 ); - v = svarianceyc( N, 1, x, 2, 1 ); + v = svarianceyc( 4, 1, x, 2, 1 ); t.strictEqual( v, 6.25, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/test/test.ndarray.native.js b/lib/node_modules/@stdlib/stats/base/svarianceyc/test/test.ndarray.native.js index 1209c9324116..5aa8b35322d9 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/test/test.ndarray.native.js @@ -22,7 +22,6 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); var Float32Array = require( '@stdlib/array/float32' ); @@ -131,7 +130,6 @@ tape( 'if provided a `correction` parameter yielding `N-correction` less than or }); tape( 'the function supports a `stride` parameter', opts, function test( t ) { - var N; var x; var v; @@ -146,15 +144,13 @@ tape( 'the function supports a `stride` parameter', opts, function test( t ) { 2.0 ]); - N = floor( x.length / 2 ); - v = svarianceyc( N, 1, x, 2, 0 ); + v = svarianceyc( 4, 1, x, 2, 0 ); t.strictEqual( v, 6.25, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', opts, function test( t ) { - var N; var x; var v; @@ -169,8 +165,7 @@ tape( 'the function supports a negative `stride` parameter', opts, function test 2.0 ]); - N = floor( x.length / 2 ); - v = svarianceyc( N, 1, x, -2, 6 ); + v = svarianceyc( 4, 1, x, -2, 6 ); t.strictEqual( v, 6.25, 'returns expected value' ); t.end(); @@ -189,7 +184,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`', }); tape( 'the function supports an `offset` parameter', opts, function test( t ) { - var N; var x; var v; @@ -203,9 +197,8 @@ tape( 'the function supports an `offset` parameter', opts, function test( t ) { 3.0, 4.0 // 3 ]); - N = floor( x.length / 2 ); - v = svarianceyc( N, 1, x, 2, 1 ); + v = svarianceyc( 4, 1, x, 2, 1 ); t.strictEqual( v, 6.25, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/test/test.svarianceyc.js b/lib/node_modules/@stdlib/stats/base/svarianceyc/test/test.svarianceyc.js index 4f7b762d4610..b3958706e4b5 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/test/test.svarianceyc.js +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/test/test.svarianceyc.js @@ -21,7 +21,6 @@ // MODULES // var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); var Float32Array = require( '@stdlib/array/float32' ); @@ -122,7 +121,6 @@ tape( 'if provided a `correction` parameter yielding `N-correction` less than or }); tape( 'the function supports a `stride` parameter', function test( t ) { - var N; var x; var v; @@ -137,15 +135,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) { 2.0 ]); - N = floor( x.length / 2 ); - v = svarianceyc( N, 1, x, 2 ); + v = svarianceyc( 4, 1, x, 2 ); t.strictEqual( v, 6.25, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', function test( t ) { - var N; var x; var v; @@ -160,8 +156,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) 2.0 ]); - N = floor( x.length / 2 ); - v = svarianceyc( N, 1, x, -2 ); + v = svarianceyc( 4, 1, x, -2 ); t.strictEqual( v, 6.25, 'returns expected value' ); t.end(); @@ -182,7 +177,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`', tape( 'the function supports view offsets', function test( t ) { var x0; var x1; - var N; var v; x0 = new Float32Array([ @@ -198,9 +192,8 @@ tape( 'the function supports view offsets', function test( t ) { ]); x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element - N = floor(x1.length / 2); - v = svarianceyc( N, 1, x1, 2 ); + v = svarianceyc( 4, 1, x1, 2 ); t.strictEqual( v, 6.25, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/test/test.svarianceyc.native.js b/lib/node_modules/@stdlib/stats/base/svarianceyc/test/test.svarianceyc.native.js index 3fd5c7b2faa6..36114f5da184 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/test/test.svarianceyc.native.js +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/test/test.svarianceyc.native.js @@ -22,7 +22,6 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); var Float32Array = require( '@stdlib/array/float32' ); @@ -131,7 +130,6 @@ tape( 'if provided a `correction` parameter yielding `N-correction` less than or }); tape( 'the function supports a `stride` parameter', opts, function test( t ) { - var N; var x; var v; @@ -146,15 +144,13 @@ tape( 'the function supports a `stride` parameter', opts, function test( t ) { 2.0 ]); - N = floor( x.length / 2 ); - v = svarianceyc( N, 1, x, 2 ); + v = svarianceyc( 4, 1, x, 2 ); t.strictEqual( v, 6.25, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', opts, function test( t ) { - var N; var x; var v; @@ -169,8 +165,7 @@ tape( 'the function supports a negative `stride` parameter', opts, function test 2.0 ]); - N = floor( x.length / 2 ); - v = svarianceyc( N, 1, x, -2 ); + v = svarianceyc( 4, 1, x, -2 ); t.strictEqual( v, 6.25, 'returns expected value' ); t.end(); @@ -191,7 +186,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`', tape( 'the function supports view offsets', opts, function test( t ) { var x0; var x1; - var N; var v; x0 = new Float32Array([ @@ -207,9 +201,8 @@ tape( 'the function supports view offsets', opts, function test( t ) { ]); x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element - N = floor(x1.length / 2); - v = svarianceyc( N, 1, x1, 2 ); + v = svarianceyc( 4, 1, x1, 2 ); t.strictEqual( v, 6.25, 'returns expected value' ); t.end(); From 6eba0833d073d3e2bdb670b25fd23d18c3220361 Mon Sep 17 00:00:00 2001 From: Vinit Pandit Date: Mon, 30 Dec 2024 09:34:12 +0000 Subject: [PATCH 02/20] fix: fixing cppcheck error --- 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: passed - 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 --- --- 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: passed - 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 --- --- .../stats/base/svarianceyc/benchmark/c/benchmark.length.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/c/benchmark.length.c index 1d1040fcc849..58d05b4c6c9f 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/c/benchmark.length.c @@ -107,6 +107,7 @@ static double benchmark1( int iterations, int len ) { v = 0.0f; t = tic(); for ( i = 0; i < iterations; i++ ) { + // cppcheck-suppress uninitvar v = stdlib_strided_svarianceyc( len, 1.0f, x, 1 ); if ( v != v ) { printf( "should not return NaN\n" ); @@ -140,6 +141,7 @@ static double benchmark2( int iterations, int len ) { v = 0.0f; t = tic(); for ( i = 0; i < iterations; i++ ) { + // cppcheck-suppress uninitvar v = stdlib_strided_svarianceyc_ndarray( len, 1.0f, x, 1, 0 ); if ( v != v ) { printf( "should not return NaN\n" ); From 8e403f3d0d5cf9968d23c8d33ad128f19df305a9 Mon Sep 17 00:00:00 2001 From: Vinit Pandit Date: Sat, 4 Jan 2025 12:10:10 +0530 Subject: [PATCH 03/20] fix: fixing mistakes --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - 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: passed - 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 --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: passed - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: passed - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: passed - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: passed - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: passed - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: passed - 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/stats/base/svarianceyc/README.md | 17 +++------ .../base/svarianceyc/benchmark/benchmark.js | 4 +-- .../svarianceyc/benchmark/benchmark.native.js | 4 +-- .../benchmark/benchmark.ndarray.js | 4 +-- .../benchmark/benchmark.ndarray.native.js | 4 +-- .../stats/base/svarianceyc/examples/index.js | 4 ++- .../stats/base/svarianceyc/lib/index.js | 1 - .../stats/base/svarianceyc/lib/ndarray.js | 4 +-- .../stats/base/svarianceyc/lib/svarianceyc.js | 35 ++----------------- .../stats/base/svarianceyc/manifest.json | 12 ++----- .../stats/base/svarianceyc/src/addon.c | 1 - 11 files changed, 22 insertions(+), 68 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/README.md b/lib/node_modules/@stdlib/stats/base/svarianceyc/README.md index 68353dba9cf3..4f5869362385 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/README.md +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/README.md @@ -164,7 +164,6 @@ While [`typed array`][mdn-typed-array] views mandate a view offset based on the ```javascript var Float32Array = require( '@stdlib/array/float32' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); @@ -194,18 +193,12 @@ var v = svarianceyc.ndarray( 4, 1, x, 2, 1 ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var Float32Array = require( '@stdlib/array/float32' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var svarianceyc = require( '@stdlib/stats/base/svarianceyc' ); -var x; -var i; - -x = new Float32Array( 10 ); -for ( i = 0; i < x.length; i++ ) { - x[ i ] = round( (randu()*100.0) - 50.0 ); -} +var x = discreteUniform( 10, -50, 50, { + 'dtype': 'float32' +}); console.log( x ); var v = svarianceyc( x.length, 1, x, 1 ); @@ -260,8 +253,6 @@ The function accepts the following arguments: - **x**: `[in] float*` input array. - **strideX**: stride length for `x`. -The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute the [variance][variance] of every other element in `x`, - ```c float stdlib_strided_svarianceyc( const CBLAS_INT N, const float correction, const float *X, const CBLAS_INT strideX ); ``` diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.js index 42de4b75e183..5557ddf0f572 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.js @@ -30,7 +30,7 @@ var svarianceyc = require( './../lib/svarianceyc.js' ); // VARIABLES // -var option = { +var options = { 'dtype': 'float32' }; @@ -47,7 +47,7 @@ var option = { function createBenchmark( len ) { var x; - x = uniform( len, -10, 10, option ); + x = uniform( len, -10, 10, options ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.native.js index 34f9eecd555e..4ac7a1639e11 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.native.js @@ -35,7 +35,7 @@ var svarianceyc = tryRequire( resolve( __dirname, './../lib/svarianceyc.native.j var opts = { 'skip': ( svarianceyc instanceof Error ) }; -var option = { +var options = { 'dtype': 'float32' }; @@ -52,7 +52,7 @@ var option = { function createBenchmark( len ) { var x; - x = uniform( len, -10, 10, option ); + x = uniform( len, -10, 10, options ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.ndarray.js index f974ddcf93bb..c8d4f72b717f 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.ndarray.js @@ -30,7 +30,7 @@ var svarianceyc = require( './../lib/ndarray.js' ); // VARIABLES // -var option = { +var options = { 'dtype': 'float32' }; @@ -47,7 +47,7 @@ var option = { function createBenchmark( len ) { var x; - x = uniform( len, -10, 10, option ); + x = uniform( len, -10, 10, options ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.ndarray.native.js index 2bdb48c6fc05..94478308b33c 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.ndarray.native.js @@ -35,7 +35,7 @@ var svarianceyc = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) var opts = { 'skip': ( svarianceyc instanceof Error ) }; -var option = { +var options = { 'dtype': 'float32' }; @@ -52,7 +52,7 @@ var option = { function createBenchmark( len ) { var x; - x = uniform( len, -10, 10, option ); + x = uniform( len, -10, 10, options ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/examples/index.js b/lib/node_modules/@stdlib/stats/base/svarianceyc/examples/index.js index 6a8becd8deba..675f264799c9 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/examples/index.js +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/examples/index.js @@ -23,7 +23,9 @@ var svarianceyc = require( './../lib' ); var x; -x = discreteUniform( 10, -50, 50 ); +x = discreteUniform( 10, -50, 50, { + 'dtype': 'float32' +}); console.log( x ); var v = svarianceyc( x.length, 1, x, 1 ); diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/lib/index.js b/lib/node_modules/@stdlib/stats/base/svarianceyc/lib/index.js index cdaa30e4f317..e9635dc7c2cf 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/lib/index.js +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/lib/index.js @@ -34,7 +34,6 @@ * * @example * var Float32Array = require( '@stdlib/array/float32' ); -* var floor = require( '@stdlib/math/base/special/floor' ); * var svarianceyc = require( '@stdlib/stats/base/svarianceyc' ); * * var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/lib/ndarray.js b/lib/node_modules/@stdlib/stats/base/svarianceyc/lib/ndarray.js index a82998f67c41..27aa0836a8e7 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/lib/ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/lib/ndarray.js @@ -45,12 +45,10 @@ var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); * * @example * var Float32Array = require( '@stdlib/array/float32' ); -* var floor = require( '@stdlib/math/base/special/floor' ); * * var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); -* var N = floor( x.length / 2 ); * -* var v = svarianceyc( N, 1, x, 2, 1 ); +* var v = svarianceyc( 4, 1, x, 2, 1 ); * // returns 6.25 */ function svarianceyc( N, correction, x, strideX, offsetX ) { diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/lib/svarianceyc.js b/lib/node_modules/@stdlib/stats/base/svarianceyc/lib/svarianceyc.js index 08b5d1f58fd1..2332c207a715 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/lib/svarianceyc.js +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/lib/svarianceyc.js @@ -20,7 +20,8 @@ // MODULES // -var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var stride2offset = require( '@stdlib/strided/base/stride2offset' ); +var ndarray = require( './ndarray.js' ); // MAIN // @@ -51,37 +52,7 @@ var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); * // returns ~4.3333 */ function svarianceyc( N, correction, x, strideX ) { - var sum; - var ix; - var S; - var v; - var d; - var n; - var i; - - n = N - correction; - if ( N <= 0 || n <= 0.0 ) { - return NaN; - } - if ( N === 1 || strideX === 0 ) { - return 0.0; - } - if ( strideX < 0 ) { - ix = (1-N) * strideX; - } else { - ix = 0; - } - sum = x[ ix ]; - ix += strideX; - S = 0.0; - for ( i = 2; i <= N; i++ ) { - v = x[ ix ]; - sum = float64ToFloat32( sum+v ); - d = float64ToFloat32( float64ToFloat32( i*v ) - sum ); - S = float64ToFloat32( S + float64ToFloat32( float64ToFloat32( float64ToFloat32( 1.0/(i*(i-1)) ) * d ) * d ) ); // eslint-disable-line max-len - ix += strideX; - } - return float64ToFloat32( S/n ); + return ndarray( N, correction, x, strideX, stride2offset( N, strideX ) ); } diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/manifest.json b/lib/node_modules/@stdlib/stats/base/svarianceyc/manifest.json index 44eefc954631..8400991c4ca5 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/manifest.json +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/manifest.json @@ -35,9 +35,7 @@ "include": [ "./include" ], - "libraries": [ - "-lm" - ], + "libraries": [], "libpath": [], "dependencies": [ "@stdlib/napi/export", @@ -59,9 +57,7 @@ "include": [ "./include" ], - "libraries": [ - "-lm" - ], + "libraries": [], "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", @@ -95,9 +91,7 @@ "include": [ "./include" ], - "libraries": [ - "-lm" - ], + "libraries": [], "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/src/addon.c b/lib/node_modules/@stdlib/stats/base/svarianceyc/src/addon.c index 26a46972c4da..b9af126d2838 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/src/addon.c +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/src/addon.c @@ -57,7 +57,6 @@ static napi_value addon_method( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 2 ); STDLIB_NAPI_ARGV_INT64( env, offesetX, argv, 4 ); STDLIB_NAPI_CREATE_DOUBLE( env, (double)stdlib_strided_svarianceyc_ndarray( N, correction, X, strideX, offesetX ), v ); - return v; } STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method ) From aec6b5adab07223674160ffa73d173d22e23795e Mon Sep 17 00:00:00 2001 From: Vinit Pandit Date: Sat, 4 Jan 2025 12:58:29 +0530 Subject: [PATCH 04/20] fix: fixing comments --- 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: passed - 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 --- --- 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 --- --- .../base/svarianceyc/include/stdlib/stats/base/svarianceyc.h | 2 +- lib/node_modules/@stdlib/stats/base/svarianceyc/src/main.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/include/stdlib/stats/base/svarianceyc.h b/lib/node_modules/@stdlib/stats/base/svarianceyc/include/stdlib/stats/base/svarianceyc.h index 02794063d290..d2f27a6ab8f6 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/include/stdlib/stats/base/svarianceyc.h +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/include/stdlib/stats/base/svarianceyc.h @@ -34,7 +34,7 @@ extern "C" { float API_SUFFIX(stdlib_strided_svarianceyc)( const CBLAS_INT N, const float correction, const float *X, const CBLAS_INT strideX ); /** -* Computes the variance of a single-precision floating-point strided array using a one-pass algorithm proposed by Youngs and Cramer. +* Computes the variance of a single-precision floating-point strided array using a one-pass algorithm proposed by Youngs and Cramer, using alternative indexing semantics. */ float API_SUFFIX(stdlib_strided_svarianceyc_ndarray)( const CBLAS_INT N, const float correction, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ); diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/src/main.c b/lib/node_modules/@stdlib/stats/base/svarianceyc/src/main.c index fa6e87a31530..280840300eaf 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/src/main.c +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/src/main.c @@ -44,7 +44,7 @@ float API_SUFFIX(stdlib_strided_svarianceyc)( const CBLAS_INT N, const float cor /** -* Computes the variance of a single-precision floating-point strided array using a one-pass algorithm proposed by Youngs and Cramer using alternative indexing semantics. +* Computes the variance of a single-precision floating-point strided array using a one-pass algorithm proposed by Youngs and Cramer, using alternative indexing semantics. * * @param N number of indexed elements * @param correction degrees of freedom adjustment From b00ece3cdb5b9b20e1b76a1bb4db91c1ad8dd850 Mon Sep 17 00:00:00 2001 From: Vinit Pandit Date: Sat, 4 Jan 2025 23:56:23 +0530 Subject: [PATCH 05/20] fix: fixing Readme --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: 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 --- --- 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: passed - 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 --- --- lib/node_modules/@stdlib/stats/base/svarianceyc/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/README.md b/lib/node_modules/@stdlib/stats/base/svarianceyc/README.md index 4f5869362385..68408d824100 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/README.md +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/README.md @@ -251,7 +251,7 @@ The function accepts the following arguments: - **N**: `[in] CBLAS_INT` number of indexed elements. - **correction**: `[in] float` 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 [variance][variance] according to `N-c` where c corresponds to the provided degrees of freedom adjustment. When computing the [variance][variance] 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 unbiased sample [variance][variance], 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**: `[in] float*` input array. -- **strideX**: stride length for `x`. +- **strideX**: `[in] CBLAS_INT` stride length for `x`. ```c float stdlib_strided_svarianceyc( const CBLAS_INT N, const float correction, const float *X, const CBLAS_INT strideX ); @@ -259,7 +259,7 @@ float stdlib_strided_svarianceyc( const CBLAS_INT N, const float correction, con #### stdlib_strided_svarianceyc_ndarray( N, correction, \*X, strideX, offsetX ) -Computes the [variance][variance] of a single-precision floating-point strided array using a one-pass algorithm proposed by Youngs and Cramer and alternative indexing semantics. +Computes the [variance][variance] of a single-precision floating-point strided array using a one-pass algorithm proposed by Youngs and Cramer and using alternative indexing semantics. ```c const float x[] = { 1.0f, -2.0f, 2.0f }; From b5df58398db737c90c22f5eb63388d0450b97dfd Mon Sep 17 00:00:00 2001 From: Vinit Pandit <106718914+MeastroZI@users.noreply.github.com> Date: Sat, 4 Jan 2025 23:57:22 +0530 Subject: [PATCH 06/20] style: remove extra space Signed-off-by: Vinit Pandit <106718914+MeastroZI@users.noreply.github.com> --- lib/node_modules/@stdlib/stats/base/svarianceyc/docs/repl.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/svarianceyc/docs/repl.txt index c81ef714e0d3..4c7a405454d4 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/docs/repl.txt @@ -57,7 +57,6 @@ > {{alias}}( 3, 1, x1, 2 ) ~4.3333 - {{alias}}.ndarray( N, correction, x, strideX, offsetX ) Computes the variance of a single-precision floating-point strided array using a one-pass algorithm proposed by Youngs and Cramer and alternative From 1fd8e2fca2942b04b5c207763c8a57c64190bf7d Mon Sep 17 00:00:00 2001 From: Vinit Pandit <106718914+MeastroZI@users.noreply.github.com> Date: Sun, 5 Jan 2025 00:09:33 +0530 Subject: [PATCH 07/20] Revert previous commit Signed-off-by: Vinit Pandit <106718914+MeastroZI@users.noreply.github.com> --- lib/node_modules/@stdlib/stats/base/svarianceyc/docs/repl.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/svarianceyc/docs/repl.txt index 4c7a405454d4..c81ef714e0d3 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/docs/repl.txt @@ -57,6 +57,7 @@ > {{alias}}( 3, 1, x1, 2 ) ~4.3333 + {{alias}}.ndarray( N, correction, x, strideX, offsetX ) Computes the variance of a single-precision floating-point strided array using a one-pass algorithm proposed by Youngs and Cramer and alternative From 199e4da1c880ebf6d557da3472ec759f0b4bc8e9 Mon Sep 17 00:00:00 2001 From: Vinit Pandit Date: Mon, 6 Jan 2025 17:13:44 +0530 Subject: [PATCH 08/20] fix: readme fix --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: 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 --- --- 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: passed - 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 --- --- 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: passed - 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 --- --- lib/node_modules/@stdlib/stats/base/svarianceyc/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/README.md b/lib/node_modules/@stdlib/stats/base/svarianceyc/README.md index 68408d824100..d406e408b59a 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/README.md +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/README.md @@ -328,10 +328,10 @@ int main( void ) { -
- * * * +
+ ## References - Youngs, Edward A., and Elliot M. Cramer. 1971. "Some Results Relevant to Choice of Sum and Sum-of-Product Algorithms." _Technometrics_ 13 (3): 657–65. doi:[10.1080/00401706.1971.10488826][@youngs:1971a]. From 925f3f70e321548f79f970789cc9f86952cb8634 Mon Sep 17 00:00:00 2001 From: Vinit Pandit Date: Mon, 6 Jan 2025 17:27:28 +0530 Subject: [PATCH 09/20] style: fix spaces --- 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: passed - 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 --- --- 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 --- --- lib/node_modules/@stdlib/stats/base/svarianceyc/src/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/src/main.c b/lib/node_modules/@stdlib/stats/base/svarianceyc/src/main.c index 280840300eaf..12f060ef5c3a 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/src/main.c +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/src/main.c @@ -60,8 +60,8 @@ float API_SUFFIX(stdlib_strided_svarianceyc_ndarray)( const CBLAS_INT N, const f float sum; double n; float S; - float v; - float d; + float v; + float d; n = (double)N - (double)correction; if ( N <= 0 || n <= 0.0f ) { From e79e0f3154a221d0fa67dd154379ce6e26c006d8 Mon Sep 17 00:00:00 2001 From: Vinit Pandit <106718914+MeastroZI@users.noreply.github.com> Date: Mon, 6 Jan 2025 17:28:57 +0530 Subject: [PATCH 10/20] Some fixes Signed-off-by: Vinit Pandit <106718914+MeastroZI@users.noreply.github.com> --- lib/node_modules/@stdlib/stats/base/svarianceyc/docs/repl.txt | 2 +- lib/node_modules/@stdlib/stats/base/svarianceyc/lib/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/svarianceyc/docs/repl.txt index c81ef714e0d3..c8320f182444 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/docs/repl.txt @@ -46,7 +46,7 @@ > {{alias}}( x.length, 1, x, 1 ) ~4.3333 - // Using `N` and `stride` parameters: + // Using `N` and stride parameters: > x = new {{alias:@stdlib/array/float32}}( [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ] ); > {{alias}}( 3, 1, x, 2 ) ~4.3333 diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/lib/index.js b/lib/node_modules/@stdlib/stats/base/svarianceyc/lib/index.js index e9635dc7c2cf..5835bc2ddedd 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/lib/index.js +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/lib/index.js @@ -38,7 +38,7 @@ * * var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); * -* var v = svarianceyc.ndarray( x.length, 1, x, 2, 1 ); +* var v = svarianceyc.ndarray( 4, 1, x, 2, 1 ); * // returns 6.25 */ From 4f2726d15d45a83c5dca61de6334ca3ca4cfe554 Mon Sep 17 00:00:00 2001 From: Vinit Pandit Date: Mon, 6 Jan 2025 15:20:57 +0000 Subject: [PATCH 11/20] style: fixing space in manifest --- 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 --- --- 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 --- --- 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 --- --- lib/node_modules/@stdlib/stats/base/svarianceyc/manifest.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/manifest.json b/lib/node_modules/@stdlib/stats/base/svarianceyc/manifest.json index 8400991c4ca5..47febd9f446e 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/manifest.json +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/manifest.json @@ -27,8 +27,8 @@ ], "confs": [ { - "task": "build", - "wasm": false, + "task": "build", + "wasm": false, "src": [ "./src/main.c" ], From ec22b4d6466915104d4112ec1ca635ff2a96c390 Mon Sep 17 00:00:00 2001 From: Vinit Pandit Date: Mon, 6 Jan 2025 16:38:51 +0000 Subject: [PATCH 12/20] fix: cleanups --- 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: passed - 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: passed - 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 --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: passed - 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: passed - 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/stats/base/svarianceyc/benchmark/benchmark.js | 4 +--- .../stats/base/svarianceyc/benchmark/benchmark.native.js | 4 +--- .../stats/base/svarianceyc/benchmark/benchmark.ndarray.js | 4 +--- .../svarianceyc/benchmark/benchmark.ndarray.native.js | 4 +--- .../@stdlib/stats/base/svarianceyc/examples/index.js | 4 +--- .../svarianceyc/include/stdlib/stats/base/svarianceyc.h | 2 +- .../@stdlib/stats/base/svarianceyc/src/main.c | 8 ++++---- 7 files changed, 10 insertions(+), 20 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.js index 5557ddf0f572..4f797d9a04b9 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.js @@ -45,9 +45,7 @@ var options = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - - x = uniform( len, -10, 10, options ); + var x = uniform( len, -10, 10, options ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.native.js index 4ac7a1639e11..ac3eed32893a 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.native.js @@ -50,9 +50,7 @@ var options = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - - x = uniform( len, -10, 10, options ); + var x = uniform( len, -10, 10, options ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.ndarray.js index c8d4f72b717f..62bae635a6fc 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.ndarray.js @@ -45,9 +45,7 @@ var options = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - - x = uniform( len, -10, 10, options ); + var x = uniform( len, -10, 10, options ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.ndarray.native.js index 94478308b33c..3dbafab017de 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/benchmark/benchmark.ndarray.native.js @@ -50,9 +50,7 @@ var options = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - - x = uniform( len, -10, 10, options ); + var x = uniform( len, -10, 10, options ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/examples/index.js b/lib/node_modules/@stdlib/stats/base/svarianceyc/examples/index.js index 675f264799c9..8273e6e91f19 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/examples/index.js +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/examples/index.js @@ -21,9 +21,7 @@ var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var svarianceyc = require( './../lib' ); -var x; - -x = discreteUniform( 10, -50, 50, { +var x = discreteUniform( 10, -50, 50, { 'dtype': 'float32' }); console.log( x ); diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/include/stdlib/stats/base/svarianceyc.h b/lib/node_modules/@stdlib/stats/base/svarianceyc/include/stdlib/stats/base/svarianceyc.h index d2f27a6ab8f6..ae23270a7b5c 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/include/stdlib/stats/base/svarianceyc.h +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/include/stdlib/stats/base/svarianceyc.h @@ -34,7 +34,7 @@ extern "C" { float API_SUFFIX(stdlib_strided_svarianceyc)( const CBLAS_INT N, const float correction, const float *X, const CBLAS_INT strideX ); /** -* Computes the variance of a single-precision floating-point strided array using a one-pass algorithm proposed by Youngs and Cramer, using alternative indexing semantics. +* Computes the variance of a single-precision floating-point strided array using a one-pass algorithm proposed by Youngs and Cramer and alternative indexing semantics. */ float API_SUFFIX(stdlib_strided_svarianceyc_ndarray)( const CBLAS_INT N, const float correction, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ); diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/src/main.c b/lib/node_modules/@stdlib/stats/base/svarianceyc/src/main.c index 12f060ef5c3a..255e42cf7e31 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/src/main.c +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/src/main.c @@ -44,7 +44,7 @@ float API_SUFFIX(stdlib_strided_svarianceyc)( const CBLAS_INT N, const float cor /** -* Computes the variance of a single-precision floating-point strided array using a one-pass algorithm proposed by Youngs and Cramer, using alternative indexing semantics. +* Computes the variance of a single-precision floating-point strided array using a one-pass algorithm proposed by Youngs and Cramer and alternative indexing semantics. * * @param N number of indexed elements * @param correction degrees of freedom adjustment @@ -65,7 +65,7 @@ float API_SUFFIX(stdlib_strided_svarianceyc_ndarray)( const CBLAS_INT N, const f n = (double)N - (double)correction; if ( N <= 0 || n <= 0.0f ) { - return 0.0f / 0.0f; // Nan + return 0.0f / 0.0f; // NaN } if ( N ==1 || strideX == 0 ) { return 0.0f; @@ -78,8 +78,8 @@ float API_SUFFIX(stdlib_strided_svarianceyc_ndarray)( const CBLAS_INT N, const f di = (double)i; v = X[ ix ]; sum += v; - d = (float)(di*(double)v) - sum; - S += (float)(1.0/(di*(di-1.0))) * d * d; + d = (float)( di * (double)v ) - sum; + S += (float)( 1.0 / ( di * ( di-1.0 ) ) ) * d * d; ix += strideX; } return (double)S / n; From 7515d0fb228475002f00c269f1ef4516cc84934f Mon Sep 17 00:00:00 2001 From: Vinit Pandit <106718914+MeastroZI@users.noreply.github.com> Date: Mon, 6 Jan 2025 23:10:46 +0530 Subject: [PATCH 13/20] revert: spacing Co-authored-by: Aayush Khanna <96649223+aayush0325@users.noreply.github.com> Signed-off-by: Vinit Pandit <106718914+MeastroZI@users.noreply.github.com> --- lib/node_modules/@stdlib/stats/base/svarianceyc/src/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/src/main.c b/lib/node_modules/@stdlib/stats/base/svarianceyc/src/main.c index 255e42cf7e31..b1b0e441261f 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/src/main.c +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/src/main.c @@ -78,8 +78,8 @@ float API_SUFFIX(stdlib_strided_svarianceyc_ndarray)( const CBLAS_INT N, const f di = (double)i; v = X[ ix ]; sum += v; - d = (float)( di * (double)v ) - sum; - S += (float)( 1.0 / ( di * ( di-1.0 ) ) ) * d * d; + d = (float)(di*(double)v) - sum; + S += (float)(1.0/(di*(di-1.0))) * d * d; ix += strideX; } return (double)S / n; From a5f454fe7b9a9b8dd1e2697f304518367ef38f02 Mon Sep 17 00:00:00 2001 From: Vinit Pandit <106718914+MeastroZI@users.noreply.github.com> Date: Mon, 6 Jan 2025 23:39:43 +0530 Subject: [PATCH 14/20] Update lib/node_modules/@stdlib/stats/base/svarianceyc/README.md Co-authored-by: Aayush Khanna <96649223+aayush0325@users.noreply.github.com> Signed-off-by: Vinit Pandit <106718914+MeastroZI@users.noreply.github.com> --- lib/node_modules/@stdlib/stats/base/svarianceyc/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/README.md b/lib/node_modules/@stdlib/stats/base/svarianceyc/README.md index d406e408b59a..fd799459c956 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/README.md +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/README.md @@ -259,7 +259,7 @@ float stdlib_strided_svarianceyc( const CBLAS_INT N, const float correction, con #### stdlib_strided_svarianceyc_ndarray( N, correction, \*X, strideX, offsetX ) -Computes the [variance][variance] of a single-precision floating-point strided array using a one-pass algorithm proposed by Youngs and Cramer and using alternative indexing semantics. +Computes the [variance][variance] of a single-precision floating-point strided array using a one-pass algorithm proposed by Youngs and Cramer and alternative indexing semantics. ```c const float x[] = { 1.0f, -2.0f, 2.0f }; From 3c717135ec1baf26487b49b87a0e173d0cbc1569 Mon Sep 17 00:00:00 2001 From: Vinit Pandit <106718914+MeastroZI@users.noreply.github.com> Date: Wed, 15 Jan 2025 23:21:27 +0530 Subject: [PATCH 15/20] style: add trailing space in repl txt Signed-off-by: Vinit Pandit <106718914+MeastroZI@users.noreply.github.com> --- lib/node_modules/@stdlib/stats/base/svarianceyc/docs/repl.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/svarianceyc/docs/repl.txt index c8320f182444..0587a06a38bd 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/docs/repl.txt @@ -112,3 +112,4 @@ See Also -------- + From 644042d58a57f0c6b0527b581bda9ede8ecfee77 Mon Sep 17 00:00:00 2001 From: Vinit Pandit <106718914+MeastroZI@users.noreply.github.com> Date: Wed, 15 Jan 2025 23:30:12 +0530 Subject: [PATCH 16/20] style: removing space Signed-off-by: Vinit Pandit <106718914+MeastroZI@users.noreply.github.com> --- lib/node_modules/@stdlib/stats/base/svarianceyc/docs/repl.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/svarianceyc/docs/repl.txt index 0587a06a38bd..c8320f182444 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/docs/repl.txt @@ -112,4 +112,3 @@ See Also -------- - From bb02a55351ca7cd808d936571cd28d1dc4ebc5f9 Mon Sep 17 00:00:00 2001 From: Athan Date: Fri, 17 Jan 2025 15:02:22 -0800 Subject: [PATCH 17/20] Apply suggestions from code review Signed-off-by: Athan --- lib/node_modules/@stdlib/stats/base/svarianceyc/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/README.md b/lib/node_modules/@stdlib/stats/base/svarianceyc/README.md index fd799459c956..7c217e50da0c 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/README.md +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/README.md @@ -237,7 +237,7 @@ console.log( v ); #### stdlib_strided_svarianceyc( N, correction, \*X, strideX ) -Computes the [variance][variance] of a single-precision floating-point strided array `x` using a one-pass algorithm proposed by Youngs and Cramer. +Computes the [variance][variance] of a single-precision floating-point strided array using a one-pass algorithm proposed by Youngs and Cramer. ```c const float x[] = { 1.0f, -2.0f, 2.0f }; From f5682971fb2e1d63fb4665d3e2fcbd206cf8d61d Mon Sep 17 00:00:00 2001 From: Athan Date: Fri, 17 Jan 2025 15:06:09 -0800 Subject: [PATCH 18/20] refactor: fix typo Signed-off-by: Athan --- lib/node_modules/@stdlib/stats/base/svarianceyc/src/addon.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/src/addon.c b/lib/node_modules/@stdlib/stats/base/svarianceyc/src/addon.c index b9af126d2838..998a31a67814 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/src/addon.c +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/src/addon.c @@ -55,8 +55,8 @@ static napi_value addon_method( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_FLOAT( env, correction, argv, 1 ); STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 2 ); - STDLIB_NAPI_ARGV_INT64( env, offesetX, argv, 4 ); - STDLIB_NAPI_CREATE_DOUBLE( env, (double)stdlib_strided_svarianceyc_ndarray( N, correction, X, strideX, offesetX ), v ); + STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 4 ); + STDLIB_NAPI_CREATE_DOUBLE( env, (double)stdlib_strided_svarianceyc_ndarray( N, correction, X, strideX, offsetX ), v ); return v; } STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method ) From 8c84368fd06283b967b16646182b2f83b7eb0e56 Mon Sep 17 00:00:00 2001 From: Athan Date: Fri, 17 Jan 2025 15:06:40 -0800 Subject: [PATCH 19/20] style: add empty line Signed-off-by: Athan --- lib/node_modules/@stdlib/stats/base/svarianceyc/src/addon.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/src/addon.c b/lib/node_modules/@stdlib/stats/base/svarianceyc/src/addon.c index 998a31a67814..ec11ab8e854a 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/src/addon.c +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/src/addon.c @@ -59,4 +59,5 @@ static napi_value addon_method( napi_env env, napi_callback_info info ) { STDLIB_NAPI_CREATE_DOUBLE( env, (double)stdlib_strided_svarianceyc_ndarray( N, correction, X, strideX, offsetX ), v ); return v; } + STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method ) From 1b00b786a6fa032edd7fc6a21b07cab7236b2b87 Mon Sep 17 00:00:00 2001 From: Athan Date: Fri, 17 Jan 2025 15:08:03 -0800 Subject: [PATCH 20/20] style: add missing space Signed-off-by: Athan --- lib/node_modules/@stdlib/stats/base/svarianceyc/src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/base/svarianceyc/src/main.c b/lib/node_modules/@stdlib/stats/base/svarianceyc/src/main.c index b1b0e441261f..abb8ba71ad76 100644 --- a/lib/node_modules/@stdlib/stats/base/svarianceyc/src/main.c +++ b/lib/node_modules/@stdlib/stats/base/svarianceyc/src/main.c @@ -67,7 +67,7 @@ float API_SUFFIX(stdlib_strided_svarianceyc_ndarray)( const CBLAS_INT N, const f if ( N <= 0 || n <= 0.0f ) { return 0.0f / 0.0f; // NaN } - if ( N ==1 || strideX == 0 ) { + if ( N == 1 || strideX == 0 ) { return 0.0f; } ix = offsetX;