File tree Expand file tree Collapse file tree 4 files changed +10
-40
lines changed
lib/node_modules/@stdlib/math/base/tools/evalpoly-compile-c Expand file tree Collapse file tree 4 files changed +10
-40
lines changed Original file line number Diff line number Diff 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' );
129127var 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 );
149134console.log( str );
150135```
151136
Original file line number Diff line number Diff 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'`.
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 1919'use strict' ;
2020
2121var 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' ) ;
2523var tryRequire = require ( '@stdlib/utils/try-require' ) ;
2624
2725var compile = tryRequire ( resolve ( __dirname , '..' , 'lib' ) ) ;
@@ -32,23 +30,10 @@ if ( compile instanceof Error ) {
3230}
3331
3432function 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}
You can’t perform that action at this time.
0 commit comments