evalrational.js (1973B)
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 P = [ 36 0.25479851061131551, 37 -0.32555031186804491, 38 -0.65031853770896507, 39 -0.28919126444774784, 40 -0.045251321448739056, 41 -0.0020713321167745952, 42 0 43 ]; 44 var Q = [ 45 1.0, 46 2.0767117023730469, 47 1.4606242909763515, 48 0.43593529692665969, 49 0.054151797245674225, 50 0.0021284987017821144, 51 -0.55789841321675513e-6 52 ]; 53 54 // Header to add to output files: 55 var header = licenseHeader( 'Apache-2.0', 'js', { 56 'year': ( new Date() ).getFullYear(), 57 'copyright': 'The Stdlib Authors' 58 }); 59 header += '\n/* This is a generated file. Do not edit directly. */\n'; 60 61 62 // MAIN // 63 64 /** 65 * Main execution sequence. 66 * 67 * @private 68 */ 69 function main() { 70 var fpath; 71 var opts; 72 var str; 73 74 opts = { 75 'encoding': 'utf8' 76 }; 77 78 fpath = resolve( __dirname, '..', 'lib', 'rational_pq.js' ); 79 str = header + compile( P, Q ); 80 writeFileSync( fpath, str, opts ); 81 } 82 83 main();