aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2010-01-15 00:35:26 -0500
committerGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2010-01-15 00:35:26 -0500
commitbfe6fdde2488c67ac8de01603d20167c61a788f2 (patch)
tree86b3d8250ff5bc707dc3761404d4ea4c575cbe00
parentddc32adb0e9b8683a5070bc78c1a1250d9313e85 (diff)
allow to multiply a householder sequence and a matrix when one is real and one is complex.
This is especially important as in bidiagonalization, the band matrix is real.
-rw-r--r--Eigen/src/Householder/HouseholderSequence.h29
-rw-r--r--test/upperbidiagonalization.cpp3
2 files changed, 24 insertions, 8 deletions
diff --git a/Eigen/src/Householder/HouseholderSequence.h b/Eigen/src/Householder/HouseholderSequence.h
index 61a8e8c1d..f8ae4136b 100644
--- a/Eigen/src/Householder/HouseholderSequence.h
+++ b/Eigen/src/Householder/HouseholderSequence.h
@@ -88,13 +88,28 @@ struct ei_hseq_side_dependent_impl<VectorsType, CoeffsType, OnTheRight>
}
};
+template<typename OtherScalarType, typename MatrixType> struct ei_matrix_type_times_scalar_type
+{
+ typedef typename ei_scalar_product_traits<OtherScalarType, typename MatrixType::Scalar>::ReturnType
+ ResultScalar;
+ typedef Matrix<ResultScalar, MatrixType::RowsAtCompileTime, MatrixType::ColsAtCompileTime,
+ 0, MatrixType::MaxRowsAtCompileTime, MatrixType::MaxColsAtCompileTime> Type;
+};
+
template<typename VectorsType, typename CoeffsType, int Side> class HouseholderSequence
: public AnyMatrixBase<HouseholderSequence<VectorsType,CoeffsType,Side> >
{
- typedef typename VectorsType::Scalar Scalar;
+ enum {
+ RowsAtCompileTime = ei_traits<HouseholderSequence>::RowsAtCompileTime,
+ ColsAtCompileTime = ei_traits<HouseholderSequence>::ColsAtCompileTime,
+ MaxRowsAtCompileTime = ei_traits<HouseholderSequence>::MaxRowsAtCompileTime,
+ MaxColsAtCompileTime = ei_traits<HouseholderSequence>::MaxColsAtCompileTime
+ };
+ typedef typename ei_traits<HouseholderSequence>::Scalar Scalar;
+
typedef typename ei_hseq_side_dependent_impl<VectorsType,CoeffsType,Side>::EssentialVectorType
EssentialVectorType;
-
+
public:
typedef HouseholderSequence<
@@ -179,17 +194,19 @@ template<typename VectorsType, typename CoeffsType, int Side> class HouseholderS
}
template<typename OtherDerived>
- typename OtherDerived::PlainMatrixType operator*(const MatrixBase<OtherDerived>& other) const
+ typename ei_matrix_type_times_scalar_type<Scalar, OtherDerived>::Type operator*(const MatrixBase<OtherDerived>& other) const
{
- typename OtherDerived::PlainMatrixType res(other);
+ typename ei_matrix_type_times_scalar_type<Scalar, OtherDerived>::Type
+ res(other.template cast<typename ei_matrix_type_times_scalar_type<Scalar, OtherDerived>::ResultScalar>());
applyThisOnTheLeft(res);
return res;
}
template<typename OtherDerived> friend
- typename OtherDerived::PlainMatrixType operator*(const MatrixBase<OtherDerived>& other, const HouseholderSequence& h)
+ typename ei_matrix_type_times_scalar_type<Scalar, OtherDerived>::Type operator*(const MatrixBase<OtherDerived>& other, const HouseholderSequence& h)
{
- typename OtherDerived::PlainMatrixType res(other);
+ typename ei_matrix_type_times_scalar_type<Scalar, OtherDerived>::Type
+ res(other.template cast<typename ei_matrix_type_times_scalar_type<Scalar, OtherDerived>::ResultScalar>());
h.applyThisOnTheRight(res);
return res;
}
diff --git a/test/upperbidiagonalization.cpp b/test/upperbidiagonalization.cpp
index e6f66a2d5..f64c1aed0 100644
--- a/test/upperbidiagonalization.cpp
+++ b/test/upperbidiagonalization.cpp
@@ -24,7 +24,6 @@
#include "main.h"
#include <Eigen/SVD>
-#include <Eigen/LU>
template<typename MatrixType> void upperbidiag(const MatrixType& m)
{
@@ -39,7 +38,7 @@ template<typename MatrixType> void upperbidiag(const MatrixType& m)
RealMatrixType b(rows, cols);
b.setZero();
b.block(0,0,cols,cols) = ubd.bidiagonal();
- MatrixType c = ubd.householderU() * b.template cast<Scalar>() * ubd.householderV().adjoint();
+ MatrixType c = ubd.householderU() * b * ubd.householderV().adjoint();
VERIFY_IS_APPROX(a,c);
}