NuMFor 9f2ab49 (2024-04-08)
Numerical (Modern) Fortran. Library for Simple Numerical computing
grids Module Reference

This module provides convenience routines to create grids Description: Submodule Arrays. More...

Functions/Subroutines

real(dp) function, dimension(num), public linspace (start, end, num, endpoint, retstep)
 
real(dp) function, dimension(num), public logspace (start, end, num, endpoint, base)
 Makes a grid with numbers spaced evenly on a log scale.
 
real(dp) function, dimension(num), public geomspace (start, end, num, endpoint)
 Makes a grid with numbers spaced evenly on a log scale.
 
real(dp) function, dimension(num), public loglinspace (start, end, num, step, ratio)
 loglinspace Computes a grid that may behave as linearly or logarithmically spaced
 
integer function, dimension(:), allocatable, public arange (start, end, step)
 arange: Return evenly spaced integer values within a given interval
 

Detailed Description

This module provides convenience routines to create grids Description: Submodule Arrays.

Function/Subroutine Documentation

◆ arange()

integer function, dimension(:), allocatable, public arange ( integer, intent(in) start,
integer, intent(in) end,
integer, intent(in), optional step )

arange: Return evenly spaced integer values within a given interval

Values are generated within the half-open interval [start, end) (in other words, the interval including start but excluding end).

Parameters
[in]startthe starting value of the interval.
[in]endthe final value of the interval (not included)
[in]stepSpacing between values.
Returns
A sequence of numbers spaced evenly

◆ geomspace()

real(dp) function, dimension(num), public geomspace ( real(dp), intent(in) start,
real(dp), intent(in) end,
integer, intent(in) num,
logical, intent(in), optional endpoint )

Makes a grid with numbers spaced evenly on a log scale.

Note
: Is similar to logspace but with endpoints specified directly. Also accepts simultaneously negative start and end
Parameters
[in]startstart is the starting value
[in]endend is the final value of
[in]numNumber of samples to generate. Must
[in]endpointIf True, end is
Returns
A sequence of numbers spaced evenly on a log scale.

Examples:

print '(4(f8.2,1x))', geomspace(1._dp, 1000._dp, num=4)
! gives: 1.00 10.00 100.00 1000.00
print '(4(f8.2,1x))', geomspace(-1000._dp, -1._dp, num=4)
! gives: -1000.00 -100.00 -10.00 -1.00

References logspace().

Here is the call graph for this function:

◆ linspace()

real(dp) function, dimension(num), public linspace ( real(dp), intent(in) start,
real(dp), intent(in) end,
integer, intent(in) num,
logical, intent(in), optional endpoint,
real(dp), intent(out), optional retstep )
Parameters
[in]startThe starting value of the
[in]endThe end value of the sequence,
[in]numNumber of samples to generate. Must
[in]endpointIf True, end is
[out]retstepIf present, return
Returns
An array of uniformly spaced numbers

Examples:

print "(5(f4.2,1x))", linspace(2._dp, 3.0_dp, num=5)
! Gives: 2.00 2.25 2.50 2.75 3.00
print "(5(f4.2,1x))", linspace(2._dp, 3.0_dp, num=5, endpoint=.false.)
! Gives: 2.00 2.20 2.40 2.60 2.80
print "(5(f4.2,1x))", linspace(2._dp, 3.0_dp, num=5, retstep=step)
! Gives: 2.00 2.25 2.50 2.75 3.00

References basic::zero.

Referenced by histograms::histogram(), and logspace().

Here is the caller graph for this function:

◆ loglinspace()

real(dp) function, dimension(num), public loglinspace ( real(dp), intent(in) start,
real(dp), intent(in) end,
integer, intent(in) num,
real(dp), intent(in), optional step,
real(dp), intent(in), optional ratio )

loglinspace Computes a grid that may behave as linearly or logarithmically spaced

From package RADIAL by Salvat et al 1995 Computer Physics Communications. The grid is such that:

  1. R(1)=0, R(NP)=RN,
  2. A*R(I)+B*log(R(I))-C= I (I > 0), with A=1/STEP and B=1/log(RATIO).
    Parameters
    [in]startStarting value
    [in]endFinal value of the sequence
    [in]numNumber of points
    [in]stepApproximated step in the linear region
    [in]ratioquotient between consecutive points in the logarithmic region
    Returns
    Array of points with the grid of dimension num

    Examples:

xmin = 1.e-4_dp; xmax = 10._dp
ratio = 1.15_dp; steps = [0.125_dp, 0.25_dp, 0.5_dp, 1._dp]
v = loglinspace(xmin, xmax, 50, step=0.4_dp, ratio=1.15_dp)

◆ logspace()

real(dp) function, dimension(num), public logspace ( real(dp), intent(in) start,
real(dp), intent(in) end,
integer, intent(in) num,
logical, intent(in), optional endpoint,
real(dp), intent(in), optional base )

Makes a grid with numbers spaced evenly on a log scale.

In linear space, the sequence starts at base**start (base to the power of start) and ends with base**end

Parameters
[in]startbase**start is the starting value of the sequence.
[in]endbase**end is the final value of the sequence.
[in]numNumber of samples to generate. Must be positive.
[in]endpointIf True, end is the last sample. Otherwise, it is not included. Default is True
[in]baseThe base of the log space. Default is 10.
Returns
A sequence of numbers spaced evenly on a log scale.

Examples:

print '(4(f8.2,1x))', logspace(2._dp, 3.0_dp, num=4)
! gives: 100.00 215.44 464.16 1000.00
print '(4(f8.2,1x))', logspace(2.0_dp, 3.0_dp, num=4, base=2.0_dp)
! gives: 4.00 5.04 6.35 8.00
print '(4(f8.2,1x))', logspace(3._dp, zero, 4)
! gives: 1000.00 100.00 10.00 1.00

References linspace().

Referenced by geomspace().

Here is the call graph for this function:
Here is the caller graph for this function: