time-to-botec

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

evalrational.js (3185B)


      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 	-0.180355685678449379109e-1,
     37 	0.25126649619989678683e-1,
     38 	0.494103151567532234274e-1,
     39 	0.172491608709613993966e-1,
     40 	-0.259453563205438108893e-3,
     41 	-0.541009869215204396339e-3,
     42 	-0.324588649825948492091e-4,
     43 	0.0
     44 ];
     45 var Q1 = [
     46 	0.1e1,
     47 	0.196202987197795200688e1,
     48 	0.148019669424231326694e1,
     49 	0.541391432071720958364e0,
     50 	0.988504251128010129477e-1,
     51 	0.82130967464889339326e-2,
     52 	0.224936291922115757597e-3,
     53 	-0.223352763208617092964e-6
     54 ];
     55 
     56 var P2 = [
     57 	0.490622454069039543534e-1,
     58 	-0.969117530159521214579e-1,
     59 	-0.414983358359495381969e0,
     60 	-0.406567124211938417342e0,
     61 	-0.158413586390692192217e0,
     62 	-0.240149820648571559892e-1,
     63 	-0.100346687696279557415e-2
     64 ];
     65 var Q2 = [
     66 	0.1e1,
     67 	0.302349829846463038743e1,
     68 	0.348739585360723852576e1,
     69 	0.191415588274426679201e1,
     70 	0.507137738614363510846e0,
     71 	0.577039722690451849648e-1,
     72 	0.195768102601107189171e-2
     73 ];
     74 
     75 var P3 = [
     76 	-0.292329721830270012337e-1,
     77 	0.144216267757192309184e0,
     78 	-0.142440390738631274135e0,
     79 	0.542809694055053558157e-1,
     80 	-0.850535976868336437746e-2,
     81 	0.431171342679297331241e-3,
     82 	0.0
     83 ];
     84 var Q3 = [
     85 	0.1e1,
     86 	-0.150169356054485044494e1,
     87 	0.846973248876495016101e0,
     88 	-0.220095151814995745555e0,
     89 	0.25582797155975869989e-1,
     90 	-0.100666795539143372762e-2,
     91 	-0.827193521891290553639e-6
     92 ];
     93 
     94 // Header to add to output files:
     95 var header = licenseHeader( 'Apache-2.0', 'js', {
     96 	'year': ( new Date() ).getFullYear(),
     97 	'copyright': 'The Stdlib Authors'
     98 });
     99 header += '\n/* This is a generated file. Do not edit directly. */\n';
    100 
    101 
    102 // MAIN //
    103 
    104 /**
    105 * Main execution sequence.
    106 *
    107 * @private
    108 */
    109 function main() {
    110 	var fpath;
    111 	var opts;
    112 	var str;
    113 
    114 	opts = {
    115 		'encoding': 'utf8'
    116 	};
    117 
    118 	fpath = resolve( __dirname, '..', 'lib', 'rational_p1q1.js' );
    119 	str = header + compile( P1, Q1 );
    120 	writeFileSync( fpath, str, opts );
    121 
    122 	fpath = resolve( __dirname, '..', 'lib', 'rational_p2q2.js' );
    123 	str = header + compile( P2, Q2 );
    124 	writeFileSync( fpath, str, opts );
    125 
    126 	fpath = resolve( __dirname, '..', 'lib', 'rational_p3q3.js' );
    127 	str = header + compile( P3, Q3 );
    128 	writeFileSync( fpath, str, opts );
    129 }
    130 
    131 main();