numtools

perform numerical operations on vectors and matrices in unix pipes
git clone git://src.adamsgaard.dk/numtools # fast
git clone https://src.adamsgaard.dk/numtools.git # slow
Log | Files | Refs | README | LICENSE Back to index

range.1 (2392B)


      1 .Dd $Mdocdate$
      2 .Dt RANGE 1
      3 .Os
      4 .Sh NAME
      5 .Nm range
      6 .Nd generates an evenly spaced vector over a range
      7 .Sh SYNOPSIS
      8 .Nm
      9 .Op Fl b
     10 .Op Fl d Ar delimstr
     11 .Op Fl e
     12 .Op Fl l
     13 .Op Fl n
     14 .Op Fl N Ar num
     15 .Op Fl p Ar prec
     16 .Op Fl s
     17 .Oo
     18 .Op Ar min_val
     19 .Ar max_val
     20 .Oc
     21 .Sh DESCRIPTION
     22 .Nm
     23 generates floating-point numbers that are by default evenly distributed
     24 in the linear, closed interval
     25 .Ar [ min_val ;
     26 .Ar max_val ].
     27 If
     28 .Ar max_val
     29 is not specified, it is 1.
     30 If
     31 .Ar min_val
     32 is not specified, it is 0.
     33 If
     34 .Ar min_val
     35 and/or
     36 .Ar max_val
     37 are negative, they must be prefixed with the '--' option.
     38 .Pp
     39 The options are as follows:
     40 .Bl -tag -width Ds
     41 .It Fl b
     42 Do not include
     43 .Ar min_val
     44 as the first value, making it a half-open interval
     45 .Ar \] min_val ;
     46 .Ar max_val ],
     47 or an entirely open interval when combined with
     48 .Op Ar e .
     49 .It Fl d Ar delimstr
     50 Separate output values by
     51 .Ar delimstr .
     52 The default delimiter is newlines.
     53 .It Fl e
     54 Do not include
     55 .Ar max_val
     56 as the last value, making it a half-open interval
     57 .Ar [ min_val ;
     58 .Ar max_val [,
     59 or an entirely open interval when combined with
     60 .Op Ar b .
     61 .It Fl l
     62 Produce output with even intervals in logarithmic space between
     63 .Ar min_val
     64 and
     65 .Ar max_val ,
     66 where both must be positive numbers.
     67 .It Fl n
     68 Do not print a newline after the final value.
     69 .It Fl N Ar num
     70 Number of values to produce within the specified range.
     71 The default is 10.
     72 .It Fl p Ar prec
     73 Print the output values with
     74 .Ar prec
     75 digits of precision.
     76 By default, the output is printed with 17 digits of precision, which is
     77 full double precision on 64-bit systems.
     78 .It Fl s
     79 Print the numerical spacing between numbers and exit.
     80 .El
     81 .Sh EXAMPLES
     82 Generate four equally-spaced numbers in the closed default range [0;1]:
     83 .Dl $ range -N 4
     84 .Dl 0
     85 .Dl 0.33333333333333331
     86 .Dl 0.66666666666666663
     87 .Dl 1
     88 .Pp
     89 Generate four numbers in the range ]0;1[:
     90 .Dl $ range -be -N 4
     91 .Dl 0.20000000000000001
     92 .Dl 0.40000000000000002
     93 .Dl 0.60000000000000009
     94 .Dl 0.80000000000000004
     95 .Pp
     96 Generate three space-separated numbers:
     97 .Dl $ range -d' ' -N 3 1 3
     98 .Dl 1 2 3
     99 .Pp
    100 Generate three numbers evenly distributed in logspace from 1 to 100:
    101 .Dl $ range -l -N 3 1 100
    102 .Dl 1
    103 .Dl 10
    104 .Dl 100
    105 .Pp
    106 Generate three numbers in the range [-2;-1]:
    107 .Dl $ range -N 3 -- -2 -1
    108 .Dl -2
    109 .Dl -1.5
    110 .Dl -1
    111 .Sh SEE ALSO
    112 .Xr max 1 ,
    113 .Xr mean 1 ,
    114 .Xr min 1 ,
    115 .Xr randnum 1 ,
    116 .Xr rangetest 1
    117 .Sh AUTHORS
    118 .An Anders Damsgaard Aq Mt anders@adamsgaard.dk