Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Mar 24, 2024
1 parent 0230813 commit 9a10e5e
Show file tree
Hide file tree
Showing 22 changed files with 1,898 additions and 72 deletions.
1 change: 0 additions & 1 deletion .github/.keepalive

This file was deleted.

3 changes: 3 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ shrinkwrap = false

# Disable automatically "saving" dependencies on install:
save = false

# Generate provenance metadata:
provenance = true
36 changes: 30 additions & 6 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,80 @@
#
# Contributors listed in alphabetical order.

Aditya Sapra <110766802+adityacodes30@users.noreply.github.com>
Adarsh Palaskar <adarshpalaskar99@gmail.com>
Aditya Sapra <adityaework@gmail.com>
AgPriyanshu18 <113460573+AgPriyanshu18@users.noreply.github.com>
Ali Salesi <ali_sal1381@yahoo.com>
Aman Bhansali <bhansali.1@iitj.ac.in>
Amit Jimiwal <amitjimiwal45@gmail.com>
Anudeep Sanapala <anudeep0306@gmail.com>
Athan Reines <kgryte@gmail.com>
Ayaka <73595362+USERSATOSHI@users.noreply.github.com>
Brendan Graetz <bguiz@users.noreply.github.com>
Bruno Fenzl <brunofenzl@gmail.com>
Chinmay J <86140365+JawHawk@users.noreply.github.com>
Bryan Elee <rxbryn@gmail.com>
Chinmay Joshi <86140365+JawHawk@users.noreply.github.com>
Christopher Dambamuromo <chridam@gmail.com>
Dan Rose <danoftheroses@gmail.com>
Daniel Killenberger <daniel.killenberger@gmail.com>
Dominik Moritz <domoritz@gmail.com>
Dorrin Sotoudeh <dorrinsotoudeh123@gmail.com>
EuniceSim142 <77243938+EuniceSim142@users.noreply.github.com>
Frank Kovacs <fran70kk@gmail.com>
GUNJ JOSHI <gunjjoshi8372@gmail.com>
Golden <103646877+AuenKr@users.noreply.github.com>
Golden Kumar <103646877+AuenKr@users.noreply.github.com>
Gunj Joshi <gunjjoshi8372@gmail.com>
Harshita Kalani <harshitakalani02@gmail.com>
Jaimin Godhani <112328542+Jai0401@users.noreply.github.com>
James Gelok <jdgelok@gmail.com>
Jaysukh Makvana <jaysukhmakvana2004@gmail.com>
Jithin KS <jithinks112@gmail.com>
Joel Mathew Koshy <joelmathewkoshy@gmail.com>
Joey Reed <joeyrreed@gmail.com>
Jordan Gallivan <115050475+Jordan-Gallivan@users.noreply.github.com>
Joris Labie <joris.labie1@gmail.com>
Justin Dennison <justin1dennison@gmail.com>
Karthik Prakash <116057817+skoriop@users.noreply.github.com>
Khaldon <kahmd1444@gmail.com>
Lovelin <100030865+lovelindhoni@users.noreply.github.com>
Manik Sharma <maniksharma.rke@gmail.com>
Marcus Fantham <mfantham@users.noreply.github.com>
Matt Cochrane <matthew.cochrane.eng@gmail.com>
Mihir Pandit <129577900+MSP20086@users.noreply.github.com>
Milan Raj <rajsite@users.noreply.github.com>
Momtchil Momtchev <momtchil@momtchev.com>
Muhammad Haris <harriskhan047@outlook.com>
Naresh Jagadeesan <naresh.naresh000@gmail.com>
Nithin Katta <88046362+nithinkatta@users.noreply.github.com>
Ognjen Jevremović <ognjenjevremovic@users.noreply.github.com>
Oneday12323 <107678750+Oneday12323@users.noreply.github.com>
Philipp Burckhardt <pburckhardt@outlook.com>
Prajwal Kulkarni <prajwalkulkarni76@gmail.com>
Pranav Goswami <goswami.4@iitj.ac.in>
Praneki <97080887+PraneGIT@users.noreply.github.com>
Pratik <97464067+Pratik772846@users.noreply.github.com>
Priyansh <88396544+itsspriyansh@users.noreply.github.com>
Raunak Kumar Gupta <raunakmodanwal321@gmail.com>
Rejoan Sardar <119718513+Rejoan-Sardar@users.noreply.github.com>
Ricky Reusser <rsreusser@gmail.com>
Robert Gislason <gztown2216@yahoo.com>
Roman Stetsyk <25715951+romanstetsyk@users.noreply.github.com>
Rutam <138517416+performant23@users.noreply.github.com>
Ryan Seal <splrk@users.noreply.github.com>
Sai Srikar Dumpeti <80447788+the-r3aper7@users.noreply.github.com>
Seyyed Parsa Neshaei <spneshaei@users.noreply.github.com>
Shashank Shekhar Singh <shashankshekharsingh1205@gmail.com>
Shraddheya Shendre <shendreshraddheya@gmail.com>
Shubham <shubh622005@gmail.com>
Shubham Mishra <shubh622005@gmail.com>
Snehil Shah <130062020+Snehil-Shah@users.noreply.github.com>
Spandan Barve <114365550+marsian83@users.noreply.github.com>
Spandan Barve <contact@marsian.dev>
Stephannie Jiménez Gacha <steff456@hotmail.com>
Suraj kumar <125961509+kumarsuraj212003@users.noreply.github.com>
Tirtadwipa Manunggal <tirtadwipa.manunggal@gmail.com>
Utkarsh <http://utkarsh11105@gmail.com>
Utkarsh Raj <rajutkarsh2505@gmail.com>
Varad Gupta <varadgupta21@gmail.com>
Yernar Yergaziyev <yernar.yergaziyev@erg.kz>
naveen <stupiddint@gmail.com>
nishant-s7 <97207366+nishant-s7@users.noreply.github.com>
orimiles5 <97595296+orimiles5@users.noreply.github.com>
rei2hu <reimu@reimu.ws>
84 changes: 61 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,20 @@ npm install @stdlib/math-base-tools-evalpoly-compile
var compile = require( '@stdlib/math-base-tools-evalpoly-compile' );
```

#### compile( c )
#### compile( c\[, options] )

Compiles a module `string` containing an exported function which evaluates a [polynomial][@stdlib/math/base/tools/evalpoly] having coefficients `c`.
Compiles a module string containing an exported function which evaluates a [polynomial][@stdlib/math/base/tools/evalpoly] having coefficients `c`.

```javascript
var str = compile( [ 3.0, 2.0, 1.0 ] );
// returns <string>
```

In the example above, the output `string` would correspond to the following module:
The function supports the following `options`:

- **dtype**: input argument floating-point data type (e.g., `float64` or `float32`). Default: `'float64'`.

In the example above, the output string would correspond to the following module:

<!-- eslint-disable no-unused-expressions -->

Expand All @@ -94,7 +98,7 @@ function evalpoly( x ) {
if ( x === 0.0 ) {
return 3.0;
}
return 3.0 + (x * (2.0 + (x * 1.0))); // eslint-disable-line max-len
return 3.0 + (x * (2.0 + (x * 1.0)));
}


Expand All @@ -105,6 +109,55 @@ module.exports = evalpoly;

The coefficients should be ordered in **ascending** degree, thus matching summation notation.

By default, the function assumes double-precision floating-point arithmetic. To emulate single-precision floating-point arithmetic, set the `dtype` option to `'float32'`.

```javascript
var str = compile( [ 3.0, 2.0, 1.0 ], {
'dtype': 'float32'
});
// returns <string>
```

In the previous example, the output string would correspond to the following module:

<!-- eslint-disable no-unused-expressions -->

```javascript
'use strict';

// MODULES //

var float64ToFloat32 = require( '@stdlib/number-float64-base-to-float32' );


// MAIN //

/**
* Evaluates a polynomial.
*
* ## Notes
*
* - The implementation uses [Horner's rule][horners-method] for efficient computation.
*
* [horners-method]: https://en.wikipedia.org/wiki/Horner%27s_method
*
* @private
* @param {number} x - value at which to evaluate the polynomial
* @returns {number} evaluated polynomial
*/
function evalpoly( x ) {
if ( x === 0.0 ) {
return 3.0;
}
return float64ToFloat32(3.0 + float64ToFloat32(x * float64ToFloat32(2.0 + float64ToFloat32(x * 1.0)))); // eslint-disable-line max-len
}


// EXPORTS //

module.exports = evalpoly;
```

</section>

<!-- /.usage -->
Expand All @@ -126,29 +179,14 @@ The coefficients should be ordered in **ascending** degree, thus matching summat
<!-- eslint no-undef: "error" -->

```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' );

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 module for evaluating a polynomial:
str = compile( coef );
var str = compile( coef );
console.log( str );
```

Expand Down
6 changes: 3 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9a10e5e

Please sign in to comment.