* don't laugh, but these bugs took me forever to fix.

* expand unit tests to make sure to catch them: they nearly escaped the existing tests as these memory violations were highly dependent on the numbers of rows and cols.
This commit is contained in:
Benoit Jacob
2009-11-19 22:01:13 -05:00
parent eac3232095
commit 6cbf662f14
2 changed files with 15 additions and 18 deletions

View File

@@ -410,7 +410,7 @@ struct ei_triangular_assignment_selector<Derived1, Derived2, StrictlyLowerTriang
{
for(int i = j+1; i < dst.rows(); ++i)
dst.copyCoeff(i, j, src);
int maxi = std::min(j, dst.rows());
int maxi = std::min(j, dst.rows()-1);
if (ClearOpposite)
for(int i = 0; i <= maxi; ++i)
dst.coeffRef(i, j) = 0;
@@ -432,9 +432,9 @@ struct ei_triangular_assignment_selector<Derived1, Derived2, UnitUpperTriangular
{
for(int i = maxi+1; i < dst.rows(); ++i)
dst.coeffRef(i, j) = 0;
dst.coeffRef(j, j) = 1;
}
}
dst.diagonal().setOnes();
}
};
template<typename Derived1, typename Derived2, bool ClearOpposite>
@@ -451,9 +451,9 @@ struct ei_triangular_assignment_selector<Derived1, Derived2, UnitLowerTriangular
{
for(int i = 0; i < maxi; ++i)
dst.coeffRef(i, j) = 0;
dst.coeffRef(j, j) = 1;
}
}
dst.diagonal().setOnes();
}
};