evalpoly.js (2096B)
1 /** 2 * @license Apache-2.0 3 * 4 * Copyright (c) 2018 The Stdlib Authors. 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 /* 20 * This script compiles modules for evaluating polynomial functions. If any polynomial coefficients change, this script should be rerun to update the compiled files. 21 */ 22 'use strict'; 23 24 // MODULES // 25 26 var resolve = require( 'path' ).resolve; 27 var writeFileSync = require( '@stdlib/fs/write-file' ).sync; 28 var licenseHeader = require( '@stdlib/_tools/licenses/header' ); 29 var compile = require( './../../../../base/tools/evalpoly-compile' ); 30 31 32 // VARIABLES // 33 34 // Polynomial coefficients ordered in ascending degree... 35 var P = [ 36 -6.485021904942025371773e1, 37 -1.228866684490136173410e2, 38 -7.500855792314704667340e1, 39 -1.615753718733365076637e1, 40 -8.750608600031904122785e-1 41 ]; 42 var Q = [ 43 1.945506571482613964425e2, 44 4.853903996359136964868e2, 45 4.328810604912902668951e2, 46 1.650270098316988542046e2, 47 2.485846490142306297962e1, 48 1.0 49 ]; 50 51 // Header to add to output files: 52 var header = licenseHeader( 'Apache-2.0', 'js', { 53 'year': ( new Date() ).getFullYear(), 54 'copyright': 'The Stdlib Authors' 55 }); 56 header += '\n/* This is a generated file. Do not edit directly. */\n'; 57 58 59 // MAIN // 60 61 /** 62 * Main execution sequence. 63 * 64 * @private 65 */ 66 function main() { 67 var fpath; 68 var opts; 69 var str; 70 71 opts = { 72 'encoding': 'utf8' 73 }; 74 75 fpath = resolve( __dirname, '..', 'lib', 'polyval_p.js' ); 76 str = header + compile( P ); 77 writeFileSync( fpath, str, opts ); 78 79 fpath = resolve( __dirname, '..', 'lib', 'polyval_q.js' ); 80 str = header + compile( Q ); 81 writeFileSync( fpath, str, opts ); 82 } 83 84 main();