invoke_binary Subroutine

subroutine invoke_binary(action)

Arguments

Type IntentOptional Attributes Name
procedure(binary_f), intent(in), pointer :: action

Contents

Source Code


Variables

Type Visibility Attributes Name Initial
logical, public :: is_cart
type(rpn_t), public :: us
type(rpn_t), public :: zs

Source Code

    subroutine invoke_binary(action)
        procedure(binary_f), pointer, intent(in) :: action
        type(rpn_t) :: us, zs
        logical :: is_cart

        zs = stack%pop()
        if (complex_mode) then
            is_cart = zs%is_cartesian()
            if (.not. is_cart) then
                zs = to_cartesian(zs)
            end if
            us = stack%peek(1)
            if (.not. us%is_cartesian()) then
                us = to_polar(us)
            end if
            us = action(us,zs)
            if (.not. is_cart) then
                us = to_polar(us)
            end if
            call stack%set(us)
        else
            us = stack%peek(1)
            call stack%set(action(us,zs))
        end if
    end subroutine invoke_binary