diff options
Diffstat (limited to 'Eigen/src/Core/products/SelfadjointRank2Update.h')
-rw-r--r-- | Eigen/src/Core/products/SelfadjointRank2Update.h | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/Eigen/src/Core/products/SelfadjointRank2Update.h b/Eigen/src/Core/products/SelfadjointRank2Update.h index a617f1cc6..13b088031 100644 --- a/Eigen/src/Core/products/SelfadjointRank2Update.h +++ b/Eigen/src/Core/products/SelfadjointRank2Update.h @@ -25,15 +25,17 @@ #ifndef EIGEN_SELFADJOINTRANK2UPTADE_H #define EIGEN_SELFADJOINTRANK2UPTADE_H +namespace internal { + /* Optimized selfadjoint matrix += alpha * uv' + vu' * It corresponds to the Level2 syr2 BLAS routine */ template<typename Scalar, typename Index, typename UType, typename VType, int UpLo> -struct ei_selfadjoint_rank2_update_selector; +struct selfadjoint_rank2_update_selector; template<typename Scalar, typename Index, typename UType, typename VType> -struct ei_selfadjoint_rank2_update_selector<Scalar,Index,UType,VType,Lower> +struct selfadjoint_rank2_update_selector<Scalar,Index,UType,VType,Lower> { static void run(Scalar* mat, Index stride, const UType& u, const VType& v, Scalar alpha) { @@ -41,52 +43,53 @@ struct ei_selfadjoint_rank2_update_selector<Scalar,Index,UType,VType,Lower> for (Index i=0; i<size; ++i) { Map<Matrix<Scalar,Dynamic,1> >(mat+stride*i+i, size-i) += - (alpha * ei_conj(u.coeff(i))) * v.tail(size-i) - + (alpha * ei_conj(v.coeff(i))) * u.tail(size-i); + (alpha * conj(u.coeff(i))) * v.tail(size-i) + + (alpha * conj(v.coeff(i))) * u.tail(size-i); } } }; template<typename Scalar, typename Index, typename UType, typename VType> -struct ei_selfadjoint_rank2_update_selector<Scalar,Index,UType,VType,Upper> +struct selfadjoint_rank2_update_selector<Scalar,Index,UType,VType,Upper> { static void run(Scalar* mat, Index stride, const UType& u, const VType& v, Scalar alpha) { const Index size = u.size(); for (Index i=0; i<size; ++i) Map<Matrix<Scalar,Dynamic,1> >(mat+stride*i, i+1) += - (alpha * ei_conj(u.coeff(i))) * v.head(i+1) - + (alpha * ei_conj(v.coeff(i))) * u.head(i+1); + (alpha * conj(u.coeff(i))) * v.head(i+1) + + (alpha * conj(v.coeff(i))) * u.head(i+1); } }; -template<bool Cond, typename T> struct ei_conj_expr_if - : ei_meta_if<!Cond, const T&, - CwiseUnaryOp<ei_scalar_conjugate_op<typename ei_traits<T>::Scalar>,T> > {}; +template<bool Cond, typename T> struct conj_expr_if + : meta_if<!Cond, const T&, + CwiseUnaryOp<scalar_conjugate_op<typename traits<T>::Scalar>,T> > {}; +} // end namespace internal template<typename MatrixType, unsigned int UpLo> template<typename DerivedU, typename DerivedV> SelfAdjointView<MatrixType,UpLo>& SelfAdjointView<MatrixType,UpLo> ::rankUpdate(const MatrixBase<DerivedU>& u, const MatrixBase<DerivedV>& v, Scalar alpha) { - typedef ei_blas_traits<DerivedU> UBlasTraits; + typedef internal::blas_traits<DerivedU> UBlasTraits; typedef typename UBlasTraits::DirectLinearAccessType ActualUType; - typedef typename ei_cleantype<ActualUType>::type _ActualUType; + typedef typename internal::cleantype<ActualUType>::type _ActualUType; const ActualUType actualU = UBlasTraits::extract(u.derived()); - typedef ei_blas_traits<DerivedV> VBlasTraits; + typedef internal::blas_traits<DerivedV> VBlasTraits; typedef typename VBlasTraits::DirectLinearAccessType ActualVType; - typedef typename ei_cleantype<ActualVType>::type _ActualVType; + typedef typename internal::cleantype<ActualVType>::type _ActualVType; const ActualVType actualV = VBlasTraits::extract(v.derived()); Scalar actualAlpha = alpha * UBlasTraits::extractScalarFactor(u.derived()) * VBlasTraits::extractScalarFactor(v.derived()); - enum { IsRowMajor = (ei_traits<MatrixType>::Flags&RowMajorBit) ? 1 : 0 }; - ei_selfadjoint_rank2_update_selector<Scalar, Index, - typename ei_cleantype<typename ei_conj_expr_if<IsRowMajor ^ UBlasTraits::NeedToConjugate,_ActualUType>::ret>::type, - typename ei_cleantype<typename ei_conj_expr_if<IsRowMajor ^ VBlasTraits::NeedToConjugate,_ActualVType>::ret>::type, + enum { IsRowMajor = (internal::traits<MatrixType>::Flags&RowMajorBit) ? 1 : 0 }; + internal::selfadjoint_rank2_update_selector<Scalar, Index, + typename internal::cleantype<typename internal::conj_expr_if<IsRowMajor ^ UBlasTraits::NeedToConjugate,_ActualUType>::ret>::type, + typename internal::cleantype<typename internal::conj_expr_if<IsRowMajor ^ VBlasTraits::NeedToConjugate,_ActualVType>::ret>::type, (IsRowMajor ? int(UpLo==Upper ? Lower : Upper) : UpLo)> ::run(const_cast<Scalar*>(_expression().data()),_expression().outerStride(),actualU,actualV,actualAlpha); |