diff options
author | Gael Guennebaud <g.gael@free.fr> | 2009-07-27 13:17:39 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2009-07-27 13:17:39 +0200 |
commit | 0590c18555bd5d195e29ee6a131285cf0f80f9d1 (patch) | |
tree | a7c26663e1f1c7b72e666889cb1bf7d4c0df01b7 /Eigen/src | |
parent | b5e40642898e3af17e67a7b78fa3b63191e11bb7 (diff) |
various compilation and bug fixes in selfadjoint stuff
Diffstat (limited to 'Eigen/src')
-rw-r--r-- | Eigen/src/Core/SelfAdjointView.h | 13 | ||||
-rw-r--r-- | Eigen/src/Core/products/SelfadjointMatrixVector.h | 3 | ||||
-rw-r--r-- | Eigen/src/Core/products/SelfadjointProduct.h | 2 | ||||
-rw-r--r-- | Eigen/src/Core/products/SelfadjointRank2Update.h | 10 | ||||
-rw-r--r-- | Eigen/src/QR/Tridiagonalization.h | 18 |
5 files changed, 23 insertions, 23 deletions
diff --git a/Eigen/src/Core/SelfAdjointView.h b/Eigen/src/Core/SelfAdjointView.h index 4787bcbd8..3faebfc5d 100644 --- a/Eigen/src/Core/SelfAdjointView.h +++ b/Eigen/src/Core/SelfAdjointView.h @@ -125,20 +125,24 @@ template<typename MatrixType, unsigned int UpLo> class SelfAdjointView * The vectors \a u and \c v \b must be column vectors, however they can be * a adjoint expression without any overhead. Only the meaningful triangular * part of the matrix is updated, the rest is left unchanged. + * + * \sa rankUpdate(const MatrixBase<DerivedU>&, Scalar) */ template<typename DerivedU, typename DerivedV> - SelfAdjointView& rank2update(const MatrixBase<DerivedU>& u, const MatrixBase<DerivedV>& v, Scalar alpha = Scalar(1)); + SelfAdjointView& rankUpdate(const MatrixBase<DerivedU>& u, const MatrixBase<DerivedV>& v, Scalar alpha = Scalar(1)); /** Perform a symmetric rank K update of the selfadjoint matrix \c *this: * \f$ this = this + \alpha ( u u^* ) \f$ where \a u is a vector or matrix. - * + * * \returns a reference to \c *this * * Note that to perform \f$ this = this + \alpha ( u^* u ) \f$ you can simply * call this function with u.adjoint(). + * + * \sa rankUpdate(const MatrixBase<DerivedU>&, const MatrixBase<DerivedV>&, Scalar) */ template<typename DerivedU> - SelfAdjointView& rankKupdate(const MatrixBase<DerivedU>& u, Scalar alpha = Scalar(1)); + SelfAdjointView& rankUpdate(const MatrixBase<DerivedU>& u, Scalar alpha = Scalar(1)); /////////// Cholesky module /////////// @@ -231,13 +235,14 @@ struct ei_selfadjoint_product_returntype<Lhs,LhsMode,false,Rhs,0,true> template<typename Dest> void evalTo(Dest& dst) const { - dst.resize(m_lhs.rows(), m_rhs.cols()); dst.setZero(); evalTo(dst,1); } template<typename Dest> void evalTo(Dest& dst, Scalar alpha) const { + ei_assert(dst.rows()==m_lhs.rows() && dst.cols()==m_rhs.cols()); + const ActualLhsType lhs = LhsBlasTraits::extract(m_lhs); const ActualRhsType rhs = RhsBlasTraits::extract(m_rhs); diff --git a/Eigen/src/Core/products/SelfadjointMatrixVector.h b/Eigen/src/Core/products/SelfadjointMatrixVector.h index 8e0dc9526..279836f8a 100644 --- a/Eigen/src/Core/products/SelfadjointMatrixVector.h +++ b/Eigen/src/Core/products/SelfadjointMatrixVector.h @@ -63,9 +63,6 @@ static EIGEN_DONT_INLINE void ei_product_selfadjoint_vector( rhs = r; } - for (int i=0;i<size;i++) - res[i] = 0; - int bound = std::max(0,size-8) & 0xfffffffE; if (FirstTriangular) bound = size - bound; diff --git a/Eigen/src/Core/products/SelfadjointProduct.h b/Eigen/src/Core/products/SelfadjointProduct.h index d971720d6..f6420d10c 100644 --- a/Eigen/src/Core/products/SelfadjointProduct.h +++ b/Eigen/src/Core/products/SelfadjointProduct.h @@ -126,7 +126,7 @@ struct ei_selfadjoint_product<Scalar,MatStorageOrder, ColMajor, AAT, UpLo> template<typename MatrixType, unsigned int UpLo> template<typename DerivedU> SelfAdjointView<MatrixType,UpLo>& SelfAdjointView<MatrixType,UpLo> -::rankKupdate(const MatrixBase<DerivedU>& u, Scalar alpha) +::rankUpdate(const MatrixBase<DerivedU>& u, Scalar alpha) { typedef ei_blas_traits<DerivedU> UBlasTraits; typedef typename UBlasTraits::DirectLinearAccessType ActualUType; diff --git a/Eigen/src/Core/products/SelfadjointRank2Update.h b/Eigen/src/Core/products/SelfadjointRank2Update.h index 65a321fde..f7dcc003f 100644 --- a/Eigen/src/Core/products/SelfadjointRank2Update.h +++ b/Eigen/src/Core/products/SelfadjointRank2Update.h @@ -41,7 +41,7 @@ struct ei_selfadjoint_rank2_update_selector<Scalar,UType,VType,LowerTriangular> // std::cerr << "lower \n" << u.transpose() << "\n" << v.transpose() << "\n\n"; for (int i=0; i<size; ++i) { -// std::cerr << +// std::cerr << Map<Matrix<Scalar,Dynamic,1> >(mat+stride*i+i, size-i) += (alpha * ei_conj(u.coeff(i))) * v.end(size-i) + (alpha * ei_conj(v.coeff(i))) * u.end(size-i); @@ -70,13 +70,13 @@ template<bool Cond, typename T> struct ei_conj_expr_if template<typename MatrixType, unsigned int UpLo> template<typename DerivedU, typename DerivedV> SelfAdjointView<MatrixType,UpLo>& SelfAdjointView<MatrixType,UpLo> -::rank2update(const MatrixBase<DerivedU>& u, const MatrixBase<DerivedV>& v, Scalar alpha) +::rankUpdate(const MatrixBase<DerivedU>& u, const MatrixBase<DerivedV>& v, Scalar alpha) { typedef ei_blas_traits<DerivedU> UBlasTraits; typedef typename UBlasTraits::DirectLinearAccessType ActualUType; typedef typename ei_cleantype<ActualUType>::type _ActualUType; const ActualUType actualU = UBlasTraits::extract(u.derived()); - + typedef ei_blas_traits<DerivedV> VBlasTraits; typedef typename VBlasTraits::DirectLinearAccessType ActualVType; typedef typename ei_cleantype<ActualVType>::type _ActualVType; @@ -87,8 +87,8 @@ SelfAdjointView<MatrixType,UpLo>& SelfAdjointView<MatrixType,UpLo> enum { IsRowMajor = (ei_traits<MatrixType>::Flags&RowMajorBit)?1:0 }; ei_selfadjoint_rank2_update_selector<Scalar, - typename ei_conj_expr_if<IsRowMajor ^ UBlasTraits::NeedToConjugate,_ActualUType>::ret, - typename ei_conj_expr_if<IsRowMajor ^ VBlasTraits::NeedToConjugate,_ActualVType>::ret, + 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, (IsRowMajor ? (UpLo==UpperTriangular ? LowerTriangular : UpperTriangular) : UpLo)> ::run(const_cast<Scalar*>(_expression().data()),_expression().stride(),actualU,actualV,actualAlpha); diff --git a/Eigen/src/QR/Tridiagonalization.h b/Eigen/src/QR/Tridiagonalization.h index cf737bd30..a003fd59a 100644 --- a/Eigen/src/QR/Tridiagonalization.h +++ b/Eigen/src/QR/Tridiagonalization.h @@ -224,21 +224,19 @@ void Tridiagonalization<MatrixType>::_compute(MatrixType& matA, CoeffVectorType& // Apply similarity transformation to remaining columns, // i.e., A = H' A H where H = I - h v v' and v = matA.col(i).end(n-i-1) - matA.col(i).coeffRef(i+1) = 1; - // hCoeffs.end(n-i-1) = (matA.corner(BottomRight,n-i-1,n-i-1).template part<LowerTriangular|SelfAdjoint>() - // * matA.col(i).end(n-i-1)).lazy(); - // TODO map the above code to the function call below: - ei_product_selfadjoint_vector<Scalar,MatrixType::Flags&RowMajorBit,LowerTriangularBit> - (n-i-1,matA.corner(BottomRight,n-i-1,n-i-1).data(), matA.stride(), matA.col(i).end(n-i-1).data(), const_cast<Scalar*>(hCoeffs.end(n-i-1).data())); +// hCoeffs.end(n-i-1) = (matA.corner(BottomRight,n-i-1,n-i-1).template selfadjointView<LowerTriangular>() +// * (h * matA.col(i).end(n-i-1))); + + hCoeffs.end(n-i-1).setZero(); + ei_product_selfadjoint_vector<Scalar,MatrixType::Flags&RowMajorBit,LowerTriangular,false,false> + (n-i-1,matA.corner(BottomRight,n-i-1,n-i-1).data(), matA.stride(), matA.col(i).end(n-i-1).data(), 1, const_cast<Scalar*>(hCoeffs.end(n-i-1).data()), h); - hCoeffs.end(n-i-1) = hCoeffs.end(n-i-1)*h - + (h*ei_conj(h)*Scalar(-0.5)*(matA.col(i).end(n-i-1).dot(hCoeffs.end(n-i-1)))) * - matA.col(i).end(n-i-1); + hCoeffs.end(n-i-1) += (h*Scalar(-0.5)*(matA.col(i).end(n-i-1).dot(hCoeffs.end(n-i-1)))) * matA.col(i).end(n-i-1); matA.corner(BottomRight, n-i-1, n-i-1).template selfadjointView<LowerTriangular>() - .rank2update(matA.col(i).end(n-i-1), hCoeffs.end(n-i-1), -1); + .rankUpdate(matA.col(i).end(n-i-1), hCoeffs.end(n-i-1), -1); // note: at that point matA(i+1,i+1) is the (i+1)-th element of the final diagonal // note: the sequence of the beta values leads to the subdiagonal entries |