mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-03 10:40:39 +08:00
bug #1182: Backported abs2 implementation from development branch
This commit is contained in:
parent
04d9fe13c6
commit
b4388ee38b
@ -218,8 +218,8 @@ struct conj_retval
|
|||||||
* Implementation of abs2 *
|
* Implementation of abs2 *
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
template<typename Scalar>
|
template<typename Scalar,bool IsComplex>
|
||||||
struct abs2_impl
|
struct abs2_impl_default
|
||||||
{
|
{
|
||||||
typedef typename NumTraits<Scalar>::Real RealScalar;
|
typedef typename NumTraits<Scalar>::Real RealScalar;
|
||||||
static inline RealScalar run(const Scalar& x)
|
static inline RealScalar run(const Scalar& x)
|
||||||
@ -228,15 +228,26 @@ struct abs2_impl
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename RealScalar>
|
template<typename Scalar>
|
||||||
struct abs2_impl<std::complex<RealScalar> >
|
struct abs2_impl_default<Scalar, true> // IsComplex
|
||||||
{
|
{
|
||||||
static inline RealScalar run(const std::complex<RealScalar>& x)
|
typedef typename NumTraits<Scalar>::Real RealScalar;
|
||||||
|
static inline RealScalar run(const Scalar& x)
|
||||||
{
|
{
|
||||||
return real(x)*real(x) + imag(x)*imag(x);
|
return real(x)*real(x) + imag(x)*imag(x);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename Scalar>
|
||||||
|
struct abs2_impl
|
||||||
|
{
|
||||||
|
typedef typename NumTraits<Scalar>::Real RealScalar;
|
||||||
|
static inline RealScalar run(const Scalar& x)
|
||||||
|
{
|
||||||
|
return abs2_impl_default<Scalar,NumTraits<Scalar>::IsComplex>::run(x);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template<typename Scalar>
|
template<typename Scalar>
|
||||||
struct abs2_retval
|
struct abs2_retval
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user