ctest Function

private function ctest(n, a, il, i, ir)

test the convexity of the angle formed by (il,a(il)), (i,a(i)), (ir,a(ir)) at the vertex (i,a(i)), up to within the tolerance toler. if convexity holds then the function is set to .true., otherwise ctest=.false. the parameter toler is set to 0.4 by default.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: n

length of the vector a

real(kind=wp), intent(in) :: a(n)

vector of double

integer, intent(in) :: il

integers such that il<i<ir

integer, intent(in) :: i

integers such that il<i<ir

integer, intent(in) :: ir

integers such that il<i<ir

Return Value logical

  • .true. if the angle formed by (il,a(il)), (i,a(i)), (ir,a(ir)) at the vertex (i,a(i)), is convex up to within the tolerance toler, i.e., if (a(i)-a(il))(ir-i)-(a(ir)-a(i))(i-il)>toler.
  • .false., otherwise.

Called by

proc~~ctest~~CalledByGraph proc~ctest polyroots_module::ctest proc~cmerge polyroots_module::cmerge proc~cmerge->proc~ctest proc~cnvex polyroots_module::cnvex proc~cnvex->proc~cmerge proc~start polyroots_module::start proc~start->proc~cnvex proc~polzeros polyroots_module::polzeros proc~polzeros->proc~start

Source Code

    function ctest(n, a, il, i, ir)

        !! test the convexity of the angle formed by (il,a(il)), (i,a(i)),
        !! (ir,a(ir)) at the vertex (i,a(i)), up to within the tolerance
        !! toler. if convexity holds then the function is set to .true.,
        !! otherwise ctest=.false. the parameter toler is set to 0.4 by default.

        implicit none

        integer,intent(in) :: n !! length of the vector a
        integer,intent(in) :: i !! integers such that il<i<ir
        integer,intent(in) :: il !! integers such that il<i<ir
        integer,intent(in) :: ir !! integers such that il<i<ir
        real(wp),intent(in) :: a(n) !! vector of double
        logical :: ctest !! * .true. if the angle formed by (il,a(il)), (i,a(i)), (ir,a(ir)) at
                         !!   the vertex (i,a(i)), is convex up to within the tolerance
                         !!   toler, i.e., if
                         !!   (a(i)-a(il))*(ir-i)-(a(ir)-a(i))*(i-il)>toler.
                         !! * .false.,  otherwise.

        real(wp) :: s1, s2

        real(wp), parameter :: toler = 0.4_wp

        s1 = a(i) - a(il)
        s2 = a(ir) - a(i)
        s1 = s1*(ir - i)
        s2 = s2*(i - il)
        ctest = .false.
        if (s1 > (s2 + toler)) ctest = .true.

    end function ctest