Skip to content
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

build: update scaffolding for creating unary math strided packages #2993

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ limitations under the License.

-->

<!-- THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. -->

# {{ALIAS}}

> {{PKG_DESC}}
Expand Down Expand Up @@ -135,17 +137,16 @@ var y = new {{TYPED_ARRAY_CTOR}}( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] );
<!-- eslint no-undef: "error" -->

```javascript
var uniform = require( '@stdlib/random/base/uniform' );
var random = require( '@stdlib/random/array/uniform' );
var zeros = require( '@stdlib/array/zeros' );
var {{TYPED_ARRAY_CTOR}} = require( '@stdlib/array/{{TYPED_ARRAY_DTYPE}}' );
var {{ALIAS}} = require( '@{{PKG}}' );

var x = new {{TYPED_ARRAY_CTOR}}( 10 );
var y = new {{TYPED_ARRAY_CTOR}}( 10 );
var x = random( 10, {{C_RAND_MIN}}, {{C_RAND_MAX}}, {
'dtype': '{{TYPED_ARRAY_DTYPE}}'
});
var y = zeros( 10, '{{TYPED_ARRAY_DTYPE}}' );

var i;
for ( i = 0; i < x.length; i++ ) {
x[ i ] = uniform( {{C_RAND_MIN}}, {{C_RAND_MAX}} );
}
console.log( x );
console.log( y );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,22 @@
* limitations under the License.
*/

/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */

'use strict';

// MODULES //

var bench = require( '@stdlib/bench' );
var uniform = require( '@stdlib/random/base/uniform' ).factory;
var random = require( '@stdlib/random/array/uniform' );
var zeros = require( '@stdlib/array/zeros' );
var isnan{{C_TYPE_SUFFIX}} = require( '@stdlib/math/base/assert/is-nan{{C_TYPE_SUFFIX}}' );
var pow = require( '@stdlib/math/base/special/pow' );
var {{TYPED_ARRAY_CTOR}} = require( '@stdlib/array/{{TYPED_ARRAY_DTYPE}}' );
var pkg = require( './../package.json' ).name;
var {{ALIAS}} = require( './../lib/main.js' );


// VARIABLES //

var rand = uniform( {{C_RAND_MIN}}, {{C_RAND_MAX}} );


// FUNCTIONS //

/**
Expand All @@ -48,11 +46,10 @@ function createBenchmark( len ) {
var y;
var i;

x = new {{TYPED_ARRAY_CTOR}}( len );
y = new {{TYPED_ARRAY_CTOR}}( len );
for ( i = 0; i < x.length; i++ ) {
x[ i ] = rand();
}
x = random( len, {{C_RAND_MIN}}, {{C_RAND_MAX}}, {
'dtype': '{{TYPED_ARRAY_DTYPE}}'
});
y = zeros( len, '{{TYPED_ARRAY_DTYPE}}' );
return benchmark;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@
* limitations under the License.
*/

/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */

'use strict';

// MODULES //

var resolve = require( 'path' ).resolve;
var bench = require( '@stdlib/bench' );
var uniform = require( '@stdlib/random/base/uniform' ).factory;
var random = require( '@stdlib/random/array/uniform' );
var zeros = require( '@stdlib/array/zeros' );
var isnan{{C_TYPE_SUFFIX}} = require( '@stdlib/math/base/assert/is-nan{{C_TYPE_SUFFIX}}' );
var pow = require( '@stdlib/math/base/special/pow' );
var {{TYPED_ARRAY_CTOR}} = require( '@stdlib/array/{{TYPED_ARRAY_DTYPE}}' );
Expand All @@ -36,7 +39,6 @@ var {{ALIAS}} = tryRequire( resolve( __dirname, './../lib/{{ALIAS_SNAKECASE}}.na
var opts = {
'skip': ( {{ALIAS}} instanceof Error )
};
var rand = uniform( {{C_RAND_MIN}}, {{C_RAND_MAX}} );


// FUNCTIONS //
Expand All @@ -53,11 +55,10 @@ function createBenchmark( len ) {
var y;
var i;

x = new {{TYPED_ARRAY_CTOR}}( len );
y = new {{TYPED_ARRAY_CTOR}}( len );
for ( i = 0; i < x.length; i++ ) {
x[ i ] = rand();
}
x = random( len, {{C_RAND_MIN}}, {{C_RAND_MAX}}, {
'dtype': '{{TYPED_ARRAY_DTYPE}}'
});
y = zeros( len, '{{TYPED_ARRAY_DTYPE}}' );
return benchmark;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,22 @@
* limitations under the License.
*/

/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */

'use strict';

// MODULES //

var bench = require( '@stdlib/bench' );
var uniform = require( '@stdlib/random/base/uniform' ).factory;
var random = require( '@stdlib/random/array/uniform' );
var zeros = require( '@stdlib/array/zeros' );
var isnan{{C_TYPE_SUFFIX}} = require( '@stdlib/math/base/assert/is-nan{{C_TYPE_SUFFIX}}' );
var pow = require( '@stdlib/math/base/special/pow' );
var {{TYPED_ARRAY_CTOR}} = require( '@stdlib/array/{{TYPED_ARRAY_DTYPE}}' );
var pkg = require( './../package.json' ).name;
var {{ALIAS}} = require( './../lib/ndarray.js' );


// VARIABLES //

var rand = uniform( {{C_RAND_MIN}}, {{C_RAND_MAX}} );


// FUNCTIONS //

/**
Expand All @@ -48,11 +46,10 @@ function createBenchmark( len ) {
var y;
var i;

x = new {{TYPED_ARRAY_CTOR}}( len );
y = new {{TYPED_ARRAY_CTOR}}( len );
for ( i = 0; i < x.length; i++ ) {
x[ i ] = rand();
}
x = random( len, {{C_RAND_MIN}}, {{C_RAND_MAX}}, {
'dtype': '{{TYPED_ARRAY_DTYPE}}'
});
y = zeros( len, '{{TYPED_ARRAY_DTYPE}}' );
return benchmark;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@
* limitations under the License.
*/

/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */

'use strict';

// MODULES //

var resolve = require( 'path' ).resolve;
var bench = require( '@stdlib/bench' );
var uniform = require( '@stdlib/random/base/uniform' ).factory;
var random = require( '@stdlib/random/array/uniform' );
var zeros = require( '@stdlib/array/zeros' );
var isnan{{C_TYPE_SUFFIX}} = require( '@stdlib/math/base/assert/is-nan{{C_TYPE_SUFFIX}}' );
var pow = require( '@stdlib/math/base/special/pow' );
var {{TYPED_ARRAY_CTOR}} = require( '@stdlib/array/{{TYPED_ARRAY_DTYPE}}' );
Expand All @@ -36,7 +39,6 @@ var {{ALIAS}} = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) )
var opts = {
'skip': ( {{ALIAS}} instanceof Error )
};
var rand = uniform( {{C_RAND_MIN}}, {{C_RAND_MAX}} );


// FUNCTIONS //
Expand All @@ -53,11 +55,10 @@ function createBenchmark( len ) {
var y;
var i;

x = new {{TYPED_ARRAY_CTOR}}( len );
y = new {{TYPED_ARRAY_CTOR}}( len );
for ( i = 0; i < x.length; i++ ) {
x[ i ] = rand();
}
x = random( len, {{C_RAND_MIN}}, {{C_RAND_MAX}}, {
'dtype': '{{TYPED_ARRAY_DTYPE}}'
});
y = zeros( len, '{{TYPED_ARRAY_DTYPE}}' );
return benchmark;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
# limitations under the License.
#/

# THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY.

# VARIABLES #

ifndef VERBOSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
* limitations under the License.
*/

/**
* Benchmark `{{ALIAS_SNAKECASE}}`.
*/
/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */

#include "{{PKG_INCLUDE}}.h"
#include <stdlib.h>
#include <stdio.h>
Expand All @@ -35,7 +34,7 @@
/**
* Prints the TAP version.
*/
void print_version() {
static void print_version() {
printf( "TAP version 13\n" );
}

Expand All @@ -45,7 +44,7 @@ void print_version() {
* @param total total number of tests
* @param passing total number of passing tests
*/
void print_summary( int total, int passing ) {
static void print_summary( int total, int passing ) {
printf( "#\n" );
printf( "1..%d\n", total ); // TAP plan
printf( "# total %d\n", total );
Expand All @@ -60,7 +59,7 @@ void print_summary( int total, int passing ) {
* @param iterations number of iterations
* @param elapsed elapsed time in seconds
*/
void print_results( int iterations, double elapsed ) {
static void print_results( int iterations, double elapsed ) {
double rate = (double)iterations / elapsed;
printf( " ---\n" );
printf( " iterations: %d\n", iterations );
Expand All @@ -74,7 +73,7 @@ void print_results( int iterations, double elapsed ) {
*
* @return clock time
*/
double tic() {
static double tic() {
struct timeval now;
gettimeofday( &now, NULL );
return (double)now.tv_sec + (double)now.tv_usec/1.0e6;
Expand All @@ -85,9 +84,9 @@ double tic() {
*
* @param a minimum value
* @param b maximum value
* @return random number
* @return random number
*/
double rand_uniform( double a, double b ) {
static double rand_uniform( double a, double b ) {
double x;
int r;

Expand All @@ -102,9 +101,9 @@ double rand_uniform( double a, double b ) {
*
* @param a minimum value
* @param b maximum value
* @return random number
* @return random number
*/
float rand_uniformf( float a, float b ) {
static float rand_uniformf( float a, float b ) {
return (float)rand_uniform( (double)a, (double)b );
}

Expand All @@ -113,9 +112,9 @@ float rand_uniformf( float a, float b ) {
*
* @param iterations number of iterations
* @param len array length
* @return elapsed time in seconds
* @return elapsed time in seconds
*/
double benchmark( int iterations, int len ) {
static double benchmark( int iterations, int len ) {
double elapsed;
{{C_TYPE}} x[ len ];
{{C_TYPE}} y[ len ];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY.

# A `.gyp` file for building a Node.js native add-on.
#
# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* limitations under the License.
*/

/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */

// TypeScript Version: 4.1

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* limitations under the License.
*/

/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */

import {{ALIAS}} = require( './index' );


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
# limitations under the License.
#/

# THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY.

# VARIABLES #

ifndef VERBOSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,24 @@
* limitations under the License.
*/

/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */
gunjjoshi marked this conversation as resolved.
Show resolved Hide resolved

#include "{{PKG_INCLUDE}}.h"
#include <stdint.h>
#include <stdio.h>

int main( void ) {
// Create an input strided array:
const {{C_TYPE}} x[] = { {{C_X_VALUES_LEN_8}} };

// Create an output strided array:
{{C_TYPE}} y[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
{{C_TYPE}} y[] = { 0.0{{C_TYPE_SUFFIX}}, 0.0{{C_TYPE_SUFFIX}}, 0.0{{C_TYPE_SUFFIX}}, 0.0{{C_TYPE_SUFFIX}}, 0.0{{C_TYPE_SUFFIX}}, 0.0{{C_TYPE_SUFFIX}}, 0.0{{C_TYPE_SUFFIX}}, 0.0{{C_TYPE_SUFFIX}} };

// Specify the number of elements:
const int64_t N = 4;
// Specify the number of indexed elements:
const int N = 4;

// Specify the stride lengths:
const int64_t strideX = 2;
const int64_t strideY = 2;
// Specify stride lengths:
const int strideX = 2;
const int strideY = 2;

// Compute the results:
stdlib_strided_{{ALIAS_SNAKECASE}}( N, x, strideX, y, strideY );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@
* limitations under the License.
*/

/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */
gunjjoshi marked this conversation as resolved.
Show resolved Hide resolved

'use strict';

var uniform = require( '@stdlib/random/base/uniform' );
var {{TYPED_ARRAY_CTOR}} = require( '@stdlib/array/{{TYPED_ARRAY_DTYPE}}' );
var random = require( '@stdlib/random/array/uniform' );
var zeros = require( '@stdlib/array/zeros' );
var {{ALIAS}} = require( './../lib' );

var x = new {{TYPED_ARRAY_CTOR}}( 10 );
var y = new {{TYPED_ARRAY_CTOR}}( 10 );

var i;
for ( i = 0; i < x.length; i++ ) {
x[ i ] = uniform( {{C_RAND_MIN}}, {{C_RAND_MAX}} );
}
var x = random( 10, {{C_RAND_MIN}}, {{C_RAND_MAX}}, {
'dtype': '{{TYPED_ARRAY_DTYPE}}'
});
console.log( x );

var y = zeros( 10, '{{TYPED_ARRAY_DTYPE}}' );
console.log( y );

{{ALIAS}}.ndarray( x.length, x, 1, 0, y, -1, y.length-1 );
Expand Down
Loading
Loading