Revision 303 trunk/src/linad99/ludcmp_solve.cpp

ludcmp_solve.cpp (revision 303)
69 69
   ivector index2 = dcmp.get_index2();
70 70

  
71 71
   //check if invertable
72
   double det = 1.0;
72
   double ln_det = 0.0;
73 73
   for (int i = lb; i <= ub; i++)
74 74
   {
75
      det *= dcmp(i, i);
75
      ln_det += log(dcmp(i, i));
76 76
   }
77
   if (det == 0.0)
77
   if (exp(ln_det) == 0.0)
78 78
   {
79 79
      cerr <<
80 80
	 "Error in matrix inverse -- matrix singular in solve(dmatrix)\n";
......
148 148
   dmatrix & alpha = clu1.get_L();
149 149

  
150 150
   //check if invertable
151
   double det = 1.0;
151
	double ln_det = 0.0;
152 152
   for (int i = lb; i <= ub; i++)
153 153
   {
154
      det *= clu1(i, i);
154
		ln_det += log(clu1(i, i));
155 155
   }
156
   if (det == 0.0)
156
	if(exp(ln_det)==0.0)
157 157
   {
158 158
      cerr <<
159 159
	 "Error in matrix inverse -- matrix singular in solve(dvar_matrix)\n";

Also available in: Unified diff