Subtract a scalar from an autodiff array
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(array_type), | intent(in), | target | :: | a | ||
| real(kind=real32), | intent(in) | :: | b |
module function subtract_scalar(a, b) result(c) !! Subtract a scalar from an autodiff array implicit none class(array_type), intent(in), target :: a real(real32), intent(in) :: b type(array_type), pointer :: c c => a%create_result() c%val = a%val - b c%get_partial_left => get_partial_add c%get_partial_left_val => get_partial_add_val if(a%requires_grad)then c%requires_grad = .true. c%is_forward = a%is_forward c%operation = 'subtract_scalar' c%left_operand => a c%owns_left_operand = a%is_temporary end if end function subtract_scalar