The 'acol' Command-line Utility

O2scl contains a command-line utility, acol, designed to facilitate the manipulation of two-dimensional data tables, either stored in a generic text-file, or o2scl::table objects stored using the I/O facilities in O2scl .

acol has a command, run, which allows you to run a set of commands which are given in a separate file. An example script in the extras directory of the documentation is named acol.scr. The associated output is a useful demonstration of the capabilities of acol.

#
# -----------------------------------------------------------------
# This file documents the use of the 'acol' command. The command
# 'help' provides the full help text. You can also get help on the
# commands individually, e.g.
# -----------------------------------------------------------------
> help create
Usage: create <name> <low> <hi> <step>

Create a table from uniform grid.

Create a new table with one column whose entries are an evenly-spaced grid. 
This takes four arguments, the name of the column, the first value, the 
increment between successive values and the maximum possible value. Note that 
finite precision arithmetic may cause small deviations from the expected 
result. If a table is currently in memory, it is deallocated beforehand. 
# -----------------------------------------------------------------
# The full command list is given with 'commands'
# -----------------------------------------------------------------
> commands
Command list:

alias        delete-rows  get          internal     quit         slice        
assign       deriv        get-conv     interp       read         sort         
calc         deriv2       get-row      license      rename       stats        
cat          exit         get-unit     list         run          sum          
commands     filelist     help         max          select       to-hist      
contours     find-row     index        min          select-rows  type         
convert-unit fit          insert       nlines       set          version      
create       function     insert-full  no-intro     set-data     warranty     
create3      gen3-list    integ        output       set-unit     
delete-col   generic      interactive  preview      show-units   

# -----------------------------------------------------------------
# Use 'create' to create a table with one column
# -----------------------------------------------------------------
> create x 0 1 0.1
# -----------------------------------------------------------------
# Use 'function' to apply a function to create a new column
# -----------------------------------------------------------------
> function sin(x) s
> function sqrt(1-s*s) c
# -----------------------------------------------------------------
# The 'deriv' command computes derivatives
# -----------------------------------------------------------------
> deriv x s c2
# -----------------------------------------------------------------
# Use 'output' to see the results
# -----------------------------------------------------------------
> output
 x             s             c             c2           
 0.000000e+00  0.000000e+00  1.000000e+00  9.999995e-01 
 1.000000e-01  9.983342e-02  9.950042e-01  9.950034e-01 
 2.000000e-01  1.986693e-01  9.800666e-01  9.800667e-01 
 3.000000e-01  2.955202e-01  9.553365e-01  9.553335e-01 
 4.000000e-01  3.894183e-01  9.210610e-01  9.210695e-01 
 5.000000e-01  4.794255e-01  8.775826e-01  8.775485e-01 
 6.000000e-01  5.646425e-01  8.253356e-01  8.254605e-01 
 7.000000e-01  6.442177e-01  7.648422e-01  7.643741e-01 
 8.000000e-01  7.173561e-01  6.967067e-01  6.984518e-01 
 9.000000e-01  7.833269e-01  6.216100e-01  6.150954e-01 
 1.000000e+00  8.414710e-01  5.403023e-01  5.646134e-01 
# -----------------------------------------------------------------
# Or give 'output' command an argument to output to a file
# -----------------------------------------------------------------
> output test.txt
# -----------------------------------------------------------------
# Change the output precision using set
# -----------------------------------------------------------------
> set precision 4
> output
 x           s           c           c2         
 0.0000e+00  0.0000e+00  1.0000e+00  1.0000e+00 
 1.0000e-01  9.9833e-02  9.9500e-01  9.9500e-01 
 2.0000e-01  1.9867e-01  9.8007e-01  9.8007e-01 
 3.0000e-01  2.9552e-01  9.5534e-01  9.5533e-01 
 4.0000e-01  3.8942e-01  9.2106e-01  9.2107e-01 
 5.0000e-01  4.7943e-01  8.7758e-01  8.7755e-01 
 6.0000e-01  5.6464e-01  8.2534e-01  8.2546e-01 
 7.0000e-01  6.4422e-01  7.6484e-01  7.6437e-01 
 8.0000e-01  7.1736e-01  6.9671e-01  6.9845e-01 
 9.0000e-01  7.8333e-01  6.2161e-01  6.1510e-01 
 1.0000e+00  8.4147e-01  5.4030e-01  5.6461e-01 
> set precision 6
# -----------------------------------------------------------------
# Shell commands are proceeded by an '!'
# -----------------------------------------------------------------
> !cat test.txt
acol: Executing system command: cat test.txt
 x             s             c             c2           
 0.000000e+00  0.000000e+00  1.000000e+00  9.999995e-01 
 1.000000e-01  9.983342e-02  9.950042e-01  9.950034e-01 
 2.000000e-01  1.986693e-01  9.800666e-01  9.800667e-01 
 3.000000e-01  2.955202e-01  9.553365e-01  9.553335e-01 
 4.000000e-01  3.894183e-01  9.210610e-01  9.210695e-01 
 5.000000e-01  4.794255e-01  8.775826e-01  8.775485e-01 
 6.000000e-01  5.646425e-01  8.253356e-01  8.254605e-01 
 7.000000e-01  6.442177e-01  7.648422e-01  7.643741e-01 
 8.000000e-01  7.173561e-01  6.967067e-01  6.984518e-01 
 9.000000e-01  7.833269e-01  6.216100e-01  6.150954e-01 
 1.000000e+00  8.414710e-01  5.403023e-01  5.646134e-01 
acol: Done with system command (returned 0).
# -----------------------------------------------------------------
# Or store the results in the internal format 
# -----------------------------------------------------------------
> internal test.o2
# -----------------------------------------------------------------
# Generic test files can be read using the 'generic' command
# -----------------------------------------------------------------
> generic test.txt
> output
 x             s             c             c2           
 0.000000e+00  0.000000e+00  1.000000e+00  9.999995e-01 
 1.000000e-01  9.983342e-02  9.950042e-01  9.950034e-01 
 2.000000e-01  1.986693e-01  9.800666e-01  9.800667e-01 
 3.000000e-01  2.955202e-01  9.553365e-01  9.553335e-01 
 4.000000e-01  3.894183e-01  9.210610e-01  9.210695e-01 
 5.000000e-01  4.794255e-01  8.775826e-01  8.775485e-01 
 6.000000e-01  5.646425e-01  8.253356e-01  8.254605e-01 
 7.000000e-01  6.442177e-01  7.648422e-01  7.643741e-01 
 8.000000e-01  7.173561e-01  6.967067e-01  6.984518e-01 
 9.000000e-01  7.833269e-01  6.216100e-01  6.150954e-01 
 1.000000e+00  8.414710e-01  5.403023e-01  5.646134e-01 
# -----------------------------------------------------------------
# Files in the internal format can be read with 'read'
# -----------------------------------------------------------------
> read test.o2
No name specified, reading first table object.
> output
 x             s             c             c2           
 0.000000e+00  0.000000e+00  1.000000e+00  9.999995e-01 
 1.000000e-01  9.983342e-02  9.950042e-01  9.950034e-01 
 2.000000e-01  1.986693e-01  9.800666e-01  9.800667e-01 
 3.000000e-01  2.955202e-01  9.553365e-01  9.553335e-01 
 4.000000e-01  3.894183e-01  9.210610e-01  9.210695e-01 
 5.000000e-01  4.794255e-01  8.775826e-01  8.775485e-01 
 6.000000e-01  5.646425e-01  8.253356e-01  8.254605e-01 
 7.000000e-01  6.442177e-01  7.648422e-01  7.643741e-01 
 8.000000e-01  7.173561e-01  6.967067e-01  6.984518e-01 
 9.000000e-01  7.833269e-01  6.216100e-01  6.150954e-01 
 1.000000e+00  8.414710e-01  5.403023e-01  5.646134e-01 
# -----------------------------------------------------------------
# Tables also contain constant values in addition to data
# -----------------------------------------------------------------
> assign pi acos(-1.0)
# -----------------------------------------------------------------
# The 'list' command lists the column and constant names
# -----------------------------------------------------------------
> list
Table name: acol
1 constant:
pi 3.141593e+00
4 columns: 
0. x  1. s  2. c  3. c2 
11 lines of data.
# -----------------------------------------------------------------
# Constants can be used in expressions
# -----------------------------------------------------------------
> function x*pi/2 x2
# -----------------------------------------------------------------
# Columns can be renamed. Legal column names contain letters
# numbers and underscores, and begin with a letter.
# -----------------------------------------------------------------
> rename x2 x_2
> output
 x             s             c             c2            x_2          
 []            []            []            []            []           
 0.000000e+00  0.000000e+00  1.000000e+00  9.999995e-01  0.000000e+00 
 1.000000e-01  9.983342e-02  9.950042e-01  9.950034e-01  1.570796e-01 
 2.000000e-01  1.986693e-01  9.800666e-01  9.800667e-01  3.141593e-01 
 3.000000e-01  2.955202e-01  9.553365e-01  9.553335e-01  4.712389e-01 
 4.000000e-01  3.894183e-01  9.210610e-01  9.210695e-01  6.283185e-01 
 5.000000e-01  4.794255e-01  8.775826e-01  8.775485e-01  7.853982e-01 
 6.000000e-01  5.646425e-01  8.253356e-01  8.254605e-01  9.424778e-01 
 7.000000e-01  6.442177e-01  7.648422e-01  7.643741e-01  1.099557e+00 
 8.000000e-01  7.173561e-01  6.967067e-01  6.984518e-01  1.256637e+00 
 9.000000e-01  7.833269e-01  6.216100e-01  6.150954e-01  1.413717e+00 
 1.000000e+00  8.414710e-01  5.403023e-01  5.646134e-01  1.570796e+00 
# -----------------------------------------------------------------
# (Remove test files created earlier.)
# -----------------------------------------------------------------
> !rm test.txt
acol: Executing system command: rm test.txt
acol: Done with system command (returned 0).
> !rm test.o2
acol: Executing system command: rm test.o2
acol: Done with system command (returned 0).

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).