next | previous | forward | backward | up | top | index | toc | Macaulay2 website
SVDComplexes :: pseudoInverse

pseudoInverse -- compute the pseudoInverse of a chainComplex

Synopsis

Description

In case the field is RR we use the SVD normal form to compute the pseudo inverse. In case of QQ we compute the pseudo inverse directly over QQ.

i1 : needsPackage "RandomComplexes"

o1 = RandomComplexes

o1 : Package
i2 : setRandomSeed "a pretty good example";
i3 : h={2,3,1}

o3 = {2, 3, 1}

o3 : List
i4 : r={2,3}

o4 = {2, 3}

o4 : List
i5 : C=randomChainComplex(h,r,Height=>11,ZeroMean=>true)

       4       8       4
o5 = ZZ  <-- ZZ  <-- ZZ
                      
     0       1       2

o5 : ChainComplex
i6 : C.dd

           4                                          8
o6 = 0 : ZZ  <------------------------------------- ZZ  : 1
                | -4 -18 -6 -14 -10 -18 -16 -28 |
                | 8  16  22 -12 -20 -14 -8  6   |
                | 6  15  15 -3  -9  -3  0   12  |
                | 2  7   4  3   1   4   4   9   |

           8                            4
     1 : ZZ  <----------------------- ZZ  : 2
                | -5  22  19  -41 |
                | -54 26  55  -66 |
                | 31  -26 -29 25  |
                | 33  50  -23 36  |
                | -20 -16 24  -47 |
                | 2   -22 -1  -10 |
                | -12 -6  3   9   |
                | 25  -16 -30 43  |

o6 : ChainComplexMap
i7 : CQ=C**QQ

       4       8       4
o7 = QQ  <-- QQ  <-- QQ
                      
     0       1       2

o7 : ChainComplex
i8 : CR=C**RR_53

         4         8         4
o8 = RR    <-- RR    <-- RR
       53        53        53
                          
     0         1         2

o8 : ChainComplex
i9 : CRplus = pseudoInverse CR

         4         8         4
o9 = RR    <-- RR    <-- RR
       53        53        53
                          
     -2        -1        0

o9 : ChainComplex
i10 : CQplus = pseudoInverse CQ

        4       8       4
o10 = QQ  <-- QQ  <-- QQ  <-- 0
                               
      -2      -1      0       1

o10 : ChainComplex
i11 : CRplus.dd

               4                                                                                                        8
o11 = -2 : RR    <------------------------------------------------------------------------------------------------- RR    : -1
             53     | .0130658   -.00710013 .00910891  .00617097   .00616535  .00510154  -.0108838  -.00160172  |     53
                    | .00363228  .00323956  -.00408194 .0104004    -.00386761 -.00421635 -.00125529 -.00211786  |
                    | -.00265724 .00380405  -.00358933 -.0016806   -.00115101 -.00166389 .00291106  -.000639162 |
                    | -.0129721  .00195488  -.00650979 -.000997146 -.00888455 -.0055727  .0094004   .00387383   |

               8                                                          4
      -1 : RR    <--------------------------------------------------- RR    : 0
             53     | -.00131432 .00348016  .0024824   .000742313 |     53
                    | -.00687747 .00658955  .00601697  .0027222   |
                    | -.00148997 .00975584  .0063005   .00142258  |
                    | -.00652617 -.0059618  -.00161923 .00136167  |
                    | -.00521185 -.00944196 -.00410162 .000619358 |
                    | -.008322   -.00701722 -.00171373 .00179488  |
                    | -.00718333 -.00422171 -.00037803 .00173283  |
                    | -.0116078  .00168319  .00449225  .00365066  |

o11 : ChainComplexMap
i12 : CQplus.dd

             4                                                                                                                                                                                              8
o12 = -2 : QQ  <----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- QQ  : -1
                  | 22455062/1718617773  -305060062/42965444325 391368268/42965444325  88379471/14321814775  264897193/42965444325  219189842/42965444325  -467627593/42965444325 -2219954/1385982075 |
                  | 2080832/572872591    46396386/14321814775   -58460804/14321814775  148952386/14321814775 -55391154/14321814775  -60385726/14321814775  -17977996/14321814775  -978438/461994025   |
                  | -1522260/572872591   54480883/14321814775   -51405662/14321814775  -24069267/14321814775 -16484537/14321814775  -23829853/14321814775  41691712/14321814775   -295289/461994025   |
                  | -22294079/1718617773 83992087/42965444325   -279696193/42965444325 -14280946/14321814775 -381728443/42965444325 -239433617/42965444325 403892368/42965444325  5369054/1385982075  |

             8                                                                     4
      -1 : QQ  <---------------------------------------------------------------- QQ  : 0
                  | -6884/5237683  18228/5237683  1182/476153  3888/5237683  |
                  | -36022/5237683 34514/5237683  2865/476153  14258/5237683 |
                  | -7804/5237683  51098/5237683  3000/476153  7451/5237683  |
                  | -34182/5237683 -31226/5237683 -771/476153  7132/5237683  |
                  | -27298/5237683 -49454/5237683 -1953/476153 3244/5237683  |
                  | -2564/308099   -2162/308099   -48/28009    553/308099    |
                  | -37624/5237683 -22112/5237683 -180/476153  9076/5237683  |
                  | -60798/5237683 8816/5237683   2139/476153  19121/5237683 |

            4
      0 : QQ  <----- 0 : 1
                 0

o12 : ChainComplexMap
i13 : (CQplus**RR_53).dd

               4                                                                                                        8
o13 = -2 : RR    <------------------------------------------------------------------------------------------------- RR    : -1
             53     | .0130658   -.00710013 .00910891  .00617097   .00616535  .00510154  -.0108838  -.00160172  |     53
                    | .00363228  .00323956  -.00408194 .0104004    -.00386761 -.00421635 -.00125529 -.00211786  |
                    | -.00265724 .00380405  -.00358933 -.0016806   -.00115101 -.00166389 .00291106  -.000639162 |
                    | -.0129721  .00195488  -.00650979 -.000997146 -.00888455 -.0055727  .0094004   .00387383   |

               8                                                          4
      -1 : RR    <--------------------------------------------------- RR    : 0
             53     | -.00131432 .00348016  .0024824   .000742313 |     53
                    | -.00687747 .00658955  .00601697  .0027222   |
                    | -.00148997 .00975584  .0063005   .00142258  |
                    | -.00652617 -.0059618  -.00161923 .00136167  |
                    | -.00521185 -.00944196 -.00410162 .000619358 |
                    | -.008322   -.00701722 -.00171373 .00179488  |
                    | -.00718333 -.00422171 -.00037803 .00173283  |
                    | -.0116078  .00168319  .00449225  .00365066  |

              4
      0 : RR    <----- 0 : 1
            53     0

o13 : ChainComplexMap
i14 : CRplus.dd^2

               4                                                                 4
o14 = -2 : RR    <---------------------------------------------------------- RR    : 0
             53     | -1.69407e-20 -4.74338e-20 -2.71051e-20 5.0822e-21  |     53
                    | -3.38813e-20 2.87991e-20  2.87991e-20  1.43996e-20 |
                    | 0            2.20229e-20  1.35525e-20  2.5411e-21  |
                    | 2.71051e-20  4.06576e-20  1.35525e-20  -5.0822e-21 |

o14 : ChainComplexMap
i15 : CQplus.dd^2

             4          4
o15 = -2 : QQ  <----- QQ  : 0
                  0

             8
      -1 : QQ  <----- 0 : 1
                  0

o15 : ChainComplexMap

Pseudo inverses frequently exist also over finite fields.

i16 : Fp=ZZ/nextPrime 10^3

o16 = Fp

o16 : QuotientRing
i17 : Cp=C**Fp

        4       8       4
o17 = Fp  <-- Fp  <-- Fp
                       
      0       1       2

o17 : ChainComplex
i18 : Cpplus=pseudoInverse Cp

        4       8       4
o18 = Fp  <-- Fp  <-- Fp  <-- 0
                               
      -2      -1      0       1

o18 : ChainComplex
i19 : Cpplus.dd

             4                                                   8
o19 = -2 : Fp  <---------------------------------------------- Fp  : -1
                  | -503 196  106  -420 -383 278  -1  308  |
                  | -447 -399 -485 370  -440 -273 157 266  |
                  | -56  -279 92   145  65   351  358 -70  |
                  | 166  39   -496 -313 -356 126  276 -330 |

             8                                4
      -1 : Fp  <--------------------------- Fp  : 0
                  | -33  -170 -193 -108 |
                  | 384  -230 -455 -340 |
                  | 441  -18  -244 -235 |
                  | 445  475  -353 -86  |
                  | 478  -364 -160 22   |
                  | 426  68   -87  -121 |
                  | -76  390  55   -140 |
                  | -161 -357 -65  -391 |

            4
      0 : Fp  <----- 0 : 1
                 0

o19 : ChainComplexMap
i20 : Cpplus.dd^2

             4          4
o20 = -2 : Fp  <----- Fp  : 0
                  0

             8
      -1 : Fp  <----- 0 : 1
                  0

o20 : ChainComplexMap
i21 : arePseudoInverses(Cp,Cpplus)

o21 = true

Caveat

Over finite fields the algorithm can fail.

See also

Ways to use pseudoInverse :

For the programmer

The object pseudoInverse is a method function with options.