Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef SPARSELU_HEAP_RELAX_SNODE_H
00029 #define SPARSELU_HEAP_RELAX_SNODE_H
00030
00031 namespace Eigen {
00032 namespace internal {
00033
00045 template <typename Scalar, typename Index>
00046 void SparseLUImpl<Scalar,Index>::heap_relax_snode (const Index n, IndexVector& et, const Index relax_columns, IndexVector& descendants, IndexVector& relax_end)
00047 {
00048
00049
00050 IndexVector post;
00051 internal::treePostorder(n, et, post);
00052 IndexVector inv_post(n+1);
00053 Index i;
00054 for (i = 0; i < n+1; ++i) inv_post(post(i)) = i;
00055
00056
00057 IndexVector iwork(n);
00058 IndexVector et_save(n+1);
00059 for (i = 0; i < n; ++i)
00060 {
00061 iwork(post(i)) = post(et(i));
00062 }
00063 et_save = et;
00064 et = iwork;
00065
00066
00067 relax_end.setConstant(emptyIdxLU);
00068 Index j, parent;
00069 descendants.setZero();
00070 for (j = 0; j < n; j++)
00071 {
00072 parent = et(j);
00073 if (parent != n)
00074 descendants(parent) += descendants(j) + 1;
00075 }
00076
00077 Index snode_start;
00078 Index k;
00079 Index nsuper_et_post = 0;
00080 Index nsuper_et = 0;
00081 Index l;
00082 for (j = 0; j < n; )
00083 {
00084 parent = et(j);
00085 snode_start = j;
00086 while ( parent != n && descendants(parent) < relax_columns )
00087 {
00088 j = parent;
00089 parent = et(j);
00090 }
00091
00092 ++nsuper_et_post;
00093 k = n;
00094 for (i = snode_start; i <= j; ++i)
00095 k = (std::min)(k, inv_post(i));
00096 l = inv_post(j);
00097 if ( (l - k) == (j - snode_start) )
00098 {
00099
00100 relax_end(k) = l;
00101 ++nsuper_et;
00102 }
00103 else
00104 {
00105 for (i = snode_start; i <= j; ++i)
00106 {
00107 l = inv_post(i);
00108 if (descendants(i) == 0)
00109 {
00110 relax_end(l) = l;
00111 ++nsuper_et;
00112 }
00113 }
00114 }
00115 j++;
00116
00117 while (descendants(j) != 0 && j < n) j++;
00118 }
00119
00120
00121 et = et_save;
00122 }
00123
00124 }
00125
00126 }
00127 #endif // SPARSELU_HEAP_RELAX_SNODE_H