mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Set cost of conjugate to 0 (in practice it boils down to a no-op).
This is also important to make sure that A.conjugate() * B.conjugate() does not evaluate its arguments into temporaries (e.g., if A and B are fixed and small, or * fall back to lazyProduct)
This commit is contained in:
@@ -117,7 +117,15 @@ template<typename Scalar>
|
||||
struct functor_traits<scalar_conjugate_op<Scalar> >
|
||||
{
|
||||
enum {
|
||||
Cost = NumTraits<Scalar>::IsComplex ? NumTraits<Scalar>::AddCost : 0,
|
||||
Cost = 0,
|
||||
// Yes the cost is zero even for complexes because in most cases for which
|
||||
// the cost is used, conjugation turns to be a no-op. Some examples:
|
||||
// cost(a*conj(b)) == cost(a*b)
|
||||
// cost(a+conj(b)) == cost(a+b)
|
||||
// <etc.
|
||||
// If we don't set it to zero, then:
|
||||
// A.conjugate().lazyProduct(B.conjugate())
|
||||
// will bake its operands. We definitely don't want that!
|
||||
PacketAccess = packet_traits<Scalar>::HasConj
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user