📄 abstractsolver.java
字号:
package org.jutil.math.matrix;/** * <p>A helper class for classes that solve systems of equations using * matrices. That often involves solve a triangular system at the end.</p> * * @path $Source: /cvsroot/org-jutil/jutil.org/src/org/jutil/math/matrix/AbstractSolver.java,v $ * @version $Revision: 1.3 $ * @date $Date: 2002/07/02 14:27:31 $ * @state $State: Exp $ * @author Marko van Dooren * @release $Name: $ */public abstract class AbstractSolver { /** * <p>Solve the uppertriangular linear system of equations defined by * <code>R * x = b</code></p> * * @param R * The uppertriangular matrix containing the coefficients of the * equations. * @param b * A column containing the right-hand sides of the equations. */ /*@ @ public behavior @ @ pre R != null; @ pre b != null; @ pre R.isSquare(); @ pre R.isUpperTriangular(); @ pre b.size() == R.getNbRows(); @ pre (* R is nonsingular *); @ @ post (* R.times(\result).equals(b) *); @*/ public Column backSubstitute(Matrix R, Column b) { int size = b.size(); Column result = (Column) b.clone(); for (int i=size; i >= 1; i--) { double bi = result.elementAt(i)/R.elementAt(i,i); result.setElementAt(i,bi); for (int j=i-1; j>= 1; j--) { double bj = result.elementAt(j) - R.elementAt(j,i) * bi; result.setElementAt(j,bj); } } return result; } /** * <p>Solve the lowertriangular linear system of equations defined by * <code>L * x = b</code></p> * * @param L * The lowertriangular matrix containing the coefficients of the * equations. * @param b * A column containing the right-hand sides of the equations. */ /*@ @ public behavior @ @ pre L != null; @ pre b != null; @ pre L.isSquare(); @ pre L.isLowerTriangular(); @ pre b.size() == L.getNbRows(); @ pre (* L is nonsingular *); @ @ post (* L.times(\result).equals(b) *); @*/ public Column forwardSubstitute(Matrix L, Column b) { int size = b.size(); Column result = (Column) b.clone(); for (int i=1; i <= size; i++) { double bi = result.elementAt(i)/L.elementAt(i,i); result.setElementAt(i,bi); for (int j=i+1; j<= size; j++) { double bj = result.elementAt(j) - L.elementAt(j,i) * bi; result.setElementAt(j,bj); } } return result; }}/*<copyright>Copyright (C) 1997-2002. 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://www.jutil.org/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://jutil.org/</copyright>*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -