File indexing completed on 2018-03-02 18:36:16 UTC
view on githubraw file Latest commit 4cee17c1 on 2002-11-15 04:03:25 UTC
4cee17c1be Patr*0001
0002 subroutine cubic( t, f, fp, ta, fa, fpa, tlower, tupper )
0003
0004
0005
0006
0007 double precision t, f, fp, ta, fa, fpa, tlower, tupper
0008
0009
0010
0011
0012 double precision sign, den, anum
0013 double precision z1, b, discri
0014
0015
0016
0017
0018
0019
0020 z1 = dble(fp) + dble(fpa) - 3.d0*dble(fa-f)/dble(ta-t)
0021 b = z1 + dble(fp)
0022
0023
0024
0025
0026
0027 if (abs(z1).le.1.) then
0028 discri = z1*z1-dble(fp)*dble(fpa)
0029 if (discri .lt. 0.d0) then
0030 if (fp.lt.0.) t = tupper
0031 if (fp.ge.0.) t = tlower
0032 return
0033 else
0034 discri = dsqrt(discri)
0035 end if
0036 else
0037 discri = dble(fp)/z1
0038 discri = discri*dble(fpa)
0039 discri = z1-discri
0040 if (z1.ge.0.d0 .and. discri.ge.0.d0) then
0041 discri = dsqrt(z1)*dsqrt(discri)
0042 else if (z1.le.0.d0 .and. discri.le.0.d0) then
0043 discri = dsqrt(-z1)*dsqrt(-discri)
0044 else
0045 if (fp.lt.0.) t = tupper
0046 if (fp.ge.0.) t = tlower
0047 return
0048 end if
0049 end if
0050
0051
0052
0053
0054
0055 if (t-ta .lt. 0.0) then
0056 discri = -discri
0057 end if
0058
0059 sign = (t-ta)/abs(t-ta)
0060 if (sngl(b)*sign .gt. 0.0) then
0061 t = t + fp*(ta-t)/sngl(b+discri)
0062 else
0063 den = sngl(z1+b+dble(fpa))
0064 anum = sngl(b-discri)
0065 if (abs((t-ta)*anum).lt.(tupper-tlower)*abs(den)) then
0066 t = t + anum*(ta-t)/den
0067 else
0068 t = tupper
0069 end if
0070 end if
0071
0072 t = max( t, tlower )
0073 t = min( t, tupper )
0074
0075 return
0076 end