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.]
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=rk), | intent(in) | :: | x |
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