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 Nov 21, 2024
1 parent 8fb6f77 commit 7708be4
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ A total of 5 people contributed to this release. Thank you to the following cont

<details>

- [`35ea456`](https://github.com/stdlib-js/stdlib/commit/35ea456c3f527fda8c717b5f31deccb6ba9e44d2) - **refactor:** use `stdlib_base_round` instead of builtin in `math/base/special/cround` [(#3216)](https://github.com/stdlib-js/stdlib/pull/3216) _(by Gunj Joshi)_
- [`7e2c16b`](https://github.com/stdlib-js/stdlib/commit/7e2c16b05d85b9d25c21626d4cbce381fcfe5d32) - **refactor:** remove unused header, update benchmarks in `math/base/special/croundf` [(#3217)](https://github.com/stdlib-js/stdlib/pull/3217) _(by Gunj Joshi)_
- [`c660c70`](https://github.com/stdlib-js/stdlib/commit/c660c705bb3478f4fb6cb818c9b1d3429e8a6774) - **chore:** use correct `Makefile` and update benchmarks in `math/base/special/csch` [(#3209)](https://github.com/stdlib-js/stdlib/pull/3209) _(by Gunj Joshi)_
- [`b6a2b0b`](https://github.com/stdlib-js/stdlib/commit/b6a2b0b27dc8cc1e9fc02d9679a3ce468cf49b9d) - **docs:** update namespace table of contents [(#3192)](https://github.com/stdlib-js/stdlib/pull/3192) _(by stdlib-bot, Philipp Burckhardt)_
Expand Down
15 changes: 9 additions & 6 deletions base/special/cround/benchmark/c/benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,23 @@ static double rand_double( void ) {
*/
static double benchmark( void ) {
double elapsed;
double re;
double im;
double re[ 100 ];
double im[ 100 ];
double t;
int i;

double complex z;
double complex y;

for ( i = 0; i < 100; i++ ) {
re[ i ] = ( 1000.0 * rand_double() ) - 500.0;
im[ i ] = ( 1000.0 * rand_double() ) - 500.0;
}

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
re = ( 1000.0*rand_double() ) - 500.0;
im = ( 1000.0*rand_double() ) - 500.0;
z = re + im*I;
y = round( creal(z) ) + round( cimag(z) )*I;
z = re[ i % 100 ] + im[ i % 100 ]*I;
y = round( creal( z ) ) + round( cimag( z ) )*I;
if ( y != y ) {
printf( "should not return NaN\n" );
break;
Expand Down
9 changes: 6 additions & 3 deletions base/special/cround/benchmark/c/native/benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,22 @@ static double rand_double( void ) {
*/
static double benchmark( void ) {
double elapsed;
double v[ 100 ];
double re;
double im;
double t;
double v;
int i;

stdlib_complex128_t x;
stdlib_complex128_t y;

for ( i = 0; i < 100; i++ ) {
v[ i ] = ( 1000.0 * rand_double() ) - 500.0;
}

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
v = ( 1000.0*rand_double() ) - 500.0;
x = stdlib_complex128( v, v );
x = stdlib_complex128( v[ i % 100 ], v[ i % 100 ] );
y = stdlib_base_cround( x );
stdlib_complex128_reim( y, &re, &im );
if ( re != re ) {
Expand Down
9 changes: 6 additions & 3 deletions base/special/cround/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"dependencies": [
"@stdlib/math/base/napi/unary",
"@stdlib/complex/float64/ctor",
"@stdlib/complex/float64/reim"
"@stdlib/complex/float64/reim",
"@stdlib/math/base/special/round"
]
},
{
Expand All @@ -53,7 +54,8 @@
"libpath": [],
"dependencies": [
"@stdlib/complex/float64/ctor",
"@stdlib/complex/float64/reim"
"@stdlib/complex/float64/reim",
"@stdlib/math/base/special/round"
]
},
{
Expand All @@ -68,7 +70,8 @@
"libpath": [],
"dependencies": [
"@stdlib/complex/float64/ctor",
"@stdlib/complex/float64/reim"
"@stdlib/complex/float64/reim",
"@stdlib/math/base/special/round"
]
}
]
Expand Down
6 changes: 3 additions & 3 deletions base/special/cround/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "stdlib/math/base/special/cround.h"
#include "stdlib/complex/float64/ctor.h"
#include "stdlib/complex/float64/reim.h"
#include <math.h>
#include "stdlib/math/base/special/round.h"

/**
* Rounds each component of a double-precision complex floating-point number to the nearest integer.
Expand Down Expand Up @@ -48,7 +48,7 @@ stdlib_complex128_t stdlib_base_cround( const stdlib_complex128_t z ) {

stdlib_complex128_reim( z, &re, &im );

re = round( re ); // TODO: replace with stdlib function once available
im = round( im ); // TODO: replace with stdlib function once available
re = stdlib_base_round( re );
im = stdlib_base_round( im );
return stdlib_complex128( re, im );
}

0 comments on commit 7708be4

Please sign in to comment.