diff options
Diffstat (limited to 'sys/vops/ak/acnvs.x')
-rw-r--r-- | sys/vops/ak/acnvs.x | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/sys/vops/ak/acnvs.x b/sys/vops/ak/acnvs.x new file mode 100644 index 00000000..9a11eda9 --- /dev/null +++ b/sys/vops/ak/acnvs.x @@ -0,0 +1,54 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +# ACNV -- Vector convolution. The output vector is equal to the sum of its +# initial value and the convolution of the input vector with the kernel. +# This routine assumes boundary extension on the input vector has been provided. +# For short kernels, we unroll the inner do loop into a single statement to +# reduce loop overhead. +# +# Example: npix=10, kpix=5, 2 pixels out of bounds on either end. +# in[1] corresponds to x = -1 +# +# -1 0 1 2 3 4 5 6 7 8 9 10 11 12 (x coord) +# 1 2 3 4 5 +# 1 2 3 4 5 +# ... +# 1 2 3 4 5 + +procedure acnvs (in, out, npix, kernel, knpix) + +short in[npix+knpix-1] # input vector, including boundary pixels +short out[ARB] # output vector +int npix # length of output vector +short kernel[knpix] # convolution kernel +int knpix # size of convolution kernel + +int i, j +short sum, k1, k2, k3, k4, k5 + +begin + switch (knpix) { + case 3: + k1 = kernel[1] + k2 = kernel[2] + k3 = kernel[3] + do i = 1, npix + out[i] = out[i] + k1 * in[i] + k2 * in[i+1] + k3 * in[i+2] + case 5: + k1 = kernel[1] + k2 = kernel[2] + k3 = kernel[3] + k4 = kernel[4] + k5 = kernel[5] + do i = 1, npix + out[i] = out[i] + k1 * in[i] + k2 * in[i+1] + k3 * in[i+2] + + k4 * in[i+3] + k5 * in[i+4] + default: + do i = 1, npix { + sum = out[i] + do j = 1, knpix + sum = sum + (kernel[j] * in[i+j-1]) + out[i] = sum + } + } +end |