[OctDev] Function mean() fails with a complex matrix

Alois Schlögl alois.schloegl at tugraz.at
Thu Mar 5 02:31:33 CST 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


I was digging in my old files and found the attached version of
sumskipnan for an oct-file. It considers complex numbers, but fails at
line 198, which should combine he real and the imaginary part in one
complex matrix. Has anyone a clue how to do this in the correct way ?

Alois



Alois Schlögl wrote:
> Jaroslav Hajek wrote:
>> On Fri, Feb 20, 2009 at 10:59 AM, Jussi Leinonen <jussi.leinonen at fmi.fi> wrote:
>>> To: bug at octave.org
>>> Cc: jussi.leinonen at fmi.fi
>>> Subject: Function mean() fails with a complex matrix
>>> --------
>>> Bug report for Octave 3.0.1 configured for i486-pc-linux-gnu
>>>
>>> Description:
>>> -----------
>>>
>>> There seems to be a bug (hopefully not a "feature"!) that causes
>>> mean() to fail when given a complex matrix as an argument.
>>>
>>> Repeat-By:
>>> ---------
>>>
>>> octave:43> c = [1 1+i 2-i];
>>> octave:44> mean(c)
>>> error: octave_base_value::array_value(): wrong type argument complex
>>> matrix'
>>> error: sumskipnan: first input argument must be a real matrix
>>> error: evaluating if command near line 72, column 1
>>> error: called from mean' in file
>>> /usr/share/octave/packages/nan-1.0.6/mean.m'
>>>
>>> Fix:
>>> ---
>>>
>>> Apparently the problem is in the function sumskipnan(), which should
>>> be edited to support complex numbers (it is not documented that it
>>> does not), or alternatively, mean() could be implemented differently.
>>>
>> Hi,
>> bug reports for OctaveForge packages should be reported to its mailing list
>> <octave-dev at lists.sourceforge.net>.
> 
>> The NaN-aware mean is relatively easy to simulate:
>> mask = isnan (x);
>> x(mask) = 0;
>> m = sum(x) ./ sum (! mask);
> 
>> regards
> 
> 
> 
> You are using sumskipnan.oct. Unfortunately, the sumskipnan.oct does not
> yet support complex numbers.
> 
> I suggest using sumskipnan.mex or sumskipnan.m.
> 
> When you delete sumskipnan.oct, everything should work fine again.
> If the performance penalty is too bad, use sumskipnan.mex.
> 	mkoctfile -mex sumskipnan.cpp
> 
> 
> 
> regards,
>    Alois
> 
> 
> 
> 
> 
> 
> 

-
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
- -OSBC tackles the biggest issue in open source: Open Sourcing the
Enterprise
- -Strategies to boost innovation and cut costs with open source
participation
- -Receive a $600 discount off the registration fee with the source
code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Octave-dev mailing list
Octave-dev at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/octave-dev

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkmvjeAACgkQzSlbmAlvEIjAPACeO7O52UO/A6YuKdrdIto5ZWrO
nkgAoJbMY8v/2FJHnVw9lFyUQ4AU3PK1
=ej/C
-----END PGP SIGNATURE-----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sumskipnan.cc
Type: text/x-c++src
Size: 5268 bytes
Desc: not available
Url : https://www-old.cae.wisc.edu/pipermail/bug-octave/attachments/20090305/bf589686/attachment.bin 


More information about the Bug-octave mailing list