evalrational.js (2273B)
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 38474670393.31776828316099004518914832218, 37 36857665043.51950660081971227404959150474, 38 15889202453.72942008945006665994637853242, 39 4059208354.298834770194507810788393801607, 40 680547661.1834733286087695557084801366446, 41 78239755.00312005289816041245285376206263, 42 6246580.776401795264013335510453568106366, 43 341986.3488721347032223777872763188768288, 44 12287.19451182455120096222044424100527629, 45 261.6140441641668190791708576058805625502, 46 2.506628274631000502415573855452633787834 47 ]; 48 var Q = [ 49 0.0, 50 362880.0, 51 1026576.0, 52 1172700.0, 53 723680.0, 54 269325.0, 55 63273.0, 56 9450.0, 57 870.0, 58 45.0, 59 1.0 60 ]; 61 62 // Header to add to output files: 63 var header = licenseHeader( 'Apache-2.0', 'js', { 64 'year': ( new Date() ).getFullYear(), 65 'copyright': 'The Stdlib Authors' 66 }); 67 header += '\n/* This is a generated file. Do not edit directly. */\n'; 68 69 70 // MAIN // 71 72 /** 73 * Main execution sequence. 74 * 75 * @private 76 */ 77 function main() { 78 var fpath; 79 var opts; 80 var str; 81 82 opts = { 83 'encoding': 'utf8' 84 }; 85 86 fpath = resolve( __dirname, '..', 'lib', 'rational_pq.js' ); 87 str = header + compile( P, Q ); 88 writeFileSync( fpath, str, opts ); 89 } 90 91 main();