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
00029
00030 #ifndef SPARSELU_COLUMN_DFS_H
00031 #define SPARSELU_COLUMN_DFS_H
00032
00033 template <typename Scalar, typename Index> class SparseLUImpl;
00034 namespace Eigen {
00035
00036 namespace internal {
00037
00038 template<typename IndexVector, typename ScalarVector>
00039 struct column_dfs_traits : no_assignment_operator
00040 {
00041 typedef typename ScalarVector::Scalar Scalar;
00042 typedef typename IndexVector::Scalar Index;
00043 column_dfs_traits(Index jcol, Index& jsuper, typename SparseLUImpl<Scalar, Index>::GlobalLU_t& glu, SparseLUImpl<Scalar, Index>& luImpl)
00044 : m_jcol(jcol), m_jsuper_ref(jsuper), m_glu(glu), m_luImpl(luImpl)
00045 {}
00046 bool update_segrep(Index , Index )
00047 {
00048 return true;
00049 }
00050 void mem_expand(IndexVector& lsub, Index& nextl, Index chmark)
00051 {
00052 if (nextl >= m_glu.nzlmax)
00053 m_luImpl.memXpand(lsub, m_glu.nzlmax, nextl, LSUB, m_glu.num_expansions);
00054 if (chmark != (m_jcol-1)) m_jsuper_ref = emptyIdxLU;
00055 }
00056 enum { ExpandMem = true };
00057
00058 Index m_jcol;
00059 Index& m_jsuper_ref;
00060 typename SparseLUImpl<Scalar, Index>::GlobalLU_t& m_glu;
00061 SparseLUImpl<Scalar, Index>& m_luImpl;
00062 };
00063
00064
00092 template <typename Scalar, typename Index>
00093 Index SparseLUImpl<Scalar,Index>::column_dfs(const Index m, const Index jcol, IndexVector& perm_r, Index maxsuper, Index& nseg, BlockIndexVector lsub_col, IndexVector& segrep, BlockIndexVector repfnz, IndexVector& xprune, IndexVector& marker, IndexVector& parent, IndexVector& xplore, GlobalLU_t& glu)
00094 {
00095
00096 Index jsuper = glu.supno(jcol);
00097 Index nextl = glu.xlsub(jcol);
00098 VectorBlock<IndexVector> marker2(marker, 2*m, m);
00099
00100
00101 column_dfs_traits<IndexVector, ScalarVector> traits(jcol, jsuper, glu, *this);
00102
00103
00104 for (Index k = 0; ((k < m) ? lsub_col[k] != emptyIdxLU : false) ; k++)
00105 {
00106 Index krow = lsub_col(k);
00107 lsub_col(k) = emptyIdxLU;
00108 Index kmark = marker2(krow);
00109
00110
00111 if (kmark == jcol) continue;
00112
00113 dfs_kernel(jcol, perm_r, nseg, glu.lsub, segrep, repfnz, xprune, marker2, parent,
00114 xplore, glu, nextl, krow, traits);
00115 }
00116
00117 Index fsupc, jptr, jm1ptr, ito, ifrom, istop;
00118 Index nsuper = glu.supno(jcol);
00119 Index jcolp1 = jcol + 1;
00120 Index jcolm1 = jcol - 1;
00121
00122
00123 if ( jcol == 0 )
00124 {
00125 nsuper = glu.supno(0) = 0 ;
00126 }
00127 else
00128 {
00129 fsupc = glu.xsup(nsuper);
00130 jptr = glu.xlsub(jcol);
00131 jm1ptr = glu.xlsub(jcolm1);
00132
00133
00134 if ( (nextl-jptr != jptr-jm1ptr-1) ) jsuper = emptyIdxLU;
00135
00136
00137
00138 if ( (jcol - fsupc) >= maxsuper) jsuper = emptyIdxLU;
00139
00140
00141
00142
00143
00144
00145 if (jsuper == emptyIdxLU)
00146 {
00147 if ( (fsupc < jcolm1-1) )
00148 {
00149 ito = glu.xlsub(fsupc+1);
00150 glu.xlsub(jcolm1) = ito;
00151 istop = ito + jptr - jm1ptr;
00152 xprune(jcolm1) = istop;
00153 glu.xlsub(jcol) = istop;
00154
00155 for (ifrom = jm1ptr; ifrom < nextl; ++ifrom, ++ito)
00156 glu.lsub(ito) = glu.lsub(ifrom);
00157 nextl = ito;
00158 }
00159 nsuper++;
00160 glu.supno(jcol) = nsuper;
00161 }
00162 }
00163
00164
00165 glu.xsup(nsuper+1) = jcolp1;
00166 glu.supno(jcolp1) = nsuper;
00167 xprune(jcol) = nextl;
00168 glu.xlsub(jcolp1) = nextl;
00169
00170 return 0;
00171 }
00172
00173 }
00174
00175 }
00176
00177 #endif