Dear octave-forge developers,
the attached patch fixes qamdemod(). Its purpose is to provide a
nearest-neighbour quantizer against a pre-defined set of points (called
QAM signal space constellations).
What was wrong:
* Returned an output vector, even if the input was a matrix or
multi-dimensional array
* The output vector was never pre-allocated
* Only the first length(input) elements were processed, instead of
processing all of them [i.e. numel(input)]
Applied fixes:
* pre-allocate output variable that has the same size as the input
* change the loop boundaries to 1:numel(input)
* when subtracting the same scalar from all elements, use a vectorized
version
It still features a loop which is not pre-compiled
for k = 1:numel(y)
[n z(k)] = min(abs(y(k) - x))
end
but the only way that this could be vectorized is by converting the
input data to a vector, processing it and converting it back to a
matrix/multi-dimensional array again with something like
a=y(:);
b=min(abs(repmat(a,[1 m]) - x))
z=reshape(x,size(y);
and I am not sure whether this is wise from a speed and memory usage
POV. Maybe this nearest-neighbour quantization loop could/should be
moved into a builtin function?
best regards,
Christian Neumair
--
Christian Neumair <cneum...@gnome.org>
--- /usr/share/octave/packages/communications-1.0.6/qamdemod.m 2009-07-16 17:07:46.000000000 +0200
+++ qamdemod.m 2009-07-16 17:06:41.000000000 +0200
@@ -1,4 +1,5 @@
## Copyright (C) 2007 Sylvain Pelissier <sylvain.peliss...@gmail.com>
+## 2009 Christian Neumair <cneum...@gnome.org>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
@@ -33,7 +34,9 @@ function z = qamdemod(y,m)
x = qammod(0:(m-1),m);
x = reshape(x,1,m);
- for k = 1:length(y)
+
+ z = zeros(size(y));
+ for k = 1:numel(y)
[n z(k)] = min(abs(y(k) - x));
- z(k) = z(k) - 1;
end
+ z = z - 1;
------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Octave-dev mailing list
Octave-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/octave-dev