utilities Module

Utilities for parallel random number generation and sparse arrays


Uses

  • module~~utilities~~UsesGraph module~utilities utilities omp_lib omp_lib module~utilities->omp_lib

Used by

  • module~~utilities~~UsedByGraph module~utilities utilities module~libfida libfida module~libfida->module~utilities program~fidasim fidasim program~fidasim->module~libfida

Contents


Variables

TypeVisibility AttributesNameInitial
real(kind=Float64), protected :: AM =nearest(1.0, -1.0)/IM
type(rng_type), public, dimension(:), allocatable:: rng

Interfaces

public interface randind

Procedure for generating a random array index/subscripts

  • private subroutine randind_n(n, randomi)

    Generate a array of uniformally-distributed random integers in the range [1, n]

    Arguments

    Type IntentOptional AttributesName
    integer, intent(in) :: n

    Largest possible value

    integer, intent(out), dimension(:):: randomi

    Array of uniform deviates

  • private subroutine randind_w_1(w, randomi)

    Generate an array of random indices of an 1D array distributed according to w

    Arguments

    Type IntentOptional AttributesName
    real(kind=Float64), intent(in), dimension(:):: w

    1D array of index weights

    integer, intent(out), dimension(:):: randomi

    Random indices

  • private subroutine randind_w_2(w, randomi)

    Generate an array of random subscripts of an 2D array distributed according to w

    Arguments

    Type IntentOptional AttributesName
    real(kind=Float64), intent(in), dimension(:,:):: w

    2D array of subscript weights

    integer, intent(out), dimension(:,:):: randomi

    A 2D (ndim, :) array of random subscripts

public interface sparse

Creates a sparse array from a dense array

  • private subroutine sparse_1(A, SA)

    Routine to create a 1D sparse array from a 1D dense array

    Arguments

    Type IntentOptional AttributesName
    real(kind=Float64), intent(in), dimension(:):: A

    Dense Array

    type(SparseArray), intent(out) :: SA

    Sparse Array

  • private subroutine sparse_2(A, SA)

    Routine to create a 2D sparse array from a 2D dense array

    Arguments

    Type IntentOptional AttributesName
    real(kind=Float64), intent(in), dimension(:,:):: A

    Dense Array

    type(SparseArray), intent(out) :: SA

    Sparse Array

  • private subroutine sparse_3(A, SA)

    Routine to create a 3D sparse array from a 3D dense array

    Arguments

    Type IntentOptional AttributesName
    real(kind=Float64), intent(in), dimension(:,:,:):: A

    Dense Array

    type(SparseArray), intent(out) :: SA

    Sparse Array

  • private subroutine sparse_4(A, SA)

    Routine to create a 4D sparse array from a 4D dense array

    Arguments

    Type IntentOptional AttributesName
    real(kind=Float64), intent(in), dimension(:,:,:,:):: A

    Dense Array

    type(SparseArray), intent(out) :: SA

    Sparse Array

public interface deriv

Procedure for finding derivatives from an array

  • private subroutine deriv_1d(x, y, yp)

    Uses 3 point lagrangian method to calculate the derivative of an array

    Arguments

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

    X Values

    real(kind=Float64), intent(in), dimension(:):: y

    Y Values

    real(kind=Float64), intent(out), dimension(:):: yp

    Derivative of Y w.r.t. X

  • private subroutine deriv_2d(x, y, z, zxp, zyp)

    Uses 3 point lagrangian method to calculate the partial derivative of an array Z w.r.t X and Y

    Arguments

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

    X Values

    real(kind=Float64), intent(in), dimension(:):: y

    Y Values

    real(kind=Float64), intent(in), dimension(:,:):: z

    Z Values

    real(kind=Float64), intent(out), dimension(:,:):: zxp

    Derivative of Z w.r.t. X

    real(kind=Float64), intent(out), dimension(:,:):: zyp

    Derivative of Z w.r.t. Y


Derived Types

type, public :: rng_type

Random Number Generator Derived Type

Components

TypeVisibility AttributesNameInitial
integer(kind=Int32), public, dimension(ns):: state

type, public :: SparseArray

Components

TypeVisibility AttributesNameInitial
integer, public :: nnz =0

Number of non-zero elements

integer, public :: nd =0

Number of dimensions

integer, public, dimension(:), allocatable:: dims

Dimensions of array

integer, public, dimension(:), allocatable:: inds

Linear index of non-zero elements

real(kind=Float64), public, dimension(:), allocatable:: vals

Array values


Functions

public function sub2ind(dims, subs) result(ind)

Calculates the linear index of an array with dimensions dims and subcripts subs

Arguments

Type IntentOptional AttributesName
integer, intent(in), dimension(:):: dims

Dimension of Array

integer, intent(in), dimension(:):: subs

Subscripts to convert

Return Value integer

Linear index

public function rng_uniform(self) result(u)

Generate a uniformally-distributed random number in the range [0,1)

Arguments

Type IntentOptional AttributesName
type(rng_type), intent(inout) :: self

Random Number Generator

Return Value real(kind=Float64)

Uniform random deviate

public function rng_normal(self) result(n)

Generate a normally-distributed random number with mean 0 and standard deviation 1

Arguments

Type IntentOptional AttributesName
type(rng_type), intent(inout) :: self

Random Number Generator

Return Value real(kind=Float64)

Normal random deviate

public function get_value(SA, subs) result(val)

Gets value of sparse array SA at the subscripts subs

Arguments

Type IntentOptional AttributesName
type(SparseArray), intent(in) :: SA

Sparse Array

integer, intent(in), dimension(:):: subs

Subscripts of Sparse Array

Return Value real(kind=Float64)

Value of SA at subs


Subroutines

public subroutine ind2sub(dims, ind, subs)

Calculate the subscripts subs into an array with dimensions dims given the corresponding linear index ind

Arguments

Type IntentOptional AttributesName
integer, intent(in), dimension(:):: dims

Dimensions of array

integer, intent(in) :: ind

Linear index

integer, intent(out), dimension(:):: subs

Subscripts corresponding to the linear index

public subroutine rng_init(self, seed)

Procedure to initialize a random number generator with a seed

Arguments

Type IntentOptional AttributesName
type(rng_type), intent(inout) :: self

Random Number Generator

integer(kind=Int32), intent(in) :: seed

Initial Seed Value

public subroutine randu(randomu)

Generate an array of uniformally-distributed random deviates

Arguments

Type IntentOptional AttributesName
real(kind=Float64), intent(out), dimension(:):: randomu

Array of uniform random deviates

public subroutine randn(randomn)

Generate an array of normally-distributed random deviates

Arguments

Type IntentOptional AttributesName
real(kind=Float64), intent(out), dimension(:):: randomn

Array of normal random deviates