aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/SparseLU/SparseLU_Memory.h
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2013-10-29 11:26:52 +0100
committerGravatar Gael Guennebaud <g.gael@free.fr>2013-10-29 11:26:52 +0100
commit90b5d303db61b6ea399a1ea43c3830b8ebba55f6 (patch)
tree6cbf990367d0e0020fbc552b78244b08c2aa41a9 /Eigen/src/SparseLU/SparseLU_Memory.h
parent9b863c1830c535bbba08be655e7fb8c19ac39ae3 (diff)
Fix bug #672: use exceptions in SuperLU if they are enabled only
Diffstat (limited to 'Eigen/src/SparseLU/SparseLU_Memory.h')
-rw-r--r--Eigen/src/SparseLU/SparseLU_Memory.h34
1 files changed, 20 insertions, 14 deletions
diff --git a/Eigen/src/SparseLU/SparseLU_Memory.h b/Eigen/src/SparseLU/SparseLU_Memory.h
index a5158025c..767519754 100644
--- a/Eigen/src/SparseLU/SparseLU_Memory.h
+++ b/Eigen/src/SparseLU/SparseLU_Memory.h
@@ -77,16 +77,23 @@ Index SparseLUImpl<Scalar,Index>::expand(VectorType& vec, Index& length, Index
old_vec = vec.segment(0,nbElts);
//Allocate or expand the current vector
- try
+#ifdef EIGEN_EXCEPTIONS
+ try
+#endif
{
vec.resize(new_len);
}
+#ifdef EIGEN_EXCEPTIONS
catch(std::bad_alloc& )
+#else
+ if(!vec.size())
+#endif
{
- if ( !num_expansions )
+ if (!num_expansions)
{
// First time to allocate from LUMemInit()
- throw; // Pass the exception to LUMemInit() which has a try... catch block
+ // Let LUMemInit() deals with it.
+ return 0;
}
if (keep_prev)
{
@@ -101,11 +108,17 @@ Index SparseLUImpl<Scalar,Index>::expand(VectorType& vec, Index& length, Index
{
alpha = (alpha + 1)/2;
new_len = Index(alpha * length);
+#ifdef EIGEN_EXCEPTIONS
try
+#endif
{
vec.resize(new_len);
}
+#ifdef EIGEN_EXCEPTIONS
catch(std::bad_alloc& )
+#else
+ if (!vec.size())
+#endif
{
tries += 1;
if ( tries > 10) return new_len;
@@ -166,14 +179,10 @@ Index SparseLUImpl<Scalar,Index>::memInit(Index m, Index n, Index annz, Index lw
// Reserve memory for L/U factors
do
{
- try
- {
- expand<ScalarVector>(glu.lusup, glu.nzlumax, 0, 0, num_expansions);
- expand<ScalarVector>(glu.ucol,glu.nzumax, 0, 0, num_expansions);
- expand<IndexVector>(glu.lsub,glu.nzlmax, 0, 0, num_expansions);
- expand<IndexVector>(glu.usub,glu.nzumax, 0, 1, num_expansions);
- }
- catch(std::bad_alloc& )
+ if( (!expand<ScalarVector>(glu.lusup, glu.nzlumax, 0, 0, num_expansions))
+ || (!expand<ScalarVector>(glu.ucol, glu.nzumax, 0, 0, num_expansions))
+ || (!expand<IndexVector> (glu.lsub, glu.nzlmax, 0, 0, num_expansions))
+ || (!expand<IndexVector> (glu.usub, glu.nzumax, 0, 1, num_expansions)) )
{
//Reduce the estimated size and retry
glu.nzlumax /= 2;
@@ -181,10 +190,7 @@ Index SparseLUImpl<Scalar,Index>::memInit(Index m, Index n, Index annz, Index lw
glu.nzlmax /= 2;
if (glu.nzlumax < annz ) return glu.nzlumax;
}
-
} while (!glu.lusup.size() || !glu.ucol.size() || !glu.lsub.size() || !glu.usub.size());
-
-
++num_expansions;
return 0;