[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Nonconformant \ behaviour
From: |
Richard Gould |
Subject: |
Re: Nonconformant \ behaviour |
Date: |
Tue, 30 Jan 2001 08:02:45 +1100 |
> | 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.
Using this appears to give me the same answers as matlab for the overall
problem (if it helps, I'm trying to port the QP module from mathwork's
optimisation package - the code in question appears in the eqsolv function
at the end of qpsub.m).
Matlab's help gives the following description of the behaviour of \ - this
seems to explain why pinv(A)*b doesn't give the same behaviour:
Backslash or left matrix divide.
A\B is the matrix division of A into B, which is roughly the
same as INV(A)*B , except it is computed in a different way.
If A is an N-by-N matrix and B is a column vector with N
components, or a matrix with several such columns, then
X = A\B is the solution to the equation A*X = B computed by
Gaussian elimination. A warning message is printed if A is
badly scaled or nearly singular. A\EYE(SIZE(A)) produces the
inverse of A.
If A is an M-by-N matrix with M < or > N and B is a column
vector with M components, or a matrix with several such columns,
then X = A\B is the solution in the least squares sense to the
under- or overdetermined system of equations A*X = B. The
effective rank, K, of A is determined from the QR decomposition
with pivoting. A solution X is computed which has at most K
nonzero components per column. If K < N this will usually not
be the same solution as PINV(A)*B. A\EYE(SIZE(A)) produces a
generalized inverse of A.
C = MLDIVIDE(A,B) is called for the syntax 'A \ B' when A or B is an
object.
Unfortunately, linear algebra has never really been my strong point, but I
need a QP package for some financial maths work I'm doing. I've ordered the
cFSQP package, but need a quick and dirty temp solution till I get that
working.
Thanks,
Richard Gould
-------------------------------------------------------------
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
-------------------------------------------------------------
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: Nonconformant \ behaviour,
Richard Gould <=