Skip to content

Commit

Permalink
implementation changed
Browse files Browse the repository at this point in the history
  • Loading branch information
AbhijitRaut04 committed Nov 15, 2024
1 parent da8bf36 commit 4be1efa
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@license Apache-2.0
Copyright (c) 2018 The Stdlib Authors.
Copyright (c) 2024 The Stdlib Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ int main(void) {
double* v = ( double* )malloc(2 * sizeof(double));
int i;
for ( i = 0; i < 10; i++ ) {
double* v = stdlib_base_minmax( x1[ i ], x2[ i ] );
v = stdlib_base_minmax( x1[ i ], x2[ i ] );
printf( "x1[ %d ]: %lf, x2[ %d ]: %lf, minmax( x1[ %d ], x2[ %d ] ): ( %lf, %lf )\n", i, x1[ i ], i, x2[ i ], i, i, v[0], v[1] );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ extern "C" {
* @param y Second value
* @return A double containing the minimum and maximum values
*/
double* stdlib_base_minmax(const double x, const double y);
double* stdlib_base_minmax(const double x, const double y, double* out, int stride, int offset );

#ifdef __cplusplus
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var addon = require( './../src/addon.node' );
* // returns [ NaN, NaN ]
*/
function minmax( x, y ) {
return addon( x, y );
return addon( x, y, [ 0.0, 0.0 ], 1, 0 );
}


Expand Down
14 changes: 6 additions & 8 deletions lib/node_modules/@stdlib/math/base/special/minmax/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,17 @@
*/


double* stdlib_base_minmax( const double x, const double y ) {
double* stdlib_base_minmax( const double x, const double y, double* out, int stride, int offset ) {

double* result = ( double* )malloc(2 * sizeof(double));

if( stdlib_base_is_nan( x ) || stdlib_base_is_nan( y ) ){
result[0] = 0.0 / 0.0;
result[1] = 0.0 / 0.0;
out[ offset ] = 0.0 / 0.0;
out[ offset + stride ] = 0.0 / 0.0;
}
else{
result[0] = stdlib_base_min( x, y );
result[1] = stdlib_base_max( x, y );
out[ offset ] = stdlib_base_min( x, y );
out[ offset + stride ] = stdlib_base_max( x, y );
}

return result;
return out;

}

0 comments on commit 4be1efa

Please sign in to comment.