Arithmetic

From Eigenvector Research Documentation Wiki
Jump to navigation Jump to search

Purpose

Apply simple arithmetic operations to all or part of dataset.

Synopsis

[cx] = arithmetic(x);
[cx] = arithmetic(x, op, const);
[cx] = arithmetic(x, op, const, indices);
[cx] = arithmetic(x, op, const, indices, modes);

Description

Apply an arithmetic operation to the input dataset or array (n-way), or a specified subset thereof. The supported operations are listed below. These are applied element-wise, so 'multiply' is applied as '.*' for example. The operation is applied to x or the specified subset of x.

Available operations:

 add      : Adds const.                        xij = xij+const
 subtract : Subtract const.                    xij = xij-const
 multiply : Multiply by const.                 xij = xij*const
 divide   : Divide by const.                   xij = xij/const
 inverse  : Invert and multiply by const.      xij = const/xij
 power    : Raise to power of const.           xij = xij^const
 root     : Take const root.                   xij = xij^(1/const)
 modulus  : Modulus after division by const.   xij = mod(xij,const)
 round    : Round to nearest 1/const fraction. xij = round(xij*const)/const
 log      : Log to base const.                 xij = log(xij)/log(const)
 antilog  : Antilog to base const.             xij = const^(xij)
 noop     : Identity op. Make no change.       xij = xij

Inputs

  • x = dataset or array.

Optional Inputs

  • operation = name (char) of arithmetic operation to apply.
  • const = value (double) used in the operation.
  • indices = a cell of requested indices (e.g. {[1:5] [10:20]} ).
  • modes = Modes (integer, or vector) to which indicies should be applied. See nindex/nassign for indices and modes usage.

Outputs

  • cx = modified dataset or array.

Options

options = a structure array with the following fields:

  • isundo: [ 'yes' | {'no'} ] Change operation to undo mode.

See Also

nindex, preprocess