This HTML automatically generated with rman for NEMO
Table of Contents

Name

tabgen - Create an arbitrarely large ASCII table with (random) values

Synopsis

tabgen [parameter=value]

Description

Create a table with (random) numbers. Either uniformly ditributed numbers between 0 and 1, from a gaussian (normal) distribution with mean 0 and sigma 1, a constant value, or a linearly increasing value (0, 1, 2, ...). See mode= below.

The number or rows and columns can be arbitrarely large, but not all table(5NEMO) programs in NEMO will be able to deal with large columns or rows. Usually rows can be managed with the nmax= keyword, but columns is hidden deeper and not under user control.

Using mode < 0 numbers are generated but not output, in effect allowing a benchmark.

This program has no real use other than benchmarking and testing the limits
of other program being fed very large tables. See EXAMPLES below for a counter example.

Parameters

The following parameters are recognized in order; they may be given in any order if the keyword is also given. Use --help to confirm this man page is up to date.
out=
Output ascii table [???]
nr=
Number of rows [10]
nc=
Number of columns [5]
mode=
The distribution of numbers: 1=uniform 2=normal 3=constant 4=linear < 0 : no output, but the absolute value determines which distribution of numbers [1]
seed=
Random seed [123]
fmt=
The printf(3) style format specifier. [%g]
sep=c|s|v|t
Separator between columns. c=comma s=space v=vertical bar t=tab. If none of these are given, the string is taken literal [Default: space]

Performance

On a typical 2020 machine it takes 0.23 seconds to create and output 1M random numbers, however most of the time is the output function. Using mode < 0 you can test the speed of just producing random numbers. About 95% of the time is spent in printf(3) , as can be seen with this benchmark:
    /usr/bin/time tabgen . 10000 10000 -1
    1.38user 0.29system 0:01.68elapsed 99%CPU
    
    /usr/bin/time tabgen . 10000 10000 1
    28.60user 0.14system 0:28.77elapsed 99%CPU
    
The raw production of random numbers is thus about 72 Mrups (same speed as numpy.random.normal), where the Linpack benchmark claims this machine runs at 50 GFlops.

Generating a sequence of numbers is relatively slow in tabgen. To generate 10M numbers is slow compared ot the standard unix tool seq(1) :

    /usr/bin/time tabgen - 10000000 1 4 fmt=%-10.f > tab2
    9.89user 0.07system 0:09.97elapsed 99%CPU
    /usr/bin/time seq 10000000 > tab2
    0.19user 0.22system 0:00.42elapsed 98%CPU
    
which is most likely the more complex operations of a floating point fprintf(3) .

The nemoinp(1NEMO) program can also generate a simple table, but the maximum number of elements in an implied list is limited (100,000 currently). This is where tabgen might be useful:

     nemoinp 1:200000 > tab1
     ### Fatal error [nemoinp]: Too many items in list, use a bigger nmax=100000
     
     tabgen - 200000 1 mode=4 > tab1
     wc -l tab1
     200000 tab1

See Also

seq(1) , tabhead(1NEMO) , tabmath(1NEMO) , xrandom(1NEMO) , nemoinp(1NEMO) , xrandom(3NEMO) , printf(3)

Author

Peter Teuben

Update History


12-Jul-2020    V0.1 Created    PJT
14-jul-2020    V0.3 mode= implemented    PJT
25-jul-2020    V0.4 changed meaning of mode=    PJT
29-apr-2022    V0.6 cleanup and tableV2 things     PJT
5-oct-2022    V0.7 added sep=    PJT


Table of Contents