Skip to content

docs: replace manual for loop in examples #6490

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

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions lib/node_modules/@stdlib/math/base/special/polygamma/README.md
Original file line number Diff line number Diff line change
@@ -74,7 +74,7 @@ v = polygamma( 2, -1.0 );
If `x` on the other hand is a negative even `integer`, the function returns `NaN`.

```javascript
v = polygamma( 2, -4.0 );
var v = polygamma( 2, -4.0 );
// returns NaN

v = polygamma( 2, -2.0 );
@@ -105,21 +105,18 @@ v = polygamma( NaN, NaN );
<!-- eslint no-undef: "error" -->

```javascript
var randu = require( '@stdlib/random/base/randu' );
var round = require( '@stdlib/math/base/special/round' );
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var uniform = require( '@stdlib/random/array/uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var polygamma = require( '@stdlib/math/base/special/polygamma' );

var n;
var x;
var v;
var i;

for ( i = 0; i < 100; i++ ) {
x = (randu()*100.0) - 50.0;
n = round( randu()*50.0 );
v = polygamma( x, n );
console.log( 'x: %d, ψ^(%d)(x): %d', x, n, v );
}
var opts = {
'dtype': 'float64'
};
var x = uniform( 100, -50.0, 50.0, opts );
var n = discreteUniform( 100, 0, 50, opts );

logEachMap( 'x: %0.4f, ψ^(%d)(x): %0.4f', x, n, polygamma );
```

</section>
Original file line number Diff line number Diff line change
@@ -18,18 +18,15 @@

'use strict';

var randu = require( '@stdlib/random/base/randu' );
var round = require( '@stdlib/math/base/special/round' );
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var uniform = require( '@stdlib/random/array/uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var polygamma = require( './../lib' );

var n;
var x;
var v;
var i;
var opts = {
'dtype': 'float64'
};
var x = uniform( 100, -50.0, 50.0, opts );
var n = discreteUniform( 100, 0, 50, opts );

for ( i = 0; i < 100; i++ ) {
x = (randu()*100.0) - 50.0;
n = round( randu()*50.0 );
v = polygamma( n, x );
console.log( 'x: %d, ψ^(%d)(x): %d', x, n, v );
}
logEachMap( 'x: %0.4f, ψ^(%d)(x): %0.4f', x, n, polygamma );
18 changes: 8 additions & 10 deletions lib/node_modules/@stdlib/math/base/special/pow/README.md
Original file line number Diff line number Diff line change
@@ -94,19 +94,17 @@ v = pow( NaN, NaN );
<!-- eslint no-undef: "error" -->

```javascript
var randu = require( '@stdlib/random/base/randu' );
var round = require( '@stdlib/math/base/special/round' );
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var pow = require( '@stdlib/math/base/special/pow' );

var b;
var x;
var i;
var opts = {
'dtype': 'float64'
};
var b = discreteUniform( 100, 0, 10, opts );
var x = discreteUniform( 100, -5, 5, opts );

for ( i = 0; i < 100; i++ ) {
b = round( randu()*10.0 );
x = round( randu()*10.0 ) - 5.0;
console.log( '%d^%d = %d', b, x, pow( b, x ) );
}
logEachMap( '%d^%d = %0.4f', b, x, pow );
```

</section>
18 changes: 8 additions & 10 deletions lib/node_modules/@stdlib/math/base/special/pow/examples/index.js
Original file line number Diff line number Diff line change
@@ -18,16 +18,14 @@

'use strict';

var randu = require( '@stdlib/random/base/randu' );
var round = require( '@stdlib/math/base/special/round' );
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var pow = require( './../lib' );

var b;
var x;
var i;
var opts = {
'dtype': 'float64'
};
var b = discreteUniform( 100, 0, 10, opts );
var x = discreteUniform( 100, -5, 5, opts );

for ( i = 0; i < 100; i++ ) {
b = round( randu()*10.0 );
x = round( randu()*10.0 ) - 5.0;
console.log( '%d^%d = %d', b, x, pow( b, x ) );
}
logEachMap( '%d^%d = %0.4f', b, x, pow );
20 changes: 8 additions & 12 deletions lib/node_modules/@stdlib/math/base/special/powm1/README.md
Original file line number Diff line number Diff line change
@@ -92,21 +92,17 @@ y = powm1( 5.0, NaN );
<!-- eslint no-undef: "error" -->

```javascript
var randu = require( '@stdlib/random/base/randu' );
var round = require( '@stdlib/math/base/special/round' );
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var powm1 = require( '@stdlib/math/base/special/powm1' );

var b;
var x;
var y;
var i;
var opts = {
'dtype': 'float64'
};
var b = discreteUniform( 100, 0, 10, opts );
var x = discreteUniform( 100, -5, 5, opts );

for ( i = 0; i < 100; i++ ) {
b = round( randu()*10.0 );
x = round( randu()*10.0 ) - 5.0;
y = powm1( b, x );
console.log( '%d^%d - 1 = %d', b, x, y );
}
logEachMap( '%d^%d - 1 = %0.4f', b, x, powm1 );
```

</section>
20 changes: 8 additions & 12 deletions lib/node_modules/@stdlib/math/base/special/powm1/examples/index.js
Original file line number Diff line number Diff line change
@@ -18,18 +18,14 @@

'use strict';

var randu = require( '@stdlib/random/base/randu' );
var round = require( '@stdlib/math/base/special/round' );
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var powm1 = require( './../lib' );

var b;
var x;
var y;
var i;
var opts = {
'dtype': 'float64'
};
var b = discreteUniform( 100, 0, 10, opts );
var x = discreteUniform( 100, -5, 5, opts );

for ( i = 0; i < 100; i++ ) {
b = round( randu()*10.0 );
x = round( randu()*10.0 ) - 5.0;
y = powm1( b, x );
console.log( '%d^%d - 1 = %d', b, x, y );
}
logEachMap( '%d^%d - 1 = %0.4f', b, x, powm1 );
16 changes: 7 additions & 9 deletions lib/node_modules/@stdlib/math/base/special/rad2deg/README.md
Original file line number Diff line number Diff line change
@@ -71,19 +71,17 @@ d = rad2deg( NaN );
<!-- eslint no-undef: "error" -->

```javascript
var randu = require( '@stdlib/random/base/randu' );
var uniform = require( '@stdlib/random/array/uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var TWO_PI = require( '@stdlib/constants/float64/two-pi' );
var rad2deg = require( '@stdlib/math/base/special/rad2deg' );

var r;
var d;
var i;
var opts = {
'dtype': 'float64'
};
var r = uniform( 100, 0.0, TWO_PI, opts );

for ( i = 0; i < 100; i++ ) {
r = randu() * TWO_PI;
d = rad2deg( r );
console.log( 'radians: %d => degrees: %d', r, d );
}
logEachMap( 'radians: %0.4f => degrees: %0.4f', r, rad2deg );
```

</section>
Original file line number Diff line number Diff line change
@@ -18,16 +18,14 @@

'use strict';

var randu = require( '@stdlib/random/base/randu' );
var uniform = require( '@stdlib/random/array/uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var TWO_PI = require( '@stdlib/constants/float64/two-pi' );
var rad2deg = require( './../lib' );

var r;
var d;
var i;
var opts = {
'dtype': 'float64'
};
var r = uniform( 100, 0.0, TWO_PI, opts );

for ( i = 0; i < 100; i++ ) {
r = randu() * TWO_PI;
d = rad2deg( r );
console.log( 'radians: %d => degrees: %d', r, d );
}
logEachMap( 'radians: %0.4f => degrees: %0.4f', r, rad2deg );
16 changes: 7 additions & 9 deletions lib/node_modules/@stdlib/math/base/special/rad2degf/README.md
Original file line number Diff line number Diff line change
@@ -71,19 +71,17 @@ d = rad2degf( NaN );
<!-- eslint no-undef: "error" -->

```javascript
var randu = require( '@stdlib/random/base/randu' );
var uniform = require( '@stdlib/random/array/uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var TWO_PI = require( '@stdlib/constants/float32/two-pi' );
var rad2degf = require( '@stdlib/math/base/special/rad2degf' );

var r;
var d;
var i;
var opts = {
'dtype': 'float32'
};
var r = uniform( 100, 0.0, TWO_PI, opts );

for ( i = 0; i < 100; i++ ) {
r = randu() * TWO_PI;
d = rad2degf( r );
console.log( 'radians: %d => degrees: %d', r, d );
}
logEachMap( 'radians: %0.4f => degrees: %0.4f', r, rad2degf );
```

</section>
Original file line number Diff line number Diff line change
@@ -18,16 +18,14 @@

'use strict';

var randu = require( '@stdlib/random/base/randu' );
var uniform = require( '@stdlib/random/array/uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var TWO_PI = require( '@stdlib/constants/float32/two-pi' );
var rad2degf = require( './../lib' );

var r;
var d;
var i;
var opts = {
'dtype': 'float32'
};
var r = uniform( 100, 0.0, TWO_PI, opts );

for ( i = 0; i < 100; i++ ) {
r = randu() * TWO_PI;
d = rad2degf( r );
console.log( 'radians: %d => degrees: %d', r, d );
}
logEachMap( 'radians: %0.4f => degrees: %0.4f', r, rad2degf );
15 changes: 8 additions & 7 deletions lib/node_modules/@stdlib/math/base/special/rcbrt/README.md
Original file line number Diff line number Diff line change
@@ -86,15 +86,16 @@ v = rcbrt( Infinity );
<!-- eslint no-undef: "error" -->

```javascript
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var rcbrt = require( '@stdlib/math/base/special/rcbrt' );

var x;
var i;
for ( i = 0; i < 100; i++ ) {
x = discreteUniform( 0.0, 100.0 );
console.log( 'rcbrt(%d) = %d', x, rcbrt( x ) );
}
var opts = {
'dtype': 'float64'
};
var x = discreteUniform( 100, 0, 100, opts );

logEachMap( 'rcbrt(%d) = %0.4f', x, rcbrt );
```

</section>
Original file line number Diff line number Diff line change
@@ -18,12 +18,13 @@

'use strict';

var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var rcbrt = require( './../lib' );

var x;
var i;
for ( i = 0; i < 100; i++ ) {
x = discreteUniform( 0.0, 100.0 );
console.log( 'rcbrt(%d) = %d', x, rcbrt( x ) );
}
var opts = {
'dtype': 'float64'
};
var x = discreteUniform( 100, 0, 100, opts );

logEachMap( 'rcbrt(%d) = %0.4f', x, rcbrt );
Loading