time-to-botec

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

index.js (1890B)


      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 'use strict';
     20 
     21 /**
     22 * Evaluate a rational function.
     23 *
     24 * @module @stdlib/math/base/tools/evalrational
     25 *
     26 * @example
     27 * var evalrational = require( '@stdlib/math/base/tools/evalrational' );
     28 *
     29 * // 2x^3 + 4x^2 - 5x^1 - 6x^0 => degree 4
     30 * var P = [ -6.0, -5.0, 4.0, 2.0 ];
     31 *
     32 * // 0.5x^1 + 3x^0 => degree 2
     33 * var Q = [ 3.0, 0.5, 0.0, 0.0 ]; // zero-padded
     34 *
     35 * var v = evalrational( P, Q, 6.0 ); // => ( -6*6^0 - 5*6^1 + 4*6^2 + 2*6^3 ) / ( 3*6^0 + 0.5*6^1 + 0*6^2 + 0*6^3 ) = (-6-30+144+432)/(3+3)
     36 * // returns 90.0
     37 *
     38 * @example
     39 * var evalrational = require( '@stdlib/math/base/tools/evalrational' );
     40 *
     41 * var P = [ 20.0, 8.0, 3.0 ];
     42 * var Q = [ 10.0, 9.0, 1.0 ];
     43 *
     44 * var rational = evalrational.factory( P, Q );
     45 *
     46 * var v = rational( 10.0 ); // => (20*10^0 + 8*10^1 + 3*10^2) / (10*10^0 + 9*10^1 + 1*10^2) = (20+80+300)/(10+90+100)
     47 * // returns 2.0
     48 *
     49 * v = rational( 2.0 ); // => (20*2^0 + 8*2^1 + 3*2^2) / (10*2^0 + 9*2^1 + 1*2^2) = (20+16+12)/(10+18+4)
     50 * // returns 1.5
     51 */
     52 
     53 // MODULES //
     54 
     55 var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
     56 var evalrational = require( './evalrational.js' );
     57 var factory = require( './factory.js' );
     58 
     59 
     60 // MAIN //
     61 
     62 setReadOnly( evalrational, 'factory', factory );
     63 
     64 
     65 // EXPORTS //
     66 
     67 module.exports = evalrational;