Skip to content

Commit

Permalink
refactor: use stdlib package for summing three numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
kgryte committed Nov 21, 2023
1 parent a3748a5 commit 1f0ecb0
Show file tree
Hide file tree
Showing 28 changed files with 32 additions and 212 deletions.
10 changes: 2 additions & 8 deletions lib/node_modules/@stdlib/array/base/ternary2d/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,9 @@ var ternary2d = require( '@stdlib/array/base/ternary2d' );
Applies a ternary callback to elements in three two-dimensional nested input arrays and assigns results to elements in a two-dimensional nested output array.

```javascript
var add = require( '@stdlib/math/base/ops/add3' );
var zeros2d = require( '@stdlib/array/base/zeros2d' );

function add( x, y, z ) {
return x + y + z;
}

var x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ];
var out = zeros2d( [ 2, 2 ] );

Expand Down Expand Up @@ -86,12 +83,9 @@ The function accepts the following arguments:
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory;
var filled2dBy = require( '@stdlib/array/base/filled2d-by' );
var zeros2d = require( '@stdlib/array/base/zeros2d' );
var add = require( '@stdlib/math/base/ops/add3' );
var ternary2d = require( '@stdlib/array/base/ternary2d' );

function add( x, y, z ) {
return x + y + z;
}

var shape = [ 3, 3 ];

var x = filled2dBy( shape, discreteUniform( -100, 100 ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,13 @@ var floor = require( '@stdlib/math/base/special/floor' );
var filled2dBy = require( '@stdlib/array/base/filled2d-by' );
var zeros2d = require( '@stdlib/array/base/zeros2d' );
var numel = require( '@stdlib/ndarray/base/numel' );
var add = require( '@stdlib/math/base/ops/add3' );
var pkg = require( './../package.json' ).name;
var ternary2d = require( './../lib' );


// FUNCTIONS //

/**
* Returns the sum.
*
* @private
* @param {number} x - first value
* @param {number} y - second value
* @param {number} z - third value
* @returns {number} sum
*/
function add( x, y, z ) {
return x + y + z;
}

/**
* Creates a benchmark function.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,10 @@ type Ternary<T, U, V, W> = ( v1: T, v2: U, v3: V ) => W;
* @param fcn - ternary callback
*
* @example
* var add = require( `@stdlib/math/base/ops/add3` );
* var ones2d = require( `@stdlib/array/base/ones2d` );
* var zeros2d = require( `@stdlib/array/base/zeros2d` );
*
* function add( x, y, z ) {
* return x + y + z;
* }
*
* var shape = [ 2, 2 ];
*
* var x = ones2d( shape );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,9 @@
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory;
var filled2dBy = require( '@stdlib/array/base/filled2d-by' );
var zeros2d = require( '@stdlib/array/base/zeros2d' );
var add = require( '@stdlib/math/base/ops/add3' );
var ternary2d = require( './../lib' );

function add( x, y, z ) {
return x + y + z;
}

var shape = [ 3, 3 ];

var x = filled2dBy( shape, discreteUniform( -100, 100 ) );
Expand Down
5 changes: 1 addition & 4 deletions lib/node_modules/@stdlib/array/base/ternary2d/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,11 @@
* @module @stdlib/array/base/ternary2d
*
* @example
* var add = require( '@stdlib/math/base/ops/add3' );
* var ones2d = require( '@stdlib/array/base/ones2d' );
* var zeros2d = require( '@stdlib/array/base/zeros2d' );
* var ternary2d = require( '@stdlib/array/base/ternary2d' );
*
* function add( x, y, z ) {
* return x + y + z;
* }
*
* var shape = [ 2, 2 ];
*
* var x = ones2d( shape );
Expand Down
5 changes: 1 addition & 4 deletions lib/node_modules/@stdlib/array/base/ternary2d/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,10 @@
* @returns {void}
*
* @example
* var add = require( '@stdlib/math/base/ops/add3' );
* var ones2d = require( '@stdlib/array/base/ones2d' );
* var zeros2d = require( '@stdlib/array/base/zeros2d' );
*
* function add( x, y, z ) {
* return x + y + z;
* }
*
* var shape = [ 2, 2 ];
*
* var x = ones2d( shape );
Expand Down
17 changes: 1 addition & 16 deletions lib/node_modules/@stdlib/array/base/ternary2d/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,10 @@

var tape = require( 'tape' );
var zeros2d = require( '@stdlib/array/base/zeros2d' );
var add = require( '@stdlib/math/base/ops/add3' );
var ternary2d = require( './../lib' );


// FUNCTIONS //

/**
* Returns the sum.
*
* @private
* @param {number} x - first value
* @param {number} y - second value
* @param {number} z - third value
* @returns {number} sum
*/
function add( x, y, z ) {
return x + y + z;
}


// TESTS //

tape( 'main export is a function', function test( t ) {
Expand Down
10 changes: 2 additions & 8 deletions lib/node_modules/@stdlib/array/base/ternary3d/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,9 @@ var ternary3d = require( '@stdlib/array/base/ternary3d' );
Applies a ternary callback to elements in three three-dimensional nested input arrays and assigns results to elements in a three-dimensional nested output array.

```javascript
var add = require( '@stdlib/math/base/ops/add3' );
var zeros3d = require( '@stdlib/array/base/zeros3d' );

function add( x, y, z ) {
return x + y + z;
}

var x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ];
var out = zeros3d( [ 1, 2, 2 ] );

Expand Down Expand Up @@ -85,13 +82,10 @@ The function accepts the following arguments:
```javascript
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory;
var filled3dBy = require( '@stdlib/array/base/filled3d-by' );
var add = require( '@stdlib/math/base/ops/add3' );
var zeros3d = require( '@stdlib/array/base/zeros3d' );
var ternary3d = require( '@stdlib/array/base/ternary3d' );

function add( x, y, z ) {
return x + y + z;
}

var shape = [ 3, 3, 3 ];

var x = filled3dBy( shape, discreteUniform( -100, 100 ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,13 @@ var floor = require( '@stdlib/math/base/special/floor' );
var filled3dBy = require( '@stdlib/array/base/filled3d-by' );
var zeros3d = require( '@stdlib/array/base/zeros3d' );
var numel = require( '@stdlib/ndarray/base/numel' );
var add = require( '@stdlib/math/base/ops/add3' );
var pkg = require( './../package.json' ).name;
var ternary3d = require( './../lib' );


// FUNCTIONS //

/**
* Returns the sum.
*
* @private
* @param {number} x - first value
* @param {number} y - second value
* @param {number} z - third value
* @returns {number} sum
*/
function add( x, y, z ) {
return x + y + z;
}

/**
* Creates a benchmark function.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,10 @@ type Ternary<T, U, V, W> = ( v1: T, v2: U, v3: V ) => W;
* @param fcn - ternary callback
*
* @example
* var add = require( `@stdlib/math/base/ops/add3` );
* var ones3d = require( `@stdlib/array/base/ones3d` );
* var zeros3d = require( `@stdlib/array/base/zeros3d` );
*
* function add( x, y, z ) {
* return x + y + z;
* }
*
* var shape = [ 1, 2, 2 ];
*
* var x = ones3d( shape );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,9 @@
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory;
var filled3dBy = require( '@stdlib/array/base/filled3d-by' );
var zeros3d = require( '@stdlib/array/base/zeros3d' );
var add = require( '@stdlib/math/base/ops/add3' );
var ternary3d = require( './../lib' );

function add( x, y, z ) {
return x + y + z;
}

var shape = [ 3, 3, 3 ];

var x = filled3dBy( shape, discreteUniform( -100, 100 ) );
Expand Down
5 changes: 1 addition & 4 deletions lib/node_modules/@stdlib/array/base/ternary3d/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,11 @@
* @module @stdlib/array/base/ternary3d
*
* @example
* var add = require( '@stdlib/math/base/ops/add3' );
* var ones3d = require( '@stdlib/array/base/ones3d' );
* var zeros3d = require( '@stdlib/array/base/zeros3d' );
* var ternary3d = require( '@stdlib/array/base/ternary3d' );
*
* function add( x, y, z ) {
* return x + y + z;
* }
*
* var shape = [ 1, 2, 2 ];
*
* var x = ones3d( shape );
Expand Down
5 changes: 1 addition & 4 deletions lib/node_modules/@stdlib/array/base/ternary3d/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,10 @@
* @returns {void}
*
* @example
* var add = require( '@stdlib/math/base/ops/add3' );
* var ones3d = require( '@stdlib/array/base/ones3d' );
* var zeros3d = require( '@stdlib/array/base/zeros3d' );
*
* function add( x, y, z ) {
* return x + y + z;
* }
*
* var shape = [ 1, 2, 2 ];
*
* var x = ones3d( shape );
Expand Down
17 changes: 1 addition & 16 deletions lib/node_modules/@stdlib/array/base/ternary3d/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,11 @@
// MODULES //

var tape = require( 'tape' );
var add = require( '@stdlib/math/base/ops/add3' );
var zeros3d = require( '@stdlib/array/base/zeros3d' );
var ternary3d = require( './../lib' );


// FUNCTIONS //

/**
* Returns the sum.
*
* @private
* @param {number} x - first value
* @param {number} y - second value
* @param {number} z - third value
* @returns {number} sum
*/
function add( x, y, z ) {
return x + y + z;
}


// TESTS //

tape( 'main export is a function', function test( t ) {
Expand Down
10 changes: 2 additions & 8 deletions lib/node_modules/@stdlib/array/base/ternary4d/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,9 @@ var ternary4d = require( '@stdlib/array/base/ternary4d' );
Applies a ternary callback to elements in three four-dimensional nested input arrays and assigns results to elements in a four-dimensional nested output array.

```javascript
var add = require( '@stdlib/math/base/ops/add3' );
var zeros4d = require( '@stdlib/array/base/zeros4d' );

function add( x, y, z ) {
return x + y + z;
}

var x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ];
var out = zeros4d( [ 1, 1, 2, 2 ] );

Expand Down Expand Up @@ -86,12 +83,9 @@ The function accepts the following arguments:
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory;
var filled4dBy = require( '@stdlib/array/base/filled4d-by' );
var zeros4d = require( '@stdlib/array/base/zeros4d' );
var add = require( '@stdlib/math/base/ops/add3' );
var ternary4d = require( '@stdlib/array/base/ternary4d' );

function add( x, y, z ) {
return x + y + z;
}

var shape = [ 1, 3, 3, 3 ];

var x = filled4dBy( shape, discreteUniform( -100, 100 ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,13 @@ var floor = require( '@stdlib/math/base/special/floor' );
var filled4dBy = require( '@stdlib/array/base/filled4d-by' );
var zeros4d = require( '@stdlib/array/base/zeros4d' );
var numel = require( '@stdlib/ndarray/base/numel' );
var add = require( '@stdlib/math/base/ops/add3' );
var pkg = require( './../package.json' ).name;
var ternary4d = require( './../lib' );


// FUNCTIONS //

/**
* Returns the sum.
*
* @private
* @param {number} x - first value
* @param {number} y - second value
* @param {number} z - third value
* @returns {number} sum
*/
function add( x, y, z ) {
return x + y + z;
}

/**
* Creates a benchmark function.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,10 @@ type Ternary<T, U, V, W> = ( v1: T, v2: U, v3: V ) => W;
* @param fcn - ternary callback
*
* @example
* var add = require( `@stdlib/math/base/ops/add3` );
* var ones4d = require( `@stdlib/array/base/ones4d` );
* var zeros4d = require( `@stdlib/array/base/zeros4d` );
*
* function add( x, y, z ) {
* return x + y + z;
* }
*
* var shape = [ 1, 1, 2, 2 ];
*
* var x = ones4d( shape );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,9 @@
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory;
var filled4dBy = require( '@stdlib/array/base/filled4d-by' );
var zeros4d = require( '@stdlib/array/base/zeros4d' );
var add = require( '@stdlib/math/base/ops/add3' );
var ternary4d = require( './../lib' );

function add( x, y, z ) {
return x + y + z;
}

var shape = [ 1, 3, 3, 3 ];

var x = filled4dBy( shape, discreteUniform( -100, 100 ) );
Expand Down
5 changes: 1 addition & 4 deletions lib/node_modules/@stdlib/array/base/ternary4d/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,11 @@
* @module @stdlib/array/base/ternary4d
*
* @example
* var add = require( '@stdlib/math/base/ops/add3' );
* var ones4d = require( '@stdlib/array/base/ones4d' );
* var zeros4d = require( '@stdlib/array/base/zeros4d' );
* var ternary4d = require( '@stdlib/array/base/ternary4d' );
*
* function add( x, y, z ) {
* return x + y + z;
* }
*
* var shape = [ 1, 1, 2, 2 ];
*
* var x = ones4d( shape );
Expand Down
Loading

0 comments on commit 1f0ecb0

Please sign in to comment.