[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #39314] convn(x, y, "valid") produces results
From: |
Marco cecchetti |
Subject: |
[Octave-bug-tracker] [bug #39314] convn(x, y, "valid") produces results that are different from Matlab |
Date: |
Mon, 12 Aug 2013 22:25:56 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0 |
Follow-up Comment #5, bug #39314 (project octave):
Indeed the problem can be reproduced with integer values too and is present
only for arrays with more than 2 dimensions. The bug is inside the convolve_nd
function (liboctave/numeric/oct-convn.cc) and exactly inside the following
loops:
for (octave_idx_type ja = 0; ja < na - nb + 1; ja++)
for (octave_idx_type jb = 0; jb < nb; jb++)
convolve_nd<T, R> (a + ma*(ja + jb), ad, acd, b + mb*jb, bd, bcd,
c + ldc*ja, ccd, nd-1, inner);
The 'b + mb*jb' argument should be 'b + mb*(nb-jb-1)' in fact convolution is
always a sum of products of this type: a(u1, u2, u3) * b(x1-u1, x2-u2,
x3-u3).
The following octave example is straightforward:
octave:1> v = [1,2]
v =
1 2
octave:2> vvv = reshape(v,1,1,2)
vvv =
ans(:,:,1) = 1
ans(:,:,2) = 2
octave:3> convn(vvv, vvv, 'valid')
ans = 5
octave:4> convn(vvv, vvv)
ans =
ans(:,:,1) = 1
ans(:,:,2) = 4
ans(:,:,3) = 4
The correct result for convn(vvv, vvv, 'valid') should be vvvv(1,1,2) that is
4 instead we get the same result as we computed dot(v, v).
I attached a patch with the correct implementation. I tested it with the zzz
and hhh as input and it works fine.
(file #28829)
_______________________________________________________
Additional Item Attachment:
File name: convn.diff Size:1 KB
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?39314>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Octave-bug-tracker] [bug #39314] convn(x, y, "valid") produces results that are different from Matlab,
Marco cecchetti <=