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]
addrow=t|f
add a row counter, 1 being the first. [f]

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) , however the new addrow= parameter makes it about 3x faster.

    /usr/bin/time tabgen - 10000000 1 4 fmt=%-10.f > tab2
    2.07user 0.10system 0:02.18elapsed 99%CPU
    /usr/bin/time seq 10000000 > tab2
    0.05user 0.04system 0:00.10elapsed 100%CPU (
but
    /usr/bin/time tabgen - 10000000 0 addrow=t > tab2
    0.65user 0.07system 0:00.73elapsed 99%CPU
    

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
14-feb-2024    V0.8 added addrow=    PJT


Table of Contents