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

    r3839 r4068  
    2525*************************************************************************/
    2626
    27 using System;
    2827
    29 namespace alglib
    30 {
    31     public class schur
    32     {
    33         /*************************************************************************
    34         Subroutine performing the Schur decomposition of a general matrix by using
    35         the QR algorithm with multiple shifts.
     28namespace alglib {
     29  public class schur {
     30    /*************************************************************************
     31    Subroutine performing the Schur decomposition of a general matrix by using
     32    the QR algorithm with multiple shifts.
    3633
    37         The source matrix A is represented as S'*A*S = T, where S is an orthogonal
    38         matrix (Schur vectors), T - upper quasi-triangular matrix (with blocks of
    39         sizes 1x1 and 2x2 on the main diagonal).
     34    The source matrix A is represented as S'*A*S = T, where S is an orthogonal
     35    matrix (Schur vectors), T - upper quasi-triangular matrix (with blocks of
     36    sizes 1x1 and 2x2 on the main diagonal).
    4037
    41         Input parameters:
    42             A   -   matrix to be decomposed.
    43                     Array whose indexes range within [0..N-1, 0..N-1].
    44             N   -   size of A, N>=0.
     38    Input parameters:
     39        A   -   matrix to be decomposed.
     40                Array whose indexes range within [0..N-1, 0..N-1].
     41        N   -   size of A, N>=0.
    4542
    4643
    47         Output parameters:
    48             A   -   contains matrix T.
    49                     Array whose indexes range within [0..N-1, 0..N-1].
    50             S   -   contains Schur vectors.
    51                     Array whose indexes range within [0..N-1, 0..N-1].
     44    Output parameters:
     45        A   -   contains matrix T.
     46                Array whose indexes range within [0..N-1, 0..N-1].
     47        S   -   contains Schur vectors.
     48                Array whose indexes range within [0..N-1, 0..N-1].
    5249
    53         Note 1:
    54             The block structure of matrix T can be easily recognized: since all
    55             the elements below the blocks are zeros, the elements a[i+1,i] which
    56             are equal to 0 show the block border.
     50    Note 1:
     51        The block structure of matrix T can be easily recognized: since all
     52        the elements below the blocks are zeros, the elements a[i+1,i] which
     53        are equal to 0 show the block border.
    5754
    58         Note 2:
    59             The algorithm performance depends on the value of the internal parameter
    60             NS of the InternalSchurDecomposition subroutine which defines the number
    61             of shifts in the QR algorithm (similarly to the block width in block-matrix
    62             algorithms in linear algebra). If you require maximum performance on
    63             your machine, it is recommended to adjust this parameter manually.
     55    Note 2:
     56        The algorithm performance depends on the value of the internal parameter
     57        NS of the InternalSchurDecomposition subroutine which defines the number
     58        of shifts in the QR algorithm (similarly to the block width in block-matrix
     59        algorithms in linear algebra). If you require maximum performance on
     60        your machine, it is recommended to adjust this parameter manually.
    6461
    65         Result:
    66             True,
    67                 if the algorithm has converged and parameters A and S contain the result.
    68             False,
    69                 if the algorithm has not converged.
     62    Result:
     63        True,
     64            if the algorithm has converged and parameters A and S contain the result.
     65        False,
     66            if the algorithm has not converged.
    7067
    71         Algorithm implemented on the basis of the DHSEQR subroutine (LAPACK 3.0 library).
    72         *************************************************************************/
    73         public static bool rmatrixschur(ref double[,] a,
    74             int n,
    75             ref double[,] s)
    76         {
    77             bool result = new bool();
    78             double[] tau = new double[0];
    79             double[] wi = new double[0];
    80             double[] wr = new double[0];
    81             double[,] a1 = new double[0,0];
    82             double[,] s1 = new double[0,0];
    83             int info = 0;
    84             int i = 0;
    85             int j = 0;
     68    Algorithm implemented on the basis of the DHSEQR subroutine (LAPACK 3.0 library).
     69    *************************************************************************/
     70    public static bool rmatrixschur(ref double[,] a,
     71        int n,
     72        ref double[,] s) {
     73      bool result = new bool();
     74      double[] tau = new double[0];
     75      double[] wi = new double[0];
     76      double[] wr = new double[0];
     77      double[,] a1 = new double[0, 0];
     78      double[,] s1 = new double[0, 0];
     79      int info = 0;
     80      int i = 0;
     81      int j = 0;
    8682
    87            
    88             //
    89             // Upper Hessenberg form of the 0-based matrix
    90             //
    91             ortfac.rmatrixhessenberg(ref a, n, ref tau);
    92             ortfac.rmatrixhessenbergunpackq(ref a, n, ref tau, ref s);
    93            
    94             //
    95             // Convert from 0-based arrays to 1-based,
    96             // then call InternalSchurDecomposition
    97             // Awkward, of course, but Schur decompisiton subroutine
    98             // is too complex to fix it.
    99             //
    100             //
    101             a1 = new double[n+1, n+1];
    102             s1 = new double[n+1, n+1];
    103             for(i=1; i<=n; i++)
    104             {
    105                 for(j=1; j<=n; j++)
    106                 {
    107                     a1[i,j] = a[i-1,j-1];
    108                     s1[i,j] = s[i-1,j-1];
    109                 }
    110             }
    111             hsschur.internalschurdecomposition(ref a1, n, 1, 1, ref wr, ref wi, ref s1, ref info);
    112             result = info==0;
    113            
    114             //
    115             // convert from 1-based arrays to -based
    116             //
    117             for(i=1; i<=n; i++)
    118             {
    119                 for(j=1; j<=n; j++)
    120                 {
    121                     a[i-1,j-1] = a1[i,j];
    122                     s[i-1,j-1] = s1[i,j];
    123                 }
    124             }
    125             return result;
     83
     84      //
     85      // Upper Hessenberg form of the 0-based matrix
     86      //
     87      ortfac.rmatrixhessenberg(ref a, n, ref tau);
     88      ortfac.rmatrixhessenbergunpackq(ref a, n, ref tau, ref s);
     89
     90      //
     91      // Convert from 0-based arrays to 1-based,
     92      // then call InternalSchurDecomposition
     93      // Awkward, of course, but Schur decompisiton subroutine
     94      // is too complex to fix it.
     95      //
     96      //
     97      a1 = new double[n + 1, n + 1];
     98      s1 = new double[n + 1, n + 1];
     99      for (i = 1; i <= n; i++) {
     100        for (j = 1; j <= n; j++) {
     101          a1[i, j] = a[i - 1, j - 1];
     102          s1[i, j] = s[i - 1, j - 1];
    126103        }
     104      }
     105      hsschur.internalschurdecomposition(ref a1, n, 1, 1, ref wr, ref wi, ref s1, ref info);
     106      result = info == 0;
     107
     108      //
     109      // convert from 1-based arrays to -based
     110      //
     111      for (i = 1; i <= n; i++) {
     112        for (j = 1; j <= n; j++) {
     113          a[i - 1, j - 1] = a1[i, j];
     114          s[i - 1, j - 1] = s1[i, j];
     115        }
     116      }
     117      return result;
    127118    }
     119  }
    128120}
Note: See TracChangeset for help on using the changeset viewer.