Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add C implementation for @stdlib/stats/base/dists/signrank/quantile #4734

Open
wants to merge 28 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
db060f5
adding c implementaion in readme.md
jalajk3004 Jan 13, 2025
9d4bc06
Added a benchmark file
jalajk3004 Jan 13, 2025
10daf8c
feat:add c implementation example file
jalajk3004 Jan 13, 2025
bb39038
feat:add the C src files
jalajk3004 Jan 13, 2025
f3d811f
changes in package.json
jalajk3004 Jan 13, 2025
b826bd5
feat:added test files
jalajk3004 Jan 13, 2025
8b0152b
feat:added test files
jalajk3004 Jan 13, 2025
2e3d912
feat:added test files
jalajk3004 Jan 13, 2025
7b865ea
feat:added test files
jalajk3004 Jan 13, 2025
eb33638
feat:added test files
jalajk3004 Jan 13, 2025
66cb237
docs: update related packages sections
stdlib-bot Jan 13, 2025
b157d1c
docs: update namespace TypeScript declaration comments
stdlib-bot Jan 13, 2025
9ccf049
fix: add `math/base/speical/abs` in manifest.json of `blas/ext/base/d…
aayush0325 Jan 13, 2025
fefd435
docs: update examples of `stats/base/dmin`
aayush0325 Jan 13, 2025
4dec3dd
feat: add C ndarray interface and refactor implementation for `stats/…
aayush0325 Jan 14, 2025
f742e64
refactor: update `blas/ext/base/dapx` to follow current project conve…
headlessNode Jan 14, 2025
93ba64e
docs: update related packages sections
stdlib-bot Jan 14, 2025
d558d5f
feat: add C implementation for `stats/base/dists/geometric/skewness`
0PrashantYadav0 Jan 14, 2025
14c1188
docs: update REPL namespace documentation
stdlib-bot Jan 14, 2025
774fae5
docs: update namespace table of contents
stdlib-bot Jan 14, 2025
cc0e85c
docs: update namespace TypeScript declarations
stdlib-bot Jan 14, 2025
d4fa726
bench: refactor random number generation in `stats/base/dists/arcsine`
anandkaranubc Jan 14, 2025
ebc9e35
feat: add C implementation for `number/float32/base/signbit`
Neerajpathak07 Jan 14, 2025
8c49027
feat: add C `ndarray` API and refactor `blas/ext/base/sapxsumors`
headlessNode Jan 14, 2025
307f740
refactoring C implementation
jalajk3004 Jan 14, 2025
320feda
fix: edit the header file
jalajk3004 Jan 14, 2025
95ca0d5
fix:refactor c implementation
jalajk3004 Jan 15, 2025
29fa8b9
fix
jalajk3004 Jan 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/node_modules/@stdlib/array/base/docs/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3365,10 +3365,10 @@ interface Namespace {
*
* @example
* var x = [ 1, 2, 3, 4 ];
* var idx = [ 5, 6, 7, 8 ];
* var y = [ 5, 6, 7, 8 ];
* var mask = [ 0, 1, 0, 1 ];
*
* var out = ns.mskfilter2( x, idx, mask );
* var out = ns.mskfilter2( x, y, mask );
* // returns [ [ 2, 4 ], [ 6, 8 ] ]
*/
mskfilter2: typeof mskfilter2;
Expand Down
20 changes: 10 additions & 10 deletions lib/node_modules/@stdlib/blas/ext/base/dapx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ The function has the following parameters:
- **N**: number of indexed elements.
- **alpha**: scalar constant.
- **x**: input [`Float64Array`][@stdlib/array/float64].
- **strideX**: stride length for `x`.
- **strideX**: stride length.

The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to add a constant to every other element:

Expand Down Expand Up @@ -168,14 +168,14 @@ console.log( x );
#include "stdlib/blas/ext/base/dapx.h"
```

#### c_dapx( N, alpha, \*X, strideX )
#### stdlib_strided_dapx( N, alpha, \*X, strideX )

Adds a scalar constant to each element in a double-precision floating-point strided array.

```c
double x[] = { 1.0, 2.0, 3.0, 4.0 };

c_dapx( 4, 5.0, x, 1 );
stdlib_strided_dapx( 4, 5.0, x, 1 );

```

Expand All @@ -187,29 +187,29 @@ The function accepts the following arguments:
- **strideX**: `[in] CBLAS_INT` stride length for `X`.

```c
void c_dapx( const CBLAS_INT N, const double alpha, double *X, const CBLAS_INT strideX );
void stdlib_strided_dapx( const CBLAS_INT N, const double alpha, double *X, const CBLAS_INT strideX );
```

#### c_dapx_ndarray( N, alpha, \*X, strideX, offsetX )
#### stdlib_strided_dapx_ndarray( N, alpha, \*X, strideX, offsetX )

Adds a scalar constant to each element in a double-precision floating-point strided array using alternative indexing semantics.

```c
double x[] = { 1.0, 2.0, 3.0, 4.0 };

c_dapx_ndarray( 4, 5.0, x, 1, 0 );
stdlib_strided_dapx_ndarray( 4, 5.0, x, 1, 0 );
```

The function accepts the following arguments:

- **N**: `[in] CBLAS_INT` number of indexed elements.
- **alpha**: `[in] double` scalar constant.
- **X**: `[inout] double*` input array.
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
- **strideX**: `[in] CBLAS_INT` stride length.
- **offsetX**: `[in] CBLAS_INT` starting index.

```c
void c_dapx_ndarray( const CBLAS_INT N, const double alpha, double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
void stdlib_strided_dapx_ndarray( const CBLAS_INT N, const double alpha, double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
```

</section>
Expand Down Expand Up @@ -245,7 +245,7 @@ int main( void ) {
const int strideX = 1;

// Fill the array:
c_dapx( N, 5.0, x, strideX );
stdlib_strided_dapx( N, 5.0, x, strideX );

// Print the result:
for ( int i = 0; i < 8; i++ ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ static double benchmark1( int iterations, int len ) {
t = tic();
for ( i = 0; i < iterations; i++ ) {
// cppcheck-suppress uninitvar
c_dapx( len, 5.0, x, 1 );
stdlib_strided_dapx( len, 5.0, x, 1 );
if ( x[ 0 ] != x[ 0 ] ) {
printf( "should not return NaN\n" );
break;
Expand All @@ -131,7 +131,7 @@ static double benchmark2( int iterations, int len ) {
t = tic();
for ( i = 0; i < iterations; i++ ) {
// cppcheck-suppress uninitvar
c_dapx_ndarray( len, 5.0, x, 1, 0 );
stdlib_strided_dapx_ndarray( len, 5.0, x, 1, 0 );
if ( x[ 0 ] != x[ 0 ] ) {
printf( "should not return NaN\n" );
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ int main( void ) {
const int strideX = 1;

// Add a constant to each element:
c_dapx( N, 5.0, x, strideX );
stdlib_strided_dapx( N, 5.0, x, strideX );

// Print the result:
for ( int i = 0; i < 8; i++ ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ extern "C" {
/**
* Adds a scalar constant to each element in a double-precision floating-point strided array.
*/
void API_SUFFIX(c_dapx)( const CBLAS_INT N, const double alpha, double *X, const CBLAS_INT strideX );
void API_SUFFIX(stdlib_strided_dapx)( const CBLAS_INT N, const double alpha, double *X, const CBLAS_INT strideX );

/**
* Adds a scalar constant to each element in a double-precision floating-point strided array using alternative indexing semantics.
*/
void API_SUFFIX(c_dapx_ndarray)( const CBLAS_INT N, const double alpha, double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
void API_SUFFIX(stdlib_strided_dapx_ndarray)( const CBLAS_INT N, const double alpha, double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );

#ifdef __cplusplus
}
Expand Down
3 changes: 1 addition & 2 deletions lib/node_modules/@stdlib/blas/ext/base/dapx/lib/ndarray.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ var M = 5;
* var Float64Array = require( '@stdlib/array/float64' );
*
* var x = new Float64Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] );
* var alpha = 5.0;
*
* dapx( 3, alpha, x, 1, x.length-3 );
* dapx( 3, 5.0, x, 1, x.length-3 );
* // x => <Float64Array>[ 1.0, -2.0, 3.0, 1.0, 10.0, -1.0 ]
*/
function dapx( N, alpha, x, strideX, offsetX ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ var addon = require( './../src/addon.node' );
* var Float64Array = require( '@stdlib/array/float64' );
*
* var x = new Float64Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] );
* var alpha = 5.0;
*
* dapx( 3, alpha, x, 1, x.length-3 );
* dapx( 3, 5.0, x, 1, x.length-3 );
* // x => <Float64Array>[ 1.0, -2.0, 3.0, 1.0, 10.0, -1.0 ]
*/
function dapx( N, alpha, x, strideX, offsetX ) {
Expand Down
4 changes: 2 additions & 2 deletions lib/node_modules/@stdlib/blas/ext/base/dapx/src/addon.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static napi_value addon( napi_env env, napi_callback_info info ) {
STDLIB_NAPI_ARGV_DOUBLE( env, alpha, argv, 1 );
STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 );
STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 2 );
API_SUFFIX(c_dapx)( N, alpha, X, strideX );
API_SUFFIX(stdlib_strided_dapx)( N, alpha, X, strideX );
return NULL;
}

Expand All @@ -56,7 +56,7 @@ static napi_value addon_method( napi_env env, napi_callback_info info ) {
STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 );
STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 4 );
STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 2 );
API_SUFFIX(c_dapx_ndarray)( N, alpha, X, strideX, offsetX );
API_SUFFIX(stdlib_strided_dapx_ndarray)( N, alpha, X, strideX, offsetX );
return NULL;
}

Expand Down
6 changes: 3 additions & 3 deletions lib/node_modules/@stdlib/blas/ext/base/dapx/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
* @param X input array
* @param strideX stride length
*/
void API_SUFFIX(c_dapx)( const CBLAS_INT N, const double alpha, double *X, const CBLAS_INT strideX ) {
void API_SUFFIX(stdlib_strided_dapx)( const CBLAS_INT N, const double alpha, double *X, const CBLAS_INT strideX ) {
CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX );
API_SUFFIX(c_dapx_ndarray)( N, alpha, X, strideX, ox );
API_SUFFIX(stdlib_strided_dapx_ndarray)( N, alpha, X, strideX, ox );
}

/**
Expand All @@ -42,7 +42,7 @@ void API_SUFFIX(c_dapx)( const CBLAS_INT N, const double alpha, double *X, const
* @param strideX stride length
* @param offsetX starting index
*/
void API_SUFFIX(c_dapx_ndarray)( const CBLAS_INT N, const double alpha, double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) {
void API_SUFFIX(stdlib_strided_dapx_ndarray)( const CBLAS_INT N, const double alpha, double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) {
CBLAS_INT ix;
CBLAS_INT m;
CBLAS_INT i;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@
"libpath": [],
"dependencies": [
"@stdlib/blas/base/shared",
"@stdlib/strided/base/stride2offset"
"@stdlib/strided/base/stride2offset",
"@stdlib/math/base/special/abs"
]
},
{
Expand Down
145 changes: 133 additions & 12 deletions lib/node_modules/@stdlib/blas/ext/base/sapxsumors/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ limitations under the License.

# sapxsumors

> Add a constant to each single-precision floating-point strided array element and compute the sum using ordinary recursive summation.
> Add a scalar constant to each single-precision floating-point strided array element and compute the sum using ordinary recursive summation.

<section class="intro">

Expand All @@ -36,9 +36,9 @@ limitations under the License.
var sapxsumors = require( '@stdlib/blas/ext/base/sapxsumors' );
```

#### sapxsumors( N, alpha, x, stride )
#### sapxsumors( N, alpha, x, strideX )

Adds a constant to each single-precision floating-point strided array element and computes the sum using ordinary recursive summation.
Adds a scalar constant to each single-precision floating-point strided array element and computes the sum using ordinary recursive summation.

```javascript
var Float32Array = require( '@stdlib/array/float32' );
Expand All @@ -52,10 +52,11 @@ var v = sapxsumors( x.length, 5.0, x, 1 );
The function has the following parameters:

- **N**: number of indexed elements.
- **alpha**: scalar constant.
- **x**: input [`Float32Array`][@stdlib/array/float32].
- **stride**: index increment for `x`.
- **strideX**: stride length.

The `N` and `stride` parameters determine which elements in the strided array are accessed at runtime. For example, to access every other element in `x`,
The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to access every other element:

```javascript
var Float32Array = require( '@stdlib/array/float32' );
Expand All @@ -80,9 +81,9 @@ var v = sapxsumors( 4, 5.0, x1, 2 );
// returns 25.0
```

#### sapxsumors.ndarray( N, alpha, x, stride, offset )
#### sapxsumors.ndarray( N, alpha, x, strideX, offsetX )

Adds a constant to each single-precision floating-point strided array element and computes the sum using ordinary recursive summation and alternative indexing semantics.
Adds a scalar constant to each single-precision floating-point strided array element and computes the sum using ordinary recursive summation and alternative indexing semantics.

```javascript
var Float32Array = require( '@stdlib/array/float32' );
Expand All @@ -95,9 +96,9 @@ var v = sapxsumors.ndarray( x.length, 5.0, x, 1, 0 );

The function has the following additional parameters:

- **offset**: starting index for `x`.
- **offsetX**: starting index.

While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offset` parameter supports indexing semantics based on a starting index. For example, to access 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 access every other element starting from the second element:

```javascript
var Float32Array = require( '@stdlib/array/float32' );
Expand Down Expand Up @@ -130,12 +131,13 @@ var v = sapxsumors.ndarray( 4, 5.0, x, 2, 1 );
<!-- eslint no-undef: "error" -->

```javascript
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory;
var filledarrayBy = require( '@stdlib/array/filled-by' );
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var Float32Array = require( '@stdlib/array/float32' );
var sapxsumors = require( '@stdlib/blas/ext/base/sapxsumors' );

var x = filledarrayBy( 10, 'float32', discreteUniform( 0, 100 ) );
var x = discreteUniform( 10, -100, 100, {
'dtype': 'float32'
});
console.log( x );

var v = sapxsumors( x.length, 5.0, x, 1 );
Expand All @@ -146,6 +148,125 @@ console.log( v );

<!-- /.examples -->

<!-- C interface documentation. -->

* * *

<section class="c">

## C APIs

<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->

<section class="intro">

</section>

<!-- /.intro -->

<!-- C usage documentation. -->

<section class="usage">

### Usage

```c
#include "stdlib/blas/ext/base/sapxsumors.h"
```

#### stdlib_strided_sapxsumors( N, alpha, \*X, strideX )

Adds a scalar constant to each single-precision floating-point strided array element and computes the sum using ordinary recursive summation.

```c
const float x[] = { 1.0f, 2.0f, 3.0f, 4.0f };

float v = stdlib_strided_sapxsumors( 4, 5.0f, x, 1 );
// returns 30.0
```

The function accepts the following arguments:

- **N**: `[in] CBLAS_INT` number of indexed elements.
- **alpha**: `[in] float` scalar constant.
- **X**: `[in] float*` input array.
- **strideX**: `[in] CBLAS_INT` stride length.

```c
float stdlib_strided_sapxsumors( const CBLAS_INT N, const float alpha, const float *X, const CBLAS_INT strideX );
```

#### stdlib_strided_sapxsumors_ndarray( N, alpha, \*X, strideX, offsetX )

Adds a scalar constant to each single-precision floating-point strided array element and computes the sum using ordinary recursive summation and alternative indexing semantics.

```c
const float x[] = { 1.0f, 2.0f, 3.0f, 4.0f };

float v = stdlib_strided_sapxsumors_ndarray( 4, 5.0f, x, 1, 0 );
// returns 30.0
```

The function accepts the following arguments:

- **N**: `[in] CBLAS_INT` number of indexed elements.
- **alpha**: `[in] float` scalar constant.
- **X**: `[in] float*` input array.
- **strideX**: `[in] CBLAS_INT` stride length.
- **offsetX**: `[in] CBLAS_INT` starting index.

```c
float stdlib_strided_sapxsumors_ndarray( const CBLAS_INT N, const float alpha, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
```

</section>

<!-- /.usage -->

<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="notes">

</section>

<!-- /.notes -->

<!-- C API usage examples. -->

<section class="examples">

### Examples

```c
#include "stdlib/blas/ext/base/sapxsumors.h"
#include <stdio.h>

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 indexed elements:
const int N = 8;

// Specify a stride:
const int strideX = 1;

// Compute the sum:
float v = stdlib_strided_sapxsumors( N, 5.0f, x, strideX );

// Print the result:
printf( "Sum: %f\n", v );
}
```

</section>

<!-- /.examples -->

</section>

<!-- /.c -->

<section class="references">

</section>
Expand Down
Loading
Loading