time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

evalpoly.js (2033B)


      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 Lp = [
     36 	6.666666666666735130e-01, // 0x3FE55555 0x55555593
     37 	3.999999999940941908e-01, // 0x3FD99999 0x9997FA04
     38 	2.857142874366239149e-01, // 0x3FD24924 0x94229359
     39 	2.222219843214978396e-01, // 0x3FCC71C5 0x1D8E78AF
     40 	1.818357216161805012e-01, // 0x3FC74664 0x96CB03DE
     41 	1.531383769920937332e-01, // 0x3FC39A09 0xD078C69F
     42 	1.479819860511658591e-01  // 0x3FC2F112 0xDF3E5244
     43 ];
     44 
     45 // Header to add to output files:
     46 var header = licenseHeader( 'Apache-2.0', 'js', {
     47 	'year': ( new Date() ).getFullYear(),
     48 	'copyright': 'The Stdlib Authors'
     49 });
     50 header += '\n/* This is a generated file. Do not edit directly. */\n';
     51 
     52 
     53 // MAIN //
     54 
     55 /**
     56 * Main execution sequence.
     57 *
     58 * @private
     59 */
     60 function main() {
     61 	var fpath;
     62 	var opts;
     63 	var str;
     64 
     65 	opts = {
     66 		'encoding': 'utf8'
     67 	};
     68 
     69 	fpath = resolve( __dirname, '..', 'lib', 'polyval_lp.js' );
     70 	str = header + compile( Lp );
     71 	writeFileSync( fpath, str, opts );
     72 }
     73 
     74 main();