vsum

Functions

int main(int argc, char *argv[])

vsum [ option ] [ infile ]

  • -l int

    • length of vector \((1 \le L)\)

  • -m int

    • order of vector \((0 \le L - 1)\)

  • -t int

    • output interval \((1 \le T)\)

  • infile str

    • double-type vectors

  • stdout

    • double-type summation

The input of this command is

\[ \begin{array}{ccc} \underbrace{x_1(1), \; \ldots, \; x_1(L)}_L, & \underbrace{x_2(1), \; \ldots, \; x_2(L)}_L, & \ldots, \end{array} \]
and the output is
\[ \begin{array}{ccc} \underbrace{s_{0}(1), \; \ldots, \; s_{0}(L)}_L, & \underbrace{s_{T}(1), \; \ldots, \; s_{T}(L)}_L, & \ldots, \end{array} \]
where
\[ s_t(l) = \sum_{\tau=1}^{T} x_{t+\tau}(l). \]
If \(T\) is not given, the summation of the whole input is computed.

echo 0 1 2 3 4 5 6 7 8 9 | x2x +ad | vsum -l 2 | x2x +da
# 20
# 25
echo 0 1 2 3 4 5 6 7 | x2x +ad | vsum -l 2 -t 2 | x2x +da
# 2
# 4
# 10
# 12
Parameters:
  • argc[in] Number of arguments.

  • argv[in] Argument vector.

Returns:

0 on success, 1 on failure.

See also

average vstat