digits Function

private pure function digits(x)

Returns an array of 10 reals, with zeros everywhere and a one corresponding to the input number, for example: digits(0) = [1., 0., 0., 0., 0., 0., 0., 0., 0., 0.] digits(1) = [0., 1., 0., 0., 0., 0., 0., 0., 0., 0.] digits(6) = [0., 0., 0., 0., 0., 0., 1., 0., 0., 0.]

Arguments

Type IntentOptional AttributesName
real(kind=rk), intent(in) :: x

Return Value real(kind=rk) (10)


Contents

Source Code


Source Code

  pure function digits(x)
    !! Returns an array of 10 reals, with zeros everywhere
    !! and a one corresponding to the input number, for example:
    !!   digits(0) = [1., 0., 0., 0., 0., 0., 0., 0., 0., 0.]
    !!   digits(1) = [0., 1., 0., 0., 0., 0., 0., 0., 0., 0.]
    !!   digits(6) = [0., 0., 0., 0., 0., 0., 1., 0., 0., 0.]
    real(rk), intent(in) :: x
    real(rk) :: digits(10)
    digits = 0
    digits(int(x + 1)) = 1
  end function digits