octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Behavior of mldivide in Octave relative to Matlab


From: Marco Caliari
Subject: Re: Behavior of mldivide in Octave relative to Matlab
Date: Wed, 09 Apr 2008 09:18:54 +0200 (CEST)

 Only a final note: the case m=50 and n=20000 works in Matlab's A\b whereas
it fails in Matlab's [Q,R,E]=qr(A) (same problem of exhaustion of the memory
as in Octave).

I think you can do `[Q,R,E] = qr (A,0)' instead, to get E as
permutation vector rather than matrix.

To summarize: in order to imitate the Matlab's behaviour of A\b, you can do

[Q,R,E] = qr(A,0);
x = (R(:,1:m)\(Q'*b));
x(n) = 0;
x(E) = x;

Thanks for the hint, Jaroslav. Corcerning the underdetermined case, I'm completely satisfied now (yes, David, I have a code depending on sparse solutions of underdetermined systems), because I can reproduce Matlab with the four clear lines above.
Concerning near-singular matrices, for the script

for i = 12:16
  A = [10^(-i), 0, -10^(-i); 0, 10^(-i), -10^(-i); -10^(-i), 0, 10];
  b = ones(3,1);
  x = A \ b;
  norm(A*x-b)
end

I prefer Matlab's result. So, I would appreciate a different function or an optional argument for mldivide. Not sure what should be the default behaviour.

Best regards,

Marco


reply via email to

[Prev in Thread] Current Thread [Next in Thread]