counter_stream_type Derived Type

type, public :: counter_stream_type

1 つの (seed, counter) の draw を連番で引く列。鍵の計算と PCG64 生成器の作成を 1 回で済ませ、 next_uniform の n 回目は counter_uniform(seed, counter, first_draw + n - 1) と同じ値を返す。 生成器は C++ 側で確保するので、open したら close する。


Inherits

type~~counter_stream_type~~InheritsGraph type~counter_stream_type counter_stream_type c_ptr c_ptr type~counter_stream_type->c_ptr handle

Type-Bound Procedures

procedure, public :: open => open_counter_stream

  • private subroutine open_counter_stream(self, seed, counter, first_draw)

    (seed, counter) の PCG64 を開き、first_draw 回進めた位置に置く。

    Arguments

    Type IntentOptional Attributes Name
    class(counter_stream_type), intent(inout) :: self
    integer(kind=i32), intent(in) :: seed
    integer(kind=i64), intent(in) :: counter(:)
    integer(kind=i64), intent(in) :: first_draw

procedure, public :: next_uniform => counter_stream_next_uniform

  • private function counter_stream_next_uniform(self) result(uniform)

    次の draw を (0, 1) で返す。

    Arguments

    Type IntentOptional Attributes Name
    class(counter_stream_type), intent(inout) :: self

    Return Value real(kind=dp)

procedure, public :: close => close_counter_stream

  • private subroutine close_counter_stream(self)

    生成器を解放する(開いていなければ何もしない)。

    Arguments

    Type IntentOptional Attributes Name
    class(counter_stream_type), intent(inout) :: self

Source Code

  type :: counter_stream_type
    private
    type(c_ptr) :: handle = c_null_ptr
  contains
    procedure :: open => open_counter_stream
    procedure :: next_uniform => counter_stream_next_uniform
    procedure :: close => close_counter_stream
  end type counter_stream_type