get_partial_power_base_val Subroutine

pure subroutine get_partial_power_base_val(this, upstream_grad, output)

Arguments

Type IntentOptional Attributes Name
class(array_type), intent(in) :: this
real(kind=real32), intent(in), dimension(:,:) :: upstream_grad
real(kind=real32), intent(out), dimension(:,:) :: output

Source Code

  pure subroutine get_partial_power_base_val(this, upstream_grad, output)
    implicit none
    class(array_type), intent(in) :: this
    real(real32), dimension(:,:), intent(in) :: upstream_grad
    real(real32), dimension(:,:), intent(out) :: output

    if(all(abs(this%right_operand%val - 1._real32).lt.1.E-6_real32))then
       output = upstream_grad
    elseif(all(abs(this%right_operand%val - 2._real32).lt.1.E-6_real32))then
       output = upstream_grad * this%left_operand%val * 2._real32
    else
       if(this%right_operand%is_scalar)then
          output = upstream_grad * this%right_operand%val(1,1) * &
               this%left_operand%val ** ( this%right_operand%val(1,1) - 1.0_real32 )
       else
          output = upstream_grad * this%right_operand%val * &
               this%left_operand%val ** ( this%right_operand%val - 1.0_real32 )
       end if
    end if
  end subroutine get_partial_power_base_val