linear_intpl

Functions

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

linear_intpl [ option ] [ infile ]

  • -l int

    • output length \((1 \le L)\)

  • -m int

    • number of interpolation points \((0 \le L-1)\)

  • -s double

    • minimum value of x-axis \((x_{min})\)

  • -e double

    • maximum value of x-axis \((x_{max})\)

  • infile str

    • double-type 2D data sequence

  • stdout

    • double-type linear interpolated 1D data sequence

The input of this command is a 2-dimensional data sequence:

\[ \begin{array}{ccccc} x_0, & y_0, & x_1, & y_1, & \ldots \end{array} \]
The output is
\[ \begin{array}{cccc} f(x_{min}), & f(x_{min}+t), & f(x_{min}+2t), & \ldots, & f(x_{max}), \end{array} \]
where \(t\) is the interval:
\[ t = \frac{x_{max} - x_{min}}{L - 1}, \]
and \(f(\cdot)\) is a linear interpolation function:
\[ f(x) = ax + b. \]
The slope \(a\) and the intercept \(b\) are calculated from the two points that sandwitch \(x\).

# x: 0, 2, 3, 5
# y: 2, 2, 0, 1
echo 0 2 2 2 3 0 5 1 | x2x +ad | linear_intpl -m 10 | x2x +da
# 2, 2, 2, 2, 2, 1, 0, 0.25, 0.5, 0.75, 1
Parameters:
  • argc[in] Number of arguments.

  • argv[in] Argument vector.

Returns:

0 on success, 1 on failure.