next up previous [pdf]

Next: Implementation: system/main/add.c Up: Main programs Previous: Main programs

sfadd: Add, multiply, or divide RSF datasets.

sfadd > out.rsf scale= add= sqrt= abs= log= exp= mode= [< file0.rsf] file1.rsf file2.rsf ...
The various operations, if selected, occur in the following order:

(1) Take absolute value, abs=
(2) Add a scalar, add=
(3) Take the natural logarithm, log=
(4) Take the square root, sqrt=
(5) Multiply by a scalar, scale=
(6) Compute the base-e exponential, exp=
(7) Add, multiply, or divide the data sets, mode=

sfadd operates on integer, float, or complex data, but all the input
and output files must be of the same data type.

An alternative to sfadd is sfmath, which is more versatile, but may be
less efficient.

bools abs= If true take absolute value [nin]
floats add= Scalar values to add to each dataset [nin]
bools exp= If true compute exponential [nin]
bools log= If true take logarithm [nin]
string mode= 'a' means add (default), 'p' or 'm' means multiply, 'd' means divide

floats scale= Scalar values to multiply each dataset with [nin]
bools sqrt= If true take square root [nin]

sfadd is useful for combining (adding, dividing, or multiplying) several datasets. What if you want to subtract two datasets? Easy. Use the scale parameter as follows:

bash$ sfadd data1.rsf data2.rsf scale=1,-1 > diff.rsf
or
bash$ sfadd < data1.rsf data2.rsf scale=1,-1 > diff.rsf
The same task can be accomplished with the more general sfmath program:
bash$ sfmath one=data1.rsf two=data2.rsf output='one-two' > diff.rsf
or
bash$ sfmath < data1.rsf two=data2.rsf output='input-two' > diff.rsf
In both cases, the size and shape of data1.rsf and data2.rsf hypercubes should be the same, and a warning message is printed out if the the axis sampling parameters (such as o1 or d1) in these files are different.



Subsections
next up previous [pdf]

Next: Implementation: system/main/add.c Up: Main programs Previous: Main programs

2012-07-19