1D piecewise type. Used for the spectral type
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
real(kind=wp), | public, | allocatable | :: | array(:,:) |
Input array to sample from. Should be size(n, 2). 1st column is x-axis, 2nd column is y-axis |
||
real(kind=wp), | public, | allocatable | :: | cdf(:) |
cumulative distribution function (CDF) of array. |
initalise the piecewise1D type with an array size (n, 2). Calculates the CDF of this array. Input array
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | array(:,:) |
Overloaded sampling function
Randomly sample from 1D array
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(piecewise1D), | intent(in) | :: | this | |||
real(kind=wp), | intent(out) | :: | x |
Return value |
||
real(kind=wp), | intent(out) | :: | y |
Not used, but here so we can have same interface as 2D sample routine. |
||
real(kind=wp), | intent(in), | optional | :: | value |
Optional x value. If not present we generate a random one in the range [0., 1.] |
type, extends(piecewise) :: piecewise1D !> Input array to sample from. Should be size(n, 2). 1st column is x-axis, 2nd column is y-axis real(kind=wp), allocatable :: array(:, :) !> cumulative distribution function (CDF) of array. real(kind=wp), allocatable :: cdf(:) contains !> Overloaded sampling function procedure :: sample => sample1D end type piecewise1D