The LAPACK forum has moved to https://github.com/Reference-LAPACK/lapack/discussions.

pseudo inverse in Lapack

Open discussion regarding features, bugs, issues, vendors, etc.

pseudo inverse in Lapack

Postby yildirim » Wed Feb 27, 2008 11:29 am

Hi,

I have used SVD to compute pseudo inverse of a rectangular matrix as discussed in this forum. I have done little experiment in Lapack, but I couldn't get exactly what I want,

I am trying to solve following system,
V u = f

I will solve first, u = pinv(V), then recover f as f = V u,

To visualize, please see my matlab code :
clear all
V =[ 1 -1 1 -1 1 1
1 0.0651531 -0.579796 -0.644949 -0.5 0.415959
1 1.53485 1.3798 -0.155051 -0.5 0.0240408
1 -1 1 -0.447214 0.447214 -0.2
1 0.0651531 -0.579796 -0.28843 -0.223607 -0.0831918
1 1.53485 1.3798 -0.0693409 -0.223607 -0.00480816
1 -1 1 0.447214 -0.447214 -0.2
1 0.0651531 -0.579796 0.28843 0.223607 -0.0831918
1 1.53485 1.3798 0.0693409 0.223607 -0.00480816
1 -1 1 1 -1 1
1 0.0651531 -0.579796 0.644949 0.5 0.415959
1 1.53485 1.3798 0.155051 0.5 0.0240408 ]


Vinv = pinv(V);

f =[ 0.80375112917301
0.50818321639763
-0.030517040087646
0.58089326419039
0.31854856707026
-0.066814632719454
0.099613879035112
-0.014996285372342
-0.12512949591686
-0.22126017860302
-0.22281387674623
-0.16076260135218]

u = Vinv *f;
f_recover = V *u


And output as follows,
f =
0.803751129173010
0.508183216397630
-0.030517040087646
0.580893264190390
0.318548567070260
-0.066814632719454
0.099613879035112
-0.014996285372342
-0.125129495916860
-0.221260178603020
-0.222813876746230
-0.160762601352180

f_recover =
0.815348387131710
0.490392551244791
-0.006358760301715
0.571720821088822
0.314234043583125
-0.055021575747082
0.104752488657256
-0.001065783508337
-0.135509092032703
-0.228823603082296
-0.214639189970262
-0.186334341994639

why do I get this difference for this matrix V? if I use random matrix, I recover "f" perfectly

thanks,
yildirim
 
Posts: 3
Joined: Thu Jun 28, 2007 2:09 pm

Postby Julien Langou » Wed Feb 27, 2008 5:20 pm

Hello,
  1. I am not exactly sure what you want to do, you have a 12-by-6 linear
    system of equations V, a right-hand side of f of size 12 and you are looking
    for a solution u of size 6. Since there are more equations than unknowns,
    your system is overdetermined. It might have a unique solution or might not
    have any solutions at all or might have an infinite number of solutions.
    If you expect to find u such that Vu=f then your overdetermined linear
    system of equations is called consistent. In the case, you just posted
    V is not consistent with f, there is no u such that Vu = f (because V and f are
    linearly independent).
  2. when you are computing u, you would be better off by doing
    u = V \ f; rather than u = pinv(V)*f;
  3. if you take a random SQUARE matrix V say (12-by-12) then the linear
    system will probably be consistent and so, yes, Vu=f. If you take a
    random 12-by-6 matrix then the matrix V will probably be inconsitent.
    (Your case.)

Julien.
Julien Langou
 
Posts: 835
Joined: Thu Dec 09, 2004 12:32 pm
Location: Denver, CO, USA


Return to User Discussion

Who is online

Users browsing this forum: No registered users and 4 guests