120 :
public EigenBase<HouseholderSequence<VectorsType,CoeffsType,Side> >
161 : m_vectors(v), m_coeffs(h), m_trans(
false), m_length(v.diagonalSize()),
168 : m_vectors(other.m_vectors),
169 m_coeffs(other.m_coeffs),
170 m_trans(other.m_trans),
171 m_length(other.m_length),
172 m_shift(other.m_shift)
204 eigen_assert(k >= 0 && k < m_length);
233 template<
typename DestType>
inline void evalTo(
DestType&
dst)
const
235 Matrix<Scalar, DestType::RowsAtCompileTime, 1,
241 template<
typename Dest,
typename Workspace>
242 void evalTo(Dest& dst, Workspace& workspace)
const
244 workspace.resize(
rows());
245 Index vecs = m_length;
246 if( internal::is_same<
typename internal::remove_all<VectorsType>::type,Dest>::value
247 && internal::extract_data(dst) == internal::extract_data(m_vectors))
250 dst.diagonal().setOnes();
251 dst.template triangularView<StrictlyUpper>().setZero();
252 for(
Index k = vecs-1; k >= 0; --k)
256 dst.bottomRightCorner(cornerSize, cornerSize)
257 .applyHouseholderOnTheRight(
essentialVector(k), m_coeffs.coeff(k), workspace.data());
259 dst.bottomRightCorner(cornerSize, cornerSize)
260 .applyHouseholderOnTheLeft(
essentialVector(k), m_coeffs.coeff(k), workspace.data());
263 dst.col(k).tail(
rows()-k-1).setZero();
267 dst.col(k).tail(
rows()-k-1).setZero();
272 for(
Index k = vecs-1; k >= 0; --k)
276 dst.bottomRightCorner(cornerSize, cornerSize)
277 .applyHouseholderOnTheRight(
essentialVector(k), m_coeffs.coeff(k), &workspace.coeffRef(0));
279 dst.bottomRightCorner(cornerSize, cornerSize)
280 .applyHouseholderOnTheLeft(
essentialVector(k), m_coeffs.coeff(k), &workspace.coeffRef(0));
286 template<
typename Dest>
inline void applyThisOnTheRight(Dest& dst)
const
289 applyThisOnTheRight(dst, workspace);
293 template<
typename Dest,
typename Workspace>
294 inline void applyThisOnTheRight(Dest& dst, Workspace& workspace)
const
296 workspace.resize(dst.rows());
297 for(
Index k = 0; k < m_length; ++k)
299 Index actual_k = m_trans ? m_length-k-1 : k;
300 dst.rightCols(
rows()-m_shift-actual_k)
301 .applyHouseholderOnTheRight(
essentialVector(actual_k), m_coeffs.coeff(actual_k), workspace.data());
306 template<
typename Dest>
inline void applyThisOnTheLeft(Dest& dst)
const
309 applyThisOnTheLeft(dst, workspace);
313 template<
typename Dest,
typename Workspace>
314 inline void applyThisOnTheLeft(Dest& dst, Workspace& workspace)
const
316 const Index BlockSize = 48;
318 if(m_length>=BlockSize && dst.cols()>1)
320 for(
Index i = 0; i < m_length; i+=BlockSize)
322 Index end = m_trans ? (std::min)(m_length,i+BlockSize) : m_length-i;
323 Index k = m_trans ? i : (std::max)(
Index(0),end-BlockSize);
325 Index start = k + m_shift;
327 typedef Block<typename internal::remove_all<VectorsType>::type,Dynamic,Dynamic> SubVectorsType;
328 SubVectorsType sub_vecs1(m_vectors.const_cast_derived(), Side==
OnTheRight ? k : start,
332 typename internal::conditional<Side==OnTheRight, Transpose<SubVectorsType>, SubVectorsType&>::type sub_vecs(sub_vecs1);
333 Block<Dest,Dynamic,Dynamic> sub_dst(dst,dst.rows()-
rows()+m_shift+k,0,
rows()-m_shift-k,dst.cols());
334 apply_block_householder_on_the_left(sub_dst, sub_vecs, m_coeffs.segment(k, bs), !m_trans);
339 workspace.resize(dst.cols());
340 for(
Index k = 0; k < m_length; ++k)
342 Index actual_k = m_trans ? k : m_length-k-1;
343 dst.bottomRows(
rows()-m_shift-actual_k)
344 .applyHouseholderOnTheLeft(
essentialVector(actual_k), m_coeffs.coeff(actual_k), workspace.data());
356 template<
typename OtherDerived>
360 res(other.template cast<
typename internal::matrix_type_times_scalar_type<Scalar,OtherDerived>::ResultScalar>());
361 applyThisOnTheLeft(res);
403 template <
typename VectorsType2,
typename CoeffsType2,
int S
ide2>
friend class HouseholderSequence;
421 bool trans()
const {
return m_trans; }
423 typename VectorsType::Nested m_vectors;
424 typename CoeffsType::Nested m_coeffs;
438template<
typename OtherDerived,
typename VectorsType,
typename CoeffsType,
int S
ide>
439typename internal::matrix_type_times_scalar_type<typename VectorsType::Scalar,OtherDerived>::Type operator*(
const MatrixBase<OtherDerived>& other,
const HouseholderSequence<VectorsType,CoeffsType,Side>& h)
441 typename internal::matrix_type_times_scalar_type<typename VectorsType::Scalar,OtherDerived>::Type
442 res(other.template cast<
typename internal::matrix_type_times_scalar_type<typename VectorsType::Scalar,OtherDerived>::ResultScalar>());
443 h.applyThisOnTheRight(res);
451template<
typename VectorsType,
typename CoeffsType>
452HouseholderSequence<VectorsType,CoeffsType> householderSequence(
const VectorsType& v,
const CoeffsType& h)
454 return HouseholderSequence<VectorsType,CoeffsType,OnTheLeft>(v, h);
463template<
typename VectorsType,
typename CoeffsType>
464HouseholderSequence<VectorsType,CoeffsType,OnTheRight> rightHouseholderSequence(
const VectorsType& v,
const CoeffsType& h)
466 return HouseholderSequence<VectorsType,CoeffsType,OnTheRight>(v, h);