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

Alois Schlögl alois.schloegl at tugraz.at
Fri Feb 20 10:14:59 CST 2009


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

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







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

iEYEARECAAYFAkme1vwACgkQzSlbmAlvEIgKjACfdg/TDrjkI/AyGMSDeDMfdGfI
wmoAnRagovzw1Pnl3RaMt4xDqfa7xtUK
=7d7V
-----END PGP SIGNATURE-----


More information about the Bug-octave mailing list