testexplicitshiftqrschurdecomposer.java
来自「一个关于java 的常用工具包」· Java 代码 · 共 81 行
JAVA
81 行
package org.jutiltest.math.matrix;import org.jutil.math.matrix.Matrix;import org.jutil.junit.JutilTest;import org.jutil.junit.CVSRevision;import org.jutil.math.matrix.SchurDecomposition;import org.jutil.math.matrix.HouseholderHessenbergReducer;import org.jutil.math.matrix.ExplicitShiftQRSchurDecomposer;import junit.framework.*;/** * @path $Source: /cvsroot/org-jutil/jutil.org/src/org/jutiltest/math/matrix/TestExplicitShiftQRSchurDecomposer.java,v $ * @date $Date: 2002/07/21 18:59:19 $ * @state $State: Exp $ * @author Marko van Dooren * @release $Name: $ */public class TestExplicitShiftQRSchurDecomposer extends JutilTest{ public TestExplicitShiftQRSchurDecomposer(String name) { super(name, new CVSRevision("1.4")); } private Matrix A; private Matrix B; public void setUp() { A = new Matrix(new double [][] {{ 1,0.5,2}, { 2,0,3}, {-1,2,4} }); // B has eigenvalues 1,3,17 // The eigenvectors are : [2 3 4] [5 1 12] [6 9 -2] B = new Matrix(new double [][] {{ 20.1868131868132, -3.64835164835165, -6.85714285714286}, { 25.7802197802198, -2.47252747252747, -10.2857142857143}, { -0.0879120879120882, -2.98901098901099, 3.28571428571429} }); } public void test() { testSchur(B); testSchur(A); } public void tearDown() { //nothing actually } public void testSchur(Matrix matrix) { ExplicitShiftQRSchurDecomposer decomposer = new ExplicitShiftQRSchurDecomposer(new HouseholderHessenbergReducer()); SchurDecomposition decomposition = decomposer.decompose(matrix); Matrix R = decomposition.R(); Matrix Q = decomposition.Q(); //System.out.println(R); //System.out.println(); //System.out.println(Q); //System.out.println(); //System.out.println(Q.times(R).times(Q.returnTranspose())); //System.out.println(); //System.out.println(Q.times(Q.returnTranspose())); }} /*<copyright>Copyright (C) 1997-2001. This software is copyrighted by the people and entities mentioned after the "@author" tags above, on behalf of the JUTIL.ORG Project. The copyright is dated by the dates after the "@date" tags above. All rights reserved.This software is published under the terms of the JUTIL.ORG SoftwareLicense version 1.1 or later, a copy of which has been included withthis distribution in the LICENSE file, which can also be found athttp://org-jutil.sourceforge.net/LICENSE. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the JUTIL.ORG Software License for more details. For more information,please see http://org-jutil.sourceforge.net/</copyright>/*/
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?