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>
124 template<
typename Scalar>
125 template<
typename Derived>
147 template<
typename Scalar>
155 template<
typename Scalar>
168 else if(p==Scalar(0))
214 template<
typename Scalar>
221 m_c = p<Scalar(0) ? Scalar(-1) : Scalar(1);
225 else if(p==Scalar(0))
228 m_s = q<Scalar(0) ? Scalar(1) : Scalar(-1);
265 template<
typename VectorX,
typename VectorY,
typename OtherScalar>
275 template<
typename Derived>
276 template<
typename OtherScalar>
290 template<
typename Derived>
291 template<
typename OtherScalar>
300 template<
typename VectorX,
typename VectorY,
typename OtherScalar>
303 typedef typename VectorX::Index Index;
304 typedef typename VectorX::Scalar Scalar;
308 Index size = _x.size();
309 Index incrx = _x.innerStride();
310 Index incry = _y.innerStride();
315 OtherScalar
c = j.c();
316 OtherScalar
s = j.s();
317 if (c==OtherScalar(1) && s==OtherScalar(0))
322 if(VectorX::SizeAtCompileTime ==
Dynamic &&
324 ((incrx==1 && incry==1) || PacketSize == 1))
327 enum { Peeling = 2 };
330 Index alignedEnd = alignedStart + ((size-alignedStart)/PacketSize)*PacketSize;
332 const Packet pc = pset1<Packet>(
c);
333 const Packet ps = pset1<Packet>(
s);
336 for(Index i=0; i<alignedStart; ++i)
349 for(Index i=alignedStart; i<alignedEnd; i+=PacketSize)
351 Packet xi = pload<Packet>(px);
352 Packet yi = pload<Packet>(py);
361 Index peelingEnd = alignedStart + ((size-alignedStart)/(Peeling*PacketSize))*(Peeling*PacketSize);
362 for(Index i=alignedStart; i<peelingEnd; i+=Peeling*PacketSize)
364 Packet xi = ploadu<Packet>(px);
365 Packet xi1 = ploadu<Packet>(px+PacketSize);
366 Packet yi = pload <Packet>(py);
367 Packet yi1 = pload <Packet>(py+PacketSize);
372 px += Peeling*PacketSize;
373 py += Peeling*PacketSize;
375 if(alignedEnd!=peelingEnd)
377 Packet xi = ploadu<Packet>(x+peelingEnd);
378 Packet yi = pload <Packet>(y+peelingEnd);
384 for(Index i=alignedEnd; i<size; ++i)
394 else if(VectorX::SizeAtCompileTime !=
Dynamic &&
395 (VectorX::Flags & VectorY::Flags & PacketAccessBit) &&
396 (VectorX::Flags & VectorY::Flags &
AlignedBit))
398 const Packet pc = pset1<Packet>(
c);
399 const Packet ps = pset1<Packet>(
s);
403 for(Index i=0; i<size; i+=PacketSize)
405 Packet xi = pload<Packet>(px);
406 Packet yi = pload<Packet>(py);
417 for(Index i=0; i<size; ++i)
433 #endif // EIGEN_JACOBI_H
const AutoDiffScalar< DerType > & conj(const AutoDiffScalar< DerType > &x)
IntermediateState sqrt(const Expression &arg)
JacobiRotation operator*(const JacobiRotation &other)
void applyOnTheLeft(const EigenBase< OtherDerived > &other)
internal::traits< Derived >::Index Index
The type of indices.
void makeGivens(const Scalar &p, const Scalar &q, Scalar *z=0)
JacobiRotation(const Scalar &c, const Scalar &s)
void applyOnTheRight(const EigenBase< OtherDerived > &other)
iterative scaling algorithm to equilibrate rows and column norms in matrices
Rotation given by a cosine-sine pair.
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
JacobiRotation transpose() const
EIGEN_STRONG_INLINE const CwiseUnaryOp< internal::scalar_abs2_op< Scalar >, const Derived > abs2() const
const unsigned int PacketAccessBit
void pstore(Scalar *to, const Packet &from)
EIGEN_STRONG_INLINE const CwiseUnaryOp< internal::scalar_abs_op< Scalar >, const Derived > abs() const
RealReturnType real() const
const unsigned int AlignedBit
void pstoreu(Scalar *to, const Packet &from)
Packet psub(const Packet &a, const Packet &b)
bool makeJacobi(const MatrixBase< Derived > &, typename Derived::Index p, typename Derived::Index q)
JacobiRotation adjoint() const
NumTraits< Scalar >::Real RealScalar
Expression of a fixed-size or dynamic-size block.
void apply_rotation_in_the_plane(VectorX &_x, VectorY &_y, const JacobiRotation< OtherScalar > &j)
Packet pmul(const Packet &a, const Packet &b)
static Derived::Index first_aligned(const Derived &m)
Base class for all dense matrices, vectors, and expressions.
Packet padd(const Packet &a, const Packet &b)