-
-
Notifications
You must be signed in to change notification settings - Fork 817
feat: add C ndarray interface and refactor implementation for stats/base/dvarmpn
#4543
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
base: develop
Are you sure you want to change the base?
Changes from all commits
87a38be
fa22cd0
dddbaa2
521f17c
61d6511
4cb641f
15b7142
718f26d
06cdd25
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
DhruvArvindSingh marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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 v; | ||||||
|
@@ -107,6 +107,7 @@ static double benchmark( int iterations, int len ) { | |||||
v = 0.0; | ||||||
t = tic(); | ||||||
for ( i = 0; i < iterations; i++ ) { | ||||||
// cppcheck-suppress uninitvar | ||||||
v = stdlib_strided_dvarmpn( len, 0.0, 1, x, 1 ); | ||||||
if ( v != v ) { | ||||||
printf( "should not return NaN\n" ); | ||||||
|
@@ -120,6 +121,40 @@ 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 ]; | ||||||
float v; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
double t; | ||||||
int i; | ||||||
|
||||||
for ( i = 0; i < len; i++ ) { | ||||||
x[ i ] = ( rand_double() * 20000.0 ) - 10000.0; | ||||||
} | ||||||
v = 0.0f; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
t = tic(); | ||||||
for ( i = 0; i < iterations; i++ ) { | ||||||
// cppcheck-suppress uninitvar | ||||||
v = stdlib_strided_dvarmpn_ndarray( len, 0.0, 1, x, 1, 1 ); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
just following the convention here |
||||||
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 +177,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 - 3; i++ ) { | ||||||
len = pow( 10, i ); | ||||||
iter = ITERATIONS; | ||||||
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 ); | ||||||
} | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please update this example to remove the usage of
@stdlib/math/base/special/floor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment for all other instances
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/%40stdlib/stats/base/smax/README.md?plain=1#L74
see how the examples are written here for reference!