// 通过非线性方程组构造牛顿迭代 public NewtonMethod(NonlinearEquations e, int uNum, int eNum, int mItera, double preci, double[] sVal) { theUnknowNum = uNum; theEquationNum = eNum; theMaxIterativeTime = mItera; thePrecision = preci; theStartValue = new double[uNum]; for (int i = 0; i < uNum; i++) { theStartValue[i] = sVal[i]; } // 构造非线性方程组 theEquations = new NonlinearEquations(); theEquations.Clear(); for (int i = 0; i < eNum; i++) { theEquations.AddEquation(e[i]); } // 构造雅各比方程组 theJacobiEquations = new NonlinearEquation[theEquationNum, theUnknowNum]; for (int i = 0; i < theEquationNum; i++) { for (int j = 0; j < theUnknowNum; j++) { theJacobiEquations[i, j] = new NonlinearEquation(theUnknowNum); theJacobiEquations[i, j] = PartialDifferential(theEquations[i], j); } } theEndValue = new double[uNum]; }
public void AddEquations(NonlinearEquations Equations) // 添加非线性方程集合到当前集合 { for (int i = 0; i < Equations.Capacity; i++) { AddEquation((NonlinearEquation)Equations.List[i]); } }
private double[] ConstantMatrix(NonlinearEquations e) // 返回方程组e的常数项矩阵 { double[] y = new double[theEquationNum]; for (int i = 0; i < theEquationNum; i++) { y[i] = e[i].theConstant; } return(y); }
private double[,] CoefficientMatrix(NonlinearEquations e) // 返回方程组e的系数矩阵 { double[,] c = new double[theEquationNum, theUnknowNum]; for (int i = 0; i < theEquationNum; i++) { for (int j = 0; j < theUnknowNum; j++) { c[i, j] = e[i].theCoefficient[j]; } } return(c); }
private double[,] AugmentationMatrix(NonlinearEquations e) // 返回方程组e的增广矩阵 { double[,] a = new double[theEquationNum, theUnknowNum + 1]; for (int i = 0; i < theEquationNum; i++) { for (int j = 0; j < theUnknowNum; j++) { a[i, j] = e[i].theCoefficient[j]; } a[i, theUnknowNum] = e[i].theConstant; } return(a); }
public NonlinearEquations(NonlinearEquations Equations) // 构造函数 { AddEquations(Equations); }