Change int to Index type for SparseLU

This commit is contained in:
Desire NUENTSA
2013-01-29 16:21:24 +01:00
parent 57e50789f3
commit 8bc00925e5
18 changed files with 207 additions and 203 deletions

View File

@@ -53,19 +53,19 @@ namespace internal {
*
*/
template <typename Scalar, typename Index>
void SparseLUImpl<Scalar,Index>::panel_bmod(const int m, const int w, const int jcol,
const int nseg, ScalarVector& dense, ScalarVector& tempv,
void SparseLUImpl<Scalar,Index>::panel_bmod(const Index m, const Index w, const Index jcol,
const Index nseg, ScalarVector& dense, ScalarVector& tempv,
IndexVector& segrep, IndexVector& repfnz, GlobalLU_t& glu)
{
int ksub,jj,nextl_col;
int fsupc, nsupc, nsupr, nrow;
int krep, kfnz;
int lptr; // points to the row subscripts of a supernode
int luptr; // ...
int segsize,no_zeros ;
Index ksub,jj,nextl_col;
Index fsupc, nsupc, nsupr, nrow;
Index krep, kfnz;
Index lptr; // points to the row subscripts of a supernode
Index luptr; // ...
Index segsize,no_zeros ;
// For each nonz supernode segment of U[*,j] in topological order
int k = nseg - 1;
Index k = nseg - 1;
const Index PacketSize = internal::packet_traits<Scalar>::size;
for (ksub = 0; ksub < nseg; ksub++)
@@ -83,8 +83,8 @@ void SparseLUImpl<Scalar,Index>::panel_bmod(const int m, const int w, const int
lptr = glu.xlsub(fsupc);
// loop over the panel columns to detect the actual number of columns and rows
int u_rows = 0;
int u_cols = 0;
Index u_rows = 0;
Index u_cols = 0;
for (jj = jcol; jj < jcol + w; jj++)
{
nextl_col = (jj-jcol) * m;
@@ -101,11 +101,11 @@ void SparseLUImpl<Scalar,Index>::panel_bmod(const int m, const int w, const int
if(nsupc >= 2)
{
int ldu = internal::first_multiple<Index>(u_rows, PacketSize);
Index ldu = internal::first_multiple<Index>(u_rows, PacketSize);
Map<Matrix<Scalar,Dynamic,Dynamic>, Aligned, OuterStride<> > U(tempv.data(), u_rows, u_cols, OuterStride<>(ldu));
// gather U
int u_col = 0;
Index u_col = 0;
for (jj = jcol; jj < jcol + w; jj++)
{
nextl_col = (jj-jcol) * m;
@@ -120,12 +120,12 @@ void SparseLUImpl<Scalar,Index>::panel_bmod(const int m, const int w, const int
luptr = glu.xlusup(fsupc);
no_zeros = kfnz - fsupc;
int isub = lptr + no_zeros;
int off = u_rows-segsize;
for (int i = 0; i < off; i++) U(i,u_col) = 0;
for (int i = 0; i < segsize; i++)
Index isub = lptr + no_zeros;
Index off = u_rows-segsize;
for (Index i = 0; i < off; i++) U(i,u_col) = 0;
for (Index i = 0; i < segsize; i++)
{
int irow = glu.lsub(isub);
Index irow = glu.lsub(isub);
U(i+off,u_col) = dense_col(irow);
++isub;
}
@@ -133,7 +133,7 @@ void SparseLUImpl<Scalar,Index>::panel_bmod(const int m, const int w, const int
}
// solve U = A^-1 U
luptr = glu.xlusup(fsupc);
int lda = glu.xlusup(fsupc+1) - glu.xlusup(fsupc);
Index lda = glu.xlusup(fsupc+1) - glu.xlusup(fsupc);
no_zeros = (krep - u_rows + 1) - fsupc;
luptr += lda * no_zeros + no_zeros;
Map<Matrix<Scalar,Dynamic,Dynamic>, 0, OuterStride<> > A(glu.lusup.data()+luptr, u_rows, u_rows, OuterStride<>(lda) );
@@ -144,8 +144,8 @@ void SparseLUImpl<Scalar,Index>::panel_bmod(const int m, const int w, const int
Map<Matrix<Scalar,Dynamic,Dynamic>, 0, OuterStride<> > B(glu.lusup.data()+luptr, nrow, u_rows, OuterStride<>(lda) );
eigen_assert(tempv.size()>w*ldu + nrow*w + 1);
int ldl = internal::first_multiple<Index>(nrow, PacketSize);
int offset = (PacketSize-internal::first_aligned(B.data(), PacketSize)) % PacketSize;
Index ldl = internal::first_multiple<Index>(nrow, PacketSize);
Index offset = (PacketSize-internal::first_aligned(B.data(), PacketSize)) % PacketSize;
Map<Matrix<Scalar,Dynamic,Dynamic>, 0, OuterStride<> > L(tempv.data()+w*ldu+offset, nrow, u_cols, OuterStride<>(ldl));
L.setZero();
@@ -165,20 +165,20 @@ void SparseLUImpl<Scalar,Index>::panel_bmod(const int m, const int w, const int
segsize = krep - kfnz + 1;
no_zeros = kfnz - fsupc;
int isub = lptr + no_zeros;
Index isub = lptr + no_zeros;
int off = u_rows-segsize;
for (int i = 0; i < segsize; i++)
Index off = u_rows-segsize;
for (Index i = 0; i < segsize; i++)
{
int irow = glu.lsub(isub++);
Index irow = glu.lsub(isub++);
dense_col(irow) = U.coeff(i+off,u_col);
U.coeffRef(i+off,u_col) = 0;
}
// Scatter l into SPA dense[]
for (int i = 0; i < nrow; i++)
for (Index i = 0; i < nrow; i++)
{
int irow = glu.lsub(isub++);
Index irow = glu.lsub(isub++);
dense_col(irow) -= L.coeff(i,u_col);
L.coeffRef(i,u_col) = 0;
}
@@ -201,7 +201,7 @@ void SparseLUImpl<Scalar,Index>::panel_bmod(const int m, const int w, const int
segsize = krep - kfnz + 1;
luptr = glu.xlusup(fsupc);
int lda = glu.xlusup(fsupc+1)-glu.xlusup(fsupc);// nsupr
Index lda = glu.xlusup(fsupc+1)-glu.xlusup(fsupc);// nsupr
// Perform a trianglar solve and block update,
// then scatter the result of sup-col update to dense[]