Bugzilla – Attachment 152 Details for
Bug 206
JacobiSVD problem size constructor does not preallocate all of its resources
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Forgot Password
Login:
[x]
This bugzilla service is closed. All entries have been migrated to
https://gitlab.com/libeigen/eigen
[patch]
part 2: Non-allocating versions of HouseholderSequence::applyThisOnTheRight/Left
HouseHolderSequence.patch (text/plain), 5.60 KB, created by
Adolfo Rodriguez Tsouroukdissian
on 2011-04-07 13:13:22 UTC
(
hide
)
Description:
part 2: Non-allocating versions of HouseholderSequence::applyThisOnTheRight/Left
Filename:
MIME Type:
Creator:
Adolfo Rodriguez Tsouroukdissian
Created:
2011-04-07 13:13:22 UTC
Size:
5.60 KB
patch
obsolete
>For HouseholderSequence objects, added non-allocating versions of evalTo() and applyThisOnTheRight/Left that take additional working vector parameters. > >diff --git a/Eigen/src/Householder/HouseholderSequence.h b/Eigen/src/Householder/HouseholderSequence.h >--- a/Eigen/src/Householder/HouseholderSequence.h >+++ b/Eigen/src/Householder/HouseholderSequence.h >@@ -232,82 +232,105 @@ template<typename VectorsType, typename > { > return conjugate().setTrans(!m_trans); > } > > /** \brief Inverse of the Householder sequence (equals the adjoint). */ > ConjugateReturnType inverse() const { return adjoint(); } > > /** \internal */ >- template<typename DestType> void evalTo(DestType& dst) const >+ template<typename DestType> inline void evalTo(DestType& dst) const > { >+ Matrix<Scalar, DestType::RowsAtCompileTime, 1, >+ AutoAlign|ColMajor, DestType::MaxRowsAtCompileTime, 1> workspace(rows()); >+ evalTo(dst, workspace); >+ } >+ >+ /** \internal */ >+ template<typename Dest, typename Workspace> >+ void evalTo(Dest& dst, MatrixBase<Workspace>& workspace) const >+ { >+ workspace.derived().resize(rows()); > Index vecs = m_length; >- // FIXME find a way to pass this temporary if the user wants to >- Matrix<Scalar, DestType::RowsAtCompileTime, 1, >- AutoAlign|ColMajor, DestType::MaxRowsAtCompileTime, 1> temp(rows()); >- if( internal::is_same<typename internal::remove_all<VectorsType>::type,DestType>::value >+ if( internal::is_same<typename internal::remove_all<VectorsType>::type,Dest>::value > && internal::extract_data(dst) == internal::extract_data(m_vectors)) > { > // in-place > dst.diagonal().setOnes(); > dst.template triangularView<StrictlyUpper>().setZero(); > for(Index k = vecs-1; k >= 0; --k) > { > Index cornerSize = rows() - k - m_shift; > if(m_trans) > dst.bottomRightCorner(cornerSize, cornerSize) >- .applyHouseholderOnTheRight(essentialVector(k), m_coeffs.coeff(k), &temp.coeffRef(0)); >+ .applyHouseholderOnTheRight(essentialVector(k), m_coeffs.coeff(k), &workspace.coeffRef(0)); > else > dst.bottomRightCorner(cornerSize, cornerSize) >- .applyHouseholderOnTheLeft(essentialVector(k), m_coeffs.coeff(k), &temp.coeffRef(0)); >+ .applyHouseholderOnTheLeft(essentialVector(k), m_coeffs.coeff(k), &workspace.coeffRef(0)); > > // clear the off diagonal vector > dst.col(k).tail(rows()-k-1).setZero(); > } > // clear the remaining columns if needed > for(Index k = 0; k<cols()-vecs ; ++k) > dst.col(k).tail(rows()-k-1).setZero(); > } > else > { > dst.setIdentity(rows(), rows()); > for(Index k = vecs-1; k >= 0; --k) > { > Index cornerSize = rows() - k - m_shift; > if(m_trans) > dst.bottomRightCorner(cornerSize, cornerSize) >- .applyHouseholderOnTheRight(essentialVector(k), m_coeffs.coeff(k), &temp.coeffRef(0)); >+ .applyHouseholderOnTheRight(essentialVector(k), m_coeffs.coeff(k), &workspace.coeffRef(0)); > else > dst.bottomRightCorner(cornerSize, cornerSize) >- .applyHouseholderOnTheLeft(essentialVector(k), m_coeffs.coeff(k), &temp.coeffRef(0)); >+ .applyHouseholderOnTheLeft(essentialVector(k), m_coeffs.coeff(k), &workspace.coeffRef(0)); > } > } > } > > /** \internal */ > template<typename Dest> inline void applyThisOnTheRight(Dest& dst) const > { >- Matrix<Scalar,1,Dest::RowsAtCompileTime> temp(dst.rows()); >+ Matrix<Scalar,1,Dest::RowsAtCompileTime,RowMajor,1,Dest::MaxRowsAtCompileTime> workspace(dst.rows()); >+ applyThisOnTheRight(dst, workspace); >+ } >+ >+ /** \internal */ >+ template<typename Dest, typename Workspace> >+ inline void applyThisOnTheRight(Dest& dst, MatrixBase<Workspace>& workspace) const >+ { >+ workspace.derived().resize(dst.rows()); > for(Index k = 0; k < m_length; ++k) > { > Index actual_k = m_trans ? m_length-k-1 : k; > dst.rightCols(rows()-m_shift-actual_k) >- .applyHouseholderOnTheRight(essentialVector(actual_k), m_coeffs.coeff(actual_k), &temp.coeffRef(0)); >+ .applyHouseholderOnTheRight(essentialVector(actual_k), m_coeffs.coeff(actual_k), &workspace.coeffRef(0)); > } > } > > /** \internal */ > template<typename Dest> inline void applyThisOnTheLeft(Dest& dst) const > { >- Matrix<Scalar,1,Dest::ColsAtCompileTime> temp(dst.cols()); >+ Matrix<Scalar,1,Dest::ColsAtCompileTime,RowMajor,1,Dest::MaxColsAtCompileTime> workspace(dst.cols()); >+ applyThisOnTheLeft(dst, workspace); >+ } >+ >+ /** \internal */ >+ template<typename Dest, typename Workspace> >+ inline void applyThisOnTheLeft(Dest& dst, MatrixBase<Workspace>& workspace) const >+ { >+ workspace.derived().resize(dst.cols()); > for(Index k = 0; k < m_length; ++k) > { > Index actual_k = m_trans ? k : m_length-k-1; > dst.bottomRows(rows()-m_shift-actual_k) >- .applyHouseholderOnTheLeft(essentialVector(actual_k), m_coeffs.coeff(actual_k), &temp.coeffRef(0)); >+ .applyHouseholderOnTheLeft(essentialVector(actual_k), m_coeffs.coeff(actual_k), &workspace.coeffRef(0)); > } > } > > /** \brief Computes the product of a Householder sequence with a matrix. > * \param[in] other %Matrix being multiplied. > * \returns Expression object representing the product. > * > * This function computes \f$ HM \f$ where \f$ H \f$ is the Householder sequence represented by \p *this
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 206
:
110
|
115
|
119
|
125
|
126
|
128
|
132
|
134
|
135
|
136
|
137
|
138
|
152
|
153
|
154
|
158
|
159