mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user