power_arrays Module Function

module function power_arrays(a, b) result(c)

Raise autodiff array to power of another array

Arguments

Type IntentOptional Attributes Name
class(array_type), intent(in), target :: a
class(array_type), intent(in), target :: b

Return Value type(array_type), pointer


Source Code

  module function power_arrays(a, b) result(c)
    !! Raise autodiff array to power of another array
    implicit none
    class(array_type), intent(in), target :: a, b
    type(array_type), pointer :: c

    c => a%create_result()
    c%val = a%val ** b%val

    c%get_partial_left => get_partial_power_base
    c%get_partial_right => get_partial_power_exponent
    if(a%requires_grad .or. b%requires_grad)then
       c%requires_grad = .true.
       c%is_forward = a%is_forward .or. b%is_forward
       c%operation = 'power'
       c%left_operand => a
       c%right_operand => b
       c%owns_left_operand = a%is_temporary
       c%owns_right_operand = b%is_temporary
    end if
  end function power_arrays