evalpoly.js (1947B)
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 // Scaled polynomial coefficients ordered in ascending degree... 35 var Q = [ 36 -3.33333333333331316428e-02, // 0xBFA11111 0x111110F4 37 1.58730158725481460165e-03, // 0x3F5A01A0 0x19FE5585 38 -7.93650757867487942473e-05, // 0xBF14CE19 0x9EAADBB7 39 4.00821782732936239552e-06, // 0x3ED0CFCA 0x86E65239 40 -2.01099218183624371326e-07 // 0xBE8AFDB7 0x6E09C32D 41 ]; 42 43 // Header to add to output files: 44 var header = licenseHeader( 'Apache-2.0', 'js', { 45 'year': ( new Date() ).getFullYear(), 46 'copyright': 'The Stdlib Authors' 47 }); 48 header += '\n/* This is a generated file. Do not edit directly. */\n'; 49 50 51 // MAIN // 52 53 /** 54 * Main execution sequence. 55 * 56 * @private 57 */ 58 function main() { 59 var fpath; 60 var opts; 61 var str; 62 63 opts = { 64 'encoding': 'utf8' 65 }; 66 67 fpath = resolve( __dirname, '..', 'lib', 'polyval_q.js' ); 68 str = header + compile( Q ); 69 writeFileSync( fpath, str, opts ); 70 } 71 72 main();