C Library Functions  - linspace (3)

NAME

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

CONTENTS

Synopsis
Usage
Description
Options
Returns
Example

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.

EXAMPLE

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:


Nemo Release 3.1 linspace (3) July 22, 2023
Generated by manServer 1.08 from 5447725e-8d09-4128-b54b-dd3d6abdf4b7 using man macros.