evalrational.js (2128B)
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/evalrational-compile' ); 30 31 32 // VARIABLES // 33 34 // Polynomial coefficients ordered in ascending degree... 35 var P = [ 36 9.99999999999999996796e-01, 37 4.94214826801497100753e-01, 38 2.07448227648435975150e-01, 39 4.76367800457137231464e-02, 40 1.04213797561761569935e-02, 41 1.19135147006586384913e-03, 42 1.60119522476751861407e-04, 43 0 44 ]; 45 var Q = [ 46 1.00000000000000000320e+00, 47 7.14304917030273074085e-02, 48 -2.34591795718243348568e-01, 49 3.58236398605498653373e-02, 50 1.18139785222060435552e-02, 51 -4.45641913851797240494e-03, 52 5.39605580493303397842e-04, 53 -2.31581873324120129819e-05 54 ]; 55 56 // Header to add to output files: 57 var header = licenseHeader( 'Apache-2.0', 'js', { 58 'year': ( new Date() ).getFullYear(), 59 'copyright': 'The Stdlib Authors' 60 }); 61 header += '\n/* This is a generated file. Do not edit directly. */\n'; 62 63 64 // MAIN // 65 66 /** 67 * Main execution sequence. 68 * 69 * @private 70 */ 71 function main() { 72 var fpath; 73 var opts; 74 var str; 75 76 opts = { 77 'encoding': 'utf8' 78 }; 79 80 fpath = resolve( __dirname, '..', 'lib', 'rational_pq.js' ); 81 str = header + compile( P, Q ); 82 writeFileSync( fpath, str, opts ); 83 } 84 85 main();