31 #ifndef EIGEN_SPARSELU_MEMORY
32 #define EIGEN_SPARSELU_MEMORY
37 enum { LUNoMarker = 3 };
38 enum {emptyIdxLU = -1};
41 return (std::max)(m, (t+b)*w);
44 template<
typename Scalar>
47 return (2*w + 4 + LUNoMarker) * m *
sizeof(
Index) + (w + 1) * m *
sizeof(Scalar);
61 template <
typename Scalar,
typename StorageIndex>
62 template <
typename VectorType>
69 if(num_expansions == 0 || keep_prev)
72 new_len = (std::max)(length+1,
Index(alpha * length));
76 old_vec = vec.segment(0,nbElts);
79 #ifdef EIGEN_EXCEPTIONS
85 #ifdef EIGEN_EXCEPTIONS
86 catch(std::bad_alloc& )
108 alpha = (alpha + 1)/2;
109 new_len = (std::max)(length+1,
Index(alpha * length));
110 #ifdef EIGEN_EXCEPTIONS
116 #ifdef EIGEN_EXCEPTIONS
117 catch(std::bad_alloc& )
123 if ( tries > 10)
return new_len;
125 }
while (!vec.size());
130 vec.segment(0, nbElts) = old_vec;
134 if(num_expansions) ++num_expansions;
150 template <
typename Scalar,
typename StorageIndex>
153 Index& num_expansions = glu.num_expansions;
155 glu.nzumax = glu.nzlumax = (std::min)(fillratio * (annz+1) / n, m) * n;
156 glu.nzlmax = (std::max)(
Index(4), fillratio) * (annz+1) / 4;
159 tempSpace = (2*panel_size + 4 + LUNoMarker) * m *
sizeof(
Index) + (panel_size + 1) * m *
sizeof(Scalar);
160 if (lwork == emptyIdxLU)
162 Index estimated_size;
163 estimated_size = (5 * n + 5) *
sizeof(
Index) + tempSpace
164 + (glu.nzlmax + glu.nzumax) *
sizeof(
Index) + (glu.nzlumax+glu.nzumax) *
sizeof(Scalar) + n;
165 return estimated_size;
171 glu.xsup.resize(n+1);
172 glu.supno.resize(n+1);
173 glu.xlsub.resize(n+1);
174 glu.xlusup.resize(n+1);
175 glu.xusub.resize(n+1);
180 if( (expand<ScalarVector>(glu.lusup, glu.nzlumax, 0, 0, num_expansions)<0)
181 || (expand<ScalarVector>(glu.ucol, glu.nzumax, 0, 0, num_expansions)<0)
182 || (expand<IndexVector> (glu.lsub, glu.nzlmax, 0, 0, num_expansions)<0)
183 || (expand<IndexVector> (glu.usub, glu.nzumax, 0, 1, num_expansions)<0) )
189 if (glu.nzlumax < annz )
return glu.nzlumax;
191 }
while (!glu.lusup.size() || !glu.ucol.size() || !glu.lsub.size() || !glu.usub.size());
207 template <
typename Scalar,
typename StorageIndex>
208 template <
typename VectorType>
213 failed_size = this->expand<VectorType>(vec, maxlen, nbElts, 1, num_expansions);
215 failed_size = this->expand<VectorType>(vec, maxlen, nbElts, 0, num_expansions);
226 #endif // EIGEN_SPARSELU_MEMORY