Skip Navigation Links
Numerical Libraries
Linear Algebra
Differential Equations
Optimization
Samples
Skip Navigation Links
Linear Algebra
CSLapack
CSBlas
   1:  #region Translated by Jose Antonio De Santiago-Castillo.
   2:   
   3:  //Translated by Jose Antonio De Santiago-Castillo. 
   4:  //E-mail:JAntonioDeSantiago@gmail.com
   5:  //Web: www.DotNumerics.com
   6:  //
   7:  //Fortran to C# Translation.
   8:  //Translated by:
   9:  //F2CSharp Version 0.71 (November 10, 2009)
  10:  //Code Optimizations: None
  11:  //
  12:  #endregion
  13:   
  14:  using System;
  15:  using DotNumerics.FortranLibrary;
  16:   
  17:  namespace DotNumerics.CSLapack
  18:  {
  19:      /// <summary>
  20:      /// -- LAPACK auxiliary routine (version 3.1) --
  21:      /// Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
  22:      /// November 2006
  23:      /// Purpose
  24:      /// =======
  25:      /// 
  26:      /// DLASDT creates a tree of subproblems for bidiagonal divide and
  27:      /// conquer.
  28:      /// 
  29:      ///</summary>
  30:      public class DLASDT
  31:      {
  32:      
  33:   
  34:          #region Fields
  35:          
  36:          const double TWO = 2.0E+0; int I = 0; int IL = 0; int IR = 0; int LLST = 0; int MAXN = 0; int NCRNT = 0; int NLVL = 0; 
  37:          double TEMP = 0;
  38:   
  39:          #endregion
  40:   
  41:          public DLASDT()
  42:          {
  43:      
  44:          }
  45:      
  46:          /// <summary>
  47:          /// Purpose
  48:          /// =======
  49:          /// 
  50:          /// DLASDT creates a tree of subproblems for bidiagonal divide and
  51:          /// conquer.
  52:          /// 
  53:          ///</summary>
  54:          /// <param name="N">
  55:          /// (input) INTEGER
  56:          /// On entry, the number of diagonal elements of the
  57:          /// bidiagonal matrix.
  58:          ///</param>
  59:          /// <param name="LVL">
  60:          /// (output) INTEGER
  61:          /// On exit, the number of levels on the computation tree.
  62:          ///</param>
  63:          /// <param name="ND">
  64:          /// (output) INTEGER
  65:          /// On exit, the number of nodes on the tree.
  66:          ///</param>
  67:          /// <param name="INODE">
  68:          /// (output) INTEGER array, dimension ( N )
  69:          /// On exit, centers of subproblems.
  70:          ///</param>
  71:          /// <param name="NDIML">
  72:          /// (output) INTEGER array, dimension ( N )
  73:          /// On exit, row dimensions of left children.
  74:          ///</param>
  75:          /// <param name="NDIMR">
  76:          /// (output) INTEGER array, dimension ( N )
  77:          /// On exit, row dimensions of right children.
  78:          ///</param>
  79:          /// <param name="MSUB">
  80:          /// (input) INTEGER.
  81:          /// On entry, the maximum row dimension each subproblem at the
  82:          /// bottom of the tree can be of.
  83:          ///</param>
  84:          public void Run(int N, ref int LVL, ref int ND, ref int[] INODE, int offset_inode, ref int[] NDIML, int offset_ndiml, ref int[] NDIMR, int offset_ndimr
  85:                           , int MSUB)
  86:          {
  87:   
  88:              #region Array Index Correction
  89:              
  90:               int o_inode = -1 + offset_inode;  int o_ndiml = -1 + offset_ndiml;  int o_ndimr = -1 + offset_ndimr; 
  91:   
  92:              #endregion
  93:   
  94:   
  95:              #region Prolog
  96:              
  97:              // *
  98:              // *  -- LAPACK auxiliary routine (version 3.1) --
  99:              // *     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
 100:              // *     November 2006
 101:              // *
 102:              // *     .. Scalar Arguments ..
 103:              // *     ..
 104:              // *     .. Array Arguments ..
 105:              // *     ..
 106:              // *
 107:              // *  Purpose
 108:              // *  =======
 109:              // *
 110:              // *  DLASDT creates a tree of subproblems for bidiagonal divide and
 111:              // *  conquer.
 112:              // *
 113:              // *  Arguments
 114:              // *  =========
 115:              // *
 116:              // *   N      (input) INTEGER
 117:              // *          On entry, the number of diagonal elements of the
 118:              // *          bidiagonal matrix.
 119:              // *
 120:              // *   LVL    (output) INTEGER
 121:              // *          On exit, the number of levels on the computation tree.
 122:              // *
 123:              // *   ND     (output) INTEGER
 124:              // *          On exit, the number of nodes on the tree.
 125:              // *
 126:              // *   INODE  (output) INTEGER array, dimension ( N )
 127:              // *          On exit, centers of subproblems.
 128:              // *
 129:              // *   NDIML  (output) INTEGER array, dimension ( N )
 130:              // *          On exit, row dimensions of left children.
 131:              // *
 132:              // *   NDIMR  (output) INTEGER array, dimension ( N )
 133:              // *          On exit, row dimensions of right children.
 134:              // *
 135:              // *   MSUB   (input) INTEGER.
 136:              // *          On entry, the maximum row dimension each subproblem at the
 137:              // *          bottom of the tree can be of.
 138:              // *
 139:              // *  Further Details
 140:              // *  ===============
 141:              // *
 142:              // *  Based on contributions by
 143:              // *     Ming Gu and Huan Ren, Computer Science Division, University of
 144:              // *     California at Berkeley, USA
 145:              // *
 146:              // *  =====================================================================
 147:              // *
 148:              // *     .. Parameters ..
 149:              // *     ..
 150:              // *     .. Local Scalars ..
 151:              // *     ..
 152:              // *     .. Intrinsic Functions ..
 153:              //      INTRINSIC          DBLE, INT, LOG, MAX;
 154:              // *     ..
 155:              // *     .. Executable Statements ..
 156:              // *
 157:              // *     Find the number of levels on the tree.
 158:              // *
 159:   
 160:              #endregion
 161:   
 162:   
 163:              #region Body
 164:              
 165:              MAXN = Math.Max(1, N);
 166:              TEMP = Math.Log(Convert.ToDouble(MAXN) / Convert.ToDouble(MSUB + 1)) / Math.Log(TWO);
 167:              LVL = Convert.ToInt32(Math.Truncate(TEMP)) + 1;
 168:              // *
 169:              I = N / 2;
 170:              INODE[1 + o_inode] = I + 1;
 171:              NDIML[1 + o_ndiml] = I;
 172:              NDIMR[1 + o_ndimr] = N - I - 1;
 173:              IL = 0;
 174:              IR = 1;
 175:              LLST = 1;
 176:              for (NLVL = 1; NLVL <= LVL - 1; NLVL++)
 177:              {
 178:                  // *
 179:                  // *        Constructing the tree at (NLVL+1)-st level. The number of
 180:                  // *        nodes created on this level is LLST * 2.
 181:                  // *
 182:                  for (I = 0; I <= LLST - 1; I++)
 183:                  {
 184:                      IL = IL + 2;
 185:                      IR = IR + 2;
 186:                      NCRNT = LLST + I;
 187:                      NDIML[IL + o_ndiml] = NDIML[NCRNT + o_ndiml] / 2;
 188:                      NDIMR[IL + o_ndimr] = NDIML[NCRNT + o_ndiml] - NDIML[IL + o_ndiml] - 1;
 189:                      INODE[IL + o_inode] = INODE[NCRNT + o_inode] - NDIMR[IL + o_ndimr] - 1;
 190:                      NDIML[IR + o_ndiml] = NDIMR[NCRNT + o_ndimr] / 2;
 191:                      NDIMR[IR + o_ndimr] = NDIMR[NCRNT + o_ndimr] - NDIML[IR + o_ndiml] - 1;
 192:                      INODE[IR + o_inode] = INODE[NCRNT + o_inode] + NDIML[IR + o_ndiml] + 1;
 193:                  }
 194:                  LLST = LLST * 2;
 195:              }
 196:              ND = LLST * 2 - 1;
 197:              // *
 198:              return;
 199:              // *
 200:              // *     End of DLASDT
 201:              // *
 202:   
 203:              #endregion
 204:   
 205:          }
 206:      }
 207:  }