time-to-botec

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

evalpoly.js (5833B)


      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 SN = [
     36 	1.00000000000000000302e0,
     37 	-4.13470316229406538752e-2,
     38 	9.76945438170435310816e-4,
     39 	-9.75759303843632795789e-6,
     40 	4.62591714427012837309e-8,
     41 	-8.39167827910303881427e-11
     42 ];
     43 var SD = [
     44 	9.99999999999999996984e-1,
     45 	1.42085239326149893930e-2,
     46 	9.96412122043875552487e-5,
     47 	4.41827842801218905784e-7,
     48 	1.27997891179943299903e-9,
     49 	2.03269266195951942049e-12
     50 ];
     51 var CN = [
     52 	-1.00000000000000000080e0,
     53 	2.89159652607555242092e-2,
     54 	-4.74007206873407909465e-4,
     55 	3.59325051419993077021e-6,
     56 	-1.35249504915790756375e-8,
     57 	2.02524002389102268789e-11
     58 ];
     59 var CD = [
     60 	4.00000000000000000080e0,
     61 	5.10028056236446052392e-2,
     62 	3.17442024775032769882e-4,
     63 	1.23210355685883423679e-6,
     64 	3.06780997581887812692e-9,
     65 	4.07746040061880559506e-12
     66 ];
     67 var FN4 = [
     68 	5.48900223421373614008e-7,
     69 	1.08936580650328664411e-4,
     70 	6.81020132472518137426e-3,
     71 	1.67006611831323023771e-1,
     72 	1.62083287701538329132e0,
     73 	5.45937717161812843388e0,
     74 	4.23612862892216586994e0
     75 ];
     76 var FD4 = [
     77 	5.48900252756255700982e-7,
     78 	1.10034357153915731354e-4,
     79 	7.01710668322789753610e-3,
     80 	1.78792052963149907262e-1,
     81 	1.86792257950184183883e0,
     82 	7.30828822505564552187e0,
     83 	8.16496634205391016773e0,
     84 	1.00000000000000000000e0
     85 ];
     86 var FN8 = [
     87 	9.70507110881952024631e-14,
     88 	9.41779576128512936592e-11,
     89 	3.20092790091004902806e-8,
     90 	4.86215430826454749482e-6,
     91 	3.49556442447859055605e-4,
     92 	1.16064229408124407915e-2,
     93 	1.60300158222319456320e-1,
     94 	7.13715274100146711374e-1,
     95 	4.55880873470465315206e-1
     96 ];
     97 var FD8 = [
     98 	9.70507110881952025725e-14,
     99 	9.43720590350276732376e-11,
    100 	3.21956939101046018377e-8,
    101 	4.92435064317881464393e-6,
    102 	3.58696481881851580297e-4,
    103 	1.22253594771971293032e-2,
    104 	1.78685545332074536321e-1,
    105 	9.17463611873684053703e-1,
    106 	1.00000000000000000000e0
    107 ];
    108 var GN4 = [
    109 	7.82579040744090311069e-9,
    110 	1.97963874140963632189e-6,
    111 	1.61999794598934024525e-4,
    112 	5.38868681462177273157e-3,
    113 	7.48527737628469092119e-2,
    114 	3.97180296392337498885e-1,
    115 	6.11379109952219284151e-1,
    116 	8.71001698973114191777e-2
    117 ];
    118 var GD4 = [
    119 	7.82579218933534490868e-9,
    120 	2.02659182086343991969e-6,
    121 	1.73221081474177119497e-4,
    122 	6.22396345441768420760e-3,
    123 	9.88771761277688796203e-2,
    124 	6.66296701268987968381e-1,
    125 	1.64402202413355338886e0,
    126 	1.00000000000000000000e0
    127 ];
    128 var GN8 = [
    129 	3.14040098946363334640e-15,
    130 	3.85945925430276600453e-12,
    131 	1.70404452782044526189e-9,
    132 	3.47131167084116673800e-7,
    133 	3.48941165502279436777e-5,
    134 	1.71718239052347903558e-3,
    135 	3.84878767649974295920e-2,
    136 	3.30410979305632063225e-1,
    137 	6.97359953443276214934e-1
    138 ];
    139 var GD8 = [
    140 	3.14040098946363335242e-15,
    141 	3.87830166023954706752e-12,
    142 	1.72693748966316146736e-9,
    143 	3.57043223443740838771e-7,
    144 	3.68475504442561108162e-5,
    145 	1.90284426674399523638e-3,
    146 	4.67913194259625806320e-2,
    147 	4.87852258695304967486e-1,
    148 	1.68548898811011640017e0,
    149 	1.00000000000000000000e0
    150 ];
    151 
    152 // Header to add to output files:
    153 var header = licenseHeader( 'Apache-2.0', 'js', {
    154 	'year': ( new Date() ).getFullYear(),
    155 	'copyright': 'The Stdlib Authors'
    156 });
    157 header += '\n/* This is a generated file. Do not edit directly. */\n';
    158 
    159 
    160 // MAIN //
    161 
    162 /**
    163 * Main execution sequence.
    164 *
    165 * @private
    166 */
    167 function main() {
    168 	var fpath;
    169 	var opts;
    170 	var str;
    171 
    172 	opts = {
    173 		'encoding': 'utf8'
    174 	};
    175 
    176 	fpath = resolve( __dirname, '..', 'lib', 'polyval_sn.js' );
    177 	str = header + compile( SN );
    178 	writeFileSync( fpath, str, opts );
    179 
    180 	fpath = resolve( __dirname, '..', 'lib', 'polyval_sd.js' );
    181 	str = header + compile( SD );
    182 	writeFileSync( fpath, str, opts );
    183 
    184 	fpath = resolve( __dirname, '..', 'lib', 'polyval_cn.js' );
    185 	str = header + compile( CN );
    186 	writeFileSync( fpath, str, opts );
    187 
    188 	fpath = resolve( __dirname, '..', 'lib', 'polyval_cd.js' );
    189 	str = header + compile( CD );
    190 	writeFileSync( fpath, str, opts );
    191 
    192 	fpath = resolve( __dirname, '..', 'lib', 'polyval_fn4.js' );
    193 	str = header + compile( FN4 );
    194 	writeFileSync( fpath, str, opts );
    195 
    196 	fpath = resolve( __dirname, '..', 'lib', 'polyval_fd4.js' );
    197 	str = header + compile( FD4 );
    198 	writeFileSync( fpath, str, opts );
    199 
    200 	fpath = resolve( __dirname, '..', 'lib', 'polyval_fn8.js' );
    201 	str = header + compile( FN8 );
    202 	writeFileSync( fpath, str, opts );
    203 
    204 	fpath = resolve( __dirname, '..', 'lib', 'polyval_fd8.js' );
    205 	str = header + compile( FD8 );
    206 	writeFileSync( fpath, str, opts );
    207 
    208 	fpath = resolve( __dirname, '..', 'lib', 'polyval_gn4.js' );
    209 	str = header + compile( GN4 );
    210 	writeFileSync( fpath, str, opts );
    211 
    212 	fpath = resolve( __dirname, '..', 'lib', 'polyval_gd4.js' );
    213 	str = header + compile( GD4 );
    214 	writeFileSync( fpath, str, opts );
    215 
    216 	fpath = resolve( __dirname, '..', 'lib', 'polyval_gn8.js' );
    217 	str = header + compile( GN8 );
    218 	writeFileSync( fpath, str, opts );
    219 
    220 	fpath = resolve( __dirname, '..', 'lib', 'polyval_gd8.js' );
    221 	str = header + compile( GD8 );
    222 	writeFileSync( fpath, str, opts );
    223 }
    224 
    225 main();