Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,14 @@ static double rand_double( void ) {
*/
static double benchmark1( int iterations, int len ) {
double elapsed;
double x[ len ];
double y[ len ];
double *x;
double *y;
double t;
int i;

x = (double *) malloc( len * sizeof( double ) );
y = (double *) malloc( len * sizeof( double ) );

for ( i = 0; i < len; i++ ) {
x[ i ] = ( rand_double()*20000.0 ) - 10000.0;
y[ i ] = 0.0;
Expand All @@ -117,6 +120,9 @@ static double benchmark1( int iterations, int len ) {
if ( y[ 0 ] != y[ 0 ] ) {
printf( "should not return NaN\n" );
}

free( x );
free( y );
return elapsed;
}

Expand All @@ -129,11 +135,13 @@ static double benchmark1( int iterations, int len ) {
*/
static double benchmark2( int iterations, int len ) {
double elapsed;
double x[ len ];
double y[ len ];
double *x;
double *y;
double t;
int i;

x = (double *) malloc( len * sizeof( double ) );
y = (double *) malloc( len * sizeof( double ) );
for ( i = 0; i < len; i++ ) {
x[ i ] = ( rand_double()*20000.0 ) - 10000.0;
y[ i ] = 0.0;
Expand All @@ -150,6 +158,8 @@ static double benchmark2( int iterations, int len ) {
if ( y[ 0 ] != y[ 0 ] ) {
printf( "should not return NaN\n" );
}
free( x );
free( y );
return elapsed;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,15 @@ static double rand_double( void ) {
*/
static double benchmark1( int iterations, int len ) {
double elapsed;
double x[ len ];
double y[ len ];
double *x;
double *y;
double z;
double t;
int i;

x = (double *) malloc( len * sizeof( double ) );
y = (double *) malloc( len * sizeof( double ) );

for ( i = 0; i < len; i++ ) {
x[ i ] = ( rand_double()*20000.0 ) - 10000.0;
y[ i ] = ( rand_double()*20000.0 ) - 10000.0;
Expand All @@ -119,6 +122,8 @@ static double benchmark1( int iterations, int len ) {
if ( z != z ) {
printf( "should not return NaN\n" );
}
free( x );
free( y );
return elapsed;
}

Expand All @@ -131,12 +136,15 @@ static double benchmark1( int iterations, int len ) {
*/
static double benchmark2( int iterations, int len ) {
double elapsed;
double x[ len ];
double y[ len ];
double *x;
double *y;
double z;
double t;
int i;

x = (double *) malloc( len * sizeof( double ) );
y = (double *) malloc( len * sizeof( double ) );

for ( i = 0; i < len; i++ ) {
x[ i ] = ( rand_double()*20000.0 ) - 10000.0;
y[ i ] = ( rand_double()*20000.0 ) - 10000.0;
Expand All @@ -154,6 +162,9 @@ static double benchmark2( int iterations, int len ) {
if ( z != z ) {
printf( "should not return NaN\n" );
}

free( x );
free( y );
return elapsed;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,13 @@ static double rand_double( void ) {
*/
static double benchmark1( int iterations, int len ) {
double elapsed;
double x[ len ];
double y[ len ];
double *x;
double *y;
double t;
int i;

x = (double *) malloc( len * sizeof( double ) );
y = (double *) malloc( len * sizeof( double ) );
for ( i = 0; i < len; i++ ) {
x[ i ] = ( rand_double()*200.0 ) - 100.0;
y[ i ] = ( rand_double()*200.0 ) - 100.0;
Expand All @@ -117,6 +119,9 @@ static double benchmark1( int iterations, int len ) {
if ( y[ 0 ] != y[ 0 ] ) {
printf( "should not return NaN\n" );
}

free( x );
free( y );
return elapsed;
}

Expand All @@ -129,11 +134,14 @@ static double benchmark1( int iterations, int len ) {
*/
static double benchmark2( int iterations, int len ) {
double elapsed;
double x[ len ];
double y[ len ];
double *x;
double *y;
double t;
int i;

x = (double *) malloc( len * sizeof( double ) );
y = (double *) malloc( len * sizeof( double ) );

for ( i = 0; i < len; i++ ) {
x[ i ] = ( rand_double()*200.0 ) - 100.0;
y[ i ] = ( rand_double()*200.0 ) - 100.0;
Expand All @@ -150,6 +158,10 @@ static double benchmark2( int iterations, int len ) {
if ( y[ 0 ] != y[ 0 ] ) {
printf( "should not return NaN\n" );
}

free( x );
free( y );

return elapsed;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ var shape = [ 10, 10, 10 ];

var strides = shape2strides( shape, 'row-major' );
console.log( 'Strides: %s', strides.join( ',' ) );
// => Strides: 100,10,1
// => 'Strides: 100,10,1'

var bool = isRowMajor( strides );
console.log( bool );
// => true

strides = shape2strides( shape, 'column-major' );
console.log( 'Strides: %s', strides.join( ',' ) );
// => Strides: 1,10,100
// => 'Strides: 1,10,100'

bool = isRowMajor( strides );
console.log( bool );
Expand Down