evalpoly.js (4794B)
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 C0 = [ 36 -0.33333333333333333, 37 0.083333333333333333, 38 -0.014814814814814815, 39 0.0011574074074074074, 40 0.0003527336860670194, 41 -0.00017875514403292181, 42 0.39192631785224378e-4, 43 -0.21854485106799922e-5, 44 -0.185406221071516e-5, 45 0.8296711340953086e-6, 46 -0.17665952736826079e-6, 47 0.67078535434014986e-8, 48 0.10261809784240308e-7, 49 -0.43820360184533532e-8, 50 0.91476995822367902e-9 51 ]; 52 var C1 = [ 53 -0.0018518518518518519, 54 -0.0034722222222222222, 55 0.0026455026455026455, 56 -0.00099022633744855967, 57 0.00020576131687242798, 58 -0.40187757201646091e-6, 59 -0.18098550334489978e-4, 60 0.76491609160811101e-5, 61 -0.16120900894563446e-5, 62 0.46471278028074343e-8, 63 0.1378633446915721e-6, 64 -0.5752545603517705e-7, 65 0.11951628599778147e-7 66 ]; 67 var C2 = [ 68 0.0041335978835978836, 69 -0.0026813271604938272, 70 0.00077160493827160494, 71 0.20093878600823045e-5, 72 -0.00010736653226365161, 73 0.52923448829120125e-4, 74 -0.12760635188618728e-4, 75 0.34235787340961381e-7, 76 0.13721957309062933e-5, 77 -0.6298992138380055e-6, 78 0.14280614206064242e-6 79 ]; 80 var C3 = [ 81 0.00064943415637860082, 82 0.00022947209362139918, 83 -0.00046918949439525571, 84 0.00026772063206283885, 85 -0.75618016718839764e-4, 86 -0.23965051138672967e-6, 87 0.11082654115347302e-4, 88 -0.56749528269915966e-5, 89 0.14230900732435884e-5 90 ]; 91 var C4 = [ 92 -0.0008618882909167117, 93 0.00078403922172006663, 94 -0.00029907248030319018, 95 -0.14638452578843418e-5, 96 0.66414982154651222e-4, 97 -0.39683650471794347e-4, 98 0.11375726970678419e-4 99 ]; 100 var C5 = [ 101 -0.00033679855336635815, 102 -0.69728137583658578e-4, 103 0.00027727532449593921, 104 -0.00019932570516188848, 105 0.67977804779372078e-4, 106 0.1419062920643967e-6, 107 -0.13594048189768693e-4, 108 0.80184702563342015e-5, 109 -0.22914811765080952e-5 110 ]; 111 var C6 = [ 112 0.00053130793646399222, 113 -0.00059216643735369388, 114 0.00027087820967180448, 115 0.79023532326603279e-6, 116 -0.81539693675619688e-4, 117 0.56116827531062497e-4, 118 -0.18329116582843376e-4 119 ]; 120 var C7 = [ 121 0.00034436760689237767, 122 0.51717909082605922e-4, 123 -0.00033493161081142236, 124 0.0002812695154763237, 125 -0.00010976582244684731 126 ]; 127 var C8 = [ 128 -0.00065262391859530942, 129 0.00083949872067208728, 130 -0.00043829709854172101 131 ]; 132 133 // Header to add to output files: 134 var header = licenseHeader( 'Apache-2.0', 'js', { 135 'year': ( new Date() ).getFullYear(), 136 'copyright': 'The Stdlib Authors' 137 }); 138 header += '\n/* This is a generated file. Do not edit directly. */\n'; 139 140 141 // MAIN // 142 143 /** 144 * Main execution sequence. 145 * 146 * @private 147 */ 148 function main() { 149 var fpath; 150 var opts; 151 var str; 152 153 opts = { 154 'encoding': 'utf8' 155 }; 156 157 fpath = resolve( __dirname, '..', 'lib', 'polyval_c0.js' ); 158 str = header + compile( C0 ); 159 writeFileSync( fpath, str, opts ); 160 161 fpath = resolve( __dirname, '..', 'lib', 'polyval_c1.js' ); 162 str = header + compile( C1 ); 163 writeFileSync( fpath, str, opts ); 164 165 fpath = resolve( __dirname, '..', 'lib', 'polyval_c2.js' ); 166 str = header + compile( C2 ); 167 writeFileSync( fpath, str, opts ); 168 169 fpath = resolve( __dirname, '..', 'lib', 'polyval_c3.js' ); 170 str = header + compile( C3 ); 171 writeFileSync( fpath, str, opts ); 172 173 fpath = resolve( __dirname, '..', 'lib', 'polyval_c4.js' ); 174 str = header + compile( C4 ); 175 writeFileSync( fpath, str, opts ); 176 177 fpath = resolve( __dirname, '..', 'lib', 'polyval_c5.js' ); 178 str = header + compile( C5 ); 179 writeFileSync( fpath, str, opts ); 180 181 fpath = resolve( __dirname, '..', 'lib', 'polyval_c6.js' ); 182 str = header + compile( C6 ); 183 writeFileSync( fpath, str, opts ); 184 185 fpath = resolve( __dirname, '..', 'lib', 'polyval_c7.js' ); 186 str = header + compile( C7 ); 187 writeFileSync( fpath, str, opts ); 188 189 fpath = resolve( __dirname, '..', 'lib', 'polyval_c8.js' ); 190 str = header + compile( C8 ); 191 writeFileSync( fpath, str, opts ); 192 } 193 194 main();