help-octave
[Top][All Lists]
Advanced

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

Re: Nonconformant \ behaviour


From: John W. Eaton
Subject: Re: Nonconformant \ behaviour
Date: Mon, 29 Jan 2001 08:40:10 -0600

On 29-Jan-2001, Johan Kullstam <address@hidden> wrote:

| "Richard Gould" <address@hidden> writes:
| 
| > In matlab, the command sequence:
| > 
| > A=[1,2,3,4];
| > b=[1];
| > x=A\b
| > 
| > gives x=[0;0;0;0.2500]
| > 
| > Whilst in octave, this produces the message:
| > 
| > "error: operator \: nonconformant arguments (op1 is 1x4, op2 is 1x1)"
| 
| > Is there a way of working around this apparent discrepency?
| 
| try
| 
| x = pinv(A)*b;
| 
| but this gives
| 
| jk:4> pinv(A)*x
| ans =
| 
|   0.033333
|   0.066667
|   0.100000
|   0.133333
| 
| i am not sure what you expect A\b to do.  it's underdetermined so i
| guess matlab just picks a working solution.  you could just take
| a/some column(s) of A and divide those into b.  this gives you a
| partial x.  fill with zeros to taste.

For the \ and / operators, Octave's docs say

  If the system is not square, or if the coefficient matrix is singular,
  a minimum norm solution is computed.

and it does work except when b is a scalar, so I think this is a bug
and I've checked in a fix to the CVS sources.

It still won't provide the solution that Matlab apparently computes
because Octave's operators use Lapack to compute minimum norm
solutions, and I'm not sure what Matlab is doing.

Here is what I see with the current CVS sources:

  octave:1> a = [1,2,3,4]; b = 1; x = a \ b, a * x
  x =

    0.033333
    0.066667
    0.100000
    0.133333

  ans = 1.00000
  octave:2> norm (x)
  ans = 0.18257

Note that the norm of the solution that Matlab computes is 0.25.

jwe



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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