get_partial_power_exponent Function

function get_partial_power_exponent(this, upstream_grad) result(output)

Get the partial gradient with respect to the exponent of the power operation

Arguments

Type IntentOptional Attributes Name
class(array_type), intent(inout) :: this
type(array_type), intent(in) :: upstream_grad

Return Value type(array_type)


Source Code

  function get_partial_power_exponent(this, upstream_grad) result(output)
    !! Get the partial gradient with respect to the exponent of the power operation
    implicit none
    class(array_type), intent(inout) :: this
    type(array_type), intent(in) :: upstream_grad
    type(array_type) :: output
    logical :: left_is_temporary_local, this_is_temporary_local
    type(array_type), pointer :: ptr

    left_is_temporary_local = this%left_operand%is_temporary
    this_is_temporary_local = this%is_temporary
    this%left_operand%is_temporary = .false.
    this%is_temporary = .false.
    if(this%left_operand%is_scalar)then
       ptr => upstream_grad * log(this%left_operand%val(1,1)) * this
    else
       ptr => upstream_grad * log(this%left_operand) * this
    end if
    this%left_operand%is_temporary = left_is_temporary_local
    this%is_temporary = this_is_temporary_local
    call output%assign_and_deallocate_source(ptr)
  end function get_partial_power_exponent