Question
Hi,
I got a error when call inverseLUD() under windows xp,and my compiler is microsoft visual c++ 9.0.
Error Location: in file 'MatrixFunctors.hpp',line 508.
template <class BaseClass2>
void backSub(RefVectorBase<T, BaseClass2>& v) const
throw (MatrixException)
{
if(LU.rows() != v.size()) {
MatrixException e("Vector size does not match dimension of LUDecomp");
GPSTK_THROW(e);
}
bool first=true;
size_t N=LU.rows(),i,j,ii; // *** ii should be initialized with zero
T sum;
// un-pivot
for(i=0; i<N; i++) {
sum = v(Pivot(i));
v(Pivot(i)) = v(i);
if(first && sum != T(0)) {
ii = i;
first = false;
}
else for(j=ii; j<i; j++) sum -= LU(i,j)*v(j); // *** ii doesn't set a init value before using it
v(i) = sum;
}
// back substitution
for(i=N-1; ; i--) {
sum = v(i);
for(j=i+1; j<N; j++) sum -= LU(i,j)*v(j);
v(i) = sum / LU(i,i);
if(i == 0) break; // b/c i is unsigned
}
} // end LUD::backSub
FIX Method:
change line 497 from
size_t N=LU.rows(),i,j,ii;
to
size_t N=LU.rows(),i,j,ii(0);
Wish some super developers can check the code and fix the error.
--
YanWei - 11 Apr 2009
Answer
If you answer a question - or have a question you asked answered by someone - please remember to edit the page and set the status to answered. The status is in a drop-down list below the edit box.
--
BrianTolman - 16 Apr 2009
This change is trivial and has no effect. If you wish to silence your compiler on the issue, go ahead and submit the change
--
BrianTolman - 16 Apr 2009