Mercurial > hg > octave-lojdl
changeset 14596:ad1d7a53b1ca stable
perform convolution properly independently of matrix orientation (bug #34893)
* cconv2.f (cconv2i), csconv2.f (csconv2i), dconv2.f (dconv2i),
sconv2.f (sconv2i), zconv2.f (zconv2i), zdconv2.f (zdconv2i): Fix
iteration over the a matrix, so it's properly reversed.
* conv2.cc: Uncomment test to check for this, and add a new xtest.
author | Sunghyun Cho <sodomau@gmail.com> |
---|---|
date | Tue, 17 Apr 2012 12:47:34 +0100 |
parents | 6250e1232c9c |
children | 6980b0f35df9 |
files | libcruft/blas-xtra/cconv2.f libcruft/blas-xtra/csconv2.f libcruft/blas-xtra/dconv2.f libcruft/blas-xtra/sconv2.f libcruft/blas-xtra/zconv2.f libcruft/blas-xtra/zdconv2.f src/DLD-FUNCTIONS/conv2.cc |
diffstat | 7 files changed, 16 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/libcruft/blas-xtra/cconv2.f +++ b/libcruft/blas-xtra/cconv2.f @@ -70,7 +70,7 @@ do k = 1,na-nb+1 do j = 1,nb do i = 1,mb - call caxpy(ma-mb+1,b(i,j),a(mb+1-i,k+j-1),1,c(1,k),1) + call caxpy(ma-mb+1,b(i,j),a(mb+1-i,k+nb-j),1,c(1,k),1) end do end do end do
--- a/libcruft/blas-xtra/csconv2.f +++ b/libcruft/blas-xtra/csconv2.f @@ -76,7 +76,7 @@ do j = 1,nb do i = 1,mb btmp = b(i,j) - call caxpy(ma-mb+1,btmp,a(mb+1-i,k+j-1),1,c(1,k),1) + call caxpy(ma-mb+1,btmp,a(mb+1-i,k+nb-j),1,c(1,k),1) end do end do end do
--- a/libcruft/blas-xtra/dconv2.f +++ b/libcruft/blas-xtra/dconv2.f @@ -70,7 +70,7 @@ do k = 1,na-nb+1 do j = 1,nb do i = 1,mb - call daxpy(ma-mb+1,b(i,j),a(mb+1-i,k+j-1),1,c(1,k),1) + call daxpy(ma-mb+1,b(i,j),a(mb+1-i,k+nb-j),1,c(1,k),1) end do end do end do
--- a/libcruft/blas-xtra/sconv2.f +++ b/libcruft/blas-xtra/sconv2.f @@ -70,7 +70,7 @@ do k = 1,na-nb+1 do j = 1,nb do i = 1,mb - call saxpy(ma-mb+1,b(i,j),a(mb+1-i,k+j-1),1,c(1,k),1) + call saxpy(ma-mb+1,b(i,j),a(mb+1-i,k+nb-j),1,c(1,k),1) end do end do end do
--- a/libcruft/blas-xtra/zconv2.f +++ b/libcruft/blas-xtra/zconv2.f @@ -70,7 +70,7 @@ do k = 1,na-nb+1 do j = 1,nb do i = 1,mb - call zaxpy(ma-mb+1,b(i,j),a(mb+1-i,k+j-1),1,c(1,k),1) + call zaxpy(ma-mb+1,b(i,j),a(mb+1-i,k+nb-j),1,c(1,k),1) end do end do end do
--- a/libcruft/blas-xtra/zdconv2.f +++ b/libcruft/blas-xtra/zdconv2.f @@ -76,7 +76,7 @@ do j = 1,nb do i = 1,mb btmp = b(i,j) - call zaxpy(ma-mb+1,btmp,a(mb+1-i,k+j-1),1,c(1,k),1) + call zaxpy(ma-mb+1,btmp,a(mb+1-i,k+nb-j),1,c(1,k),1) end do end do end do
--- a/src/DLD-FUNCTIONS/conv2.cc +++ b/src/DLD-FUNCTIONS/conv2.cc @@ -262,9 +262,18 @@ %% Test cases from Bug #34893 %!assert (conv2 ([1:5;1:5], [1:2], 'same'), [4 7 10 13 10; 4 7 10 13 10]) %!assert (conv2 ([1:5;1:5]', [1:2]', 'same'), [4 7 10 13 10; 4 7 10 13 10]') -%!#assert (conv2 ([1:5;1:5], [1:2], 'valid'), [4 7 10 13; 4 7 10 13]) +%!assert (conv2 ([1:5;1:5], [1:2], 'valid'), [4 7 10 13; 4 7 10 13]) %!assert (conv2 ([1:5;1:5]', [1:2]', 'valid'), [4 7 10 13; 4 7 10 13]') +%!xtest +%! rand ("seed", 42); +%! x = rand (100); +%! y = ones (5); +%! A = conv2 (x, y)(5:end-4,5:end-4); +%! B = conv2 (x, y, "valid"); +%! assert (B, A); ## Yes, this test is for *exact* equivalence. + + %% Test input validation %!error conv2 () %!error conv2 (1)