Skip to content

Commit c12e373

Browse files
committed
docs: update examples and improve type specificity
1 parent e9360fe commit c12e373

File tree

4 files changed

+10
-40
lines changed

4 files changed

+10
-40
lines changed

lib/node_modules/@stdlib/math/base/tools/evalpoly-compile-c/README.md

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -123,29 +123,14 @@ static float polyval123( const float x ) {
123123
<!-- eslint no-undef: "error" -->
124124
125125
```javascript
126-
var randu = require( '@stdlib/random/base/randu' );
127-
var round = require( '@stdlib/math/base/special/round' );
128-
var Float64Array = require( '@stdlib/array/float64' );
126+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
129127
var compile = require( '@stdlib/math/base/tools/evalpoly-compile-c' );
130128
131-
var coef;
132-
var sign;
133-
var str;
134-
var i;
135-
136-
// Create an array of random coefficients...
137-
coef = new Float64Array( 10 );
138-
for ( i = 0; i < coef.length; i++ ) {
139-
if ( randu() < 0.5 ) {
140-
sign = -1.0;
141-
} else {
142-
sign = 1.0;
143-
}
144-
coef[ i ] = sign * round( randu()*100.0 );
145-
}
129+
// Create an array of random coefficients:
130+
var coef = discreteUniform( 10, -100, 100 );
146131
147132
// Compile a function for evaluating a polynomial:
148-
str = compile( coef );
133+
var str = compile( coef );
149134
console.log( str );
150135
```
151136

lib/node_modules/@stdlib/math/base/tools/evalpoly-compile-c/docs/types/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ interface Options {
2525
/**
2626
* Input value floating-point data type (e.g., `double` or `float`). Default: `'double'`.
2727
*/
28-
dtype?: string;
28+
dtype?: 'double' | 'float';
2929

3030
/**
3131
* Function name. Default: `'evalpoly'`.

lib/node_modules/@stdlib/math/base/tools/evalpoly-compile-c/docs/types/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ import compile = require( './index' );
5555
compile( [ 3.0, 2.0, 1.0 ], ( x: number ): number => x ); // $ExpectError
5656
}
5757

58-
// The compiler throws an error if the function is provided a `dtype` option which is not a string...
58+
// The compiler throws an error if the function is provided an invalid `dtype` option...
5959
{
6060
compile( [ 3.0, 2.0, 1.0 ], { 'dtype': true } ); // $ExpectError
6161
compile( [ 3.0, 2.0, 1.0 ], { 'dtype': false } ); // $ExpectError

lib/node_modules/@stdlib/math/base/tools/evalpoly-compile-c/examples/index.js

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@
1919
'use strict';
2020

2121
var resolve = require( 'path' ).resolve;
22-
var randu = require( '@stdlib/random/base/randu' );
23-
var round = require( '@stdlib/math/base/special/round' );
24-
var Float64Array = require( '@stdlib/array/float64' );
22+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
2523
var tryRequire = require( '@stdlib/utils/try-require' );
2624

2725
var compile = tryRequire( resolve( __dirname, '..', 'lib' ) );
@@ -32,23 +30,10 @@ if ( compile instanceof Error ) {
3230
}
3331

3432
function main() {
35-
var coef;
36-
var sign;
37-
var str;
38-
var i;
39-
40-
// Create an array of random coefficients...
41-
coef = new Float64Array( 10 );
42-
for ( i = 0; i < coef.length; i++ ) {
43-
if ( randu() < 0.5 ) {
44-
sign = -1.0;
45-
} else {
46-
sign = 1.0;
47-
}
48-
coef[ i ] = sign * round( randu()*100.0 );
49-
}
33+
// Create an array of random coefficients:
34+
var coef = discreteUniform( 10, -100, 100 );
5035

5136
// Compile a function for evaluating a polynomial:
52-
str = compile( coef );
37+
var str = compile( coef );
5338
console.log( str );
5439
}

0 commit comments

Comments
 (0)