dr___mario
dr___mario

Reputation: 53

is Matlab (R2009b) ignoring the transpose operator in "mldivide"?

I am trying to solve the linear system of equations A'*x = B using Matlab's "mldivide" (the backslash operator) in the form:

x_transp = A'\b; 

A is a square sparse matrix and that is all I know about it. The problem is that the transpose has no effect at all, so the result of the previous line of code is the same than:

x = A\b;

So, x = x_transp. However, either if I use a new variable such that:

A_transp = A';
x_transpOK1 = A_transp\b;

or simply use:

x_transpOK2 = transp(A)\b;

the result is different (x_transpOK1 = x_transpOK2 ≠ x = x_trans). This behavior occurs in Matlab version 7.9.0 (R2009b) but it does not happen in 7.12 (R2011a).

This, however, does not happen with silly examples I have tried (the behavior then is correct). The matrices that make this behavior arise are:

 A =[0.01   -0.495  0   0   0   0   0   0   0   0
        0        1  0   0   0   0   0   0   0   0
        0        0  1   0   0   0   0   0   0   0
        0        0  0   1   0   0   0   0   0   0
        0   -0.495  0   0   1   0   0   0   0   0
        0        0  0   0   0   1   0   0   0   0
        0        0  0   0   0   0   1   0   0   0
        0        0  0   0   0   0   0   1   0   0
        0        0  0   0   0   0   0   0   1   0
        0        0  0   0   0   0   0   0   0   1];

 b =   [8
        4
        0
        0
        0
        0
        0
        0
        0
        0];

Is it some kind of precision issue? Am I making any fundamental error I cannot see?

Upvotes: 3

Views: 146

Answers (2)

dr___mario
dr___mario

Reputation: 53

The guys at Mathworks replied: it is a bug in the interpreter, which have been fixed in the next versions. There is no fix for 7.9.0 and they recommend the following workaround:

A_transp = A';
x = A_transp\b;

I guess this is a great example of the typical advice to always be up-to-date...

My original post on Matlab Answers

The bug report

Upvotes: 2

brechmos
brechmos

Reputation: 1316

After all the discussion, here is my answer:

@Mario_Exec.bat, it seems to me that you might want to take this to the Matlab Answers (mathworks.com/matlabcentral/answers) as maybe someone with knowledge of the actual code (ie a Matlab employee) might be able to help you more specifically. It is an interesting question but it seems there is more going on that might need more knowledge of the actual code and decision trees.

Please do post back here when you hear back. I am curious what they say!

Upvotes: 0

Related Questions