imagend.pd (PDL-2.081) | : | imagend.pd (PDL-2.082) | ||
---|---|---|---|---|
skipping to change at line 697 | skipping to change at line 697 | |||
### The first argument is a dummy to set $GENERIC. | ### The first argument is a dummy to set $GENERIC. | |||
&PDL::_convolveND_int( $k->flat->index(0), $k, $aa, $x ); | &PDL::_convolveND_int( $k->flat->index(0), $k, $aa, $x ); | |||
} | } | |||
$x; | $x; | |||
} | } | |||
EOD | EOD | |||
Pars=>'k0()', | Pars=>'k0()', | |||
OtherPars=>'SV *k; SV *aa; SV *a;', | OtherPars=>'pdl *k; pdl *aa; pdl *a;', | |||
Code => <<'EOD' | Code => <<'EOD' | |||
/* | /* | |||
* Direct convolution | * Direct convolution | |||
* | * | |||
* Because the kernel is usually the smaller of the two arrays to be convolved, | * Because the kernel is usually the smaller of the two arrays to be convolved, | |||
* we broadcast kernel-first to keep it in the processor's cache. The strategy: | * we broadcast kernel-first to keep it in the processor's cache. The strategy: | |||
* work on a padded copy of the original image, so that (even with boundary | * work on a padded copy of the original image, so that (even with boundary | |||
* conditions) the geometry of the kernel is linearly related to the input | * conditions) the geometry of the kernel is linearly related to the input | |||
* array. Otherwise, follow the path blazed by Karl in convolve(): keep track | * array. Otherwise, follow the path blazed by Karl in convolve(): keep track | |||
* of the offsets for each kernel element in a flattened original PDL. | * of the offsets for each kernel element in a flattened original PDL. | |||
* | * | |||
* The first (PP) argument is a dummy that's only used to set the GENERIC() | * The first (PP) argument is a dummy that's only used to set the GENERIC() | |||
* macro. The other three arguments should all have the same type as the | * macro. The other three arguments should all have the same type as the | |||
* first arguments, and are all passed in as SVs. They are: the kernel, | * first arguments, and are all passed in as SVs. They are: the kernel, | |||
* the padded copy of the input PDL, and a pre-allocated output PDL. The | * the padded copy of the input PDL, and a pre-allocated output PDL. The | |||
* input PDL should be padded by the dimensionality of the kernel. | * input PDL should be padded by the dimensionality of the kernel. | |||
* | * | |||
*/ | */ | |||
short ndims; | ||||
PDL_Indx i,j; | PDL_Indx i,j; | |||
pdl *k = PDL->SvPDLV($COMP(k)); | pdl *k = $COMP(k), *a = $COMP(a), *aa = $COMP(aa); | |||
pdl *a = PDL->SvPDLV($COMP(a)); | ||||
pdl *aa = PDL->SvPDLV($COMP(aa)); | ||||
if(!k || !a || !aa) | ||||
$CROAK("convolveND: Can't convert args to PDLs - should never happen\n"); | ||||
PDL_RETERROR(PDL_err, PDL->make_physical(aa)); | PDL_RETERROR(PDL_err, PDL->make_physical(aa)); | |||
PDL_RETERROR(PDL_err, PDL->make_physical(a)); | PDL_RETERROR(PDL_err, PDL->make_physical(a)); | |||
PDL_RETERROR(PDL_err, PDL->make_physical(k)); | PDL_RETERROR(PDL_err, PDL->make_physical(k)); | |||
ndims = aa->ndims; | PDL_Indx ndims = aa->ndims; | |||
if(ndims != k->ndims || ndims != aa->ndims) | if(ndims != k->ndims || ndims != aa->ndims) | |||
$CROAK("convolveND: dims don't agree - should never happen\n"); | $CROAK("convolveND: dims don't agree - should never happen\n"); | |||
PDL_Indx koffs[k->nvals]; | PDL_Indx koffs[k->nvals]; | |||
$GENERIC() kvals[k->nvals]; | $GENERIC() kvals[k->nvals]; | |||
PDL_Indx ivec[ndims]; | PDL_Indx ivec[ndims]; | |||
/************************************/ | /************************************/ | |||
/* Fill up the koffs & kvals arrays */ | /* Fill up the koffs & kvals arrays */ | |||
/* koffs gets relative offsets into aa for each kernel value; */ | /* koffs gets relative offsets into aa for each kernel value; */ | |||
End of changes. 4 change blocks. | ||||
10 lines changed or deleted | 3 lines changed or added |