linspace Interface

public interface linspace

Module Procedures

private function linspace_real128(x1, x2, n)

NAME

 linspace(3f) - [M_LA] return a vector of linearly spaced values

SYNOPSIS

function linspace(x1,x2,n)

 integer,intent(in)               :: n
 ${TYPE}(kind=${KIND}),intent(in) :: x1,x2
 ${TYPE}(kind=${KIND})            :: linspace

Where ${TYPE} may be real or integer and ${KIND} may be any
supported kind for the corresponding type.

USAGE

Common usage:

 y = linspace(x1,x2)
 y = linspace(x1,x2,n)

DESCRIPTION

linspace returns a vector of linearly spaced values from x1 to
x2 inclusive. It gives direct control over the number of points
and always includes the endpoints, the results being the same as
[(x1+i*(x2-x1)/(n-1),i=0,n-1)] if n>1 and [x1,x2] if n<=1.

OPTIONS

X1,X2     X1 and X2 are the upper and lower bound of the values
          returned. The options can be of type REAL or INTEGER,
          but must be of the same type.

N         number of values to return

RETURNS

LINSPACE  The returned row vector starts with X1 and ends with X2,
          returning N evenly spaced values.

EXAMPLES

Sample program:

program demo_linspace
use M_LA,  only : linspace
implicit none
character(len=*), parameter :: gen='(*(g0, 1x))'
   write( *, gen ) linspace(  0,      9,    10 )
   write( *, gen ) linspace( 10.0,   20.0,  11 )
   write( *, gen ) linspace( 11.1d0, 12.1d0, 5 )
   write( *, gen ) linspace( 11.1,   12.1,   5 )
end program demo_linspace

Results: 0 1 2 3 4 5 6 7 8 9 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 11.1000000000 11.3500000000 11.6000000000 11.8500000000 12.100000000 11.1000004 11.3500004 11.6000004 11.8500004 12.1000004

Results:

Arguments

Type IntentOptional Attributes Name
real(kind=real128), intent(in) :: x1
real(kind=real128), intent(in) :: x2
integer, intent(in) :: n

Return Value real(kind=real128), (n)

private function linspace_real64(x1, x2, n)

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in) :: x1
real(kind=real64), intent(in) :: x2
integer, intent(in) :: n

Return Value real(kind=real64), (n)

private function linspace_real32(x1, x2, n)

Arguments

Type IntentOptional Attributes Name
real(kind=real32), intent(in) :: x1
real(kind=real32), intent(in) :: x2
integer, intent(in) :: n

Return Value real(kind=real32), (n)

private function linspace_int64(x1, x2, n)

Arguments

Type IntentOptional Attributes Name
integer(kind=int64), intent(in) :: x1
integer(kind=int64), intent(in) :: x2
integer, intent(in) :: n

Return Value integer(kind=int64), (n)

private function linspace_int32(x1, x2, n)

Arguments

Type IntentOptional Attributes Name
integer(kind=int32), intent(in) :: x1
integer(kind=int32), intent(in) :: x2
integer, intent(in) :: n

Return Value integer(kind=int32), (n)

private function linspace_int16(x1, x2, n)

Arguments

Type IntentOptional Attributes Name
integer(kind=int16), intent(in) :: x1
integer(kind=int16), intent(in) :: x2
integer, intent(in) :: n

Return Value integer(kind=int16), (n)

private function linspace_int8(x1, x2, n)

Arguments

Type IntentOptional Attributes Name
integer(kind=int8), intent(in) :: x1
integer(kind=int8), intent(in) :: x2
integer, intent(in) :: n

Return Value integer(kind=int8), (n)