Big renaming:

start ---> head
  end   ---> tail
Much frustration with sed syntax. Need to learn perl some day.
This commit is contained in:
Benoit Jacob
2010-01-04 21:24:43 -05:00
parent 78ba523d30
commit 39ac57fa6d
43 changed files with 158 additions and 158 deletions

View File

@@ -194,7 +194,7 @@ LDLT<MatrixType>& LDLT<MatrixType>::compute(const MatrixType& a)
{
// Find largest diagonal element
int index_of_biggest_in_corner;
biggest_in_corner = m_matrix.diagonal().end(size-j).cwise().abs()
biggest_in_corner = m_matrix.diagonal().tail(size-j).cwise().abs()
.maxCoeff(&index_of_biggest_in_corner);
index_of_biggest_in_corner += j;
@@ -227,12 +227,12 @@ LDLT<MatrixType>& LDLT<MatrixType>::compute(const MatrixType& a)
if (j == 0) {
m_matrix.row(0) = m_matrix.row(0).conjugate();
m_matrix.col(0).end(size-1) = m_matrix.row(0).end(size-1) / m_matrix.coeff(0,0);
m_matrix.col(0).tail(size-1) = m_matrix.row(0).tail(size-1) / m_matrix.coeff(0,0);
continue;
}
RealScalar Djj = ei_real(m_matrix.coeff(j,j) - m_matrix.row(j).start(j)
.dot(m_matrix.col(j).start(j)));
RealScalar Djj = ei_real(m_matrix.coeff(j,j) - m_matrix.row(j).head(j)
.dot(m_matrix.col(j).head(j)));
m_matrix.coeffRef(j,j) = Djj;
// Finish early if the matrix is not full rank.
@@ -244,13 +244,13 @@ LDLT<MatrixType>& LDLT<MatrixType>::compute(const MatrixType& a)
int endSize = size - j - 1;
if (endSize > 0) {
_temporary.end(endSize).noalias() = m_matrix.block(j+1,0, endSize, j)
* m_matrix.col(j).start(j).conjugate();
_temporary.tail(endSize).noalias() = m_matrix.block(j+1,0, endSize, j)
* m_matrix.col(j).head(j).conjugate();
m_matrix.row(j).end(endSize) = m_matrix.row(j).end(endSize).conjugate()
- _temporary.end(endSize).transpose();
m_matrix.row(j).tail(endSize) = m_matrix.row(j).tail(endSize).conjugate()
- _temporary.tail(endSize).transpose();
m_matrix.col(j).end(endSize) = m_matrix.row(j).end(endSize) / Djj;
m_matrix.col(j).tail(endSize) = m_matrix.row(j).tail(endSize) / Djj;
}
}

View File

@@ -166,7 +166,7 @@ template<> struct ei_llt_inplace<LowerTriangular>
Block<MatrixType,Dynamic,Dynamic> A20(mat,k+1,0,rs,k);
RealScalar x = ei_real(mat.coeff(k,k));
if (k>0) x -= mat.row(k).start(k).squaredNorm();
if (k>0) x -= mat.row(k).head(k).squaredNorm();
if (x<=RealScalar(0))
return false;
mat.coeffRef(k,k) = x = ei_sqrt(x);

View File

@@ -459,11 +459,11 @@ template<typename Derived> class MatrixBase
VectorBlock<Derived> segment(int start, int size);
const VectorBlock<Derived> segment(int start, int size) const;
VectorBlock<Derived> start(int size);
const VectorBlock<Derived> start(int size) const;
VectorBlock<Derived> head(int size);
const VectorBlock<Derived> head(int size) const;
VectorBlock<Derived> end(int size);
const VectorBlock<Derived> end(int size) const;
VectorBlock<Derived> tail(int size);
const VectorBlock<Derived> tail(int size) const;
typename BlockReturnType<Derived>::Type corner(CornerType type, int cRows, int cCols);
const typename BlockReturnType<Derived>::Type corner(CornerType type, int cRows, int cCols) const;
@@ -478,11 +478,11 @@ template<typename Derived> class MatrixBase
template<int CRows, int CCols>
const typename BlockReturnType<Derived, CRows, CCols>::Type corner(CornerType type) const;
template<int Size> VectorBlock<Derived,Size> start(void);
template<int Size> const VectorBlock<Derived,Size> start() const;
template<int Size> VectorBlock<Derived,Size> head(void);
template<int Size> const VectorBlock<Derived,Size> head() const;
template<int Size> VectorBlock<Derived,Size> end();
template<int Size> const VectorBlock<Derived,Size> end() const;
template<int Size> VectorBlock<Derived,Size> tail();
template<int Size> const VectorBlock<Derived,Size> tail() const;
template<int Size> VectorBlock<Derived,Size> segment(int start);
template<int Size> const VectorBlock<Derived,Size> segment(int start) const;

View File

@@ -67,7 +67,7 @@ MatrixBase<Derived>::stableNorm() const
{
bi = ei_first_aligned(&const_cast_derived().coeffRef(0), n);
if (bi>0)
ei_stable_norm_kernel(start(bi), ssq, scale, invScale);
ei_stable_norm_kernel(head(bi), ssq, scale, invScale);
}
for (; bi<n; bi+=blockSize)
ei_stable_norm_kernel(VectorBlock<Derived,Dynamic,Alignment>(derived(),bi,std::min(blockSize, n - bi)), ssq, scale, invScale);

View File

@@ -161,16 +161,16 @@ MatrixBase<Derived>::segment(int start, int size) const
*/
template<typename Derived>
inline VectorBlock<Derived>
MatrixBase<Derived>::start(int size)
MatrixBase<Derived>::head(int size)
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return VectorBlock<Derived>(derived(), 0, size);
}
/** This is the const version of start(int).*/
/** This is the const version of head(int).*/
template<typename Derived>
inline const VectorBlock<Derived>
MatrixBase<Derived>::start(int size) const
MatrixBase<Derived>::head(int size) const
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return VectorBlock<Derived>(derived(), 0, size);
@@ -193,16 +193,16 @@ MatrixBase<Derived>::start(int size) const
*/
template<typename Derived>
inline VectorBlock<Derived>
MatrixBase<Derived>::end(int size)
MatrixBase<Derived>::tail(int size)
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return VectorBlock<Derived>(derived(), this->size() - size, size);
}
/** This is the const version of end(int).*/
/** This is the const version of tail(int).*/
template<typename Derived>
inline const VectorBlock<Derived>
MatrixBase<Derived>::end(int size) const
MatrixBase<Derived>::tail(int size) const
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return VectorBlock<Derived>(derived(), this->size() - size, size);
@@ -254,17 +254,17 @@ MatrixBase<Derived>::segment(int start) const
template<typename Derived>
template<int Size>
inline VectorBlock<Derived,Size>
MatrixBase<Derived>::start()
MatrixBase<Derived>::head()
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return VectorBlock<Derived,Size>(derived(), 0);
}
/** This is the const version of start<int>().*/
/** This is the const version of head<int>().*/
template<typename Derived>
template<int Size>
inline const VectorBlock<Derived,Size>
MatrixBase<Derived>::start() const
MatrixBase<Derived>::head() const
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return VectorBlock<Derived,Size>(derived(), 0);
@@ -284,17 +284,17 @@ MatrixBase<Derived>::start() const
template<typename Derived>
template<int Size>
inline VectorBlock<Derived,Size>
MatrixBase<Derived>::end()
MatrixBase<Derived>::tail()
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return VectorBlock<Derived, Size>(derived(), size() - Size);
}
/** This is the const version of end<int>.*/
/** This is the const version of tail<int>.*/
template<typename Derived>
template<int Size>
inline const VectorBlock<Derived,Size>
MatrixBase<Derived>::end() const
MatrixBase<Derived>::tail() const
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return VectorBlock<Derived, Size>(derived(), size() - Size);

View File

@@ -41,8 +41,8 @@ struct ei_selfadjoint_rank2_update_selector<Scalar,UType,VType,LowerTriangular>
for (int i=0; i<size; ++i)
{
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);
(alpha * ei_conj(u.coeff(i))) * v.tail(size-i)
+ (alpha * ei_conj(v.coeff(i))) * u.tail(size-i);
}
}
};
@@ -55,8 +55,8 @@ struct ei_selfadjoint_rank2_update_selector<Scalar,UType,VType,UpperTriangular>
const int size = u.size();
for (int i=0; i<size; ++i)
Map<Matrix<Scalar,Dynamic,1> >(mat+stride*i, i+1) +=
(alpha * ei_conj(u.coeff(i))) * v.start(i+1)
+ (alpha * ei_conj(v.coeff(i))) * u.start(i+1);
(alpha * ei_conj(u.coeff(i))) * v.head(i+1)
+ (alpha * ei_conj(v.coeff(i))) * u.head(i+1);
}
};

View File

@@ -133,7 +133,7 @@ void ComplexEigenSolver<MatrixType>::compute(const MatrixType& matrix)
for (int i=0; i<n; i++)
{
int k;
m_eivalues.cwise().abs().end(n-i).minCoeff(&k);
m_eivalues.cwise().abs().tail(n-i).minCoeff(&k);
if (k != 0)
{
k += i;

View File

@@ -620,7 +620,7 @@ void EigenSolver<MatrixType>::hqr2(MatrixType& matH)
// Overflow control
t = ei_abs(matH.coeff(i,n));
if ((eps * t) * t > 1)
matH.col(n).end(nn-i) /= t;
matH.col(n).tail(nn-i) /= t;
}
}
}
@@ -708,7 +708,7 @@ void EigenSolver<MatrixType>::hqr2(MatrixType& matH)
// in this algo low==0 and high==nn-1 !!
if (i < low || i > high)
{
m_eivec.row(i).end(nn-i) = matH.row(i).end(nn-i);
m_eivec.row(i).tail(nn-i) = matH.row(i).tail(nn-i);
}
}

View File

@@ -150,7 +150,7 @@ void HessenbergDecomposition<MatrixType>::_compute(MatrixType& matA, CoeffVector
int remainingSize = n-i-1;
RealScalar beta;
Scalar h;
matA.col(i).end(remainingSize).makeHouseholderInPlace(h, beta);
matA.col(i).tail(remainingSize).makeHouseholderInPlace(h, beta);
matA.col(i).coeffRef(i+1) = beta;
hCoeffs.coeffRef(i) = h;
@@ -159,11 +159,11 @@ void HessenbergDecomposition<MatrixType>::_compute(MatrixType& matA, CoeffVector
// A = H A
matA.corner(BottomRight, remainingSize, remainingSize)
.applyHouseholderOnTheLeft(matA.col(i).end(remainingSize-1), h, &temp.coeffRef(0));
.applyHouseholderOnTheLeft(matA.col(i).tail(remainingSize-1), h, &temp.coeffRef(0));
// A = A H'
matA.corner(BottomRight, n, remainingSize)
.applyHouseholderOnTheRight(matA.col(i).end(remainingSize-1).conjugate(), ei_conj(h), &temp.coeffRef(0));
.applyHouseholderOnTheRight(matA.col(i).tail(remainingSize-1).conjugate(), ei_conj(h), &temp.coeffRef(0));
}
}
@@ -178,7 +178,7 @@ HessenbergDecomposition<MatrixType>::matrixQ() const
for (int i = n-2; i>=0; i--)
{
matQ.corner(BottomRight,n-i-1,n-i-1)
.applyHouseholderOnTheLeft(m_matrix.col(i).end(n-i-2), ei_conj(m_hCoeffs.coeff(i)), &temp.coeffRef(0,0));
.applyHouseholderOnTheLeft(m_matrix.col(i).tail(n-i-2), ei_conj(m_hCoeffs.coeff(i)), &temp.coeffRef(0,0));
}
return matQ;
}

View File

@@ -202,19 +202,19 @@ void Tridiagonalization<MatrixType>::_compute(MatrixType& matA, CoeffVectorType&
int remainingSize = n-i-1;
RealScalar beta;
Scalar h;
matA.col(i).end(remainingSize).makeHouseholderInPlace(h, beta);
matA.col(i).tail(remainingSize).makeHouseholderInPlace(h, beta);
// 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)
// i.e., A = H A H' where H = I - h v v' and v = matA.col(i).tail(n-i-1)
matA.col(i).coeffRef(i+1) = 1;
hCoeffs.end(n-i-1) = (matA.corner(BottomRight,remainingSize,remainingSize).template selfadjointView<LowerTriangular>()
* (ei_conj(h) * matA.col(i).end(remainingSize)));
hCoeffs.tail(n-i-1) = (matA.corner(BottomRight,remainingSize,remainingSize).template selfadjointView<LowerTriangular>()
* (ei_conj(h) * matA.col(i).tail(remainingSize)));
hCoeffs.end(n-i-1) += (ei_conj(h)*Scalar(-0.5)*(hCoeffs.end(remainingSize).dot(matA.col(i).end(remainingSize)))) * matA.col(i).end(n-i-1);
hCoeffs.tail(n-i-1) += (ei_conj(h)*Scalar(-0.5)*(hCoeffs.tail(remainingSize).dot(matA.col(i).tail(remainingSize)))) * matA.col(i).tail(n-i-1);
matA.corner(BottomRight, remainingSize, remainingSize).template selfadjointView<LowerTriangular>()
.rankUpdate(matA.col(i).end(remainingSize), hCoeffs.end(remainingSize), -1);
.rankUpdate(matA.col(i).tail(remainingSize), hCoeffs.tail(remainingSize), -1);
matA.col(i).coeffRef(i+1) = beta;
hCoeffs.coeffRef(i) = h;
@@ -242,7 +242,7 @@ void Tridiagonalization<MatrixType>::matrixQInPlace(MatrixBase<QDerived>* q) con
for (int i = n-2; i>=0; i--)
{
matQ.corner(BottomRight,n-i-1,n-i-1)
.applyHouseholderOnTheLeft(m_matrix.col(i).end(n-i-2), ei_conj(m_hCoeffs.coeff(i)), &aux.coeffRef(0,0));
.applyHouseholderOnTheLeft(m_matrix.col(i).tail(n-i-2), ei_conj(m_hCoeffs.coeff(i)), &aux.coeffRef(0,0));
}
}

View File

@@ -173,7 +173,7 @@ struct ei_unitOrthogonal_selector<Derived,3>
if((!ei_isMuchSmallerThan(src.x(), src.z()))
|| (!ei_isMuchSmallerThan(src.y(), src.z())))
{
RealScalar invnm = RealScalar(1)/src.template start<2>().norm();
RealScalar invnm = RealScalar(1)/src.template head<2>().norm();
perp.coeffRef(0) = -ei_conj(src.y())*invnm;
perp.coeffRef(1) = ei_conj(src.x())*invnm;
perp.coeffRef(2) = 0;
@@ -184,7 +184,7 @@ struct ei_unitOrthogonal_selector<Derived,3>
*/
else
{
RealScalar invnm = RealScalar(1)/src.template end<2>().norm();
RealScalar invnm = RealScalar(1)/src.template tail<2>().norm();
perp.coeffRef(0) = 0;
perp.coeffRef(1) = -ei_conj(src.z())*invnm;
perp.coeffRef(2) = ei_conj(src.y())*invnm;

View File

@@ -77,10 +77,10 @@ public:
inline Scalar& w() { return this->derived().coeffs().coeffRef(3); }
/** \returns a read-only vector expression of the imaginary part (x,y,z) */
inline const VectorBlock<Coefficients,3> vec() const { return coeffs().template start<3>(); }
inline const VectorBlock<Coefficients,3> vec() const { return coeffs().template head<3>(); }
/** \returns a vector expression of the imaginary part (x,y,z) */
inline VectorBlock<Coefficients,3> vec() { return coeffs().template start<3>(); }
inline VectorBlock<Coefficients,3> vec() { return coeffs().template head<3>(); }
/** \returns a read-only vector expression of the coefficients (x,y,z,w) */
inline const typename ei_traits<Derived>::Coefficients& coeffs() const { return derived().coeffs(); }

View File

@@ -1102,7 +1102,7 @@ struct ei_transform_right_product_impl<Other,AffineCompact, Dim,HDim, HDim,1>
static ResultType run(const TransformType& tr, const Other& other)
{
ResultType res;
res.template start<HDim>() = tr.matrix() * other;
res.template head<HDim>() = tr.matrix() * other;
res.coeffRef(Dim) = other.coeff(Dim);
}
};
@@ -1120,7 +1120,7 @@ struct ei_transform_right_product_impl<Other,Mode, Dim,HDim, Dim,Dim>
res.matrix().col(Dim) = tr.matrix().col(Dim);
res.linearExt() = (tr.linearExt() * other).lazy();
if(Mode==Affine)
res.matrix().row(Dim).template start<Dim>() = tr.matrix().row(Dim).template start<Dim>();
res.matrix().row(Dim).template head<Dim>() = tr.matrix().row(Dim).template head<Dim>();
return res;
}
};

View File

@@ -170,8 +170,8 @@ umeyama(const MatrixBase<Derived>& src, const MatrixBase<OtherDerived>& dst, boo
// Eq. (41)
// Note that we first assign dst_mean to the destination so that there no need
// for a temporary.
Rt.col(m).start(m) = dst_mean;
Rt.col(m).start(m).noalias() -= c*Rt.corner(TopLeft,m,m)*src_mean;
Rt.col(m).head(m) = dst_mean;
Rt.col(m).head(m).noalias() -= c*Rt.corner(TopLeft,m,m)*src_mean;
if (with_scaling) Rt.block(0,0,m,m) *= c;

View File

@@ -105,10 +105,10 @@ template<typename VectorsType, typename CoeffsType> class HouseholderSequence
{
if(m_trans)
dst.corner(BottomRight, length-k, length-k)
.applyHouseholderOnTheRight(m_vectors.col(k).end(length-k-1), m_coeffs.coeff(k), &temp.coeffRef(0));
.applyHouseholderOnTheRight(m_vectors.col(k).tail(length-k-1), m_coeffs.coeff(k), &temp.coeffRef(0));
else
dst.corner(BottomRight, length-k, length-k)
.applyHouseholderOnTheLeft(m_vectors.col(k).end(length-k-1), m_coeffs.coeff(k), &temp.coeffRef(k));
.applyHouseholderOnTheLeft(m_vectors.col(k).tail(length-k-1), m_coeffs.coeff(k), &temp.coeffRef(k));
}
}
@@ -122,7 +122,7 @@ template<typename VectorsType, typename CoeffsType> class HouseholderSequence
{
int actual_k = m_trans ? vecs-k-1 : k;
dst.corner(BottomRight, dst.rows(), length-actual_k)
.applyHouseholderOnTheRight(m_vectors.col(actual_k).end(length-actual_k-1), m_coeffs.coeff(actual_k), &temp.coeffRef(0));
.applyHouseholderOnTheRight(m_vectors.col(actual_k).tail(length-actual_k-1), m_coeffs.coeff(actual_k), &temp.coeffRef(0));
}
}
@@ -136,7 +136,7 @@ template<typename VectorsType, typename CoeffsType> class HouseholderSequence
{
int actual_k = m_trans ? k : vecs-k-1;
dst.corner(BottomRight, length-actual_k, dst.cols())
.applyHouseholderOnTheLeft(m_vectors.col(actual_k).end(length-actual_k-1), m_coeffs.coeff(actual_k), &temp.coeffRef(0));
.applyHouseholderOnTheLeft(m_vectors.col(actual_k).tail(length-actual_k-1), m_coeffs.coeff(actual_k), &temp.coeffRef(0));
}
}

View File

@@ -451,9 +451,9 @@ FullPivLU<MatrixType>& FullPivLU<MatrixType>::compute(const MatrixType& matrix)
// bottom-right corner by Gaussian elimination.
if(k<rows-1)
m_lu.col(k).end(rows-k-1) /= m_lu.coeff(k,k);
m_lu.col(k).tail(rows-k-1) /= m_lu.coeff(k,k);
if(k<size-1)
m_lu.block(k+1,k+1,rows-k-1,cols-k-1).noalias() -= m_lu.col(k).end(rows-k-1) * m_lu.row(k).end(cols-k-1);
m_lu.block(k+1,k+1,rows-k-1,cols-k-1).noalias() -= m_lu.col(k).tail(rows-k-1) * m_lu.row(k).tail(cols-k-1);
}
// the main loop is over, we still have to accumulate the transpositions to find the
@@ -537,8 +537,8 @@ struct ei_kernel_retval<FullPivLU<_MatrixType> >
m(dec().matrixLU().block(0, 0, rank(), cols));
for(int i = 0; i < rank(); ++i)
{
if(i) m.row(i).start(i).setZero();
m.row(i).end(cols-i) = dec().matrixLU().row(pivots.coeff(i)).end(cols-i);
if(i) m.row(i).head(i).setZero();
m.row(i).tail(cols-i) = dec().matrixLU().row(pivots.coeff(i)).tail(cols-i);
}
m.block(0, 0, rank(), rank());
m.block(0, 0, rank(), rank()).template triangularView<StrictlyLowerTriangular>().setZero();
@@ -558,7 +558,7 @@ struct ei_kernel_retval<FullPivLU<_MatrixType> >
m.col(i).swap(m.col(pivots.coeff(i)));
// see the negative sign in the next line, that's what we were talking about above.
for(int i = 0; i < rank(); ++i) dst.row(dec().permutationQ().indices().coeff(i)) = -m.row(i).end(dimker);
for(int i = 0; i < rank(); ++i) dst.row(dec().permutationQ().indices().coeff(i)) = -m.row(i).tail(dimker);
for(int i = rank(); i < cols; ++i) dst.row(dec().permutationQ().indices().coeff(i)).setZero();
for(int k = 0; k < dimker; ++k) dst.coeffRef(dec().permutationQ().indices().coeff(rank()+k), k) = Scalar(1);
}

View File

@@ -229,7 +229,7 @@ struct ei_partial_lu_impl
{
int row_of_biggest_in_col;
RealScalar biggest_in_corner
= lu.col(k).end(rows-k).cwise().abs().maxCoeff(&row_of_biggest_in_col);
= lu.col(k).tail(rows-k).cwise().abs().maxCoeff(&row_of_biggest_in_col);
row_of_biggest_in_col += k;
if(biggest_in_corner == 0) // the pivot is exactly zero: the matrix is singular
@@ -256,8 +256,8 @@ struct ei_partial_lu_impl
{
int rrows = rows-k-1;
int rsize = size-k-1;
lu.col(k).end(rrows) /= lu.coeff(k,k);
lu.corner(BottomRight,rrows,rsize).noalias() -= lu.col(k).end(rrows) * lu.row(k).end(rsize);
lu.col(k).tail(rrows) /= lu.coeff(k,k);
lu.corner(BottomRight,rrows,rsize).noalias() -= lu.col(k).tail(rrows) * lu.row(k).tail(rsize);
}
}
return true;

View File

@@ -359,14 +359,14 @@ ColPivHouseholderQR<MatrixType>& ColPivHouseholderQR<MatrixType>::compute(const
{
// first, we look up in our table colSqNorms which column has the biggest squared norm
int biggest_col_index;
RealScalar biggest_col_sq_norm = colSqNorms.end(cols-k).maxCoeff(&biggest_col_index);
RealScalar biggest_col_sq_norm = colSqNorms.tail(cols-k).maxCoeff(&biggest_col_index);
biggest_col_index += k;
// since our table colSqNorms accumulates imprecision at every step, we must now recompute
// the actual squared norm of the selected column.
// Note that not doing so does result in solve() sometimes returning inf/nan values
// when running the unit test with 1000 repetitions.
biggest_col_sq_norm = m_qr.col(biggest_col_index).end(rows-k).squaredNorm();
biggest_col_sq_norm = m_qr.col(biggest_col_index).tail(rows-k).squaredNorm();
// we store that back into our table: it can't hurt to correct our table.
colSqNorms.coeffRef(biggest_col_index) = biggest_col_sq_norm;
@@ -379,7 +379,7 @@ ColPivHouseholderQR<MatrixType>& ColPivHouseholderQR<MatrixType>::compute(const
if(biggest_col_sq_norm < threshold_helper * (rows-k))
{
m_nonzero_pivots = k;
m_hCoeffs.end(size-k).setZero();
m_hCoeffs.tail(size-k).setZero();
m_qr.corner(BottomRight,rows-k,cols-k)
.template triangularView<StrictlyLowerTriangular>()
.setZero();
@@ -396,7 +396,7 @@ ColPivHouseholderQR<MatrixType>& ColPivHouseholderQR<MatrixType>::compute(const
// generate the householder vector, store it below the diagonal
RealScalar beta;
m_qr.col(k).end(rows-k).makeHouseholderInPlace(m_hCoeffs.coeffRef(k), beta);
m_qr.col(k).tail(rows-k).makeHouseholderInPlace(m_hCoeffs.coeffRef(k), beta);
// apply the householder transformation to the diagonal coefficient
m_qr.coeffRef(k,k) = beta;
@@ -406,10 +406,10 @@ ColPivHouseholderQR<MatrixType>& ColPivHouseholderQR<MatrixType>::compute(const
// apply the householder transformation
m_qr.corner(BottomRight, rows-k, cols-k-1)
.applyHouseholderOnTheLeft(m_qr.col(k).end(rows-k-1), m_hCoeffs.coeffRef(k), &temp.coeffRef(k+1));
.applyHouseholderOnTheLeft(m_qr.col(k).tail(rows-k-1), m_hCoeffs.coeffRef(k), &temp.coeffRef(k+1));
// update our table of squared norms of the columns
colSqNorms.end(cols-k-1) -= m_qr.row(k).end(cols-k-1).cwise().abs2();
colSqNorms.tail(cols-k-1) -= m_qr.row(k).tail(cols-k-1).cwise().abs2();
}
m_cols_permutation.setIdentity(cols);

View File

@@ -306,7 +306,7 @@ FullPivHouseholderQR<MatrixType>& FullPivHouseholderQR<MatrixType>::compute(cons
m_rows_transpositions.coeffRef(k) = row_of_biggest_in_corner;
cols_transpositions.coeffRef(k) = col_of_biggest_in_corner;
if(k != row_of_biggest_in_corner) {
m_qr.row(k).end(cols-k).swap(m_qr.row(row_of_biggest_in_corner).end(cols-k));
m_qr.row(k).tail(cols-k).swap(m_qr.row(row_of_biggest_in_corner).tail(cols-k));
++number_of_transpositions;
}
if(k != col_of_biggest_in_corner) {
@@ -315,11 +315,11 @@ FullPivHouseholderQR<MatrixType>& FullPivHouseholderQR<MatrixType>::compute(cons
}
RealScalar beta;
m_qr.col(k).end(rows-k).makeHouseholderInPlace(m_hCoeffs.coeffRef(k), beta);
m_qr.col(k).tail(rows-k).makeHouseholderInPlace(m_hCoeffs.coeffRef(k), beta);
m_qr.coeffRef(k,k) = beta;
m_qr.corner(BottomRight, rows-k, cols-k-1)
.applyHouseholderOnTheLeft(m_qr.col(k).end(rows-k-1), m_hCoeffs.coeffRef(k), &temp.coeffRef(k+1));
.applyHouseholderOnTheLeft(m_qr.col(k).tail(rows-k-1), m_hCoeffs.coeffRef(k), &temp.coeffRef(k+1));
}
m_cols_permutation.setIdentity(cols);
@@ -360,7 +360,7 @@ struct ei_solve_retval<FullPivHouseholderQR<_MatrixType>, Rhs>
int remainingSize = rows-k;
c.row(k).swap(c.row(dec().rowsTranspositions().coeff(k)));
c.corner(BottomRight, remainingSize, rhs().cols())
.applyHouseholderOnTheLeft(dec().matrixQR().col(k).end(remainingSize-1),
.applyHouseholderOnTheLeft(dec().matrixQR().col(k).tail(remainingSize-1),
dec().hCoeffs().coeff(k), &temp.coeffRef(0));
}
@@ -400,7 +400,7 @@ typename FullPivHouseholderQR<MatrixType>::MatrixQType FullPivHouseholderQR<Matr
for (int k = size-1; k >= 0; k--)
{
res.block(k, k, rows-k, rows-k)
.applyHouseholderOnTheLeft(m_qr.col(k).end(rows-k-1), ei_conj(m_hCoeffs.coeff(k)), &temp.coeffRef(k));
.applyHouseholderOnTheLeft(m_qr.col(k).tail(rows-k-1), ei_conj(m_hCoeffs.coeff(k)), &temp.coeffRef(k));
res.row(k).swap(res.row(m_rows_transpositions.coeff(k)));
}
return res;

View File

@@ -197,12 +197,12 @@ HouseholderQR<MatrixType>& HouseholderQR<MatrixType>::compute(const MatrixType&
int remainingCols = cols - k - 1;
RealScalar beta;
m_qr.col(k).end(remainingRows).makeHouseholderInPlace(m_hCoeffs.coeffRef(k), beta);
m_qr.col(k).tail(remainingRows).makeHouseholderInPlace(m_hCoeffs.coeffRef(k), beta);
m_qr.coeffRef(k,k) = beta;
// apply H to remaining part of m_qr from the left
m_qr.corner(BottomRight, remainingRows, remainingCols)
.applyHouseholderOnTheLeft(m_qr.col(k).end(remainingRows-1), m_hCoeffs.coeffRef(k), &temp.coeffRef(k+1));
.applyHouseholderOnTheLeft(m_qr.col(k).tail(remainingRows-1), m_hCoeffs.coeffRef(k), &temp.coeffRef(k+1));
}
m_isInitialized = true;
return *this;
@@ -226,7 +226,7 @@ struct ei_solve_retval<HouseholderQR<_MatrixType>, Rhs>
// Note that the matrix Q = H_0^* H_1^*... so its inverse is Q^* = (H_0 H_1 ...)^T
c.applyOnTheLeft(householderSequence(
dec().matrixQR().corner(TopLeft,rows,rank),
dec().hCoeffs().start(rank)).transpose()
dec().hCoeffs().head(rank)).transpose()
);
dec().matrixQR()

View File

@@ -342,7 +342,7 @@ JacobiSVD<MatrixType, Options>& JacobiSVD<MatrixType, Options>::compute(const Ma
for(int i = 0; i < diagSize; i++)
{
int pos;
m_singularValues.end(diagSize-i).maxCoeff(&pos);
m_singularValues.tail(diagSize-i).maxCoeff(&pos);
if(pos)
{
pos += i;

View File

@@ -205,7 +205,7 @@ SVD<MatrixType>& SVD<MatrixType>::compute(const MatrixType& matrix)
g = s = scale = 0.0;
if (i < m)
{
scale = A.col(i).end(m-i).cwise().abs().sum();
scale = A.col(i).tail(m-i).cwise().abs().sum();
if (scale != Scalar(0))
{
for (k=i; k<m; k++)
@@ -219,18 +219,18 @@ SVD<MatrixType>& SVD<MatrixType>::compute(const MatrixType& matrix)
A(i, i)=f-g;
for (j=l-1; j<n; j++)
{
s = A.col(j).end(m-i).dot(A.col(i).end(m-i));
s = A.col(j).tail(m-i).dot(A.col(i).tail(m-i));
f = s/h;
A.col(j).end(m-i) += f*A.col(i).end(m-i);
A.col(j).tail(m-i) += f*A.col(i).tail(m-i);
}
A.col(i).end(m-i) *= scale;
A.col(i).tail(m-i) *= scale;
}
}
W[i] = scale * g;
g = s = scale = 0.0;
if (i+1 <= m && i+1 != n)
{
scale = A.row(i).end(n-l+1).cwise().abs().sum();
scale = A.row(i).tail(n-l+1).cwise().abs().sum();
if (scale != Scalar(0))
{
for (k=l-1; k<n; k++)
@@ -242,13 +242,13 @@ SVD<MatrixType>& SVD<MatrixType>::compute(const MatrixType& matrix)
g = -sign(ei_sqrt(s),f);
h = f*g - s;
A(i,l-1) = f-g;
rv1.end(n-l+1) = A.row(i).end(n-l+1)/h;
rv1.tail(n-l+1) = A.row(i).tail(n-l+1)/h;
for (j=l-1; j<m; j++)
{
s = A.row(i).end(n-l+1).dot(A.row(j).end(n-l+1));
A.row(j).end(n-l+1) += s*rv1.end(n-l+1).transpose();
s = A.row(i).tail(n-l+1).dot(A.row(j).tail(n-l+1));
A.row(j).tail(n-l+1) += s*rv1.tail(n-l+1).transpose();
}
A.row(i).end(n-l+1) *= scale;
A.row(i).tail(n-l+1) *= scale;
}
}
anorm = std::max( anorm, (ei_abs(W[i])+ei_abs(rv1[i])) );
@@ -265,12 +265,12 @@ SVD<MatrixType>& SVD<MatrixType>::compute(const MatrixType& matrix)
V(j, i) = (A(i, j)/A(i, l))/g;
for (j=l; j<n; j++)
{
s = V.col(j).end(n-l).dot(A.row(i).end(n-l));
V.col(j).end(n-l) += s * V.col(i).end(n-l);
s = V.col(j).tail(n-l).dot(A.row(i).tail(n-l));
V.col(j).tail(n-l) += s * V.col(i).tail(n-l);
}
}
V.row(i).end(n-l).setZero();
V.col(i).end(n-l).setZero();
V.row(i).tail(n-l).setZero();
V.col(i).tail(n-l).setZero();
}
V(i, i) = 1.0;
g = rv1[i];
@@ -282,7 +282,7 @@ SVD<MatrixType>& SVD<MatrixType>::compute(const MatrixType& matrix)
l = i+1;
g = W[i];
if (n-l>0)
A.row(i).end(n-l).setZero();
A.row(i).tail(n-l).setZero();
if (g != Scalar(0.0))
{
g = Scalar(1.0)/g;
@@ -290,15 +290,15 @@ SVD<MatrixType>& SVD<MatrixType>::compute(const MatrixType& matrix)
{
for (j=l; j<n; j++)
{
s = A.col(j).end(m-l).dot(A.col(i).end(m-l));
s = A.col(j).tail(m-l).dot(A.col(i).tail(m-l));
f = (s/A(i,i))*g;
A.col(j).end(m-i) += f * A.col(i).end(m-i);
A.col(j).tail(m-i) += f * A.col(i).tail(m-i);
}
}
A.col(i).end(m-i) *= g;
A.col(i).tail(m-i) *= g;
}
else
A.col(i).end(m-i).setZero();
A.col(i).tail(m-i).setZero();
++A(i,i);
}
// Diagonalization of the bidiagonal form: Loop over
@@ -408,7 +408,7 @@ SVD<MatrixType>& SVD<MatrixType>::compute(const MatrixType& matrix)
for (int i=0; i<n; i++)
{
int k;
W.end(n-i).maxCoeff(&k);
W.tail(n-i).maxCoeff(&k);
if (k != 0)
{
k += i;
@@ -451,8 +451,8 @@ struct ei_solve_retval<SVD<_MatrixType>, Rhs>
aux.coeffRef(i) /= si;
}
const int minsize = std::min(dec().rows(),dec().cols());
dst.col(j).start(minsize) = aux.start(minsize);
if(dec().cols()>dec().rows()) dst.col(j).end(cols()-minsize).setZero();
dst.col(j).head(minsize) = aux.head(minsize);
if(dec().cols()>dec().rows()) dst.col(j).tail(cols()-minsize).setZero();
dst.col(j) = dec().matrixV() * dst.col(j);
}
}