ccor1d(3S)

CCOR1D, ZCOR1D, SCOR1D, DCOR1D - Compute the one-dimensional (1D) correlation of two sequences.

Showing IRIX 6.5.30 (default release). Added in IRIX 6.5.15.

NAME
     CCOR1D, ZCOR1D, SCOR1D, DCOR1D - Compute the one-dimensional (1D)
     correlation of two sequences.

SYNOPSIS
     Single precision complex

          Fortran:
               CALL CCOR1D (x, incx, ix0, nx, h, inch, ih0, nh, y, incy, iy0,
               ny)

          C/C++:
               #include <scsl_fft.h>
               void ccor1d (scsl_complex *x, int incx, int ix0, int nx,
               scsl_complex *h, int inch, int ih0, int nh, scsl_complex *y,
               int incy, int iy0, int ny);

          C++ STL:
               #include <complex.h>
               #include <scsl_fft.h>
               void ccor1d (complex<float> *x, int incx, int ix0, int nx,
               complex<float> *h, int inch, int ih0, int nh, complex<float>
               *y, int incy, int iy0, int ny);

     Double precision complex

          Fortran:
               CALL ZCOR1D (x, incx, ix0, nx, h, inch, ih0, nh, y, incy, iy0,
               ny);

          C/C++:
               #include <scsl_fft.h>
               void zcor1d (scsl_zomplex *x, int incx, int ix0, int nx,
               scsl_zomplex *h, int inch, int ih0, int nh, scsl_zomplex *y,
               int incy, int iy0, int ny);

          C++ STL:
               #include <complex.h>
               #include <scsl_fft.h>
               void zcor1d (complex<double> *x, int incx, int ix0, int nx,
               complex<double> *h, int inch, int ih0, int nh, complex<double>
               *y, int incy, int iy0, int ny);

     Single precision

          Fortran:
               CALL SCOR1D (x, incx, ix0, nx, h, inch, ih0, nh, y, incy, iy0,
               ny)

          C/C++:
               #include <scsl_fft.h>
               void scor1d (float *x, int incx, int ix0, int nx, float *h, int
               inch, int ih0, int nh, float *y, int incy, int iy0, int ny);

     Double precision

          Fortran:
               CALL DCOR1D (x, incx, ix0, nx, h, inch, ih0, nh, y, incy, iy0,
               ny)

          C/C++:
               #include <scsl_fft.h>
               void dcor1d (double *x, int incx, int ix0, int nx, double *h,
               int inch, int ih0, int nh, double *y, int incy, int iy0, int
               ny);

IMPLEMENTATION
     These routines are part of the SCSL Scientific Library and can be loaded
     using either the -lscs or the -lscs_mp option.  The -lscs_mp option
     directs the linker to use the multi-processor version of the library.

     When linking to SCSL with -lscs or -lscs_mp, the default integer size is
     4 bytes (32 bits). Another version of SCSL is available in which integers
     are 8 bytes (64 bits).  This version allows the user access to larger
     memory sizes and helps when porting legacy Cray codes.  It can be loaded
     by using the -lscs_i8 option or the -lscs_i8_mp option. A program may use
     only one of the two versions; 4-byte integer and 8-byte integer library
     calls cannot be mixed.

     The C and C++ prototypes shown above are appropriate for the 4-byte
     integer version of SCSL. When using the 8-byte integer version, the
     variables of type int become long long and the <scsl_fft_i8.h> header
     file should be included.

DESCRIPTION
     These routines compute the correlation of the filter sequence h with the
     data sequence x, producing the output sequence y.

     Suppose h and x are two sequences of numbers, having nh and nx elements,
     respectively.

          h = [h(0), h(1), ..., h(nh - 1) ] , and
          x = [x(0), x(1), ..., x(nx - 1) ] .


     The correlation y is the sequence having elements defined by:

          y(0) = h(0) * x(0) + h(1) * x(1) + ... + h(nh-1) * x(nh-1)
          y(1) = h(0) * x(1) + h(1) * x(2) + ... + h(nh-1) * x(nh)
          y(2) = h(0) * x(2) + h(1) * x(3) + ... + h(nh-1) * x(nh+1)

     This example definition assumes nx >= nh. The precise definition of the
     correlation is:

                  min(nh-1,nx-1-k)
          Y(j) =         Sum {H(k)*x(j+k)},     j = 0, ..., ny-1.
                         k=0


     In the *COR1D routines, the number of terms in the output sequence is
     specified by an argument, ny.  If ny < nx, the output sequence is just
     truncated.  If ny > nx, zeros are appended to the output sequence.

     By choosing ny > nx-nh + 1, the routine does what is sometimes called
     "post-tapered" correlation.  The effect is as though the data sequence,
     x, were padded on the end with zeros, except that no zeros are actually
     stored and no multiplications by zero are actually done.

     Generally, the sequences x, h and y represent signals sampled at equal
     time intervals, and the indexes of the vectors denote the sample times.
     If all three signals begin at the same time, we may, without loss of
     generality, set the initial time to 0, as in the formulas above.

     The *COR1D routines, however, permit more generality than this. The
     signals may be time shifted from each other using input parameters
     specifiying the initial time sample for each signal. This can be useful
     in several situations. For example, if the input array has several
     leading zero values that one does not wish to store, ix0 may be set to
     the time sample corresponding to the first non-zero element in the input
     array, and earlier time samples are treated as 0.

     Note that, instead of 0, the initial time could just as easily have been
     labeled 1 or 10 or -78; the relevant point is that the first elements of
     each of the x, h and y arrays are defined to be the same time sample as
     long as ix0 = ih0 = iy0.

     See the NOTES section of this man page for information about the
     interpretation of the data types described in the following arguments.

     These routines have the following arguments:

     x         Array of dimension nx. (input).
               CCOR1D: Single precision complex array.
               ZCOR1D: Double precision complex array.
               SCOR1D: Single precision array.
               DCOR1D: Double precision array.
               Input sequences to be correlated with h.

     incx      Integer. (input)
               Increment between two successive values of x.  incx must not be
               0.

     ix0       Integer. (input)
               Time sample corresponding to the first element of x.

     nx        Integer. (input)
               The number of elements in the sequence x.  nx >= 0.

     h         Array of dimension nh. (input).
               CCOR1D: Single precision complex array.
               ZCOR1D: Double precision complex array.
               SCOR1D: Single precision array.
               DCOR1D: Double precision array.
               Input sequence to be correlated with x.

     inch      Integer.  (input)
               Increment between two successive values of h. inch must not be
               0.

     ih0       Integer.  (input)
               Time sample correspondings to the first element of h.

     nh        Integer.  (input)
               The number of elements in the sequence h.  nh >= 0.

     y         Array of dimension ny.  (output)
               CCOR1D: Single precision complex array.
               ZCOR1D: Double precision complex array.
               SCOR1D: Single precision array.
               DCOR1D: Double precision array.

               Output of the correlation. On entry, the array y need not be
               initialized.  On exit, the result overwrites y.

     incy      Integer.  (input)
               Increment between two successive values of y.  incy must not be
               0.

     iy0       Integer.  (input)
               Time sample corresponding to the first element of y.

     ny        Integer.  (input)
               Number of elements in each sequence of y.  ny >= 0.

NOTES
     The following data types are described in this documentation:

          Term Used                     Data type

     Fortran:

          Array dimensioned 0..n-1      x(0:n-1)

          Array of dimensions (m,n)     x(m,n)

          Array of dimensions (m,n,p)   x(m,n,p)

          Integer                       INTEGER (INTEGER*8 for -lscs_i8[_mp])

          Single precision              REAL

          Double precision              DOUBLE PRECISION

          Single precision complex      COMPLEX

          Double precision complex      DOUBLE COMPLEX

     C/C++:

          Array dimensioned 0..n-1      x[n]

          Array of dimensions (m,n)     x[m*n] or x[n][m]

          Array of dimensions (m,n,p)   x[m*n*p] or x[p][n][m]

          Integer                       int (long long for -lscs_i8[_mp])

          Single precision              float

          Double precision              double

          Single precision complex      scsl_complex

          Double precision complex      scsl_zomplex

     C++ STL:

          Array dimensioned 0..n-1      x[n]

          Array of dimensions (m,n)     x[m*n] or x[n][m]

          Array of dimensions (m,n,p)   x[m*n*p] or x[p][n][m]

          Integer                       int (long long for -lscs_i8[_mp])

          Single precision              float

          Double precision              double

          Single precision complex      complex<float>

          Double precision complex      complex<double>

CAUTIONS
     The arrays x, h and y must be non-overlapping.

EXAMPLES
     The following example computes the correlation of a 4-sample sequence x
     with a filter h containing 3 samples:

     Fortran:

          REAL X(0:3), H(0:2), Y(0:5)

          X(0) = 1.0
          DO I = 1, 3
             X(I) = -1.0
          ENDDO
          DO I = 0, 2
             H(I) = 1.0/(I+1)
          ENDDO
          CALL SCOR1D(X(0), 1, 0, 4, H(0), 1, 0, 3, Y(0), 1, 0, 6)


     C/C++:

          #include <scsl_fft.h>
          float x[4], h[3], y[6];
          int i;

          x[0] = 1.0f
          for (i=1; i<4; i++) {
             x[i] = -1.0f;
          }
          for (i=0; i<3; i++) {
             h[i] = 1.0f/(i+1);
          }
          scor1d(x, 1, 0, 4, h, 1, 0, 3, y, 1, 0, 6);


     The output is

                       Y(0)     Y(1)     Y(2)     Y(3)     Y(4)     Y(5)
                      0.1667  -1.8333  -1.5000  -1.0000   0.0000   0.0000


     Changing the values for ix0, ih0 and iy0 produces the following shifts in
     the output:

          ix0 = +1    0.1667   0.1667  -1.8333  -1.5000  -1.0000   0.0000
          ix0 = +2    0.3333   0.1667   0.1667  -1.8333  -1.5000  -1.0000
          ix0 = -1   -1.8333  -1.5000  -1.0000   0.0000   0.0000   0.0000
          ix0 = -2   -1.5000  -1.0000   0.0000   0.0000   0.0000   0.0000
          ih0 = +1   -1.8333  -1.5000  -1.0000   0.0000   0.0000   0.0000
          ih0 = +2   -1.5000  -1.0000   0.0000   0.0000   0.0000   0.0000
          ih0 = -1    0.1667   0.1667  -1.8333  -1.5000  -1.0000   0.0000
          ih0 = -2    0.3333   0.1667   0.1667  -1.8333  -1.5000  -1.0000
          iy0 = +1   -1.8333  -1.5000  -1.0000   0.0000   0.0000   0.0000
          iy0 = +2   -1.5000  -1.0000   0.0000   0.0000   0.0000   0.0000
          iy0 = -1    0.1667   0.1667  -1.8333  -1.5000  -1.0000   0.0000
          iy0 = -2    0.3333   0.1667   0.1667  -1.8333  -1.5000  -1.0000


SEE ALSO
     INTRO_FFT(3S), INTRO_SCSL(3S)