From a81394646f2df5434879b7915ddd03b9a5002381 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Mar 2024 09:07:15 +0000 Subject: [PATCH] Auto-generated commit --- base/tools/evalpoly-compile-c/README.md | 23 ++++--------------- .../evalpoly-compile-c/docs/types/index.d.ts | 2 +- .../evalpoly-compile-c/docs/types/test.ts | 2 +- .../evalpoly-compile-c/examples/index.js | 23 ++++--------------- 4 files changed, 10 insertions(+), 40 deletions(-) diff --git a/base/tools/evalpoly-compile-c/README.md b/base/tools/evalpoly-compile-c/README.md index 7398afa82..e78cbb1ea 100644 --- a/base/tools/evalpoly-compile-c/README.md +++ b/base/tools/evalpoly-compile-c/README.md @@ -123,29 +123,14 @@ static float polyval123( const float x ) { ```javascript -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var Float64Array = require( '@stdlib/array/float64' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var compile = require( '@stdlib/math/base/tools/evalpoly-compile-c' ); -var coef; -var sign; -var str; -var i; - -// Create an array of random coefficients... -coef = new Float64Array( 10 ); -for ( i = 0; i < coef.length; i++ ) { - if ( randu() < 0.5 ) { - sign = -1.0; - } else { - sign = 1.0; - } - coef[ i ] = sign * round( randu()*100.0 ); -} +// Create an array of random coefficients: +var coef = discreteUniform( 10, -100, 100 ); // Compile a function for evaluating a polynomial: -str = compile( coef ); +var str = compile( coef ); console.log( str ); ``` diff --git a/base/tools/evalpoly-compile-c/docs/types/index.d.ts b/base/tools/evalpoly-compile-c/docs/types/index.d.ts index f31e964b9..4aa909edb 100644 --- a/base/tools/evalpoly-compile-c/docs/types/index.d.ts +++ b/base/tools/evalpoly-compile-c/docs/types/index.d.ts @@ -25,7 +25,7 @@ interface Options { /** * Input value floating-point data type (e.g., `double` or `float`). Default: `'double'`. */ - dtype?: string; + dtype?: 'double' | 'float'; /** * Function name. Default: `'evalpoly'`. diff --git a/base/tools/evalpoly-compile-c/docs/types/test.ts b/base/tools/evalpoly-compile-c/docs/types/test.ts index 6f8b55411..bf039a869 100644 --- a/base/tools/evalpoly-compile-c/docs/types/test.ts +++ b/base/tools/evalpoly-compile-c/docs/types/test.ts @@ -55,7 +55,7 @@ import compile = require( './index' ); compile( [ 3.0, 2.0, 1.0 ], ( x: number ): number => x ); // $ExpectError } -// The compiler throws an error if the function is provided a `dtype` option which is not a string... +// The compiler throws an error if the function is provided an invalid `dtype` option... { compile( [ 3.0, 2.0, 1.0 ], { 'dtype': true } ); // $ExpectError compile( [ 3.0, 2.0, 1.0 ], { 'dtype': false } ); // $ExpectError diff --git a/base/tools/evalpoly-compile-c/examples/index.js b/base/tools/evalpoly-compile-c/examples/index.js index e092c597f..81b27f15d 100644 --- a/base/tools/evalpoly-compile-c/examples/index.js +++ b/base/tools/evalpoly-compile-c/examples/index.js @@ -19,9 +19,7 @@ 'use strict'; var resolve = require( 'path' ).resolve; -var randu = require( '@stdlib/random/base/randu' ); -var round = require( './../../../../base/special/round' ); -var Float64Array = require( '@stdlib/array/float64' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var tryRequire = require( '@stdlib/utils/try-require' ); var compile = tryRequire( resolve( __dirname, '..', 'lib' ) ); @@ -32,23 +30,10 @@ if ( compile instanceof Error ) { } function main() { - var coef; - var sign; - var str; - var i; - - // Create an array of random coefficients... - coef = new Float64Array( 10 ); - for ( i = 0; i < coef.length; i++ ) { - if ( randu() < 0.5 ) { - sign = -1.0; - } else { - sign = 1.0; - } - coef[ i ] = sign * round( randu()*100.0 ); - } + // Create an array of random coefficients: + var coef = discreteUniform( 10, -100, 100 ); // Compile a function for evaluating a polynomial: - str = compile( coef ); + var str = compile( coef ); console.log( str ); }