Renamed .trans() et al. to .reverseFlag() et at. Adapted documentation of .setReverseFlag()

This commit is contained in:
Christoph Hertzberg 2018-04-17 11:30:27 +02:00
parent 39c2cba810
commit 50633d1a83

View File

@ -174,7 +174,7 @@ template<typename VectorsType, typename CoeffsType, int Side> class HouseholderS
* \sa setLength(), setShift() * \sa setLength(), setShift()
*/ */
HouseholderSequence(const VectorsType& v, const CoeffsType& h) HouseholderSequence(const VectorsType& v, const CoeffsType& h)
: m_vectors(v), m_coeffs(h), m_trans(false), m_length(v.diagonalSize()), : m_vectors(v), m_coeffs(h), m_reverse(false), m_length(v.diagonalSize()),
m_shift(0) m_shift(0)
{ {
} }
@ -183,7 +183,7 @@ template<typename VectorsType, typename CoeffsType, int Side> class HouseholderS
HouseholderSequence(const HouseholderSequence& other) HouseholderSequence(const HouseholderSequence& other)
: m_vectors(other.m_vectors), : m_vectors(other.m_vectors),
m_coeffs(other.m_coeffs), m_coeffs(other.m_coeffs),
m_trans(other.m_trans), m_reverse(other.m_reverse),
m_length(other.m_length), m_length(other.m_length),
m_shift(other.m_shift) m_shift(other.m_shift)
{ {
@ -225,7 +225,7 @@ template<typename VectorsType, typename CoeffsType, int Side> class HouseholderS
TransposeReturnType transpose() const TransposeReturnType transpose() const
{ {
return TransposeReturnType(m_vectors.conjugate(), m_coeffs) return TransposeReturnType(m_vectors.conjugate(), m_coeffs)
.setTrans(!m_trans) .setReverseFlag(!m_reverse)
.setLength(m_length) .setLength(m_length)
.setShift(m_shift); .setShift(m_shift);
} }
@ -234,7 +234,7 @@ template<typename VectorsType, typename CoeffsType, int Side> class HouseholderS
ConjugateReturnType conjugate() const ConjugateReturnType conjugate() const
{ {
return ConjugateReturnType(m_vectors.conjugate(), m_coeffs.conjugate()) return ConjugateReturnType(m_vectors.conjugate(), m_coeffs.conjugate())
.setTrans(m_trans) .setReverseFlag(m_reverse)
.setLength(m_length) .setLength(m_length)
.setShift(m_shift); .setShift(m_shift);
} }
@ -243,7 +243,7 @@ template<typename VectorsType, typename CoeffsType, int Side> class HouseholderS
AdjointReturnType adjoint() const AdjointReturnType adjoint() const
{ {
return AdjointReturnType(m_vectors, m_coeffs.conjugate()) return AdjointReturnType(m_vectors, m_coeffs.conjugate())
.setTrans(!m_trans) .setReverseFlag(!m_reverse)
.setLength(m_length) .setLength(m_length)
.setShift(m_shift); .setShift(m_shift);
} }
@ -273,7 +273,7 @@ template<typename VectorsType, typename CoeffsType, int Side> class HouseholderS
for(Index k = vecs-1; k >= 0; --k) for(Index k = vecs-1; k >= 0; --k)
{ {
Index cornerSize = rows() - k - m_shift; Index cornerSize = rows() - k - m_shift;
if(m_trans) if(m_reverse)
dst.bottomRightCorner(cornerSize, cornerSize) dst.bottomRightCorner(cornerSize, cornerSize)
.applyHouseholderOnTheRight(essentialVector(k), m_coeffs.coeff(k), workspace.data()); .applyHouseholderOnTheRight(essentialVector(k), m_coeffs.coeff(k), workspace.data());
else else
@ -293,7 +293,7 @@ template<typename VectorsType, typename CoeffsType, int Side> class HouseholderS
for(Index k = vecs-1; k >= 0; --k) for(Index k = vecs-1; k >= 0; --k)
{ {
Index cornerSize = rows() - k - m_shift; Index cornerSize = rows() - k - m_shift;
if(m_trans) if(m_reverse)
dst.bottomRightCorner(cornerSize, cornerSize) dst.bottomRightCorner(cornerSize, cornerSize)
.applyHouseholderOnTheRight(essentialVector(k), m_coeffs.coeff(k), workspace.data()); .applyHouseholderOnTheRight(essentialVector(k), m_coeffs.coeff(k), workspace.data());
else else
@ -317,7 +317,7 @@ template<typename VectorsType, typename CoeffsType, int Side> class HouseholderS
workspace.resize(dst.rows()); workspace.resize(dst.rows());
for(Index k = 0; k < m_length; ++k) for(Index k = 0; k < m_length; ++k)
{ {
Index actual_k = m_trans ? m_length-k-1 : k; Index actual_k = m_reverse ? m_length-k-1 : k;
dst.rightCols(rows()-m_shift-actual_k) dst.rightCols(rows()-m_shift-actual_k)
.applyHouseholderOnTheRight(essentialVector(actual_k), m_coeffs.coeff(actual_k), workspace.data()); .applyHouseholderOnTheRight(essentialVector(actual_k), m_coeffs.coeff(actual_k), workspace.data());
} }
@ -340,8 +340,8 @@ template<typename VectorsType, typename CoeffsType, int Side> class HouseholderS
{ {
for(Index i = 0; i < m_length; i+=BlockSize) for(Index i = 0; i < m_length; i+=BlockSize)
{ {
Index end = m_trans ? (std::min)(m_length,i+BlockSize) : m_length-i; Index end = m_reverse ? (std::min)(m_length,i+BlockSize) : m_length-i;
Index k = m_trans ? i : (std::max)(Index(0),end-BlockSize); Index k = m_reverse ? i : (std::max)(Index(0),end-BlockSize);
Index bs = end-k; Index bs = end-k;
Index start = k + m_shift; Index start = k + m_shift;
@ -352,7 +352,7 @@ template<typename VectorsType, typename CoeffsType, int Side> class HouseholderS
Side==OnTheRight ? m_vectors.cols()-start : bs); Side==OnTheRight ? m_vectors.cols()-start : bs);
typename internal::conditional<Side==OnTheRight, Transpose<SubVectorsType>, SubVectorsType&>::type sub_vecs(sub_vecs1); typename internal::conditional<Side==OnTheRight, Transpose<SubVectorsType>, SubVectorsType&>::type sub_vecs(sub_vecs1);
Block<Dest,Dynamic,Dynamic> sub_dst(dst,dst.rows()-rows()+m_shift+k,0, rows()-m_shift-k,dst.cols()); Block<Dest,Dynamic,Dynamic> sub_dst(dst,dst.rows()-rows()+m_shift+k,0, rows()-m_shift-k,dst.cols());
apply_block_householder_on_the_left(sub_dst, sub_vecs, m_coeffs.segment(k, bs), !m_trans); apply_block_householder_on_the_left(sub_dst, sub_vecs, m_coeffs.segment(k, bs), !m_reverse);
} }
} }
else else
@ -360,7 +360,7 @@ template<typename VectorsType, typename CoeffsType, int Side> class HouseholderS
workspace.resize(dst.cols()); workspace.resize(dst.cols());
for(Index k = 0; k < m_length; ++k) for(Index k = 0; k < m_length; ++k)
{ {
Index actual_k = m_trans ? k : m_length-k-1; Index actual_k = m_reverse ? k : m_length-k-1;
dst.bottomRows(rows()-m_shift-actual_k) dst.bottomRows(rows()-m_shift-actual_k)
.applyHouseholderOnTheLeft(essentialVector(actual_k), m_coeffs.coeff(actual_k), workspace.data()); .applyHouseholderOnTheLeft(essentialVector(actual_k), m_coeffs.coeff(actual_k), workspace.data());
} }
@ -425,25 +425,27 @@ template<typename VectorsType, typename CoeffsType, int Side> class HouseholderS
protected: protected:
/** \brief Sets the transpose flag. /** \internal
* \param [in] trans New value of the transpose flag. * \brief Sets the reverse flag.
* \param [in] reverse New value of the reverse flag.
* *
* By default, the transpose flag is not set. If the transpose flag is set, then this object represents * By default, the reverse flag is not set. If the reverse flag is set, then this object represents
* \f$ H^T = H_{n-1}^T \ldots H_1^T H_0^T \f$ instead of \f$ H = H_0 H_1 \ldots H_{n-1} \f$. * \f$ H^r = H_{n-1} \ldots H_1 H_0 \f$ instead of \f$ H = H_0 H_1 \ldots H_{n-1} \f$.
* \note For real valued HouseholderSequence this is equivalent to transposing \f$ H \f$.
* *
* \sa trans() * \sa reverseFlag(), transpose(), adjoint()
*/ */
HouseholderSequence& setTrans(bool trans) HouseholderSequence& setReverseFlag(bool reverse)
{ {
m_trans = trans; m_reverse = reverse;
return *this; return *this;
} }
bool trans() const { return m_trans; } /**< \brief Returns the transpose flag. */ bool reverseFlag() const { return m_reverse; } /**< \internal \brief Returns the reverse flag. */
typename VectorsType::Nested m_vectors; typename VectorsType::Nested m_vectors;
typename CoeffsType::Nested m_coeffs; typename CoeffsType::Nested m_coeffs;
bool m_trans; bool m_reverse;
Index m_length; Index m_length;
Index m_shift; Index m_shift;
}; };