ccor2d(3S)
CCOR2D, ZCOR2D, SCOR2D, DCOR2D - Compute the two-dimensional (2D) correlation of two two-dimensional (2D) arrays
As shipped in IRIX 6.5.15. Added in IRIX 6.5.15.
NAME CCOR2D, ZCOR2D, SCOR2D, DCOR2D - Compute the two-dimensional (2D) correlation of two two-dimensional (2D) arrays SYNOPSIS Single precision complex Fortran: CALL CCOR2D (x, incx, ldx, ilx0, nx1, i2x0, nx2, h, inch, ldh, i1h0, nh1, i2h0, nh2, y, incy, ldy, i1y0, ny1, i2y0, ny2) C/C++: #include <scsl_fft.h> void ccor2d (scsl_complex *x, int incx, int ldx, int i1x0, int nx1, int i2x0, int nx2, scsl_complex *h, int inch, int ldh, int i1h0, int nh1, int i2h0, int nx2, scsl_complex *y, int incy, int ldy, int i1y0, int ny1 int i2y0, int ny2); C++ STL: #include <complex.h> #include <scsl_fft.h> void ccor2d (complex<float> *x, int incx, int ldx, int i1x0, int nx1, int i2x0, int nx2, complex<float> *h, int inch, int ldh, int i1h0, int nh1, int i2h0, int nx2, complex<float> *y, int incy, int ldy, int i1y0, int ny1 int i2y0, int ny2); Double precision complex Fortran: CALL ZCOR2D (x, incx, ldx, i1x0, nx1, i2x0, nx2, h, inch, ldh, i1h0, nh1, i2h0, nh2, y, incy, ldy, i1y0, ny1, i2y0, ny2) C/C++: #include <scsl_fft.h> void zcor2d (scsl_zomplex *x, int incx, int ldx, int i1x0, int nx1, int i2x0, int nx2, scsl_zomplex *h, int inch, int ldh, int i1h0, int nh1, int i2h0, int nx2, scsl_zomplex *y, int incy, int ldy, int i1y0, int ny1 int i2y0, int ny2) C++ STL: #include <complex.h> #include <scsl_fft.h> void zcor2d (complex<double> *x, int incx, int ldx, int i1x0, int nx1, int i2x0, int nx2, complex<double> *h, int inch, int ldh, int i1h0, int nh1, int i2h0, int nx2, complex<double> *y, int incy, int ldy, int i1y0, int ny1, int i2y0, int ny2); Single precision Fortran: CALL SCOR2D (x, incx, ldx, ilx0, nx1, i2x0, nx2, h, inch, ldh, i1h0, nh1, i2h0, nh2, y, incy, ldy, i1y0, ny1, i2y0, ny2) C/C++: #include <scsl_fft.h> void scor2d (float *x, int incx, int ldx, int i1x0, int nx1, int i2x0, int nx2, float *h, int inch, int ldh, int i1h0, int nh1, int i2h0, int nx2, float *y, int incy, int ldy, int i1y0, int ny1 int i2y0, int ny2); Double precision Fortran: CALL DCOR2D (x, incx, ldx, i1x0, nx1, i2x0, nx2, h, inch, ldh, i1h0, nh1, i2h0, nh2, y, incy, ldy, i1y0, ny1, i2y0, ny2) C/C++: #include <scsl_fft.h> void dcor2d (double *x, int incx, int ldx, int i1x0, int nx1, int i2x0, int nx2, double *h, int inch, int ldh, int i1h0, int nh1, int i2h0, int nx2, double *y, int incy, int ldy, int i1y0, int ny1 int i2y0, int ny2); 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 a 2D filter array h with a 2D array x, producing the output 2D array y. Let the following be the filter and data matrices: H = h 0 <= i < nh1, 0 <= j < nh2 i, j X = x 0 <= i < nx1, 0 <= j < nx2 i, j The correlation is defined as: Y(i,j) = Sum Sum H(k,l) * x(i+k, j+l) k l The matrix Y has values defined for 0<=i < nx1 and 0 <=j < nx2. In the *COR2D routines, the number of terms in the output array is specified by the arguments ny1 and ny2. If ny1 < nx1 or ny2 < nx2, the output array y is truncated. If ny1 >= nx1 or ny2 >= nx2, the terms beyond i = nx1-1 and j = nx2-1 are set to 0. By choosing ny2 > nx1 - nh1 + 1 or ny2 > nx2 - nh2 + 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 of each dimension with zeros, except that no zeros are actually stored and no multiplications by zero are actually done. Generally, the arrays x, h and y represent signals sampled at equal intervals in two dimensions, and the indexes of the arrays denote the samples. If all three signals are aligned, we may, without loss of generality, set the initial samples to 0 in both dimensions, as in the formulas above. The *COR2D routines, however, permit more generality than this. The signals may be shifted from each other using input parameters specifying the initial samples in each dimension. This can be useful in several situations. For example, if the input array has leading zero values that one does not wish to store, i1x0 and i2x0 may be set to the sample corresponding to the first non-zero element in the input array, and previous samples are treated as 0. Note that, instead of (0,0), the initial sample could just as easily have been labeled (1,1) or (10,1) or (0,-78); the relevant point is that the first elements of each of the x, h and y arrays are defined to be the same sample as long as i1x0 = i1h0 = i1y0 and i2x0 = i2h0 = i2y0. 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 dimensions (ldx, nx2). (input). CCOR2D: Single precision complex array. ZCOR2D: Double precision complex array. SCOR2D: Single precision array. DCOR2D: Double precision array. Input array containing the data to be correlated with h incx Integer. (input) Increment between two successive values of x. incx must not be 0. ldx Integer. (input) The number of rows in the x array, as it was declared in the calling program (the leading dimension of x). ldx >= MAX (nx1 * incx, 1). i1x0 Integer. (input) Sample corresonding to the first element of each column of x. nx1 Integer. (input) The number of elements in each column of x. nx1 >= 0. i2x0 Integer. (input). Sample corresponding to the first element of each row of x. nx2 Integer. (input). Number of elements in each row of x. nx2 >= 0. h Array of dimensions (ldh, nh2). (input). CCOR2D: Single precision complex array. ZCOR2D: Double precision complex array. SCOR2D: Single precision array. DCOR2D: Double precision array. Input array containing the filter matrix to be correlated with x. inch Integer. (input) Increment between two successive values of h. inch must not be 0. ldh Integer. (input) The number of rows in the h array, as it was declared in the calling program (the leading dimension of h). ldh >= MAX(nh1 * inch, 1). i1h0 Integer. (input) Sample corresponding to the first element of each column of h. nh1 Integer. (input) Number of elements in each column of h. nh1 >= 0. i2h0 Integer. (input) Sample corresponding to the first element of each row of h. nh2 Integer. (input) Number of elements in each row of h. nh2 >= 0. y Array of dimensions (ldy, ny2). (input and output) CCOR2D: Single precision complex array. ZCOR2D: Double precision complex array. SCOR2D: Single precision array. DCOR2D: Double precision array. Output of correlation. incy Integer. (input) Increment between two successive values of a sequence in y. incy must not be 0. ldy Integer. (input) The number of rows in the y array, as it was declared in the calling program (the leading dimension of y). ldy >= MAX( ny1 * incy, 1). i1y0 Integer. (input) Sample corresponding to the first element of each column of y. ny1 Integer. (input) Number of elements in each column of y. ny1 >= 0. i2y0 Integer. (input) Sample corresponding to the first element of each row of y. ny2 Integer. (input) Number of elements in each row of y. ny2 >= 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 4x4-sample array x with a filter h containing 3x3 samples: Fortran: REAL X(0:3,0:3), H(0:2,0:2), Y(0:5,0:5) DO J = 0, 3 DO I = 0, 3 X(I,J) = -1.0 ENDDO ENDDO X(0,0) = 1.0 DO J = 0, 2 DO I = 0, 2 H(i,j) = 1.0/(i+j+1) ENDDO ENDDO CALL SCOR2D(X, 1, 4, 0, 4, 0, 4, & H, 1, 3, 0, 3, 0, 3, & Y, 1, 6, 0, 6, 0, 6) C/C++: #include <scsl_fft.h> float x[4][4], h[3][3], y[6][6]; int i, j; for (j=0; j<4; j++) { for (i=0; i<4; i++) { x[j][i] = -1.0f; } } x[0][0] = 1.0f; for (j=0; j<3; j++) { for (i=0; i<3; i++) { h[i] = 1.0f/(i+j+1); } } scor2d((float *) x, 1, 4, 0, 4, 0, 4, (float *) h, 1, 3, 0, 3, 0, 3, (float *) y, 1, 6, 0, 6, 0, 6); The output is Y(*,0) Y(*,1) Y(*,2) Y(*,3) Y(*,4) Y(*,5) Y(0,*) -1.7000 -3.7000 -2.9167 -1.8333 0.0000 0.0000 Y(1,*) -3.7000 -3.7000 -2.9167 -1.8333 0.0000 0.0000 Y(2,*) -2.9167 -2.9167 -2.3333 -1.5000 0.0000 0.0000 Y(3,*) -1.8333 -1.8333 -1.5000 -1.0000 0.0000 0.0000 Y(4,*) 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 Y(5,*) 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 Changing i1x0 to 1 produces the following shift in the output: Y(*,0) Y(*,1) Y(*,2) Y(*,3) Y(*,4) Y(*,5) Y(0,*) -0.8667 -1.8667 -1.4167 -0.8333 0.0000 0.0000 Y(1,*) -1.7000 -3.7000 -2.9167 -1.8333 0.0000 0.0000 Y(2,*) -3.7000 -3.7000 -2.9167 -1.8333 0.0000 0.0000 Y(3,*) -2.9167 -2.9167 -2.3333 -1.5000 0.0000 0.0000 Y(4,*) -1.8333 -1.8333 -1.5000 -1.0000 0.0000 0.0000 Y(5,*) 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 Changing i2h0 to -1 produces the following shift in the output: Y(*,0) Y(*,1) Y(*,2) Y(*,3) Y(*,4) Y(*,5) Y(0,*) -3.7000 -2.9167 -1.8333 0.0000 0.0000 0.0000 Y(1,*) -3.7000 -2.9167 -1.8333 0.0000 0.0000 0.0000 Y(2,*) -2.9167 -2.3333 -1.5000 0.0000 0.0000 0.0000 Y(3,*) -1.8333 -1.5000 -1.0000 0.0000 0.0000 0.0000 Y(4,*) 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 Y(5,*) 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 Changing i1y0 to +1 and i2y0 to -1 produces the following shift in the output: Y(*,0) Y(*,1) Y(*,2) Y(*,3) Y(*,4) Y(*,5) Y(0,*) -1.8667 -3.7000 -3.7000 -2.9167 -1.8333 0.0000 Y(1,*) -1.4167 -2.9167 -2.9167 -2.3333 -1.5000 0.0000 Y(2,*) -0.8333 -1.8333 -1.8333 -1.5000 -1.0000 0.0000 Y(3,*) 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 Y(4,*) 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 Y(5,*) 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 SEE ALSO CCOR1D(3S), CCORM1D(3S), INTRO_FFT(3S), INTRO_SCSL(3S)