evalpoly.js (2000B)
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 P = [ 36 2.39423741207388267439e3, 37 4.06717289936872725516e2, 38 1.17452732554344059015e1, 39 4.09962519798587023075e-2 40 ]; 41 var Q = [ 42 2.07960819286001865907e3, 43 1.27209271178345121210e3, 44 8.50936160849306532625e1, 45 1.0 46 ]; 47 48 // Header to add to output files: 49 var header = licenseHeader( 'Apache-2.0', 'js', { 50 'year': ( new Date() ).getFullYear(), 51 'copyright': 'The Stdlib Authors' 52 }); 53 header += '\n/* This is a generated file. Do not edit directly. */\n'; 54 55 56 // MAIN // 57 58 /** 59 * Main execution sequence. 60 * 61 * @private 62 */ 63 function main() { 64 var fpath; 65 var opts; 66 var str; 67 68 opts = { 69 'encoding': 'utf8' 70 }; 71 72 fpath = resolve( __dirname, '..', 'lib', 'polyval_p.js' ); 73 str = header + compile( P ); 74 writeFileSync( fpath, str, opts ); 75 76 fpath = resolve( __dirname, '..', 'lib', 'polyval_q.js' ); 77 str = header + compile( Q ); 78 writeFileSync( fpath, str, opts ); 79 } 80 81 main();