mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
committed by
Rasmus Munk Larsen
parent
918a5f1a6f
commit
f7772e3946
@@ -17,9 +17,17 @@
|
|||||||
namespace Eigen {
|
namespace Eigen {
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
template <int n>
|
template <int N>
|
||||||
struct decrement_size {
|
struct decrement_size {
|
||||||
enum { ret = n == Dynamic ? n : n - 1 };
|
static constexpr int ret = N - 1;
|
||||||
|
};
|
||||||
|
template <>
|
||||||
|
struct decrement_size<0> {
|
||||||
|
static constexpr int ret = 0;
|
||||||
|
};
|
||||||
|
template <>
|
||||||
|
struct decrement_size<Dynamic> {
|
||||||
|
static constexpr int ret = Dynamic;
|
||||||
};
|
};
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|
||||||
@@ -67,9 +75,9 @@ EIGEN_DEVICE_FUNC void MatrixBase<Derived>::makeHouseholder(EssentialPart& essen
|
|||||||
using numext::conj;
|
using numext::conj;
|
||||||
|
|
||||||
EIGEN_STATIC_ASSERT_VECTOR_ONLY(EssentialPart)
|
EIGEN_STATIC_ASSERT_VECTOR_ONLY(EssentialPart)
|
||||||
VectorBlock<const Derived, EssentialPart::SizeAtCompileTime> tail(derived(), 1, size() - 1);
|
const VectorBlock<const Derived, EssentialPart::SizeAtCompileTime> tail(derived(), 1, size() - 1);
|
||||||
|
|
||||||
RealScalar tailSqNorm = size() == 1 ? RealScalar(0) : tail.squaredNorm();
|
RealScalar tailSqNorm = size() == 1 ? RealScalar(0) : tail.unwind().squaredNorm();
|
||||||
Scalar c0 = coeff(0);
|
Scalar c0 = coeff(0);
|
||||||
const RealScalar tol = (std::numeric_limits<RealScalar>::min)();
|
const RealScalar tol = (std::numeric_limits<RealScalar>::min)();
|
||||||
|
|
||||||
@@ -80,7 +88,7 @@ EIGEN_DEVICE_FUNC void MatrixBase<Derived>::makeHouseholder(EssentialPart& essen
|
|||||||
} else {
|
} else {
|
||||||
beta = numext::sqrt(numext::abs2(c0) + tailSqNorm);
|
beta = numext::sqrt(numext::abs2(c0) + tailSqNorm);
|
||||||
if (numext::real(c0) >= RealScalar(0)) beta = -beta;
|
if (numext::real(c0) >= RealScalar(0)) beta = -beta;
|
||||||
essential = tail / (c0 - beta);
|
essential = tail.unwind() / (c0 - beta);
|
||||||
tau = conj((beta - c0) / beta);
|
tau = conj((beta - c0) / beta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -110,10 +118,10 @@ EIGEN_DEVICE_FUNC void MatrixBase<Derived>::applyHouseholderOnTheLeft(const Esse
|
|||||||
Map<typename internal::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,
|
Block<Derived, EssentialPart::SizeAtCompileTime, Derived::ColsAtCompileTime> bottom(derived(), 1, 0, rows() - 1,
|
||||||
cols());
|
cols());
|
||||||
tmp.noalias() = essential.adjoint() * bottom;
|
tmp.noalias() = essential.adjoint() * bottom.unwind();
|
||||||
tmp += this->row(0);
|
tmp = tau * (tmp + this->row(0));
|
||||||
this->row(0) -= tau * tmp;
|
this->row(0) = this->row(0) - tmp;
|
||||||
bottom.noalias() -= tau * essential * tmp;
|
bottom.unwind().noalias() -= essential * tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,10 +150,10 @@ EIGEN_DEVICE_FUNC void MatrixBase<Derived>::applyHouseholderOnTheRight(const Ess
|
|||||||
Map<typename internal::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(),
|
Block<Derived, Derived::RowsAtCompileTime, EssentialPart::SizeAtCompileTime> right(derived(), 0, 1, rows(),
|
||||||
cols() - 1);
|
cols() - 1);
|
||||||
tmp.noalias() = right * essential;
|
tmp.noalias() = right.unwind() * essential;
|
||||||
tmp += this->col(0);
|
tmp = tau * (tmp + this->col(0));
|
||||||
this->col(0) -= tau * tmp;
|
this->col(0) = this->col(0) - tmp;
|
||||||
right.noalias() -= tau * tmp * essential.adjoint();
|
right.unwind().noalias() -= tmp * essential.adjoint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user