#!/usr/bin/perl -w
#
# dbrowaccumulate.pm
# Copyright (C) 1991-2022 by John Heidemann <johnh@isi.edu>
#
# This program is distributed under terms of the GNU general
# public license, version 2. See the file COPYING
# in $dblibdir for details.
#
=head1 NAME
dbrowaccumulate - compute a running sum of a column
=head1 SYNOPSIS
dbrowaccumulate [-C increment_constant] [-I initial_value] [-c increment_column] [-N new_column_name]
=head1 DESCRIPTION
Compute a running sum over a column of data,
or of a constant incremented per row,
perhaps to generate a cumulative distribution.
What to accumulate is specified by C<-c> or C<-C>.
The new column is named by the C<-N> argument, defaulting to C<accum>.
=head1 OPTIONS
=over 4
=item B<-c> or B<--column> COLUMN
Accumulate values from the given COLUMN.
No default.
=item B<-C> or B<--constant> K
Accumulate the given constant K for each row of input.
No default.
=item B<-I> or B<--initial-value> I
Start accumulation at value I.
Defaults to zero.
=item B<-N> or B<--new-name> N
Name the new column N.
Defaults to C<accum>.
=back
=for comment
begin_standard_fsdb_options
This module also supports the standard fsdb options:
=over 4
=item B<-d>
Enable debugging output.
=item B<-i> or B<--input> InputSource
Read from InputSource, typically a file name, or C<-> for standard input,
or (if in Perl) a IO::Handle, Fsdb::IO or Fsdb::BoundedQueue objects.
=item B<-o> or B<--output> OutputDestination
Write to OutputDestination, typically a file name, or C<-> for standard output,
or (if in Perl) a IO::Handle, Fsdb::IO or Fsdb::BoundedQueue objects.
=item B<--autorun> or B<--noautorun>
By default, programs process automatically,
but Fsdb::Filter objects in Perl do not run until you invoke
the run() method.
The C<--(no)autorun> option controls that behavior within Perl.
=item B<--help>
Show help.
=item B<--man>
Show full manual.
=back
=for comment
end_standard_fsdb_options
=head1 SAMPLE USAGE
=head2 Input:
#fsdb diff
0.0
00.000938
00.001611
00.001736
00.002006
00.002049
# | /home/johnh/BIN/DB/dbrow
# | /home/johnh/BIN/DB/dbcol diff
# | dbsort diff
=head2 Command:
cat DATA/kitrace.fsdb | dbrowaccumulate -c diff
=head2 Output:
#fsdb diff accum
0.0 0
00.000938 .000938
00.001611 .002549
00.001736 .004285
00.002006 .006291
00.002049 .00834
# | /home/johnh/BIN/DB/dbrow
# | /home/johnh/BIN/DB/dbcol diff
# | dbsort diff
# | /home/johnh/BIN/DB/dbrowaccumulate diff
=head1 SEE ALSO
L<Fsdb>,
L<dbrowenumerate>.
=cut
# WARNING: This code is derived from dbrowaccumulate.pm; that is the master copy.
use Fsdb::Filter::dbrowaccumulate;
my $f = new Fsdb::Filter::dbrowaccumulate(@ARGV);
$f->setup_run_finish; # or could just --autorun
exit 0;
=head1 AUTHOR and COPYRIGHT
Copyright (C) 1991-2022 by John Heidemann <johnh@isi.edu>
This program is distributed under terms of the GNU general
public license, version 2. See the file COPYING
with the distribution for details.
=cut
1;