time-to-botec

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

repl.txt (1831B)


      1 
      2 {{alias}}( P, Q, x )
      3     Evaluates a rational function.
      4 
      5     A rational function `f(x)` is defined as
      6 
      7                P(x)
      8         f(x) = ----
      9                Q(x)
     10 
     11     where both `P(x)` and `Q(x)` are polynomials in `x`.
     12 
     13     The coefficients for both `P` and `Q` should be sorted in ascending degree.
     14 
     15     For polynomials of different degree, the coefficient array for the lower
     16     degree polynomial should be padded with zeros.
     17 
     18     Parameters
     19     ----------
     20     P: Array<number>
     21         Numerator polynomial coefficients sorted in ascending degree.
     22 
     23     Q: Array<number>
     24         Denominator polynomial coefficients sorted in ascending degree.
     25 
     26     x: number
     27         Value at which to evaluate the rational function.
     28 
     29     Returns
     30     -------
     31     out: number
     32         Evaluated rational function.
     33 
     34     Examples
     35     --------
     36     // 2x^3 + 4x^2 - 5x^1 - 6x^0
     37     > var P = [ -6.0, -5.0, 4.0, 2.0 ];
     38 
     39     // 0.5x^1 + 3x^0
     40     > var Q = [ 3.0, 0.5, 0.0, 0.0 ]; // zero-padded
     41 
     42     // Evaluate the rational function:
     43     > var v = {{alias}}( P, Q, 6.0 )
     44     90.0
     45 
     46 
     47 {{alias}}.factory( P, Q )
     48     Returns a function for evaluating a rational function.
     49 
     50     Parameters
     51     ----------
     52     P: Array<number>
     53         Numerator polynomial coefficients sorted in ascending degree.
     54 
     55     Q: Array<number>
     56         Denominator polynomial coefficients sorted in ascending degree.
     57 
     58     Returns
     59     -------
     60     fcn: Function
     61         Function for evaluating a rational function.
     62 
     63     Examples
     64     --------
     65     > var P = [ 20.0, 8.0, 3.0 ];
     66     > var Q = [ 10.0, 9.0, 1.0 ];
     67     > var rational = {{alias}}.factory( P, Q );
     68 
     69     // (20*10^0 + 8*10^1 + 3*10^2) / (10*10^0 + 9*10^1 + 1*10^2):
     70     > var v = rational( 10.0 )
     71     2.0
     72 
     73     // (20*2^0 + 8*2^1 + 3*2^2) / (10*2^0 + 9*2^1 + 1*2^2):
     74     > v = rational( 2.0 )
     75     1.5
     76 
     77     See Also
     78     --------
     79