01 /*
02 * $Id: QzDecomposeSample.java,v 1.8 2008/02/02 03:06:27 koga Exp $
03 *
04 * Copyright (C) 2004 Koga Laboratory. All rights reserved.
05 *
06 */
07 package matxbook.chap08;
08
09 import org.mklab.nfc.eig.QZDecomposition;
10 import org.mklab.nfc.matrix.DoubleMatrix;
11 import org.mklab.nfc.matrix.Matrix;
12 import org.mklab.nfc.matrix.NumericalMatrixOperator;
13
14
15 /**
16 * QZ分解のサンプルです。
17 * @author koga
18 * @version $Revision: 1.8 $, 2004/04/15
19 */
20 public class QzDecomposeSample {
21
22 /**
23 * メインメソッド
24 *
25 * @param args コマンドライン引数
26 */
27 @SuppressWarnings("nls")
28 public static void main(String[] args) {
29 DoubleMatrix a = new DoubleMatrix(new double[][] { {1, 2}, {6, 5}});
30 DoubleMatrix b = new DoubleMatrix(new double[][] { {3, 4}, {2, 1}});
31 QZDecomposition<NumericalMatrixOperator<?>> abqzx = a.qzDecompose(b);
32 Matrix aa = abqzx.getAA();
33 Matrix bb = abqzx.getBB();
34 Matrix q = abqzx.getQ();
35 Matrix z = abqzx.getZ();
36 Matrix x = abqzx.getX();
37
38 q.conjugateTranspose().multiply(a).multiply(z).subtract(aa).print("Q#*A*Z - AA");
39 q.conjugateTranspose().multiply(b).multiply(z).subtract(bb).print("Q#*B*Z - BB");
40 Matrix m1 = a.multiply(x).multiply(bb.diagonalToVector());
41 Matrix m2 = b.multiply(x).multiply(aa.diagonalToVector());
42 m1.subtract(m2).print("A*X*diag_vec(BB) - B*X*diag_vec(AA)");
43 }
44 }
|