evalrational.js (3753B)
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 P1 = [ 36 4.0535726612579544093e+13, 37 5.4708611716525426053e+12, 38 -3.7595974497819597599e+11, 39 7.2144548214502560419e+09, 40 -5.9157479997408395984e+07, 41 2.2157953222280260820e+05, 42 -3.1714424660046133456e+02 43 ]; 44 45 var Q1 = [ 46 3.0737873921079286084e+14, 47 4.1272286200406461981e+12, 48 2.7800352738690585613e+10, 49 1.2250435122182963220e+08, 50 3.8136470753052572164e+05, 51 8.2079908168393867438e+02, 52 1.0 53 ]; 54 55 var P2 = [ 56 1.1514276357909013326e+19, 57 -5.6808094574724204577e+18, 58 -2.3638408497043134724e+16, 59 4.0686275289804744814e+15, 60 -5.9530713129741981618e+13, 61 3.7453673962438488783e+11, 62 -1.1957961912070617006e+09, 63 1.9153806858264202986e+06, 64 -1.2337180442012953128e+03 65 ]; 66 67 var Q2 = [ 68 5.3321844313316185697e+20, 69 5.6968198822857178911e+18, 70 3.0837179548112881950e+16, 71 1.1187010065856971027e+14, 72 3.0221766852960403645e+11, 73 6.3550318087088919566e+08, 74 1.0453748201934079734e+06, 75 1.2855164849321609336e+03, 76 1.0 77 ]; 78 79 var PC = [ 80 -4.4357578167941278571e+06, 81 -9.9422465050776411957e+06, 82 -6.6033732483649391093e+06, 83 -1.5235293511811373833e+06, 84 -1.0982405543459346727e+05, 85 -1.6116166443246101165e+03, 86 0.0 87 ]; 88 89 var QC = [ 90 -4.4357578167941278568e+06, 91 -9.9341243899345856590e+06, 92 -6.5853394797230870728e+06, 93 -1.5118095066341608816e+06, 94 -1.0726385991103820119e+05, 95 -1.4550094401904961825e+03, 96 1.0 97 ]; 98 99 var PS = [ 100 3.3220913409857223519e+04, 101 8.5145160675335701966e+04, 102 6.6178836581270835179e+04, 103 1.8494262873223866797e+04, 104 1.7063754290207680021e+03, 105 3.5265133846636032186e+01, 106 0.0 107 ]; 108 109 var QS = [ 110 7.0871281941028743574e+05, 111 1.8194580422439972989e+06, 112 1.4194606696037208929e+06, 113 4.0029443582266975117e+05, 114 3.7890229745772202641e+04, 115 8.6383677696049909675e+02, 116 1.0 117 ]; 118 119 // Header to add to output files: 120 var header = licenseHeader( 'Apache-2.0', 'js', { 121 'year': ( new Date() ).getFullYear(), 122 'copyright': 'The Stdlib Authors' 123 }); 124 header += '\n/* This is a generated file. Do not edit directly. */\n'; 125 126 127 // MAIN // 128 129 /** 130 * Main execution sequence. 131 * 132 * @private 133 */ 134 function main() { 135 var fpath; 136 var opts; 137 var str; 138 139 opts = { 140 'encoding': 'utf8' 141 }; 142 143 fpath = resolve( __dirname, '..', 'lib', 'rational_p1q1.js' ); 144 str = header + compile( P1, Q1 ); 145 writeFileSync( fpath, str, opts ); 146 147 fpath = resolve( __dirname, '..', 'lib', 'rational_p2q2.js' ); 148 str = header + compile( P2, Q2 ); 149 writeFileSync( fpath, str, opts ); 150 151 fpath = resolve( __dirname, '..', 'lib', 'rational_pcqc.js' ); 152 str = header + compile( PC, QC ); 153 writeFileSync( fpath, str, opts ); 154 155 fpath = resolve( __dirname, '..', 'lib', 'rational_psqs.js' ); 156 str = header + compile( PS, QS ); 157 writeFileSync( fpath, str, opts ); 158 } 159 160 main();