mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
bug #86 : use internal:: namespace instead of ei_ prefix
This commit is contained in:
@@ -28,14 +28,16 @@
|
||||
|
||||
// This file contains some helper function to deal with block householder reflectors
|
||||
|
||||
namespace internal {
|
||||
|
||||
/** \internal */
|
||||
template<typename TriangularFactorType,typename VectorsType,typename CoeffsType>
|
||||
void ei_make_block_householder_triangular_factor(TriangularFactorType& triFactor, const VectorsType& vectors, const CoeffsType& hCoeffs)
|
||||
void make_block_householder_triangular_factor(TriangularFactorType& triFactor, const VectorsType& vectors, const CoeffsType& hCoeffs)
|
||||
{
|
||||
typedef typename TriangularFactorType::Index Index;
|
||||
typedef typename VectorsType::Scalar Scalar;
|
||||
const Index nbVecs = vectors.cols();
|
||||
ei_assert(triFactor.rows() == nbVecs && triFactor.cols() == nbVecs && vectors.rows()>=nbVecs);
|
||||
eigen_assert(triFactor.rows() == nbVecs && triFactor.cols() == nbVecs && vectors.rows()>=nbVecs);
|
||||
|
||||
for(Index i = 0; i < nbVecs; i++)
|
||||
{
|
||||
@@ -54,13 +56,13 @@ void ei_make_block_householder_triangular_factor(TriangularFactorType& triFactor
|
||||
|
||||
/** \internal */
|
||||
template<typename MatrixType,typename VectorsType,typename CoeffsType>
|
||||
void ei_apply_block_householder_on_the_left(MatrixType& mat, const VectorsType& vectors, const CoeffsType& hCoeffs)
|
||||
void apply_block_householder_on_the_left(MatrixType& mat, const VectorsType& vectors, const CoeffsType& hCoeffs)
|
||||
{
|
||||
typedef typename MatrixType::Index Index;
|
||||
enum { TFactorSize = MatrixType::ColsAtCompileTime };
|
||||
Index nbVecs = vectors.cols();
|
||||
Matrix<typename MatrixType::Scalar, TFactorSize, TFactorSize> T(nbVecs,nbVecs);
|
||||
ei_make_block_householder_triangular_factor(T, vectors, hCoeffs);
|
||||
make_block_householder_triangular_factor(T, vectors, hCoeffs);
|
||||
|
||||
const TriangularView<VectorsType, UnitLower>& V(vectors);
|
||||
|
||||
@@ -72,5 +74,6 @@ void ei_apply_block_householder_on_the_left(MatrixType& mat, const VectorsType&
|
||||
mat.noalias() -= V * tmp;
|
||||
}
|
||||
|
||||
} // end namespace internal
|
||||
|
||||
#endif // EIGEN_BLOCK_HOUSEHOLDER_H
|
||||
|
||||
@@ -26,17 +26,19 @@
|
||||
#ifndef EIGEN_HOUSEHOLDER_H
|
||||
#define EIGEN_HOUSEHOLDER_H
|
||||
|
||||
template<int n> struct ei_decrement_size
|
||||
namespace internal {
|
||||
template<int n> struct decrement_size
|
||||
{
|
||||
enum {
|
||||
ret = n==Dynamic ? n : n-1
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
template<typename Derived>
|
||||
void MatrixBase<Derived>::makeHouseholderInPlace(Scalar& tau, RealScalar& beta)
|
||||
{
|
||||
VectorBlock<Derived, ei_decrement_size<Base::SizeAtCompileTime>::ret> essentialPart(derived(), 1, size()-1);
|
||||
VectorBlock<Derived, internal::decrement_size<Base::SizeAtCompileTime>::ret> essentialPart(derived(), 1, size()-1);
|
||||
makeHouseholder(essentialPart, tau, beta);
|
||||
}
|
||||
|
||||
@@ -68,18 +70,18 @@ void MatrixBase<Derived>::makeHouseholder(
|
||||
RealScalar tailSqNorm = size()==1 ? RealScalar(0) : tail.squaredNorm();
|
||||
Scalar c0 = coeff(0);
|
||||
|
||||
if(tailSqNorm == RealScalar(0) && ei_imag(c0)==RealScalar(0))
|
||||
if(tailSqNorm == RealScalar(0) && internal::imag(c0)==RealScalar(0))
|
||||
{
|
||||
tau = 0;
|
||||
beta = ei_real(c0);
|
||||
beta = internal::real(c0);
|
||||
}
|
||||
else
|
||||
{
|
||||
beta = ei_sqrt(ei_abs2(c0) + tailSqNorm);
|
||||
if (ei_real(c0)>=RealScalar(0))
|
||||
beta = internal::sqrt(internal::abs2(c0) + tailSqNorm);
|
||||
if (internal::real(c0)>=RealScalar(0))
|
||||
beta = -beta;
|
||||
essential = tail / (c0 - beta);
|
||||
tau = ei_conj((beta - c0) / beta);
|
||||
tau = internal::conj((beta - c0) / beta);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +98,7 @@ void MatrixBase<Derived>::applyHouseholderOnTheLeft(
|
||||
}
|
||||
else
|
||||
{
|
||||
Map<typename ei_plain_row_type<PlainObject>::type> tmp(workspace,cols());
|
||||
Map<typename internal::plain_row_type<PlainObject>::type> tmp(workspace,cols());
|
||||
Block<Derived, EssentialPart::SizeAtCompileTime, Derived::ColsAtCompileTime> bottom(derived(), 1, 0, rows()-1, cols());
|
||||
tmp.noalias() = essential.adjoint() * bottom;
|
||||
tmp += this->row(0);
|
||||
@@ -118,7 +120,7 @@ void MatrixBase<Derived>::applyHouseholderOnTheRight(
|
||||
}
|
||||
else
|
||||
{
|
||||
Map<typename ei_plain_col_type<PlainObject>::type> tmp(workspace,rows());
|
||||
Map<typename internal::plain_col_type<PlainObject>::type> tmp(workspace,rows());
|
||||
Block<Derived, Derived::RowsAtCompileTime, EssentialPart::SizeAtCompileTime> right(derived(), 0, 1, rows(), cols()-1);
|
||||
tmp.noalias() = right * essential.conjugate();
|
||||
tmp += this->col(0);
|
||||
|
||||
@@ -49,25 +49,27 @@
|
||||
* \sa MatrixBase::applyOnTheLeft(), MatrixBase::applyOnTheRight()
|
||||
*/
|
||||
|
||||
namespace internal {
|
||||
|
||||
template<typename VectorsType, typename CoeffsType, int Side>
|
||||
struct ei_traits<HouseholderSequence<VectorsType,CoeffsType,Side> >
|
||||
struct traits<HouseholderSequence<VectorsType,CoeffsType,Side> >
|
||||
{
|
||||
typedef typename VectorsType::Scalar Scalar;
|
||||
typedef typename VectorsType::Index Index;
|
||||
typedef typename VectorsType::StorageKind StorageKind;
|
||||
enum {
|
||||
RowsAtCompileTime = Side==OnTheLeft ? ei_traits<VectorsType>::RowsAtCompileTime
|
||||
: ei_traits<VectorsType>::ColsAtCompileTime,
|
||||
RowsAtCompileTime = Side==OnTheLeft ? traits<VectorsType>::RowsAtCompileTime
|
||||
: traits<VectorsType>::ColsAtCompileTime,
|
||||
ColsAtCompileTime = RowsAtCompileTime,
|
||||
MaxRowsAtCompileTime = Side==OnTheLeft ? ei_traits<VectorsType>::MaxRowsAtCompileTime
|
||||
: ei_traits<VectorsType>::MaxColsAtCompileTime,
|
||||
MaxRowsAtCompileTime = Side==OnTheLeft ? traits<VectorsType>::MaxRowsAtCompileTime
|
||||
: traits<VectorsType>::MaxColsAtCompileTime,
|
||||
MaxColsAtCompileTime = MaxRowsAtCompileTime,
|
||||
Flags = 0
|
||||
};
|
||||
};
|
||||
|
||||
template<typename VectorsType, typename CoeffsType, int Side>
|
||||
struct ei_hseq_side_dependent_impl
|
||||
struct hseq_side_dependent_impl
|
||||
{
|
||||
typedef Block<VectorsType, Dynamic, 1> EssentialVectorType;
|
||||
typedef HouseholderSequence<VectorsType, CoeffsType, OnTheLeft> HouseholderSequenceType;
|
||||
@@ -80,7 +82,7 @@ struct ei_hseq_side_dependent_impl
|
||||
};
|
||||
|
||||
template<typename VectorsType, typename CoeffsType>
|
||||
struct ei_hseq_side_dependent_impl<VectorsType, CoeffsType, OnTheRight>
|
||||
struct hseq_side_dependent_impl<VectorsType, CoeffsType, OnTheRight>
|
||||
{
|
||||
typedef Transpose<Block<VectorsType, 1, Dynamic> > EssentialVectorType;
|
||||
typedef HouseholderSequence<VectorsType, CoeffsType, OnTheRight> HouseholderSequenceType;
|
||||
@@ -92,35 +94,37 @@ struct ei_hseq_side_dependent_impl<VectorsType, CoeffsType, OnTheRight>
|
||||
}
|
||||
};
|
||||
|
||||
template<typename OtherScalarType, typename MatrixType> struct ei_matrix_type_times_scalar_type
|
||||
template<typename OtherScalarType, typename MatrixType> struct matrix_type_times_scalar_type
|
||||
{
|
||||
typedef typename ei_scalar_product_traits<OtherScalarType, typename MatrixType::Scalar>::ReturnType
|
||||
typedef typename scalar_product_traits<OtherScalarType, typename MatrixType::Scalar>::ReturnType
|
||||
ResultScalar;
|
||||
typedef Matrix<ResultScalar, MatrixType::RowsAtCompileTime, MatrixType::ColsAtCompileTime,
|
||||
0, MatrixType::MaxRowsAtCompileTime, MatrixType::MaxColsAtCompileTime> Type;
|
||||
};
|
||||
|
||||
} // end namespace internal
|
||||
|
||||
template<typename VectorsType, typename CoeffsType, int Side> class HouseholderSequence
|
||||
: public EigenBase<HouseholderSequence<VectorsType,CoeffsType,Side> >
|
||||
{
|
||||
enum {
|
||||
RowsAtCompileTime = ei_traits<HouseholderSequence>::RowsAtCompileTime,
|
||||
ColsAtCompileTime = ei_traits<HouseholderSequence>::ColsAtCompileTime,
|
||||
MaxRowsAtCompileTime = ei_traits<HouseholderSequence>::MaxRowsAtCompileTime,
|
||||
MaxColsAtCompileTime = ei_traits<HouseholderSequence>::MaxColsAtCompileTime
|
||||
RowsAtCompileTime = internal::traits<HouseholderSequence>::RowsAtCompileTime,
|
||||
ColsAtCompileTime = internal::traits<HouseholderSequence>::ColsAtCompileTime,
|
||||
MaxRowsAtCompileTime = internal::traits<HouseholderSequence>::MaxRowsAtCompileTime,
|
||||
MaxColsAtCompileTime = internal::traits<HouseholderSequence>::MaxColsAtCompileTime
|
||||
};
|
||||
typedef typename ei_traits<HouseholderSequence>::Scalar Scalar;
|
||||
typedef typename internal::traits<HouseholderSequence>::Scalar Scalar;
|
||||
typedef typename VectorsType::Index Index;
|
||||
|
||||
typedef typename ei_hseq_side_dependent_impl<VectorsType,CoeffsType,Side>::EssentialVectorType
|
||||
typedef typename internal::hseq_side_dependent_impl<VectorsType,CoeffsType,Side>::EssentialVectorType
|
||||
EssentialVectorType;
|
||||
|
||||
public:
|
||||
|
||||
typedef HouseholderSequence<
|
||||
VectorsType,
|
||||
typename ei_meta_if<NumTraits<Scalar>::IsComplex,
|
||||
typename ei_cleantype<typename CoeffsType::ConjugateReturnType>::type,
|
||||
typename internal::meta_if<NumTraits<Scalar>::IsComplex,
|
||||
typename internal::cleantype<typename CoeffsType::ConjugateReturnType>::type,
|
||||
CoeffsType>::ret,
|
||||
Side
|
||||
> ConjugateReturnType;
|
||||
@@ -141,8 +145,8 @@ template<typename VectorsType, typename CoeffsType, int Side> class HouseholderS
|
||||
|
||||
const EssentialVectorType essentialVector(Index k) const
|
||||
{
|
||||
ei_assert(k >= 0 && k < m_actualVectors);
|
||||
return ei_hseq_side_dependent_impl<VectorsType,CoeffsType,Side>::essentialVector(*this, k);
|
||||
eigen_assert(k >= 0 && k < m_actualVectors);
|
||||
return internal::hseq_side_dependent_impl<VectorsType,CoeffsType,Side>::essentialVector(*this, k);
|
||||
}
|
||||
|
||||
HouseholderSequence transpose() const
|
||||
@@ -163,8 +167,8 @@ template<typename VectorsType, typename CoeffsType, int Side> class HouseholderS
|
||||
// FIXME find a way to pass this temporary if the user want to
|
||||
Matrix<Scalar, DestType::RowsAtCompileTime, 1,
|
||||
AutoAlign|ColMajor, DestType::MaxRowsAtCompileTime, 1> temp(rows());
|
||||
if( ei_is_same_type<typename ei_cleantype<VectorsType>::type,DestType>::ret
|
||||
&& ei_extract_data(dst) == ei_extract_data(m_vectors))
|
||||
if( internal::is_same_type<typename internal::cleantype<VectorsType>::type,DestType>::ret
|
||||
&& internal::extract_data(dst) == internal::extract_data(m_vectors))
|
||||
{
|
||||
// in-place
|
||||
dst.diagonal().setOnes();
|
||||
@@ -227,24 +231,24 @@ template<typename VectorsType, typename CoeffsType, int Side> class HouseholderS
|
||||
}
|
||||
|
||||
template<typename OtherDerived>
|
||||
typename ei_matrix_type_times_scalar_type<Scalar, OtherDerived>::Type operator*(const MatrixBase<OtherDerived>& other) const
|
||||
typename internal::matrix_type_times_scalar_type<Scalar, OtherDerived>::Type operator*(const MatrixBase<OtherDerived>& other) const
|
||||
{
|
||||
typename ei_matrix_type_times_scalar_type<Scalar, OtherDerived>::Type
|
||||
res(other.template cast<typename ei_matrix_type_times_scalar_type<Scalar, OtherDerived>::ResultScalar>());
|
||||
typename internal::matrix_type_times_scalar_type<Scalar, OtherDerived>::Type
|
||||
res(other.template cast<typename internal::matrix_type_times_scalar_type<Scalar, OtherDerived>::ResultScalar>());
|
||||
applyThisOnTheLeft(res);
|
||||
return res;
|
||||
}
|
||||
|
||||
template<typename OtherDerived> friend
|
||||
typename ei_matrix_type_times_scalar_type<Scalar, OtherDerived>::Type operator*(const MatrixBase<OtherDerived>& other, const HouseholderSequence& h)
|
||||
typename internal::matrix_type_times_scalar_type<Scalar, OtherDerived>::Type operator*(const MatrixBase<OtherDerived>& other, const HouseholderSequence& h)
|
||||
{
|
||||
typename ei_matrix_type_times_scalar_type<Scalar, OtherDerived>::Type
|
||||
res(other.template cast<typename ei_matrix_type_times_scalar_type<Scalar, OtherDerived>::ResultScalar>());
|
||||
typename internal::matrix_type_times_scalar_type<Scalar, OtherDerived>::Type
|
||||
res(other.template cast<typename internal::matrix_type_times_scalar_type<Scalar, OtherDerived>::ResultScalar>());
|
||||
h.applyThisOnTheRight(res);
|
||||
return res;
|
||||
}
|
||||
|
||||
template<typename _VectorsType, typename _CoeffsType, int _Side> friend struct ei_hseq_side_dependent_impl;
|
||||
template<typename _VectorsType, typename _CoeffsType, int _Side> friend struct internal::hseq_side_dependent_impl;
|
||||
|
||||
protected:
|
||||
typename VectorsType::Nested m_vectors;
|
||||
|
||||
Reference in New Issue
Block a user