11 #ifndef EIGEN_JACOBI_H 12 #define EIGEN_JACOBI_H 34 template<
typename Scalar>
class JacobiRotation
45 Scalar&
c() {
return m_c; }
46 Scalar
c()
const {
return m_c; }
47 Scalar&
s() {
return m_s; }
48 Scalar
s()
const {
return m_s; }
64 template<
typename Derived>
66 bool makeJacobi(
const RealScalar& x,
const Scalar&
y,
const RealScalar&
z);
68 void makeGivens(
const Scalar& p,
const Scalar& q, Scalar* z=0);
82 template<
typename Scalar>
89 if(deno < (std::numeric_limits<RealScalar>::min)())
97 RealScalar tau = (x-z)/deno;
125 template<
typename Scalar>
126 template<
typename Derived>
148 template<
typename Scalar>
156 template<
typename Scalar>
169 else if(p==Scalar(0))
215 template<
typename Scalar>
222 m_c = p<Scalar(0) ? Scalar(-1) : Scalar(1);
226 else if(p==Scalar(0))
229 m_s = q<Scalar(0) ? Scalar(1) : Scalar(-1);
266 template<
typename VectorX,
typename VectorY,
typename OtherScalar>
276 template<
typename Derived>
277 template<
typename OtherScalar>
291 template<
typename Derived>
292 template<
typename OtherScalar>
301 template<
typename VectorX,
typename VectorY,
typename OtherScalar>
304 typedef typename VectorX::Scalar Scalar;
313 Index incrx = xpr_x.derived().innerStride();
314 Index incry = xpr_y.derived().innerStride();
319 OtherScalar
c = j.c();
320 OtherScalar
s = j.s();
321 if (c==OtherScalar(1) && s==OtherScalar(0))
326 if(VectorX::SizeAtCompileTime ==
Dynamic &&
328 (PacketSize == OtherPacketSize) &&
329 ((incrx==1 && incry==1) || PacketSize == 1))
332 enum { Peeling = 2 };
335 Index alignedEnd = alignedStart + ((size-alignedStart)/PacketSize)*PacketSize;
337 const OtherPacket pc = pset1<OtherPacket>(
c);
338 const OtherPacket ps = pset1<OtherPacket>(
s);
342 for(
Index i=0; i<alignedStart; ++i)
355 for(
Index i=alignedStart; i<alignedEnd; i+=PacketSize)
357 Packet xi = pload<Packet>(px);
358 Packet yi = pload<Packet>(py);
367 Index peelingEnd = alignedStart + ((size-alignedStart)/(Peeling*PacketSize))*(Peeling*PacketSize);
368 for(
Index i=alignedStart; i<peelingEnd; i+=Peeling*PacketSize)
370 Packet xi = ploadu<Packet>(px);
371 Packet xi1 = ploadu<Packet>(px+PacketSize);
372 Packet yi = pload <Packet>(py);
373 Packet yi1 = pload <Packet>(py+PacketSize);
378 px += Peeling*PacketSize;
379 py += Peeling*PacketSize;
381 if(alignedEnd!=peelingEnd)
383 Packet xi = ploadu<Packet>(x+peelingEnd);
384 Packet yi = pload <Packet>(y+peelingEnd);
400 else if(VectorX::SizeAtCompileTime !=
Dynamic &&
401 (VectorX::Flags & VectorY::Flags & PacketAccessBit) &&
402 (PacketSize == OtherPacketSize) &&
405 const OtherPacket pc = pset1<OtherPacket>(
c);
406 const OtherPacket ps = pset1<OtherPacket>(
s);
413 Packet xi = pload<Packet>(px);
414 Packet yi = pload<Packet>(py);
441 #endif // EIGEN_JACOBI_H
const AutoDiffScalar< DerType > & conj(const AutoDiffScalar< DerType > &x)
JacobiRotation operator*(const JacobiRotation &other)
EIGEN_DEVICE_FUNC RealReturnType real() const
void applyOnTheLeft(const EigenBase< OtherDerived > &other)
void makeGivens(const Scalar &p, const Scalar &q, Scalar *z=0)
JacobiRotation(const Scalar &c, const Scalar &s)
void applyOnTheRight(const EigenBase< OtherDerived > &other)
EIGEN_DEVICE_FUNC const SqrtReturnType sqrt() const
static constexpr size_t size(Tuple< Args... > &)
Provides access to the number of elements in a tuple as a compile-time constant expression.
Rotation given by a cosine-sine pair.
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const AbsReturnType abs() const
bool makeJacobi(const MatrixBase< Derived > &, Index p, Index q)
Base class for all dense matrices, vectors, and arrays.
JacobiRotation transpose() const
const unsigned int PacketAccessBit
static Index first_default_aligned(const DenseBase< Derived > &m)
EIGEN_DEVICE_FUNC Packet padd(const Packet &a, const Packet &b)
EIGEN_DEVICE_FUNC ColXpr col(Index i)
This is the const version of col().
EIGEN_DEVICE_FUNC void pstoreu(Scalar *to, const Packet &from)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
EIGEN_DEVICE_FUNC RowXpr row(Index i)
This is the const version of row(). */.
JacobiRotation adjoint() const
EIGEN_DEVICE_FUNC const Scalar & q
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Abs2ReturnType abs2() const
EIGEN_DEVICE_FUNC void pstore(Scalar *to, const Packet &from)
TFSIMD_FORCE_INLINE const tfScalar & z() const
NumTraits< Scalar >::Real RealScalar
TFSIMD_FORCE_INLINE const tfScalar & w() const
Expression of a fixed-size or dynamic-size block.
#define EIGEN_PLAIN_ENUM_MIN(a, b)
EIGEN_DEVICE_FUNC Packet psub(const Packet &a, const Packet &b)
void apply_rotation_in_the_plane(DenseBase< VectorX > &xpr_x, DenseBase< VectorY > &xpr_y, const JacobiRotation< OtherScalar > &j)
Base class for all dense matrices, vectors, and expressions.
EIGEN_STRONG_INLINE Scalar pmul(const LhsScalar &x, const RhsScalar &y) const