mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-20 11:56:17 +08:00
fix bug #478: RealSchur failed on a zero matrix.
This commit is contained in:
parent
c8346abcdd
commit
b96b429aa2
@ -239,38 +239,40 @@ RealSchur<MatrixType>& RealSchur<MatrixType>::compute(const MatrixType& matrix,
|
|||||||
Scalar exshift(0); // sum of exceptional shifts
|
Scalar exshift(0); // sum of exceptional shifts
|
||||||
Scalar norm = computeNormOfT();
|
Scalar norm = computeNormOfT();
|
||||||
|
|
||||||
while (iu >= 0)
|
if(norm!=0)
|
||||||
{
|
{
|
||||||
Index il = findSmallSubdiagEntry(iu, norm);
|
while (iu >= 0)
|
||||||
|
{
|
||||||
|
Index il = findSmallSubdiagEntry(iu, norm);
|
||||||
|
|
||||||
// Check for convergence
|
// Check for convergence
|
||||||
if (il == iu) // One root found
|
if (il == iu) // One root found
|
||||||
{
|
{
|
||||||
m_matT.coeffRef(iu,iu) = m_matT.coeff(iu,iu) + exshift;
|
m_matT.coeffRef(iu,iu) = m_matT.coeff(iu,iu) + exshift;
|
||||||
if (iu > 0)
|
if (iu > 0)
|
||||||
m_matT.coeffRef(iu, iu-1) = Scalar(0);
|
m_matT.coeffRef(iu, iu-1) = Scalar(0);
|
||||||
iu--;
|
iu--;
|
||||||
iter = 0;
|
iter = 0;
|
||||||
}
|
}
|
||||||
else if (il == iu-1) // Two roots found
|
else if (il == iu-1) // Two roots found
|
||||||
{
|
{
|
||||||
splitOffTwoRows(iu, computeU, exshift);
|
splitOffTwoRows(iu, computeU, exshift);
|
||||||
iu -= 2;
|
iu -= 2;
|
||||||
iter = 0;
|
iter = 0;
|
||||||
}
|
}
|
||||||
else // No convergence yet
|
else // No convergence yet
|
||||||
{
|
{
|
||||||
// The firstHouseholderVector vector has to be initialized to something to get rid of a silly GCC warning (-O1 -Wall -DNDEBUG )
|
// The firstHouseholderVector vector has to be initialized to something to get rid of a silly GCC warning (-O1 -Wall -DNDEBUG )
|
||||||
Vector3s firstHouseholderVector(0,0,0), shiftInfo;
|
Vector3s firstHouseholderVector(0,0,0), shiftInfo;
|
||||||
computeShift(iu, iter, exshift, shiftInfo);
|
computeShift(iu, iter, exshift, shiftInfo);
|
||||||
iter = iter + 1;
|
iter = iter + 1;
|
||||||
if (iter > m_maxIterations) break;
|
if (iter > m_maxIterations) break;
|
||||||
Index im;
|
Index im;
|
||||||
initFrancisQRStep(il, iu, shiftInfo, im, firstHouseholderVector);
|
initFrancisQRStep(il, iu, shiftInfo, im, firstHouseholderVector);
|
||||||
performFrancisQRStep(il, im, iu, computeU, firstHouseholderVector, workspace);
|
performFrancisQRStep(il, im, iu, computeU, firstHouseholderVector, workspace);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(iter <= m_maxIterations)
|
if(iter <= m_maxIterations)
|
||||||
m_info = Success;
|
m_info = Success;
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user