negate_array Module Function

module function negate_array(a) result(c)

Negate an autodiff array

Arguments

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

Return Value type(array_type), pointer


Source Code

  module function negate_array(a) result(c)
    !! Negate an autodiff array
    implicit none
    class(array_type), intent(in), target :: a
    type(array_type), pointer :: c

    c => a%create_result()
    c%val = -a%val

    c%get_partial_left => get_partial_negate
    c%get_partial_left_val => get_partial_negate_val
    if(a%requires_grad)then
       c%requires_grad = .true.
       c%is_forward = a%is_forward
       c%operation = 'negate'
       c%left_operand => a
       c%owns_left_operand = a%is_temporary
    end if
  end function negate_array