直方体領域 [low, high] 内で一様分布の初期位置をサンプリングする。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=dp), | intent(in) | :: | low(3) | |||
| real(kind=dp), | intent(in) | :: | high(3) | |||
| real(kind=dp), | intent(out) | :: | x(:,:) |
subroutine sample_uniform_positions(low, high, x) real(dp), intent(in) :: low(3), high(3) real(dp), intent(out) :: x(:, :) real(dp), allocatable :: u(:, :) if (size(x, 1) /= 3) error stop "x first dimension must be 3" if (any(high < low)) error stop "high must be >= low for all axes" allocate (u(3, size(x, 2))) call random_number(u) x = spread(low, dim=2, ncopies=size(x, 2)) + spread(high - low, dim=2, ncopies=size(x, 2))*u end subroutine sample_uniform_positions