| 1892 | **********************************************************************/ |
| 1893 | |
| 1894 | static int CVnlsNewton(CVodeMem cv_mem, int nflag) |
| 1895 | { |
| 1896 | N_Vector vtemp1, vtemp2, vtemp3; |
| 1897 | int convfail, ier; |
| 1898 | boole callSetup; |
| 1899 | |
| 1900 | vtemp1 = acor; /* rename acor as vtemp1 for readability */ |
| 1901 | vtemp2 = y; /* rename y as vtemp2 for readability */ |
| 1902 | vtemp3 = tempv; /* rename tempv as vtemp3 for readability */ |
| 1903 | |
| 1904 | /* Set flag convfail, input to lsetup for its evaluation decision */ |
| 1905 | convfail = ((nflag == FIRST_CALL) || (nflag == PREV_ERR_FAIL)) ? |
| 1906 | NO_FAILURES : FAIL_OTHER; |
| 1907 | |
| 1908 | /* Decide whether or not to call setup routine (if one exists) */ |
| 1909 | if (setupNonNull) { |
| 1910 | callSetup = (nflag == PREV_CONV_FAIL) || (nflag == PREV_ERR_FAIL) || |
| 1911 | (nst == 0) || (nst >= nstlp + MSBP) || (ABS(gamrat-ONE) > DGMAX); |
| 1912 | } else { |
| 1913 | crate = ONE; |
| 1914 | callSetup = FALSE; |
| 1915 | } |
| 1916 | |
| 1917 | /* Looping point for the solution of the nonlinear system. |
| 1918 | Evaluate f at the predicted y, call lsetup if indicated, and |
| 1919 | call CVNewtonIteration for the Newton iteration itself. */ |
| 1920 | |
| 1921 | loop { |
| 1922 | |
| 1923 | f(N, tn, zn[0], ftemp, f_data); |
| 1924 | nfe++; |
| 1925 | |
| 1926 | if (callSetup) { |
| 1927 | ier = lsetup(cv_mem, convfail, zn[0], ftemp, &jcur, |
| 1928 | vtemp1, vtemp2, vtemp3); |
| 1929 | nsetups++; |
| 1930 | callSetup = FALSE; |
| 1931 | gamrat = crate = ONE; |
| 1932 | gammap = gamma; |
| 1933 | nstlp = nst; |
| 1934 | /* Return if lsetup failed */ |
| 1935 | if (ier < 0) return(SETUP_FAIL_UNREC); |
| 1936 | if (ier > 0) return(CONV_FAIL); |
| 1937 | } |
| 1938 | |
| 1939 | /* Set acor to zero and load prediction into y vector */ |
| 1940 | N_VConst(ZERO, acor); |
| 1941 | N_VScale(ONE, zn[0], y); |
| 1942 | |
| 1943 | /* Do the Newton iteration */ |
| 1944 | ier = CVNewtonIteration(cv_mem); |
| 1945 | |
| 1946 | /* If there is a convergence failure and the Jacobian-related |
| 1947 | data appears not to be current, loop again with a call to lsetup |
| 1948 | in which convfail=FAIL_BAD_J. Otherwise return. */ |
| 1949 | if (ier != TRY_AGAIN) return(ier); |
| 1950 | |
| 1951 | callSetup = TRUE; |
no test coverage detected