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 ) {
123
123
<!-- eslint no-undef: "error" -->
124
124
125
125
```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' );
129
127
var compile = require( '@stdlib/math/base/tools/evalpoly-compile-c' );
130
128
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 );
146
131
147
132
// Compile a function for evaluating a polynomial:
148
- str = compile( coef );
133
+ var str = compile( coef );
149
134
console.log( str );
150
135
```
151
136
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ interface Options {
25
25
/**
26
26
* Input value floating-point data type (e.g., `double` or `float`). Default: `'double'`.
27
27
*/
28
- dtype ?: string ;
28
+ dtype ?: 'double' | 'float' ;
29
29
30
30
/**
31
31
* Function name. Default: `'evalpoly'`.
Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ import compile = require( './index' );
55
55
compile ( [ 3.0 , 2.0 , 1.0 ] , ( x : number ) : number => x ) ; // $ExpectError
56
56
}
57
57
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...
59
59
{
60
60
compile ( [ 3.0 , 2.0 , 1.0 ] , { 'dtype' : true } ) ; // $ExpectError
61
61
compile ( [ 3.0 , 2.0 , 1.0 ] , { 'dtype' : false } ) ; // $ExpectError
Original file line number Diff line number Diff line change 19
19
'use strict' ;
20
20
21
21
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' ) ;
25
23
var tryRequire = require ( '@stdlib/utils/try-require' ) ;
26
24
27
25
var compile = tryRequire ( resolve ( __dirname , '..' , 'lib' ) ) ;
@@ -32,23 +30,10 @@ if ( compile instanceof Error ) {
32
30
}
33
31
34
32
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 ) ;
50
35
51
36
// Compile a function for evaluating a polynomial:
52
- str = compile ( coef ) ;
37
+ var str = compile ( coef ) ;
53
38
console . log ( str ) ;
54
39
}
You can’t perform that action at this time.
0 commit comments