qp() in Octave 3.0.0 returns result egregiously violating input constraints

Dmitri A. Sergatskov dasergatskov at gmail.com
Sun Apr 6 16:45:31 CDT 2008


On Sun, Apr 6, 2008 at 3:21 PM, Ben Abbott <bpabbott at mac.com> wrote:
>
>  On Apr 6, 2008, at 3:55 PM, Dmitri A. Sergatskov wrote:
>
> > This is somewhat off topic.
> >
> > Looking at qp.m I see on line 205:
> >
> > xbar = pinv (A) * b;
> >
> > Should not it be:
> >
> >  xbar = A \ b;
> >
> > ?
> >
>
>
>  Dimigtri,
>
>  I recall we had modified polyfit.m to us qr instead of leftdivide. This was
> done to improve the stability of the solution.
>
>  Here's the thread below.
>
>         http://www.nabble.com/Polyfit-with-scaling-tc15191415.html#a15246667
>
>  The patch to polyfit contained
>
>  -  p = X \ y;
>  +  ## Solve by QR decomposition.
>  +  [q, r, k] = qr (v, 0);
>  +  p = r \ (y' * q)';
>  +  p(k) = p;
>
>  Should a similar approach be made here?
>
>  Ben
>

I am not really an expert here and cannot tell when QR is
preferable  to SVD. In the case of polyfit we switched to
QR mostly because it is what Matlab uses there.
I think SVD is more generic and robust, but QR may
be more accurate. QR is also more expensive computationally
(in case it matters) than SVD.
In any case  I think either of them is better
than calculating inverse matrix explicitly.

Sincerely,

Dmitri.

p.s. Perhaps we should switch this discussion to help-octave list.
--


More information about the Help-octave mailing list