in ScalarMultiple, make the factor type independent from the matrix scalar type.

This is an optimization for complex matrices, allowing to do only a real multiplication
when a complex multiplication is not needed, e.g. in normalized().
This commit is contained in:
Benoit Jacob
2007-12-26 08:30:21 +00:00
parent dad245af56
commit 05a49547e1
5 changed files with 40 additions and 22 deletions

View File

@@ -172,4 +172,21 @@ inline bool isApprox(const std::complex<double>& a, const std::complex<double>&
}
// isApproxOrLessThan wouldn't make sense for complex numbers
#define EIGEN_MAKE_MORE_OVERLOADED_COMPLEX_OPERATOR_STAR(T,U) \
inline std::complex<T> operator*(U a, const std::complex<T>& b) \
{ \
return std::complex<T>(static_cast<T>(a)*b.real(), \
static_cast<T>(a)*b.imag()); \
} \
inline std::complex<T> operator*(const std::complex<T>& b, U a) \
{ \
return std::complex<T>(static_cast<T>(a)*b.real(), \
static_cast<T>(a)*b.imag()); \
}
EIGEN_MAKE_MORE_OVERLOADED_COMPLEX_OPERATOR_STAR(int, float)
EIGEN_MAKE_MORE_OVERLOADED_COMPLEX_OPERATOR_STAR(int, double)
EIGEN_MAKE_MORE_OVERLOADED_COMPLEX_OPERATOR_STAR(float, double)
EIGEN_MAKE_MORE_OVERLOADED_COMPLEX_OPERATOR_STAR(double, float)
#endif // EIGEN_MATHFUNCTIONS_H