10 typedef complex<double>
Cd_t;
13 void sb04od_(
char *REDUCE,
char *TRANS,
char *JOBD,
int *M,
int *
N,
double *A,
int *LDA,
double *B,
int *LDB,
double *C,
int *LDC,
double *D,
int *LDD,
double *E,
int *LDE,
double *F,
int *LDF,
double *SCALE,
double *DIF,
double *P,
int *LDP,
double *Q,
int *LDQ,
double *U,
int *LDU,
double *V,
int *LDV,
int* IWORK,
double* DWORK,
int* LDWORK,
int* INFO);
24 Eigen::MatrixXd A(4,4), B(4,4), C(4,4), D(4,4), E(4,4), F(4,4), P(4,4), Q(4,4), U(4,4), V(4,4), A1(4,4), B1(4,4), C1(4,4), D1(4,4), E1(4,4), F1(4,4);
25 A = Eigen::MatrixXd::Random(4,4);
26 B = Eigen::MatrixXd::Random(4, 4);
27 C = Eigen::MatrixXd::Random(4, 4);
28 D = Eigen::MatrixXd::Random(4, 4);
29 E = Eigen::MatrixXd::Random(4, 4);
30 F = Eigen::MatrixXd::Random(4, 4);
47 int ldA = A.outerStride();
48 int ldB = B.outerStride();
49 int ldC = C.outerStride();
50 int ldD = D.outerStride();
51 int ldE = E.outerStride();
52 int ldF = F.outerStride();
53 int ldP = P.outerStride();
54 int ldQ = Q.outerStride();
55 int ldU = U.outerStride();
56 int ldV = V.outerStride();
65 cout << __LINE__ << endl
69 sb04od_(&reduce, &trans, &jobd, &M, &
N, A.data(), &ldA, B.data(), &ldB, C.data(), &ldC, D.data(), &ldD, E.data(), &ldE, F.data(), &ldF, &scale, &dif, P.data(), &ldP, Q.data(), &ldQ, U.data(), &ldU, V.data(), &ldV, &iwork[0], &dwork[0], &ldwork, &info);
73 cout <<
"ldwork: "<< ldwork << endl;
75 sb04od_(&reduce, &trans, &jobd, &M, &
N, A.data(), &ldA, B.data(), &ldB, C.data(), &ldC, D.data(), &ldD, E.data(), &ldE, F.data(), &ldF, &scale, &dif, P.data(), &ldP, Q.data(), &ldQ, U.data(), &ldU, V.data(), &ldV, &iwork[0], &dwork[0], &ldwork, &info);
76 cout << __LINE__ << endl
79 cout <<
"Scale = " << scale << endl;
80 cout <<
"A = " << A << endl;
81 cout <<
"B = " << B << endl;
82 cout <<
"C = " << C << endl;
83 cout <<
"E = " << E << endl;
84 cout <<
"F = " << F << endl;
85 cout <<
"P = " << P << endl;
86 cout <<
"Q = " << Q << endl;
87 cout << __LINE__ << endl
90 cout <<
"First equation: " << A1 * C - F * B1 - scale * C1 << endl;
91 cout <<
"Second equation: " << D1 * C - F * E1 - scale * F1 << endl;
92 cout << __LINE__ << endl
97 std::complex<double> wkopt;
98 std::complex<double> *work;
100 Eigen::Matrix<std::complex<double>, Eigen::Dynamic, Eigen::Dynamic> Ac(1000, 1000), Bc(1000, 1000), vl(1000, 1000), vr(1000, 1000), eigenvalues_temp(1000, 1), alpha_temp(1000, 1), beta_temp(1000, 1), alpha(1000, 1), beta(1000, 1);
102 cout << __LINE__ << endl
105 Ac = Eigen::MatrixXcd::Random(1000, 1000);
106 Bc = Eigen::MatrixXcd::Random(1000, 1000);
109 int ldac = Ac.outerStride();
110 int ldbc = Bc.outerStride();
113 int ldvl = vl.outerStride();
114 cout <<
"ldvl = " << ldvl << endl;
115 int ldvr = vr.outerStride();
116 double rwork[8 * 1000];
124 bwork =
new bool[1000];
126 zgges_(&jobvl, &jobvr, &sort, &
criteria_, &
N, Ac.data(), &ldac, Bc.data(), &ldbc, &sdim, alpha.data(), beta.data(), vl.data(), &ldvl, vr.data(), &ldvr, &workc[0], &lwork, &rwork[0], bwork, &info);
129 lwork = int(
real(workc[0]));
132 zgges_(&jobvl, &jobvr, &sort, &
criteria_, &
N, Ac.data(), &ldac, Bc.data(), &ldbc, &sdim, alpha.data(), beta.data(), vl.data(), &ldvl, vr.data(), &ldvr, &workc[0], &lwork, &rwork[0], bwork, &info);
136 cout <<
"info = " << info << endl;
139 Eigen::MatrixXcd AA(4,4), BB(4,4), QQ(4,4);
140 AA = Eigen::MatrixXcd::Random(4,4);
141 BB = Eigen::MatrixXcd::Random(4, 4);
142 QQ = Eigen::MatrixXcd::Random(4, 4);
143 Eigen::MatrixXcd X1 =
dlyap(AA,BB,QQ);
145 cout <<
"Testing dlyap: " << (AA*X1*BB - X1 + QQ).norm() << endl;
147 Eigen::MatrixXcd X2 =
lyap(AA,BB,Q);
149 cout <<
"Testing lyap: " << (AA*X2 + X2*BB + Q).norm() << endl;
153 cout <<
"qz info : " << qz.
info << endl;
154 cout <<
"Test qz 1: " << (qz.
VSL*qz.
S*qz.
VSR.adjoint() - AA).norm() << endl;
155 cout <<
"Test qz 2: " << (qz.
VSL * qz.
T * qz.
VSR.adjoint() - BB).norm() << endl;
Eigen::MatrixXcd lyap(Eigen::MatrixXcd A, Eigen::MatrixXcd B, Eigen::MatrixXcd Q)
Solves the Lyapunov/ sylvester equation: AX + XB + Q = 0.
bool criteria_(Cd_t alpha, Cd_t beta)
void sb04od_(char *REDUCE, char *TRANS, char *JOBD, int *M, int *N, double *A, int *LDA, double *B, int *LDB, double *C, int *LDC, double *D, int *LDD, double *E, int *LDE, double *F, int *LDF, double *SCALE, double *DIF, double *P, int *LDP, double *Q, int *LDQ, double *U, int *LDU, double *V, int *LDV, int *IWORK, double *DWORK, int *LDWORK, int *INFO)
void zgges_(char *JOBVSL, char *JOBVSR, char *SORT, bool(*SELCTG)(Cd_t a, Cd_t b), int *N, Cd_t *A, int *LDA, Cd_t *B, int *LDB, int *SDIM, Cd_t *ALPHA, Cd_t *BETA, Cd_t *VSL, int *LDVSL, Cd_t *VSR, int *LDVSR, Cd_t *WORK, int *LWORK, double *RWORK, bool *BWORK, int *INFO)
int N
Specifies number of Chebyshev polynomials, default N = 31.
Eigen::MatrixXcd dlyap(Eigen::MatrixXcd A, Eigen::MatrixXcd B, Eigen::MatrixXcd Q)
Solves the Lyapunov/ sylvester equation: AXB - X + Q = 0.
valarray< T > real(const valarray< complex< T > > &in)
real part of a complex valarray