time-to-botec

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

evalrational.js (4796B)


      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 AK0 = [
     36 	-3.333333333438e-1,
     37 	-2.070740359969e-1,
     38 	-5.041806657154e-2,
     39 	-4.923635739372e-3,
     40 	-4.293658292782e-5
     41 ];
     42 var BK0 = [
     43 	1.000000000000e+0,
     44 	7.045554412463e-1,
     45 	2.118190062224e-1,
     46 	3.048648397436e-2,
     47 	1.605037988091e-3
     48 ];
     49 
     50 var AK1 = [
     51 	-1.72847633523e-2,
     52 	-1.59372646475e-2,
     53 	-4.64910887221e-3,
     54 	-6.06834887760e-4,
     55 	-6.14830384279e-6
     56 ];
     57 var BK1 = [
     58 	1.00000000000e+0,
     59 	7.64050615669e-1,
     60 	2.97143406325e-1,
     61 	5.79490176079e-2,
     62 	5.74558524851e-3
     63 ];
     64 
     65 var AK2 = [
     66 	-1.72839517431e-2,
     67 	-1.46362417966e-2,
     68 	-3.57406772616e-3,
     69 	-3.91032032692e-4,
     70 	2.49634036069e-6
     71 ];
     72 var BK2 = [
     73 	1.00000000000e+0,
     74 	6.90560400696e-1,
     75 	2.49962384741e-1,
     76 	4.43843438769e-2,
     77 	4.24073217211e-3
     78 ];
     79 
     80 var AK3 = [
     81 	9.99944669480e-1,
     82 	1.04649839762e+2,
     83 	8.57204033806e+2,
     84 	7.31901559577e+2,
     85 	4.55174411671e+1
     86 ];
     87 var BK3 = [
     88 	1.00000000000e+0,
     89 	1.04526456943e+2,
     90 	8.23313447808e+2,
     91 	3.11993802124e+3,
     92 	3.97003311219e+3
     93 ];
     94 
     95 var AK4 = [
     96 	4.95346498136e-2,
     97 	2.99521337141e-2,
     98 	6.88296911516e-3,
     99 	5.12634846317e-4,
    100 	-2.01411722031e-5
    101 ];
    102 var BK4 = [
    103 	1.00000000000e+0,
    104 	7.59803615283e-1,
    105 	2.61547111595e-1,
    106 	4.64854522477e-2,
    107 	4.03751193496e-3
    108 ];
    109 
    110 var AK5 = [
    111 	4.52313583942e-3,
    112 	1.20744920113e-3,
    113 	-7.89724156582e-5,
    114 	-5.04476066942e-5,
    115 	-5.35770949796e-6
    116 ];
    117 var BK5 = [
    118 	1.00000000000e+0,
    119 	9.12203410349e-1,
    120 	4.05368773071e-1,
    121 	9.01638932349e-2,
    122 	9.48935714996e-3
    123 ];
    124 
    125 var AK6 = [
    126 	4.39937562904e-3,
    127 	4.87225670639e-4,
    128 	-1.28470657374e-4,
    129 	5.29110969589e-6,
    130 	1.57166771750e-7
    131 ];
    132 var BK6 = [
    133 	1.00000000000e+0,
    134 	7.94435257415e-1,
    135 	3.33094721709e-1,
    136 	7.03527806143e-2,
    137 	8.06110846078e-3
    138 ];
    139 
    140 var AK7 = [
    141 	-1.14811912320e-3,
    142 	-1.12850923276e-1,
    143 	1.51623048511e+0,
    144 	-2.18472031183e-1,
    145 	7.30002451555e-2
    146 ];
    147 var BK7 = [
    148 	1.00000000000e+0,
    149 	1.42482206905e+1,
    150 	6.97360396285e+1,
    151 	2.18938950816e+2,
    152 	2.77067027185e+2
    153 ];
    154 
    155 var AK8 = [
    156 	-1.45727889667e-4,
    157 	-2.90806748131e-1,
    158 	-1.33085045450e+1,
    159 	1.99722374056e+2,
    160 	-1.14311378756e+1
    161 ];
    162 var BK8 = [
    163 	1.00000000000e+0,
    164 	1.39612587808e+2,
    165 	2.18901116348e+3,
    166 	7.11524019009e+3,
    167 	4.55746081453e+4
    168 ];
    169 
    170 // Header to add to output files:
    171 var header = licenseHeader( 'Apache-2.0', 'js', {
    172 	'year': ( new Date() ).getFullYear(),
    173 	'copyright': 'The Stdlib Authors'
    174 });
    175 header += '\n/* This is a generated file. Do not edit directly. */\n';
    176 
    177 
    178 // MAIN //
    179 
    180 /**
    181 * Main execution sequence.
    182 *
    183 * @private
    184 */
    185 function main() {
    186 	var fpath;
    187 	var opts;
    188 	var str;
    189 
    190 	opts = {
    191 		'encoding': 'utf8'
    192 	};
    193 
    194 	fpath = resolve( __dirname, '..', 'lib', 'rational_ak0bk0.js' );
    195 	str = header + compile( AK0, BK0 );
    196 	writeFileSync( fpath, str, opts );
    197 
    198 	fpath = resolve( __dirname, '..', 'lib', 'rational_ak1bk1.js' );
    199 	str = header + compile( AK1, BK1 );
    200 	writeFileSync( fpath, str, opts );
    201 
    202 	fpath = resolve( __dirname, '..', 'lib', 'rational_ak2bk2.js' );
    203 	str = header + compile( AK2, BK2 );
    204 	writeFileSync( fpath, str, opts );
    205 
    206 	fpath = resolve( __dirname, '..', 'lib', 'rational_ak3bk3.js' );
    207 	str = header + compile( AK3, BK3 );
    208 	writeFileSync( fpath, str, opts );
    209 
    210 	fpath = resolve( __dirname, '..', 'lib', 'rational_ak4bk4.js' );
    211 	str = header + compile( AK4, BK4 );
    212 	writeFileSync( fpath, str, opts );
    213 
    214 	fpath = resolve( __dirname, '..', 'lib', 'rational_ak5bk5.js' );
    215 	str = header + compile( AK5, BK5 );
    216 	writeFileSync( fpath, str, opts );
    217 
    218 	fpath = resolve( __dirname, '..', 'lib', 'rational_ak6bk6.js' );
    219 	str = header + compile( AK6, BK6 );
    220 	writeFileSync( fpath, str, opts );
    221 
    222 	fpath = resolve( __dirname, '..', 'lib', 'rational_ak7bk7.js' );
    223 	str = header + compile( AK7, BK7 );
    224 	writeFileSync( fpath, str, opts );
    225 
    226 	fpath = resolve( __dirname, '..', 'lib', 'rational_ak8bk8.js' );
    227 	str = header + compile( AK8, BK8 );
    228 	writeFileSync( fpath, str, opts );
    229 }
    230 
    231 main();