Stability fix: hinv inverse of truly singular tensors
This commit is contained in:
parent
7fc1abd4b7
commit
7ea4631c84
1 changed files with 12 additions and 0 deletions
|
@ -658,6 +658,12 @@ tensor hinv(const tensor& t)
|
|||
zeroInv += tensor(sqr(eigVecs.y()));
|
||||
}
|
||||
|
||||
if (det(t + zeroInv) < VSMALL)
|
||||
{
|
||||
// Determinant is still zero. Return zero inverse
|
||||
return tensor::zero;
|
||||
}
|
||||
|
||||
return inv(t + zeroInv) - zeroInv;
|
||||
}
|
||||
}
|
||||
|
@ -705,6 +711,12 @@ symmTensor hinv(const symmTensor& t)
|
|||
zeroInv += sqr(eigVecs.y());
|
||||
}
|
||||
|
||||
if (det(t + zeroInv) < VSMALL)
|
||||
{
|
||||
// Determinant is still zero. Return zero inverse
|
||||
return symmTensor::zero;
|
||||
}
|
||||
|
||||
return inv(t + zeroInv) - zeroInv;
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue