Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Sep 24, 2024
1 parent 18332f7 commit f1e9bbd
Show file tree
Hide file tree
Showing 25 changed files with 406 additions and 174 deletions.
1 change: 0 additions & 1 deletion .github/.keepalive

This file was deleted.

44 changes: 44 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,50 @@

> Package changelog.
<section class="release" id="unreleased">

## Unreleased (2024-09-24)

<section class="features">

### Features

- [`126c898`](https://github.com/stdlib-js/stdlib/commit/126c89855ae2df8c6db72ca48e138f6b45a179b0) - refactor JavaScript implementation and add C `ndarray` implementation for `blas/base/dasum` [(#2942)](https://github.com/stdlib-js/stdlib/pull/2942)

</section>

<!-- /.features -->

<section class="commits">

### Commits

<details>

- [`126c898`](https://github.com/stdlib-js/stdlib/commit/126c89855ae2df8c6db72ca48e138f6b45a179b0) - **feat:** refactor JavaScript implementation and add C `ndarray` implementation for `blas/base/dasum` [(#2942)](https://github.com/stdlib-js/stdlib/pull/2942) _(by Aman Bhansali)_

</details>

</section>

<!-- /.commits -->

<section class="contributors">

### Contributors

A total of 1 person contributed to this release. Thank you to this contributor:

- Aman Bhansali

</section>

<!-- /.contributors -->

</section>

<!-- /.release -->

<section class="release" id="v0.3.0">

## 0.3.0 (2024-07-28)
Expand Down
8 changes: 8 additions & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# Contributors listed in alphabetical order.

Aayush Khanna <96649223+aayush0325@users.noreply.github.com>
Adarsh Palaskar <adarshpalaskar99@gmail.com>
Aditya Sapra <adityaework@gmail.com>
AgPriyanshu18 <113460573+AgPriyanshu18@users.noreply.github.com>
Expand All @@ -26,17 +27,20 @@ EuniceSim142 <77243938+EuniceSim142@users.noreply.github.com>
Frank Kovacs <fran70kk@gmail.com>
Golden Kumar <103646877+AuenKr@users.noreply.github.com>
Gunj Joshi <gunjjoshi8372@gmail.com>
HarshaNP <96897754+GittyHarsha@users.noreply.github.com>
Harshita Kalani <harshitakalani02@gmail.com>
Hridyanshu <124202756+HRIDYANSHU054@users.noreply.github.com>
Jaimin Godhani <112328542+Jai0401@users.noreply.github.com>
James Gelok <jdgelok@gmail.com>
Jaysukh Makvana <jaysukhmakvana2004@gmail.com>
Jenish Thapa <141203631+jenish-thapa@users.noreply.github.com>
Jithin KS <jithinks112@gmail.com>
Joel Mathew Koshy <joelmathewkoshy@gmail.com>
Joey Reed <joeyrreed@gmail.com>
Jordan Gallivan <115050475+Jordan-Gallivan@users.noreply.github.com>
Joris Labie <joris.labie1@gmail.com>
Justin Dennison <justin1dennison@gmail.com>
Kaif Mohd <mdkaifprofession@gmail.com>
Karthik Prakash <116057817+skoriop@users.noreply.github.com>
Khaldon <kahmd1444@gmail.com>
Krishnendu Das <86651039+itskdhere@users.noreply.github.com>
Expand Down Expand Up @@ -86,13 +90,17 @@ Stephannie Jiménez Gacha <steff456@hotmail.com>
Suraj kumar <125961509+kumarsuraj212003@users.noreply.github.com>
Tirtadwipa Manunggal <tirtadwipa.manunggal@gmail.com>
Tudor Pagu <104032457+tudor-pagu@users.noreply.github.com>
Tufailahmed Bargir <142114244+Tufailahmed-Bargir@users.noreply.github.com>
Utkarsh <http://utkarsh11105@gmail.com>
Utkarsh Raj <rajutkarsh2505@gmail.com>
Vaibhav Patel <98279986+noobCoderVP@users.noreply.github.com>
Varad Gupta <varadgupta21@gmail.com>
Xiaochuan Ye <tap91624@gmail.com>
Yernar Yergaziyev <yernar.yergaziyev@erg.kz>
naveen <stupiddint@gmail.com>
nishant-s7 <97207366+nishant-s7@users.noreply.github.com>
olenkabilonizhka <62379231+olenkabilonizhka@users.noreply.github.com>
orimiles5 <97595296+orimiles5@users.noreply.github.com>
rainn <88160429+AmCodesLame@users.noreply.github.com>
rei2hu <reimu@reimu.ws>
yaswanth <116426380+yaswanthkosuru@users.noreply.github.com>
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ var sum = dasum( 3, x1, 2 );
// returns 12.0
```

If either `N` or `stride` is less than or equal to `0`, the function returns `0`.
If `N` is less than or equal to `0`, the function returns `0`.

#### dasum.ndarray( N, x, stride, offset )

Expand Down Expand Up @@ -250,6 +250,28 @@ The function accepts the following arguments:
double c_dasum( const CBLAS_INT N, const double *X, const CBLAS_INT stride );
```

#### c_dasum_ndarray( N, \*X, stride, offset )

Computes the sum of absolute values using alternative indexing semantics.

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

double v = c_dasum_ndarray( 4, x, -1, 3 );
// returns 10.0
```
The function accepts the following arguments:
- **N**: `[in] CBLAS_INT` number of indexed elements.
- **X**: `[in] double*` input array.
- **stride**: `[in] CBLAS_INT` index increment for `X`.
- **offset**: `[in] CBLAS_INT` starting index for `X`.
```c
double c_dasum_ndarray( const CBLAS_INT N, const double *X, const CBLAS_INT stride, const CBLAS_INT offset );
```

</section>

<!-- /.usage -->
Expand Down Expand Up @@ -287,6 +309,12 @@ int main( void ) {

// Print the result:
printf( "sum: %lf\n", sum );

// Compute the sum of absolute values:
sum = c_dasum_ndarray( N, x, -strideX, N-1 );

// Print the result:
printf( "sum: %lf\n", sum );
}
```
Expand Down
44 changes: 42 additions & 2 deletions benchmark/c/benchmark.length.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static double rand_double( 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;
double x[ len ];
double y;
Expand All @@ -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;
double x[ len ];
double y;
double t;
int i;

for ( i = 0; i < len; i++ ) {
x[ i ] = ( rand_double()*20000.0 ) - 10000.0;
}
y = 0.0;
t = tic();
for ( i = 0; i < iterations; i++ ) {
y = c_dasum_ndarray( len, x, 1, 0 );
if ( y != y ) {
printf( "should not return NaN\n" );
break;
}
}
elapsed = tic() - t;
if ( y != y ) {
printf( "should not return NaN\n" );
}
return elapsed;
}

/**
* Main execution sequence.
*/
Expand All @@ -142,7 +175,14 @@ 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 ( 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 );
}
Expand Down
14 changes: 7 additions & 7 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f1e9bbd

Please sign in to comment.