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/sdet.cs

    r3839 r4068  
    1919*************************************************************************/
    2020
    21 using System;
    2221
    23 namespace alglib
    24 {
    25     public class sdet
    26     {
    27         /*************************************************************************
    28         Determinant calculation of the matrix given by LDLT decomposition.
     22namespace alglib {
     23  public class sdet {
     24    /*************************************************************************
     25    Determinant calculation of the matrix given by LDLT decomposition.
    2926
    30         Input parameters:
    31             A       -   LDLT-decomposition of the matrix,
    32                         output of subroutine SMatrixLDLT.
    33             Pivots  -   table of permutations which were made during
    34                         LDLT decomposition, output of subroutine SMatrixLDLT.
    35             N       -   size of matrix A.
    36             IsUpper -   matrix storage format. The value is equal to the input
    37                         parameter of subroutine SMatrixLDLT.
     27    Input parameters:
     28        A       -   LDLT-decomposition of the matrix,
     29                    output of subroutine SMatrixLDLT.
     30        Pivots  -   table of permutations which were made during
     31                    LDLT decomposition, output of subroutine SMatrixLDLT.
     32        N       -   size of matrix A.
     33        IsUpper -   matrix storage format. The value is equal to the input
     34                    parameter of subroutine SMatrixLDLT.
    3835
    39         Result:
    40             matrix determinant.
     36    Result:
     37        matrix determinant.
    4138
    42           -- ALGLIB --
    43              Copyright 2005-2008 by Bochkanov Sergey
    44         *************************************************************************/
    45         public static double smatrixldltdet(ref double[,] a,
    46             ref int[] pivots,
    47             int n,
    48             bool isupper)
    49         {
    50             double result = 0;
    51             int k = 0;
     39      -- ALGLIB --
     40         Copyright 2005-2008 by Bochkanov Sergey
     41    *************************************************************************/
     42    public static double smatrixldltdet(ref double[,] a,
     43        ref int[] pivots,
     44        int n,
     45        bool isupper) {
     46      double result = 0;
     47      int k = 0;
    5248
    53             result = 1;
    54             if( isupper )
    55             {
    56                 k = 0;
    57                 while( k<n )
    58                 {
    59                     if( pivots[k]>=0 )
    60                     {
    61                         result = result*a[k,k];
    62                         k = k+1;
    63                     }
    64                     else
    65                     {
    66                         result = result*(a[k,k]*a[k+1,k+1]-a[k,k+1]*a[k,k+1]);
    67                         k = k+2;
    68                     }
    69                 }
    70             }
    71             else
    72             {
    73                 k = n-1;
    74                 while( k>=0 )
    75                 {
    76                     if( pivots[k]>=0 )
    77                     {
    78                         result = result*a[k,k];
    79                         k = k-1;
    80                     }
    81                     else
    82                     {
    83                         result = result*(a[k-1,k-1]*a[k,k]-a[k,k-1]*a[k,k-1]);
    84                         k = k-2;
    85                     }
    86                 }
    87             }
    88             return result;
     49      result = 1;
     50      if (isupper) {
     51        k = 0;
     52        while (k < n) {
     53          if (pivots[k] >= 0) {
     54            result = result * a[k, k];
     55            k = k + 1;
     56          } else {
     57            result = result * (a[k, k] * a[k + 1, k + 1] - a[k, k + 1] * a[k, k + 1]);
     58            k = k + 2;
     59          }
    8960        }
     61      } else {
     62        k = n - 1;
     63        while (k >= 0) {
     64          if (pivots[k] >= 0) {
     65            result = result * a[k, k];
     66            k = k - 1;
     67          } else {
     68            result = result * (a[k - 1, k - 1] * a[k, k] - a[k, k - 1] * a[k, k - 1]);
     69            k = k - 2;
     70          }
     71        }
     72      }
     73      return result;
     74    }
    9075
    9176
    92         /*************************************************************************
    93         Determinant calculation of the symmetric matrix
     77    /*************************************************************************
     78    Determinant calculation of the symmetric matrix
    9479
    95         Input parameters:
    96             A       -   matrix. Array with elements [0..N-1, 0..N-1].
    97             N       -   size of matrix A.
    98             IsUpper -   if IsUpper = True, then symmetric matrix A is given by its
    99                         upper triangle, and the lower triangle isn’t used by
    100                         subroutine. Similarly, if IsUpper = False, then A is given
    101                         by its lower triangle.
     80    Input parameters:
     81        A       -   matrix. Array with elements [0..N-1, 0..N-1].
     82        N       -   size of matrix A.
     83        IsUpper -   if IsUpper = True, then symmetric matrix A is given by its
     84                    upper triangle, and the lower triangle isn’t used by
     85                    subroutine. Similarly, if IsUpper = False, then A is given
     86                    by its lower triangle.
    10287
    103         Result:
    104             determinant of matrix A.
     88    Result:
     89        determinant of matrix A.
    10590
    106           -- ALGLIB --
    107              Copyright 2005-2008 by Bochkanov Sergey
    108         *************************************************************************/
    109         public static double smatrixdet(double[,] a,
    110             int n,
    111             bool isupper)
    112         {
    113             double result = 0;
    114             int[] pivots = new int[0];
     91      -- ALGLIB --
     92         Copyright 2005-2008 by Bochkanov Sergey
     93    *************************************************************************/
     94    public static double smatrixdet(double[,] a,
     95        int n,
     96        bool isupper) {
     97      double result = 0;
     98      int[] pivots = new int[0];
    11599
    116             a = (double[,])a.Clone();
     100      a = (double[,])a.Clone();
    117101
    118             ldlt.smatrixldlt(ref a, n, isupper, ref pivots);
    119             result = smatrixldltdet(ref a, ref pivots, n, isupper);
    120             return result;
    121         }
     102      ldlt.smatrixldlt(ref a, n, isupper, ref pivots);
     103      result = smatrixldltdet(ref a, ref pivots, n, isupper);
     104      return result;
     105    }
    122106
    123107
    124         public static double determinantldlt(ref double[,] a,
    125             ref int[] pivots,
    126             int n,
    127             bool isupper)
    128         {
    129             double result = 0;
    130             int k = 0;
     108    public static double determinantldlt(ref double[,] a,
     109        ref int[] pivots,
     110        int n,
     111        bool isupper) {
     112      double result = 0;
     113      int k = 0;
    131114
    132             result = 1;
    133             if( isupper )
    134             {
    135                 k = 1;
    136                 while( k<=n )
    137                 {
    138                     if( pivots[k]>0 )
    139                     {
    140                         result = result*a[k,k];
    141                         k = k+1;
    142                     }
    143                     else
    144                     {
    145                         result = result*(a[k,k]*a[k+1,k+1]-a[k,k+1]*a[k,k+1]);
    146                         k = k+2;
    147                     }
    148                 }
    149             }
    150             else
    151             {
    152                 k = n;
    153                 while( k>=1 )
    154                 {
    155                     if( pivots[k]>0 )
    156                     {
    157                         result = result*a[k,k];
    158                         k = k-1;
    159                     }
    160                     else
    161                     {
    162                         result = result*(a[k-1,k-1]*a[k,k]-a[k,k-1]*a[k,k-1]);
    163                         k = k-2;
    164                     }
    165                 }
    166             }
    167             return result;
     115      result = 1;
     116      if (isupper) {
     117        k = 1;
     118        while (k <= n) {
     119          if (pivots[k] > 0) {
     120            result = result * a[k, k];
     121            k = k + 1;
     122          } else {
     123            result = result * (a[k, k] * a[k + 1, k + 1] - a[k, k + 1] * a[k, k + 1]);
     124            k = k + 2;
     125          }
    168126        }
     127      } else {
     128        k = n;
     129        while (k >= 1) {
     130          if (pivots[k] > 0) {
     131            result = result * a[k, k];
     132            k = k - 1;
     133          } else {
     134            result = result * (a[k - 1, k - 1] * a[k, k] - a[k, k - 1] * a[k, k - 1]);
     135            k = k - 2;
     136          }
     137        }
     138      }
     139      return result;
     140    }
    169141
    170142
    171         public static double determinantsymmetric(double[,] a,
    172             int n,
    173             bool isupper)
    174         {
    175             double result = 0;
    176             int[] pivots = new int[0];
     143    public static double determinantsymmetric(double[,] a,
     144        int n,
     145        bool isupper) {
     146      double result = 0;
     147      int[] pivots = new int[0];
    177148
    178             a = (double[,])a.Clone();
     149      a = (double[,])a.Clone();
    179150
    180             ldlt.ldltdecomposition(ref a, n, isupper, ref pivots);
    181             result = determinantldlt(ref a, ref pivots, n, isupper);
    182             return result;
    183         }
     151      ldlt.ldltdecomposition(ref a, n, isupper, ref pivots);
     152      result = determinantldlt(ref a, ref pivots, n, isupper);
     153      return result;
    184154    }
     155  }
    185156}
Note: See TracChangeset for help on using the changeset viewer.