Generate a Gaussian random autodiff array
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(array_type), | intent(in), | target | :: | a | ||
| real(kind=real32), | intent(in) | :: | mu | |||
| real(kind=real32), | intent(in) | :: | sigma |
module function gaussian_array(a, mu, sigma) result(c) !! Generate a Gaussian random autodiff array implicit none class(array_type), intent(in), target :: a real(real32), intent(in) :: mu, sigma type(array_type), pointer :: c type(array_type), pointer :: b_array c => a%create_result() c%val = 1._real32 / (sqrt(2._real32*pi)*sigma) * & exp( -0.5_real32 * ((a%val - mu)/sigma)**2._real32 ) c%get_partial_left => get_partial_gaussian c%get_partial_left_val => get_partial_gaussian_val if(a%requires_grad) then c%requires_grad = .true. c%is_forward = a%is_forward c%operation = 'gaussian' c%left_operand => a c%owns_left_operand = a%is_temporary end if allocate(b_array) b_array%is_sample_dependent = .false. b_array%requires_grad = .false. call b_array%allocate(array_shape=[2, 1]) b_array%val(1,1) = mu b_array%val(2,1) = sigma c%right_operand => b_array c%owns_right_operand = .true. end function gaussian_array