Re: [eigen] inverse unit test |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: Eigen <eigen@xxxxxxxxxxxxxxxxxxx>
- Subject: Re: [eigen] inverse unit test
- From: Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>
- Date: Thu, 10 Jun 2010 00:55:33 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=uEePxxyoceTAsXq4mDkQ5RskGoWV0bCuoMI0O2mtJzU=; b=Ssy287w+bY22qLhzx6RJZviIEqi97FeU/N/fdz+npVhwXx6/I3aCwk+5uOlK06eElr YKguOVbO31ourKApi+RNNj9d8+xPmaGGYmhla8YqkSgfbrRLIQ0tDZXQu8fxHMLg8QXo cmjV0w42bnNkZhmXFRWGD8mTyb/oO44Zgppww=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=guc+O4HE2Uhc39pqUMQEvF0UzY0IgXYEA8XiQn+yXglWj5KLiTaIrjGjEwRtTMvkV4 R+w03vNCH4BAEgOR4vmFVp9dmTk8ZHHoGgRNlxeEjVe/rYv8/j9KbxsO0YZNfW7OIZLL YSGnTKtxjnNGDAGUVOh1PqjIY5W2lOwm7miwg=
Maybe this simple hack is all we need:
static inline bool isApprox(const Scalar& x, const Scalar& y, const
RealScalar& prec)
{
return (ei_abs(x - y) <= std::min(ei_abs(x), ei_abs(y)) * prec ||
ei_abs(x - y) < NumTraits<Scalar>::epsilon());
}
- Hauke
On Thu, Jun 10, 2010 at 12:43 AM, Hauke Heibel
<hauke.heibel@xxxxxxxxxxxxxx> wrote:
> On MSVC the inverse unit test fails here:
>
> //Second: a rank one matrix (not invertible, except for 1x1 matrices)
> VectorType v3 = VectorType::Random(rows);
> MatrixType m3 = v3*v3.transpose(), m4(rows,cols);
> m3.computeInverseAndDetWithCheck(m4, det, invertible);
> VERIFY( rows==1 ? invertible : !invertible );
> VERIFY_IS_APPROX(det, m3.determinant());
> m3.computeInverseWithCheck(m4, invertible);
> VERIFY( rows==1 ? invertible : !invertible );
>
> We expect a determinant of 0 since the matrix is not invertible and
> then this check fails
>
> VERIFY_IS_APPROX(det, m3.determinant());
>
> VERIFY_IS_APPROX will always fail in case one of the two parameters is
> zero and in case both values are small it is likely to fail as well
> because
>
> abs(x-y) <= min(abs(x),abs(y)) * 1e-3
>
> here, we take the minimal value and make it even smaller.
>
> Here are some nice comparison methods we might try to adapt:
> http://www.boost.org/doc/libs/1_32_0/boost/test/floating_point_comparison..hpp
>
> - Hauke
>