31 #ifndef EIGEN_SPARSELU_MEMORY 32 #define EIGEN_SPARSELU_MEMORY 35 #include "./InternalHeaderCheck.h" 40 enum { LUNoMarker = 3 };
41 enum { emptyIdxLU = -1 };
44 template <
typename Scalar>
46 return (2 * w + 4 + LUNoMarker) * m *
sizeof(
Index) + (w + 1) * m *
sizeof(Scalar);
57 template <
typename Scalar,
typename StorageIndex>
58 template <
typename VectorType>
60 Index& num_expansions) {
64 if (num_expansions == 0 || keep_prev)
67 new_len = (std::max)(length + 1,
Index(alpha * length));
70 if (nbElts > 0) old_vec = vec.segment(0, nbElts);
73 #ifdef EIGEN_EXCEPTIONS 79 #ifdef EIGEN_EXCEPTIONS 80 catch (std::bad_alloc&)
85 if (!num_expansions) {
97 alpha = (alpha + 1) / 2;
98 new_len = (std::max)(length + 1,
Index(alpha * length));
99 #ifdef EIGEN_EXCEPTIONS 105 #ifdef EIGEN_EXCEPTIONS 106 catch (std::bad_alloc&)
112 if (tries > 10)
return new_len;
114 }
while (!vec.size());
118 if (nbElts > 0) vec.segment(0, nbElts) = old_vec;
121 if (num_expansions) ++num_expansions;
138 template <
typename Scalar,
typename StorageIndex>
140 Index panel_size, GlobalLU_t& glu) {
141 Index& num_expansions = glu.num_expansions;
143 glu.nzumax = glu.nzlumax = (std::min)(fillratio * (annz + 1) / n, m) * n;
144 glu.nzlmax = (std::max)(
Index(4), fillratio) * (annz + 1) / 4;
147 tempSpace = (2 * panel_size + 4 + LUNoMarker) * m *
sizeof(
Index) + (panel_size + 1) * m *
sizeof(Scalar);
148 if (lwork == emptyIdxLU) {
149 Index estimated_size;
150 estimated_size = (5 * n + 5) *
sizeof(
Index) + tempSpace + (glu.nzlmax + glu.nzumax) *
sizeof(
Index) +
151 (glu.nzlumax + glu.nzumax) *
sizeof(Scalar) + n;
152 return estimated_size;
158 glu.xsup.resize(n + 1);
159 glu.supno.resize(n + 1);
160 glu.xlsub.resize(n + 1);
161 glu.xlusup.resize(n + 1);
162 glu.xusub.resize(n + 1);
166 if ((expand<ScalarVector>(glu.lusup, glu.nzlumax, 0, 0, num_expansions) < 0) ||
167 (expand<ScalarVector>(glu.ucol, glu.nzumax, 0, 0, num_expansions) < 0) ||
168 (expand<IndexVector>(glu.lsub, glu.nzlmax, 0, 0, num_expansions) < 0) ||
169 (expand<IndexVector>(glu.usub, glu.nzumax, 0, 1, num_expansions) < 0)) {
174 if (glu.nzlumax < annz)
return glu.nzlumax;
176 }
while (!glu.lusup.size() || !glu.ucol.size() || !glu.lsub.size() || !glu.usub.size());
192 template <
typename Scalar,
typename StorageIndex>
193 template <
typename VectorType>
195 Index& num_expansions) {
198 failed_size = this->expand<VectorType>(vec, maxlen, nbElts, 1, num_expansions);
200 failed_size = this->expand<VectorType>(vec, maxlen, nbElts, 0, num_expansions);
202 if (failed_size)
return failed_size;
210 #endif // EIGEN_SPARSELU_MEMORY Namespace containing all symbols from the Eigen library.
Definition: B01_Experimental.dox:1
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:82
Index memXpand(VectorType &vec, Index &maxlen, Index nbElts, MemType memtype, Index &num_expansions)
Expand the existing storage.
Definition: SparseLU_Memory.h:194
Index expand(VectorType &vec, Index &length, Index nbElts, Index keep_prev, Index &num_expansions)
Definition: SparseLU_Memory.h:59
Index memInit(Index m, Index n, Index annz, Index lwork, Index fillratio, Index panel_size, GlobalLU_t &glu)
Allocate various working space for the numerical factorization phase.
Definition: SparseLU_Memory.h:139