10 #ifndef EIGEN_REAL_QZ_H 11 #define EIGEN_REAL_QZ_H 57 template<
typename _MatrixType>
class RealQZ 105 RealQZ(
const MatrixType&
A,
const MatrixType&
B,
bool computeQZ =
true) :
163 RealQZ&
compute(
const MatrixType&
A,
const MatrixType&
B,
bool computeQZ =
true);
219 template<
typename MatrixType>
228 m_T.template triangularView<StrictlyLower>().
setZero();
231 m_S.applyOnTheLeft(
m_Q.adjoint());
234 m_Z = MatrixType::Identity(dim,dim);
240 if(
m_S.coeff(
i,
j) != 0)
248 m_Q.applyOnTheRight(
i-1,
i,G);
255 m_S.applyOnTheRight(
i,
i-1,G);
256 m_T.topRows(
i).applyOnTheRight(
i,
i-1,G);
266 template<
typename MatrixType>
281 template<
typename MatrixType>
299 template<
typename MatrixType>
313 template<
typename MatrixType>
325 Matrix2s STi =
m_T.template block<2,2>(
i,
i).
template triangularView<Upper>().
326 template solve<OnTheRight>(
m_S.template block<2,2>(
i,
i));
328 Scalar q = p*p + STi(1,0)*STi(0,1);
339 m_S.rightCols(dim-i).applyOnTheLeft(i,i+1,G.
adjoint());
340 m_T.rightCols(dim-i).applyOnTheLeft(i,i+1,G.
adjoint());
343 m_Q.applyOnTheRight(i,i+1,G);
346 m_S.topRows(i+2).applyOnTheRight(i+1,i,G);
347 m_T.topRows(i+2).applyOnTheRight(i+1,i,G);
363 template<
typename MatrixType>
368 for (
Index zz=z; zz<
l; zz++)
371 Index firstColS = zz>f ? (zz-1) : zz;
373 m_S.rightCols(dim-firstColS).applyOnTheLeft(zz,zz+1,G.
adjoint());
374 m_T.rightCols(dim-zz).applyOnTheLeft(zz,zz+1,G.
adjoint());
378 m_Q.applyOnTheRight(zz,zz+1,G);
383 m_S.topRows(zz+2).applyOnTheRight(zz, zz-1,G);
384 m_T.topRows(zz+1).applyOnTheRight(zz, zz-1,G);
393 m_S.applyOnTheRight(l,l-1,G);
394 m_T.applyOnTheRight(l,l-1,G);
402 template<
typename MatrixType>
414 a11=
m_S.coeff(f+0,f+0), a12=
m_S.coeff(f+0,f+1),
415 a21=
m_S.coeff(f+1,f+0), a22=
m_S.coeff(f+1,f+1), a32=
m_S.coeff(f+2,f+1),
416 b12=
m_T.coeff(f+0,f+1),
419 a87=
m_S.coeff(l-1,l-2),
420 a98=
m_S.coeff(l-0,l-1),
426 x = ll + a11*a11*b11i*b11i - lpl*a11*b11i + a12*a21*b11i*b22i
427 - a11*a21*b12*b11i*b11i*b22i;
428 y = a11*a21*b11i*b11i - lpl*a21*b11i + a21*a22*b11i*b22i
429 - a21*a21*b12*b11i*b11i*b22i;
430 z = a21*a32*b11i*b22i;
435 x =
m_S.coeff(f,f)/
m_T.coeff(f,f)-
m_S.coeff(l,l)/
m_T.coeff(l,l) +
m_S.coeff(l,l-1)*
m_T.coeff(l-1,l) /
436 (
m_T.coeff(l-1,l-1)*
m_T.coeff(l,l));
437 y =
m_S.coeff(f+1,f)/
m_T.coeff(f,f);
440 else if (iter>23 && !(iter%8))
443 x = internal::random<Scalar>(-1.0,1.0);
444 y = internal::random<Scalar>(-1.0,1.0);
445 z = internal::random<Scalar>(-1.0,1.0);
456 a11 =
m_S.coeff(f,f), a12 =
m_S.coeff(f,f+1),
457 a21 =
m_S.coeff(f+1,f), a22 =
m_S.coeff(f+1,f+1),
458 a32 =
m_S.coeff(f+2,f+1),
460 a88 =
m_S.coeff(l-1,l-1), a89 =
m_S.coeff(l-1,l),
461 a98 =
m_S.coeff(l,l-1), a99 =
m_S.coeff(l,l),
463 b11 =
m_T.coeff(f,f), b12 =
m_T.coeff(f,f+1),
464 b22 =
m_T.coeff(f+1,f+1),
466 b88 =
m_T.coeff(l-1,l-1), b89 =
m_T.coeff(l-1,l),
467 b99 =
m_T.coeff(l,l);
469 x = ( (a88/b88 - a11/b11)*(a99/b99 - a11/b11) - (a89/b99)*(a98/b88) + (a98/b88)*(b89/b99)*(a11/b11) ) * (b11/a21)
470 + a12/b22 - (a11/b11)*(b12/b22);
471 y = (a22/b22-a11/b11) - (a21/b11)*(b12/b22) - (a88/b88-a11/b11) - (a99/b99-a11/b11) + (a98/b88)*(b89/b99);
477 for (
Index k=f; k<=l-2; k++)
486 hr.makeHouseholderInPlace(tau, beta);
487 essential2 = hr.template bottomRows<2>();
492 m_Q.template middleCols<3>(k).applyHouseholderOnTheRight(essential2, tau,
m_workspace.
data());
494 m_S.coeffRef(k+2,k-1) =
m_S.coeffRef(k+1,k-1) =
Scalar(0.0);
497 hr <<
m_T.coeff(k+2,k+2),
m_T.coeff(k+2,k),
m_T.coeff(k+2,k+1);
498 hr.makeHouseholderInPlace(tau, beta);
499 essential2 = hr.template bottomRows<2>();
504 tmp =
m_S.template middleCols<2>(k).
topRows(lr) * essential2;
505 tmp +=
m_S.col(k+2).head(lr);
506 m_S.col(k+2).head(lr) -= tau*tmp;
507 m_S.template middleCols<2>(k).
topRows(lr) -= (tau*tmp) * essential2.adjoint();
509 tmp =
m_T.template middleCols<2>(k).
topRows(lr) * essential2;
510 tmp +=
m_T.col(k+2).head(lr);
511 m_T.col(k+2).head(lr) -= tau*tmp;
512 m_T.template middleCols<2>(k).
topRows(lr) -= (tau*tmp) * essential2.adjoint();
518 tmp = essential2.adjoint()*(
m_Z.template middleRows<2>(k));
520 m_Z.row(k+2) -= tau*tmp;
521 m_Z.template middleRows<2>(k) -= essential2 * (tau*tmp);
523 m_T.coeffRef(k+2,k) =
m_T.coeffRef(k+2,k+1) =
Scalar(0.0);
527 m_S.applyOnTheRight(k+1,k,G);
528 m_T.applyOnTheRight(k+1,k,G);
535 x =
m_S.coeff(k+1,k);
536 y =
m_S.coeff(k+2,k);
538 z =
m_S.coeff(k+3,k);
546 m_Q.applyOnTheRight(l-1,l,G);
551 m_S.applyOnTheRight(l,l-1,G);
552 m_T.applyOnTheRight(l,l-1,G);
558 template<
typename MatrixType>
562 const Index dim = A_in.cols();
565 && B_in.rows()==dim && B_in.cols()==dim
566 &&
"Need square matrices of the same dimension");
587 if (f>0)
m_S.coeffRef(f,f-1) =
Scalar(0.0);
613 step(f,l, local_iter);
636 m_S.applyOnTheLeft(
i,
i+1,j_left);
637 m_S.applyOnTheRight(
i,
i+1,j_right);
638 m_T.applyOnTheLeft(
i,
i+1,j_left);
639 m_T.applyOnTheRight(
i,
i+1,j_right);
657 #endif //EIGEN_REAL_QZ Matrix< ComplexScalar, ColsAtCompileTime, 1, Options &~RowMajor, MaxColsAtCompileTime, 1 > EigenvalueType
void pushDownZero(Index z, Index f, Index l)
const MatrixType & matrixS() const
Returns matrix S in the QZ decomposition.
std::complex< typename NumTraits< Scalar >::Real > ComplexScalar
JacobiRotation< float > G
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar * data() const
Index iterations() const
Returns number of performed QR-like iterations.
Index findSmallSubdiagEntry(Index iu)
A matrix or vector expression mapping an existing array of data.
const MatrixType & matrixQR() const
RealQZ(Index size=RowsAtCompileTime==Dynamic ? 1 :RowsAtCompileTime)
Default constructor.
Namespace containing all symbols from the Eigen library.
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE NRowsBlockXpr< internal::get_fixed_value< NRowsType >::value >::Type topRows(NRowsType n)
Rotation given by a cosine-sine pair.
iterator iter(handle obj)
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
void step(Index f, Index l, Index iter)
JacobiRotation< Scalar > JRs
RealQZ & setMaxIterations(Index maxIters)
Matrix< Scalar, 3, 1 > Vector3s
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
void real_2x2_jacobi_svd(const MatrixType &matrix, Index p, Index q, JacobiRotation< RealScalar > *j_left, JacobiRotation< RealScalar > *j_right)
static const Line3 l(Rot3(), 1, 1)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void resize(Index rows, Index cols)
EIGEN_DEVICE_FUNC void makeGivens(const Scalar &p, const Scalar &q, Scalar *r=0)
RealQZ(const MatrixType &A, const MatrixType &B, bool computeQZ=true)
Constructor; computes real QZ decomposition of given matrices.
MatrixType::Scalar Scalar
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Matrix< Scalar, Dynamic, 1 > m_workspace
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
EIGEN_DEVICE_FUNC const Scalar & q
HouseholderSequenceType householderQ() const
Matrix< Scalar, 2, 1 > Vector2s
const MatrixType & matrixZ() const
Returns matrix Z in the QZ decomposition.
ComputationInfo info() const
Reports whether previous computation was successful.
Matrix< Scalar, ColsAtCompileTime, 1, Options &~RowMajor, MaxColsAtCompileTime, 1 > ColumnVectorType
EIGEN_DEVICE_FUNC JacobiRotation adjoint() const
static std::stringstream ss
mp::number< mp::cpp_dec_float< 100 >, mp::et_on > Real
Matrix< Scalar, 2, 2 > Matrix2s
EIGEN_DEVICE_FUNC JacobiRotation transpose() const
const MatrixType & matrixT() const
Returns matrix S in the QZ decomposition.
void splitOffTwoRows(Index i)
RealQZ & compute(const MatrixType &A, const MatrixType &B, bool computeQZ=true)
Computes QZ decomposition of given matrix.
Index findSmallDiagEntry(Index f, Index l)
void hessenbergTriangular()
Jet< T, N > sqrt(const Jet< T, N > &f)
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE NColsBlockXpr< internal::get_fixed_value< NColsType >::value >::Type rightCols(NColsType n)
const MatrixType & matrixQ() const
Returns matrix Q in the QZ decomposition.
Performs a real QZ decomposition of a pair of square matrices.