Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/22/10 00:44:01 (14 years ago)
Author:
swagner
Message:

Sorted usings and removed unused usings in entire solution (#1094)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.ALGLIB/2.5.0/ALGLIB-2.5.0/laguerre.cs

    r3839 r4068  
    1717*************************************************************************/
    1818
    19 using System;
    2019
    21 namespace alglib
    22 {
    23     public class laguerre
    24     {
    25         /*************************************************************************
    26         Calculation of the value of the Laguerre polynomial.
     20namespace alglib {
     21  public class laguerre {
     22    /*************************************************************************
     23    Calculation of the value of the Laguerre polynomial.
    2724
    28         Parameters:
    29             n   -   degree, n>=0
    30             x   -   argument
     25    Parameters:
     26        n   -   degree, n>=0
     27        x   -   argument
    3128
    32         Result:
    33             the value of the Laguerre polynomial Ln at x
    34         *************************************************************************/
    35         public static double laguerrecalculate(int n,
    36             double x)
    37         {
    38             double result = 0;
    39             double a = 0;
    40             double b = 0;
    41             double i = 0;
     29    Result:
     30        the value of the Laguerre polynomial Ln at x
     31    *************************************************************************/
     32    public static double laguerrecalculate(int n,
     33        double x) {
     34      double result = 0;
     35      double a = 0;
     36      double b = 0;
     37      double i = 0;
    4238
    43             result = 1;
    44             a = 1;
    45             b = 1-x;
    46             if( n==1 )
    47             {
    48                 result = b;
    49             }
    50             i = 2;
    51             while( (double)(i)<=(double)(n) )
    52             {
    53                 result = ((2*i-1-x)*b-(i-1)*a)/i;
    54                 a = b;
    55                 b = result;
    56                 i = i+1;
    57             }
    58             return result;
    59         }
     39      result = 1;
     40      a = 1;
     41      b = 1 - x;
     42      if (n == 1) {
     43        result = b;
     44      }
     45      i = 2;
     46      while ((double)(i) <= (double)(n)) {
     47        result = ((2 * i - 1 - x) * b - (i - 1) * a) / i;
     48        a = b;
     49        b = result;
     50        i = i + 1;
     51      }
     52      return result;
     53    }
    6054
    6155
    62         /*************************************************************************
    63         Summation of Laguerre polynomials using Clenshaw’s recurrence formula.
     56    /*************************************************************************
     57    Summation of Laguerre polynomials using Clenshaw’s recurrence formula.
    6458
    65         This routine calculates c[0]*L0(x) + c[1]*L1(x) + ... + c[N]*LN(x)
     59    This routine calculates c[0]*L0(x) + c[1]*L1(x) + ... + c[N]*LN(x)
    6660
    67         Parameters:
    68             n   -   degree, n>=0
    69             x   -   argument
     61    Parameters:
     62        n   -   degree, n>=0
     63        x   -   argument
    7064
    71         Result:
    72             the value of the Laguerre polynomial at x
    73         *************************************************************************/
    74         public static double laguerresum(ref double[] c,
    75             int n,
    76             double x)
    77         {
    78             double result = 0;
    79             double b1 = 0;
    80             double b2 = 0;
    81             int i = 0;
     65    Result:
     66        the value of the Laguerre polynomial at x
     67    *************************************************************************/
     68    public static double laguerresum(ref double[] c,
     69        int n,
     70        double x) {
     71      double result = 0;
     72      double b1 = 0;
     73      double b2 = 0;
     74      int i = 0;
    8275
    83             b1 = 0;
    84             b2 = 0;
    85             for(i=n; i>=0; i--)
    86             {
    87                 result = (2*i+1-x)*b1/(i+1)-(i+1)*b2/(i+2)+c[i];
    88                 b2 = b1;
    89                 b1 = result;
    90             }
    91             return result;
    92         }
     76      b1 = 0;
     77      b2 = 0;
     78      for (i = n; i >= 0; i--) {
     79        result = (2 * i + 1 - x) * b1 / (i + 1) - (i + 1) * b2 / (i + 2) + c[i];
     80        b2 = b1;
     81        b1 = result;
     82      }
     83      return result;
     84    }
    9385
    9486
    95         /*************************************************************************
    96         Representation of Ln as C[0] + C[1]*X + ... + C[N]*X^N
     87    /*************************************************************************
     88    Representation of Ln as C[0] + C[1]*X + ... + C[N]*X^N
    9789
    98         Input parameters:
    99             N   -   polynomial degree, n>=0
     90    Input parameters:
     91        N   -   polynomial degree, n>=0
    10092
    101         Output parameters:
    102             C   -   coefficients
    103         *************************************************************************/
    104         public static void laguerrecoefficients(int n,
    105             ref double[] c)
    106         {
    107             int i = 0;
     93    Output parameters:
     94        C   -   coefficients
     95    *************************************************************************/
     96    public static void laguerrecoefficients(int n,
     97        ref double[] c) {
     98      int i = 0;
    10899
    109             c = new double[n+1];
    110             c[0] = 1;
    111             for(i=0; i<=n-1; i++)
    112             {
    113                 c[i+1] = -(c[i]*(n-i)/(i+1)/(i+1));
    114             }
    115         }
     100      c = new double[n + 1];
     101      c[0] = 1;
     102      for (i = 0; i <= n - 1; i++) {
     103        c[i + 1] = -(c[i] * (n - i) / (i + 1) / (i + 1));
     104      }
    116105    }
     106  }
    117107}
Note: See TracChangeset for help on using the changeset viewer.