public static Tuple <Vector <double>, int> Newton(Vector <double> x, double eps) { Vector <double> y = CreateVector.Dense <double>(x.Count); int count = 0; do { y = x; x = x + LUDecomposition.SolveSLE(CalculateJacobiMatrixValue(x), -CalculateFuncValue(x)); ++count; } while ((x - y).L2Norm() >= eps); return(Tuple.Create(x, count)); }
public static Tuple <Vector <double>, int> NewtonHybrid(Vector <double> x, double eps, int k) { Vector <double> y = CreateVector.Dense <double>(x.Count); int count = 0; var tmpJacobi = CalculateJacobiMatrixValue(x); do { ++count; y = x; if (count % k == 0) { tmpJacobi = CalculateJacobiMatrixValue(x); } x = x + LUDecomposition.SolveSLE(tmpJacobi, -CalculateFuncValue(x)); } while ((x - y).L2Norm() >= eps && count < 100); return(Tuple.Create(x, count)); }