Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

NaN after matrix multiplication

731 views
Skip to first unread message

Grumblz

unread,
Apr 28, 2005, 12:16:30 PM4/28/05
to
L.S.
I am running Matlab 7SP1 in Linux fairly happily, but sometimes I
encounter something strange: NaN entries in a matrix after
complex-matrix multiplications. Since robust control is part of my
PhD project, the first couple of encounters I had were when I ran the
mu command. However, when I multiplied two complex matrices in the
workspace a couplle of times in succession, I got the result shown
below.
Can anyone tell me what is going on? And more importantly: how do I
get rid of this behaviour?

Sincerely,

Grumblz

>> isnan(tmp1*tmp1')

ans =

0 0 0 0 0 0 0 0 0 0 0 0
0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0

>> isnan(tmp1*tmp1')

ans =

0 0 0 0 0 0 0 0 0 0 0 0
0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 1
0 0 0 0 0 0 0 0 0 0 0 0
0 1 0
0 0 0 0 0 0 0 0 0 0 0 0
1 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0
0 0 0 0 0 0 0 0 0 0 1 0
0 0 0
0 0 0 0 0 0 0 0 0 1 0 0
0 0 0
0 0 0 0 0 0 0 0 1 0 0 0
0 0 0

Bobby Cheng

unread,
Apr 28, 2005, 12:43:32 PM4/28/05
to
Can you post the matrix here or to me so that I can investigate it further?
---Bobby Cheng
Numerical Analyst
The MathWorks, Inc.


"Grumblz" <nor...@noreply.no> wrote in message
news:ef046...@webx.raydaftYaTP...

Peter Perkins

unread,
Apr 28, 2005, 1:18:30 PM4/28/05
to
Grumblz wrote:

> I am running Matlab 7SP1 in Linux fairly happily, but sometimes I
> encounter something strange: NaN entries in a matrix after
> complex-matrix multiplications.

Do you have Infs in your data?

Grumblz

unread,
Apr 29, 2005, 9:43:05 AM4/29/05
to

I have no strange entries in my matrices, it is just a normal complex
matrix.

Grumblz

unread,
Apr 29, 2005, 10:08:40 AM4/29/05
to
The matrix I used can be found in the mat-file which is located at
<http://130.161.167.171/nan_mat.mat>
The tmp1 is the original matrix (see my previous post) and tmp2 is
one of the faulty results I got from the multiplication.

Thanx for any help,

Grumblz

Bobby Cheng

unread,
Apr 29, 2005, 10:54:19 AM4/29/05
to
Should have ask for this info before.

what is your processor?Or what does "cat /proc/cpuinfo" give you?

---Bob.


"Grumblz" <nor...@noreply.no> wrote in message

news:ef04...@webx.raydaftYaTP...

Grumblz

unread,
May 2, 2005, 3:56:03 AM5/2/05
to
"cat /proc/cpuinfo" gives:
processor : 0
vendor_id : GenuineIntel
cpu family : 15
model : 2
model name : Intel(R) Pentium(R) 4 CPU 2.40GHz
stepping : 4
cpu MHz : 2423.889
cache size : 512 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 2
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr
pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm
bogomips : 4836.55

I'm running FC 1 (2.4.22-1.2199.nptl). Does this give the problem
away?

Grumblz

Jan Simon

unread,
May 2, 2005, 7:35:04 AM5/2/05
to
Dear Grumblz!
I had comparable troubles and found out, that the numerical part of the processor lost it's stability. Test this for example with exhaustive calculations in C or another Matlab version, rotate images in PhotoShop and other tedious tasks.

There was not help but extensive cooling or buying a new processor.

Good luck, Jan Simon

Bobby Cheng

unread,
May 2, 2005, 8:43:55 AM5/2/05
to
Not really. I have put all the info into a bug report.
Meanwhile you can override the default BLAS by following the instruction in

http://www.mathworks.com/support/solutions/data/1-18QUC.html?solution=1-18QUC

Try using atlas_P4.so

Grumblz

unread,
May 3, 2005, 7:24:34 AM5/3/05
to
Thanx, I did that and so far I have not seen any NaN's fly by. I'll
post again if they somehow do re-appear.

Cheers,

Grumblz

Daniel

unread,
Jul 4, 2005, 2:43:53 PM7/4/05
to
Have there been any progress in solving this problem. I encountered
exact the same problem, but the workaround using atlas_P4.so did not
work. Using there have been less NaN, but in really large complex
matrices i found them again....
I'm grateful fir every suggestion, can't to my thesis with such a
bug.

greets

daniel

>>http://www.mathworks.com/support/solutions/data/1-18QUC.html?solution=1-18QUC <http://www.mathworks.com/support/solutions/data/1-18QUC.html?solution=1-18QUC>
>>
>> Try using atlas_P4.so

Archit

unread,
Aug 22, 2012, 6:41:05 PM8/22/12
to
Daniel <para...@web.de> wrote in message <ef04...@webx.raydaftYaTP>...
Check both your matrices for NaN values.
If you even have 1 NaN in either of your matrix,it pollutes the whole resulting matrix.
replace the NaN values with zeros using
A(isnan(A)) = 0 ;
0 new messages