evalrational.js (4105B)
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 1.0723538782003176831e+11, 37 -8.3716255451260504098e+09, 38 2.0422274357376619816e+08, 39 -2.1287548474401797963e+06, 40 1.0102532948020907590e+04, 41 -1.8402381979244993524e+01 42 ]; 43 44 var Q1 = [ 45 5.8873865738997033405e+11, 46 8.1617187777290363573e+09, 47 5.5662956624278251596e+07, 48 2.3889393209447253406e+05, 49 6.6475986689240190091e+02, 50 1.0 51 ]; 52 53 var P2 = [ 54 -2.2213976967566192242e+13, 55 -5.5107435206722644429e+11, 56 4.3600098638603061642e+10, 57 -6.9590439394619619534e+08, 58 4.6905288611678631510e+06, 59 -1.4566865832663635920e+04, 60 1.7427031242901594547e+01 61 ]; 62 63 var Q2 = [ 64 4.3386146580707264428e+14, 65 5.4266824419412347550e+12, 66 3.4015103849971240096e+10, 67 1.3960202770986831075e+08, 68 4.0669982352539552018e+05, 69 8.3030857612070288823e+02, 70 1.0 71 ]; 72 73 var P3 = [ 74 -8.0728726905150210443e+15, 75 6.7016641869173237784e+14, 76 -1.2829912364088687306e+11, 77 -1.9363051266772083678e+11, 78 2.1958827170518100757e+09, 79 -1.0085539923498211426e+07, 80 2.1363534169313901632e+04, 81 -1.7439661319197499338e+01 82 ]; 83 84 var Q3 = [ 85 3.4563724628846457519e+17, 86 3.9272425569640309819e+15, 87 2.2598377924042897629e+13, 88 8.6926121104209825246e+10, 89 2.4727219475672302327e+08, 90 5.3924739209768057030e+05, 91 8.7903362168128450017e+02, 92 1.0 93 ]; 94 95 var PC = [ 96 2.2779090197304684302e+04, 97 4.1345386639580765797e+04, 98 2.1170523380864944322e+04, 99 3.4806486443249270347e+03, 100 1.5376201909008354296e+02, 101 8.8961548424210455236e-01 102 ]; 103 104 var QC = [ 105 2.2779090197304684318e+04, 106 4.1370412495510416640e+04, 107 2.1215350561880115730e+04, 108 3.5028735138235608207e+03, 109 1.5711159858080893649e+02, 110 1.0 111 ]; 112 113 var PS = [ 114 -8.9226600200800094098e+01, 115 -1.8591953644342993800e+02, 116 -1.1183429920482737611e+02, 117 -2.2300261666214198472e+01, 118 -1.2441026745835638459e+00, 119 -8.8033303048680751817e-03 120 ]; 121 122 var QS = [ 123 5.7105024128512061905e+03, 124 1.1951131543434613647e+04, 125 7.2642780169211018836e+03, 126 1.4887231232283756582e+03, 127 9.0593769594993125859e+01, 128 1.0 129 ]; 130 131 // Header to add to output files: 132 var header = licenseHeader( 'Apache-2.0', 'js', { 133 'year': ( new Date() ).getFullYear(), 134 'copyright': 'The Stdlib Authors' 135 }); 136 header += '\n/* This is a generated file. Do not edit directly. */\n'; 137 138 139 // MAIN // 140 141 /** 142 * Main execution sequence. 143 * 144 * @private 145 */ 146 function main() { 147 var fpath; 148 var opts; 149 var str; 150 151 opts = { 152 'encoding': 'utf8' 153 }; 154 155 fpath = resolve( __dirname, '..', 'lib', 'rational_p1q1.js' ); 156 str = header + compile( P1, Q1 ); 157 writeFileSync( fpath, str, opts ); 158 159 fpath = resolve( __dirname, '..', 'lib', 'rational_p2q2.js' ); 160 str = header + compile( P2, Q2 ); 161 writeFileSync( fpath, str, opts ); 162 163 fpath = resolve( __dirname, '..', 'lib', 'rational_p3q3.js' ); 164 str = header + compile( P3, Q3 ); 165 writeFileSync( fpath, str, opts ); 166 167 fpath = resolve( __dirname, '..', 'lib', 'rational_pcqc.js' ); 168 str = header + compile( PC, QC ); 169 writeFileSync( fpath, str, opts ); 170 171 fpath = resolve( __dirname, '..', 'lib', 'rational_psqs.js' ); 172 str = header + compile( PS, QS ); 173 writeFileSync( fpath, str, opts ); 174 } 175 176 main();