evalrational.js (6593B)
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 P12 = [ 36 -0.999999999999999082554457936871832533, 37 -4.71237311120865266379041700054847734, 38 -7.94125711970499027763789342500817316, 39 -5.74657746697664735258222071695644535, 40 -0.404213349456398905981223965160595687, 41 2.47877781178642876561595890095758896, 42 2.07714151702455125992166949812126433, 43 0.858877899162360138844032265418028567, 44 0.20499222604410032375789018837922397, 45 0.0272103140348194747360175268778415049, 46 0.0015764849020876949848954081173520686 47 ]; 48 var Q12 = [ 49 1.0, 50 4.71237311120863419878375031457715223, 51 9.58619118655339853449127952145877467, 52 11.0940067269829372437561421279054968, 53 8.09075424749327792073276309969037885, 54 3.87705890159891405185343806884451286, 55 1.22758678701914477836330837816976782, 56 0.249092040606385004109672077814668716, 57 0.0295750413900655597027079600025569048, 58 0.00157648490200498142247694709728858139, 59 0.161264050344059471721062360645432809e-14 60 ]; 61 var P24 = [ 62 -2.55843734739907925764326773972215085, 63 -12.2830208240542011967952466273455887, 64 -23.9195022162767993526575786066414403, 65 -24.9256431504823483094158828285470862, 66 -14.7979122765478779075108064826412285, 67 -4.46654453928610666393276765059122272, 68 -0.0191439033405649675717082465687845002, 69 0.515412052554351265708917209749037352, 70 0.195378348786064304378247325360320038, 71 0.0334761282624174313035014426794245393, 72 0.002373665205942206348500250056602687, 73 0 74 ]; 75 var Q24 = [ 76 1.0, 77 4.80098558454419907830670928248659245, 78 9.99220727843170133895059300223445265, 79 11.8896146167631330735386697123464976, 80 8.96613256683809091593793565879092581, 81 4.47254136149624110878909334574485751, 82 1.48600982028196527372434773913633152, 83 0.319570735766764237068541501137990078, 84 0.0407358345787680953107374215319322066, 85 0.00237366520593271641375755486420859837, 86 0.239554887903526152679337256236302116e-15, 87 -0.294749244740618656265237072002026314e-17 88 ]; 89 var P48 = [ 90 0.166626112697021464248967707021688845e-16, 91 0.499999999999997739552090249208808197, 92 6.40270945019053817915772473771553187, 93 41.3833374155000608013677627389343329, 94 166.803341854562809335667241074035245, 95 453.39964786925369319960722793414521, 96 851.153712317697055375935433362983944, 97 1097.70657567285059133109286478004458, 98 938.431232478455316020076349367632922, 99 487.268001604651932322080970189930074, 100 119.953445242335730062471193124820659 101 ]; 102 var Q48 = [ 103 1.0, 104 12.4720855670474488978638945855932398, 105 78.6093129753298570701376952709727391, 106 307.470246050318322489781182863190127, 107 805.140686101151538537565264188630079, 108 1439.12019760292146454787601409644413, 109 1735.6105285756048831268586001383127, 110 1348.32500712856328019355198611280536, 111 607.225985860570846699704222144650563, 112 119.952317857277045332558673164517227, 113 0.000140165918355036060868680809129436084 114 ]; 115 var P816 = [ 116 -0.184828315274146610610872315609837439e-19, 117 0.500000000000000004122475157735807738, 118 3.02533865247313349284875558880415875, 119 13.5995927517457371243039532492642734, 120 35.3132224283087906757037999452941588, 121 67.1639424550714159157603179911505619, 122 83.5767733658513967581959839367419891, 123 71.073491212235705900866411319363501, 124 35.8621515614725564575893663483998663, 125 8.72152231639983491987779743154333318 126 ]; 127 var Q816 = [ 128 1.0, 129 5.71734397161293452310624822415866372, 130 25.293404179620438179337103263274815, 131 62.2619767967468199111077640625328469, 132 113.955048909238993473389714972250235, 133 130.807138328938966981862203944329408, 134 102.423146902337654110717764213057753, 135 44.0424772805245202514468199602123565, 136 8.89898032477904072082994913461386099, 137 -0.0296627336872039988632793863671456398 138 ]; 139 var P16INF = [ 140 0.0, 141 0.500000000000000000000000000000087317, 142 0.345625669885456215194494735902663968, 143 9.62895499360842232127552650044647769, 144 3.5936085382439026269301003761320812, 145 49.459599118438883265036646019410669, 146 7.77519237321893917784735690560496607, 147 74.4536074488178075948642351179304121, 148 2.75209340397069050436806159297952699, 149 23.9292359711471667884504840186561598, 150 0 151 ]; 152 var Q16INF = [ 153 1.0, 154 0.357918006437579097055656138920742037, 155 19.1386039850709849435325005484512944, 156 0.874349081464143606016221431763364517, 157 98.6516097434855572678195488061432509, 158 -16.1051972833382893468655223662534306, 159 154.316860216253720989145047141653727, 160 -40.2026880424378986053105969312264534, 161 60.1679136674264778074736441126810223, 162 -13.3414844622256422644504472438320114, 163 2.53795636200649908779512969030363442 164 ]; 165 166 // Header to add to output files: 167 var header = licenseHeader( 'Apache-2.0', 'js', { 168 'year': ( new Date() ).getFullYear(), 169 'copyright': 'The Stdlib Authors' 170 }); 171 header += '\n/* This is a generated file. Do not edit directly. */\n'; 172 173 174 // MAIN // 175 176 /** 177 * Main execution sequence. 178 * 179 * @private 180 */ 181 function main() { 182 var fpath; 183 var opts; 184 var str; 185 186 opts = { 187 'encoding': 'utf8' 188 }; 189 190 fpath = resolve( __dirname, '..', 'lib', 'rational_p12q12.js' ); 191 str = header + compile( P12, Q12 ); 192 writeFileSync( fpath, str, opts ); 193 194 fpath = resolve( __dirname, '..', 'lib', 'rational_p24q24.js' ); 195 str = header + compile( P24, Q24 ); 196 writeFileSync( fpath, str, opts ); 197 198 fpath = resolve( __dirname, '..', 'lib', 'rational_p48q48.js' ); 199 str = header + compile( P48, Q48 ); 200 writeFileSync( fpath, str, opts ); 201 202 fpath = resolve( __dirname, '..', 'lib', 'rational_p816q816.js' ); 203 str = header + compile( P816, Q816 ); 204 writeFileSync( fpath, str, opts ); 205 206 fpath = resolve( __dirname, '..', 'lib', 'rational_p16infq16inf.js' ); 207 str = header + compile( P16INF, Q16INF ); 208 writeFileSync( fpath, str, opts ); 209 } 210 211 main();