time-to-botec

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

evalrational.js (3604B)


      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 	-4.1298668500990866786e+11,
     37 	2.7282507878605942706e+10,
     38 	-6.2140700423540120665e+08,
     39 	6.6302997904833794242e+06,
     40 	-3.6629814655107086448e+04,
     41 	1.0344222815443188943e+02,
     42 	-1.2117036164593528341e-01
     43 ];
     44 
     45 var Q1 = [
     46 	2.3883787996332290397e+12,
     47 	2.6328198300859648632e+10,
     48 	1.3985097372263433271e+08,
     49 	4.5612696224219938200e+05,
     50 	9.3614022392337710626e+02,
     51 	1.0,
     52 	0.0
     53 ];
     54 
     55 var P2 = [
     56 	-1.8319397969392084011e+03,
     57 	-1.2254078161378989535e+04,
     58 	-7.2879702464464618998e+03,
     59 	1.0341910641583726701e+04,
     60 	1.1725046279757103576e+04,
     61 	4.4176707025325087628e+03,
     62 	7.4321196680624245801e+02,
     63 	4.8591703355916499363e+01
     64 ];
     65 
     66 var Q2 = [
     67 	-3.5783478026152301072e+05,
     68 	2.4599102262586308984e+05,
     69 	-8.4055062591169562211e+04,
     70 	1.8680990008359188352e+04,
     71 	-2.9458766545509337327e+03,
     72 	3.3307310774649071172e+02,
     73 	-2.5258076240801555057e+01,
     74 	1.0
     75 ];
     76 
     77 var PC = [
     78 	2.2779090197304684302e+04,
     79 	4.1345386639580765797e+04,
     80 	2.1170523380864944322e+04,
     81 	3.4806486443249270347e+03,
     82 	1.5376201909008354296e+02,
     83 	8.8961548424210455236e-01
     84 ];
     85 
     86 var QC = [
     87 	2.2779090197304684318e+04,
     88 	4.1370412495510416640e+04,
     89 	2.1215350561880115730e+04,
     90 	3.5028735138235608207e+03,
     91 	1.5711159858080893649e+02,
     92 	1.0
     93 ];
     94 
     95 var PS = [
     96 	-8.9226600200800094098e+01,
     97 	-1.8591953644342993800e+02,
     98 	-1.1183429920482737611e+02,
     99 	-2.2300261666214198472e+01,
    100 	-1.2441026745835638459e+00,
    101 	-8.8033303048680751817e-03
    102 ];
    103 
    104 var QS = [
    105 	5.7105024128512061905e+03,
    106 	1.1951131543434613647e+04,
    107 	7.2642780169211018836e+03,
    108 	1.4887231232283756582e+03,
    109 	9.0593769594993125859e+01,
    110 	1.0
    111 ];
    112 
    113 // Header to add to output files:
    114 var header = licenseHeader( 'Apache-2.0', 'js', {
    115 	'year': ( new Date() ).getFullYear(),
    116 	'copyright': 'The Stdlib Authors'
    117 });
    118 header += '\n/* This is a generated file. Do not edit directly. */\n';
    119 
    120 
    121 // MAIN //
    122 
    123 /**
    124 * Main execution sequence.
    125 *
    126 * @private
    127 */
    128 function main() {
    129 	var fpath;
    130 	var opts;
    131 	var str;
    132 
    133 	opts = {
    134 		'encoding': 'utf8'
    135 	};
    136 
    137 	fpath = resolve( __dirname, '..', 'lib', 'rational_p1q1.js' );
    138 	str = header + compile( P1, Q1 );
    139 	writeFileSync( fpath, str, opts );
    140 
    141 	fpath = resolve( __dirname, '..', 'lib', 'rational_p2q2.js' );
    142 	str = header + compile( P2, Q2 );
    143 	writeFileSync( fpath, str, opts );
    144 
    145 	fpath = resolve( __dirname, '..', 'lib', 'rational_pcqc.js' );
    146 	str = header + compile( PC, QC );
    147 	writeFileSync( fpath, str, opts );
    148 
    149 	fpath = resolve( __dirname, '..', 'lib', 'rational_psqs.js' );
    150 	str = header + compile( PS, QS );
    151 	writeFileSync( fpath, str, opts );
    152 }
    153 
    154 main();