rndgenPL Derived Type

type, public, extends(rndgen) :: rndgenPL

Random number generator object for power-law distribution, adapted from Silvio C. Ferreira code. The power-law distribution is given by P(k) = k^(-gamma), where k is an integer between kmin and kmax.


Inherits

type~~rndgenpl~~InheritsGraph type~rndgenpl rndgenPL type~rndgen rndgen type~rndgenpl->type~rndgen type~rndseed rndSeed type~rndgen->type~rndseed seed

Components

Type Visibility Attributes Name Initial
integer(kind=i4), public :: o_iseed
type(rndSeed), public :: seed
real(kind=dp), private :: AA
real(kind=dp), private :: expo
real(kind=dp), private :: x0
real(kind=dp), private :: xc
real(kind=dp), public :: gamma
integer(kind=i4), public :: kmin
integer(kind=i4), public :: kmax
real(kind=dp), private, allocatable :: prob(:)

Type-Bound Procedures

procedure, public :: rnd => rnd_rndgen_dp

  • private function rnd_rndgen_dp(this) result(rnd_number)

    Generates a random number in the range [0, 1)

    Arguments

    Type IntentOptional Attributes Name
    class(rndgen) :: this

    Return Value real(kind=dp)

procedure, public :: int => int_rndgen_i4

  • private function int_rndgen_i4(this, i1, i2) result(rnd_number)

    Generates a random integer number in the range [i1, i2], int32

    Arguments

    Type IntentOptional Attributes Name
    class(rndgen) :: this
    integer(kind=i4), intent(in) :: i1
    integer(kind=i4), intent(in) :: i2

    Return Value integer(kind=i4)

procedure, public :: int_i4 => int_rndgen_i4

  • private function int_rndgen_i4(this, i1, i2) result(rnd_number)

    Generates a random integer number in the range [i1, i2], int32

    Arguments

    Type IntentOptional Attributes Name
    class(rndgen) :: this
    integer(kind=i4), intent(in) :: i1
    integer(kind=i4), intent(in) :: i2

    Return Value integer(kind=i4)

procedure, public :: int_i8 => int_rndgen_i8

  • private function int_rndgen_i8(this, i1, i2) result(rnd_number)

    Generates a random integer number in the range [i1, i2], int64

    Arguments

    Type IntentOptional Attributes Name
    class(rndgen) :: this
    integer(kind=i8), intent(in) :: i1
    integer(kind=i8), intent(in) :: i2

    Return Value integer(kind=i8)

procedure, public :: real => real_rndgen_dp

  • private function real_rndgen_dp(this, r1, r2) result(rnd_number)

    Generates a random real number in the range [r1, r2), double

    Arguments

    Type IntentOptional Attributes Name
    class(rndgen) :: this
    real(kind=dp), intent(in) :: r1
    real(kind=dp), intent(in) :: r2

    Return Value real(kind=dp)

procedure, public :: real_sp => real_rndgen_sp

  • private function real_rndgen_sp(this, r1, r2) result(rnd_number)

    Generates a random real number in the range [r1, r2), single

    Arguments

    Type IntentOptional Attributes Name
    class(rndgen) :: this
    real(kind=sp), intent(in) :: r1
    real(kind=sp), intent(in) :: r2

    Return Value real(kind=sp)

procedure, public :: init => init_rndgen

  • private subroutine init_rndgen(this, iseed)

    Initializes the random number generator

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(rndgen) :: this
    integer(kind=i4) :: iseed

procedure, public :: reset => reset_rndgen

  • private subroutine reset_rndgen(this)

    Resets the random number generator

    Arguments

    Type IntentOptional Attributes Name
    class(rndgen) :: this

procedure, public :: save_seed => save_seed_rndgen

  • private subroutine save_seed_rndgen(this, u_mseed, und)

    Save the current seeds to a seeds object and, optionally, to a file unit

    Arguments

    Type IntentOptional Attributes Name
    class(rndgen) :: this
    type(rndSeed), intent(out) :: u_mseed
    integer, intent(in), optional :: und

procedure, public :: read_seed => read_seed_rndgen

  • private subroutine read_seed_rndgen(this, u_mseed, und)

    Read the seeds from a seeds object or, optionally, from a file unit

    Arguments

    Type IntentOptional Attributes Name
    class(rndgen) :: this
    type(rndSeed), intent(in) :: u_mseed
    integer, intent(in), optional :: und

generic, public :: rnd_array => rnd_array_rnd, rnd_array_real, rnd_array_int_i4

  • private function rnd_array_rnd(gen, n) result(arr)

    Generates a random array of real numbers in the range [0, 1)

    Arguments

    Type IntentOptional Attributes Name
    class(rndgen), intent(in) :: gen
    integer(kind=i4), intent(in) :: n

    Return Value real(kind=dp), allocatable, (:)

  • private function rnd_array_real(gen, n, r1, r2) result(arr)

    Generates a random array of real numbers in the range [r1, r2)

    Arguments

    Type IntentOptional Attributes Name
    class(rndgen), intent(in) :: gen
    integer(kind=i4), intent(in) :: n
    real(kind=dp), intent(in) :: r1
    real(kind=dp), intent(in) :: r2

    Return Value real(kind=dp), allocatable, (:)

  • private function rnd_array_int_i4(gen, n, i1, i2) result(arr)

    Arguments

    Type IntentOptional Attributes Name
    class(rndgen), intent(in) :: gen
    integer(kind=i4), intent(in) :: n
    integer(kind=i4), intent(in) :: i1
    integer(kind=i4), intent(in) :: i2

    Return Value integer(kind=i4), allocatable, (:)

procedure, public :: rnd_array_i4 => rnd_array_int_i4

  • private function rnd_array_int_i4(gen, n, i1, i2) result(arr)

    Arguments

    Type IntentOptional Attributes Name
    class(rndgen), intent(in) :: gen
    integer(kind=i4), intent(in) :: n
    integer(kind=i4), intent(in) :: i1
    integer(kind=i4), intent(in) :: i2

    Return Value integer(kind=i4), allocatable, (:)

procedure, public :: rnd_array_i8 => rnd_array_int_i8

  • private function rnd_array_int_i8(gen, n, i1, i2) result(arr)

    Arguments

    Type IntentOptional Attributes Name
    class(rndgen), intent(in) :: gen
    integer(kind=i4), intent(in) :: n
    integer(kind=i8), intent(in) :: i1
    integer(kind=i8), intent(in) :: i2

    Return Value integer(kind=i8), allocatable, (:)

procedure, public :: rndPL => rndPL_rndgenPL

  • private function rndPL_rndgenPL(this) result(rnd_number)

    Generates a random number following the power-law distribution

    Arguments

    Type IntentOptional Attributes Name
    class(rndgenPL) :: this

    Return Value integer(kind=i4)

procedure, public :: initPL => initPL_rndgenPL

  • private subroutine initPL_rndgenPL(this, kmin, kmax, gama, iseed)

    Initializes the power-law random number generator

    Arguments

    Type IntentOptional Attributes Name
    class(rndgenPL) :: this
    integer(kind=i4), intent(in) :: kmin
    integer(kind=i4), intent(in) :: kmax
    real(kind=dp), intent(in) :: gama
    integer, intent(in), optional :: iseed

procedure, public :: rndPL_array

  • private function rndPL_array(gen, n) result(arr)

    Arguments

    Type IntentOptional Attributes Name
    class(rndgenPL), intent(in) :: gen
    integer(kind=i4), intent(in) :: n

    Return Value integer(kind=i4), allocatable, (:)