changeset 11865:78cf5edb69ce release-3-0-x

deconv.m: Fix row/col orientation & length of output
author Ben Abbott <bpabbott@mac.com>
date Fri, 03 Oct 2008 14:56:33 +0200
parents 9780ca97156e
children 01cad2a83492
files scripts/ChangeLog scripts/polynomial/deconv.m
diffstat 2 files changed, 17 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,5 +1,7 @@
 2008-09-29  Ben Abbott <bpabbott@mac.com>
 
+	* polynomial/deconv.m: Fix row/col orientation & length of output.
+
 	* polynomial/conv.m: Correct row/col orientation of output.
 
 2008-09-24  John W. Eaton  <jwe@octave.org>
--- a/scripts/polynomial/deconv.m
+++ b/scripts/polynomial/deconv.m
@@ -49,6 +49,11 @@
 
   lb = ly - la + 1;
 
+  ## Ensure A is oriented as Y.
+  if (diff (size (y)(1:2)) * diff (size (a)(1:2)) < 0)
+    a = permute (a, [2, 1]);
+  endif
+
   if (ly > la)
     b = filter (y, a, [1, (zeros (1, ly - la))]);
   elseif (ly == la)
@@ -61,7 +66,16 @@
   if (ly == lc)
     r = y - conv (a, b);
   else
-    r = [(zeros (1, lc - ly)), y] - conv (a, b);
+    ## Respect the orientation of Y"
+    if (size (y, 1) <= size (y, 2))
+      r = [(zeros (1, lc - ly)), y] - conv (a, b);
+    else
+      r = [(zeros (lc - ly, 1)); y] - conv (a, b);
+    endif
+    if (ly < la)
+      ## Trim the remainder is equal to the length of Y.
+      r = r(end-(length(y)-1):end);
+    endif
   endif
 
 endfunction