CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/RecoTracker/RoadSearchHelixMaker/src/Dcxmatinv.cc

Go to the documentation of this file.
00001 //babar #include "BaBar/BaBar.hh"
00002 //babar #include <math.h>
00003 #include <cmath>
00004 #include <iostream>
00005 //babar #include "DcxReco/Dcxmatinv.hh"
00006 #include "RecoTracker/RoadSearchHelixMaker/interface/Dcxmatinv.hh"
00007 
00008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00009 
00010 using std::cout;
00011 using std::endl;
00012 
00013 extern int Dcxmatinv(double *array, int *norder, double *det){
00014   /* System generated locals */
00015   int i__3;
00016   double d__1;
00017 
00018   /* Local variables */
00019   const int nmax = 10;
00020 //  edm::LogInfo("RoadSearch") << "norder in Dcxmatinv = " << *norder ;
00021   if (*norder > nmax){
00022     edm::LogInfo("RoadSearch") << "In Dcxmatinv, norder ( = " << *norder << " ) > nmax ( = "
00023                            << nmax << " ); error" ; return 1000;
00024   }
00025   static double amax, save;
00026   static int i, j, k, l, ik[nmax], jk[nmax];
00027 
00028   /* Parameter adjustments */
00029   array -= (nmax+1);
00030 
00031   /* Function Body */
00032   *det = (double)1.;
00033   for (k = 1; k <= *norder; ++k) {
00034 
00035     /*       FIND LARGEST ELEMENT ARRAY(I, J) IN REST OF MATRIX */
00036 
00037     amax = (double)0.;
00038   L21:
00039     for (i = k; i <= *norder; ++i) {
00040       for (j = k; j <= *norder; ++j) {
00041         d__1 = array[i + j * nmax]; 
00042         if ((fabs(amax)-fabs(d__1)) <= 0.) {
00043           amax = array[i + j * nmax];
00044           ik[k - 1] = i;
00045           jk[k - 1] = j;
00046         }
00047       }
00048     }
00049 
00050     /*       INTERCHANGE ROWS AND COLUMNS TO PUT AMAX IN ARRAY(K, K) */
00051 
00052     if (amax == 0.) {*det = (double)0.; return 1001;}
00053 
00054     i = ik[k - 1];
00055     if ((i__3 = i - k) < 0) {
00056       goto L21;
00057     } else if (i__3 == 0) {
00058       goto L51;
00059     } else {
00060       goto L43;
00061     }
00062   L43:
00063     for (j = 1; j <= *norder; ++j) {
00064       save = array[k + j * nmax];
00065       array[k + j * nmax] = array[i + j * nmax];
00066       array[i + j * nmax] = -save;
00067     }
00068   L51:
00069     j = jk[k - 1];
00070     if ((i__3 = j - k) < 0) {
00071       goto L21;
00072     } else if (i__3 == 0) {
00073       goto L61;
00074     } else {
00075       goto L53;
00076     }
00077   L53:
00078     for (i = 1; i <= *norder; ++i) {
00079       save = array[i + k * nmax];
00080       array[i + k * nmax] = array[i + j * nmax];
00081       array[i + j * nmax] = -save;
00082     }
00083 
00084     /*       ACCUMULATE ELEMENTS OF INVERSE MATRIX */
00085 
00086   L61:
00087     for (i = 1; i <= *norder; ++i) {
00088       if (i - k != 0) {
00089         array[i + k * nmax] = -array[i + k * nmax] / amax;
00090       } 
00091     }
00092     for (i = 1; i <= *norder; ++i) {
00093       for (j = 1; j <= *norder; ++j) {
00094         if (i - k != 0) {
00095           goto L74;
00096         } else {
00097           goto L80;
00098         }
00099       L74:
00100         if (j - k != 0) {
00101           goto L75;
00102         } else {
00103           goto L80;
00104         }
00105       L75:
00106         array[i+j*nmax] += array[i+k*nmax] * array[k+j*nmax];
00107       L80:
00108         ;
00109       }
00110     }
00111     for (j = 1; j <= *norder; ++j) {
00112       if (j - k != 0) {
00113         array[k + j * nmax] /= amax;
00114       }
00115     }
00116     array[k + k * nmax] = (double)1. / amax;
00117     *det *= amax;
00118   }
00119 
00120   /*       RESTORE ORDERING OF MATRIX */
00121 
00122   for (l = 1; l <= *norder; ++l) {
00123     k = *norder - l + 1;
00124     j = ik[k - 1];
00125     if (j - k <= 0) {
00126       goto L111;
00127     } else {
00128       goto L105;
00129     }
00130   L105:
00131     for (i = 1; i <= *norder; ++i) {
00132       save = array[i + k * nmax];
00133       array[i + k * nmax] = -array[i + j * nmax];
00134       array[i + j * nmax] = save;
00135     }
00136   L111:
00137     i = jk[k - 1];
00138     if (i - k <= 0) {
00139       goto L130;
00140     } else {
00141       goto L113;
00142     }
00143   L113:
00144     for (j = 1; j <= *norder; ++j) {
00145       save = array[k + j * nmax];
00146       array[k + j * nmax] = -array[i + j * nmax];
00147       array[i + j * nmax] = save;
00148     }
00149   L130:
00150     ;
00151   }
00152   return 0;
00153 } /* Dcxmatinv */