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

projectToComplex -- compute a nearby complex with the projection method

Synopsis

Description

Using the iterated projection method we compute a nearby chainComplex C with homology h.

i1 : needsPackage "RandomComplexes"

o1 = RandomComplexes

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

o3 = {2, 3, 5, 2}

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

o4 = {4, 3, 3}

o4 : List
i5 : elapsedTime C=randomChainComplex(h,r,Height=>5,ZeroMean=>true)
 -- 0.00164096 seconds elapsed

       6       10       11       5
o5 = ZZ  <-- ZZ   <-- ZZ   <-- ZZ
                                
     0       1        2        3

o5 : ChainComplex
i6 : C.dd^2

           6          11
o6 = 0 : ZZ  <----- ZZ   : 2
                0

           10          5
     1 : ZZ   <----- ZZ  : 3
                 0

o6 : ChainComplexMap
i7 : CR=(C**RR_53)

         6         10         11         5
o7 = RR    <-- RR     <-- RR     <-- RR
       53        53         53         53
                                      
     0         1          2          3

o7 : ChainComplex
i8 : h=(SVDHomology CR)_0

o8 = HashTable{0 => 2}
               1 => 3
               2 => 5
               3 => 2

o8 : HashTable
i9 : D=disturb(C,1e-2,Strategy=>Discrete)

         6         10         11         5
o9 = RR    <-- RR     <-- RR     <-- RR
       53        53         53         53
                                      
     0         1          2          3

o9 : ChainComplex
i10 : C.dd_1

o10 = | -3 4  -4 -2 0  2  -4 -1 -1 -2 |
      | -4 4  -3 -1 -2 1  -2 -1 1  -6 |
      | -1 -4 2  2  0  -2 0  5  -1 -2 |
      | 2  -2 3  -1 4  1  -1 -3 7  5  |
      | -5 2  -3 -3 4  3  -9 0  4  -1 |
      | 2  4  -3 -3 2  3  -2 -5 -1 6  |

               6        10
o10 : Matrix ZZ  <--- ZZ
i11 : D.dd_1

o11 = | -3.03 4.04  -3.96 -2.02 0     2.02  -3.96 -.99  -1.01 -1.98 |
      | -4.04 4.04  -3.03 -1.01 -1.98 1.01  -1.98 -.99  1.01  -5.94 |
      | -.99  -4.04 1.98  1.98  0     -2.02 0     4.95  -1.01 -2.02 |
      | 1.98  -2.02 3.03  -.99  4.04  .99   -1.01 -2.97 6.93  5.05  |
      | -4.95 2.02  -3.03 -2.97 4.04  2.97  -9.09 0     4.04  -.99  |
      | 2.02  4.04  -2.97 -3.03 2.02  3.03  -1.98 -4.95 -1.01 5.94  |

                 6          10
o11 : Matrix RR    <--- RR
               53         53
i12 : D.dd^2

              6                                                                                                        11
o12 = 0 : RR    <------------------------------------------------------------------------------------------------- RR     : 2
            53     | .404    -1.0068 1.5192  1.1538  1.9168  -.96   .463   -.5122  .6336        -2.0516 1.8312 |     53
                   | .0646   -1.1216 .8444   1.6532  1.8214  -.2892 .4242  -1.2694 -7.10543e-15 -2.2028 1.676  |
                   | -.1616  .2424   -1.3062 -.932   -1.1766 .5156  -.524  .4172   -1.12        2.0808  -.198  |
                   | .4674   -.5608  .3608   -1.2064 -.004   -.7272 .1204  1.2226  1.0408       -.1148  -.3548 |
                   | -1.0218 -.7936  -.4102  -.2552  -.0934  -.1212 -.1192 1.031   -2.0768      1.2952  -.2756 |
                   | -.1818  1.23    1.303   1.7906  .596    .1688  .5644  -1.0064 .3944        -1.2468 -.3224 |

              10                                                      5
      1 : RR     <----------------------------------------------- RR    : 3
            53      | -.6666  -.2352  -3.0378 .1148   -.2808  |     53
                    | -4.9212 -3.1936 3.2648  -.5656  -.0446  |
                    | -.948   -.2004  1.4232  -.4356  -1.6118 |
                    | .0082   .7928   -.6338  .6336   -3.4756 |
                    | -.96    -1.0344 -.906   -.5544  1.8058  |
                    | -2.7814 -.6764  1.3226  .358    -3.0424 |
                    | -2.8502 -1.7236 1.2766  -.8808  .2148   |
                    | -1.7776 -.9696  -.6352  -1.2024 1.158   |
                    | -.5156  -.4808  .1528   -.4008  .7854   |
                    | -2.7992 -1.0312 2.1204  .2796   -2.8468 |

o12 : ChainComplexMap
i13 : C'=projectToComplex(D,h)

          6         10         11         5
o13 = RR    <-- RR     <-- RR     <-- RR
        53        53         53         53
                                       
      0         1          2          3

o13 : ChainComplex
i14 : C'.dd^2

              6                                                                                                                                                             11
o14 = 0 : RR    <------------------------------------------------------------------------------------------------------------------------------------------------------ RR     : 2
            53     | 0            -2.13163e-14 2.13163e-14  -3.55271e-15 1.42109e-14  -2.4869e-14  9.32587e-15  7.10543e-15  1.42109e-14  -1.77636e-14 1.77636e-14  |     53
                   | 2.84217e-14  -4.26326e-14 3.19744e-14  -3.19744e-14 3.19744e-14  -4.9738e-14  -3.10862e-15 2.13163e-14  4.9738e-14   -3.55271e-14 2.84217e-14  |
                   | 8.88178e-15  1.42109e-14  -2.66454e-14 -3.81917e-14 -1.06581e-14 -1.77636e-15 -2.57572e-14 2.66454e-14  -3.19744e-14 3.64153e-14  -3.19744e-14 |
                   | -2.66454e-14 3.55271e-15  -1.95399e-14 1.77636e-15  -3.55271e-14 3.19744e-14  -1.77636e-15 1.59872e-14  -3.90799e-14 2.84217e-14  -4.61853e-14 |
                   | -3.55271e-15 -1.42109e-14 1.42109e-14  -3.55271e-14 7.10543e-15  -1.42109e-14 -5.32907e-15 3.55271e-14  1.42109e-14  0            -7.10543e-15 |
                   | -2.84217e-14 -7.10543e-15 2.84217e-14  8.88178e-14  -1.77636e-15 2.84217e-14  3.70814e-14  -6.92779e-14 2.84217e-14  -3.55271e-14 4.26326e-14  |

              10                                                                               5
      1 : RR     <------------------------------------------------------------------------ RR    : 3
            53      | -2.78805e-14 -1.77913e-14 1.65146e-15  -1.06581e-14 -9.41469e-14 |     53
                    | -6.12078e-14 1.82293e-14  -6.85617e-14 2.9976e-14   -7.00967e-14 |
                    | 2.00256e-14  3.05311e-15  9.37445e-15  1.77636e-15  4.9738e-14   |
                    | 4.8541e-14   3.5319e-15   6.62682e-14  -1.42109e-14 1.08358e-13  |
                    | -8.3232e-14  -7.32747e-15 -4.62963e-14 1.77636e-14  -1.3145e-13  |
                    | 1.79023e-15  3.21965e-15  1.06859e-14  1.42109e-14  4.44089e-14  |
                    | -6.44831e-14 3.81639e-16  -4.19213e-14 2.4869e-14   -8.70415e-14 |
                    | -6.38656e-14 7.2789e-15   -8.79678e-14 1.77636e-14  -1.00364e-13 |
                    | -3.43655e-14 -5.58668e-15 -1.349e-14   5.88418e-15  -4.37844e-14 |
                    | 3.17871e-14  1.83742e-14  -1.67019e-14 7.10543e-15  5.15143e-14  |

o14 : ChainComplexMap
i15 : euclideanDistance(C',D)

o15 = .448104803679258

o15 : RR (of precision 53)
i16 : euclideanDistance(CR,D)

o16 = .320600000000001

o16 : RR (of precision 53)
i17 : euclideanDistance(C',CR)

o17 = .476857690728905

o17 : RR (of precision 53)
i18 : Dd=dual D
-- warning: experimental computation over inexact field begun
--          results not reliable (one warning given per session)

          5         11         10         6
o18 = RR    <-- RR     <-- RR     <-- RR
        53        53         53         53
                                       
      -3        -2         -1         0

o18 : ChainComplex
i19 : Dd[1]

          5         11         10         6
o19 = RR    <-- RR     <-- RR     <-- RR
        53        53         53         53
                                       
      -4        -3         -2         -1

o19 : ChainComplex
i20 : hd=(SVDHomology((dual CR)[1]))_0

o20 = HashTable{-1 => 2}
                -2 => 3
                -3 => 5
                -4 => 2

o20 : HashTable
i21 : C''=(dual projectToComplex(Dd[1],hd))[1]

          6         10         11         5
o21 = RR    <-- RR     <-- RR     <-- RR
        53        53         53         53
                                       
      0         1          2          3

o21 : ChainComplex
i22 : C''.dd_1,C'.dd_1

o22 = (| -2.97399 4.01598  -4.00388 -1.98841 -.00795313 1.99116  -3.99867 
       | -4.01021 4.00367  -3.04727 -1.00345 -1.99798   .989343  -2.01634 
       | -.997709 -4.00146 1.99202  1.99776  -.0167308  -1.99845 .00771421
       | 2.01706  -2.01388 3.00792  -1.00651 4.0411     .991679  -1.0065  
       | -4.97537 2.02324  -3.01162 -3.00574 4.04238    2.9954   -9.06241 
       | 2.01966  4.03259  -2.96766 -2.99251 2.00767    3.01007  -2.01016 
      -----------------------------------------------------------------------
      -1.01104 -1.00052 -2.00054 |, | -2.98033 4.0351   -3.99782 -1.99981
      -1.02492 1.00473  -5.95672 |  | -4.04257 4.04465  -3.0238  -.998421
      4.98934  -.992694 -1.99532 |  | -.969222 -4.03547 1.97053  2.00736 
      -2.94224 6.94681  5.04002  |  | 2.00364  -2.02012 3.01414  -.974022
      .016532  4.03644  -.983487 |  | -4.97333 2.02011  -3.01434 -2.98577
      -4.98017 -1.0168  5.94281  |  | 2.01721  4.04465  -2.96366 -3.01857
      -----------------------------------------------------------------------
      -.00179207 2.00275 -3.98027  -.98734     -.994252 -1.99461 |)
      -1.9914    1.0103  -1.98875  -.990828    1.01093  -5.93308 |
      -.0179669  -2.0281 -.0231496 4.95008     -1.00079 -2.01688 |
      4.03335    .981491 -1.02459  -2.96908    6.93838  5.04616  |
      4.04657    2.9784  -9.0756   -.000905901 4.03173  -.986208 |
      2.00866    3.03038 -1.98861  -4.95084    -1.00914 5.94695  |

o22 : Sequence
i23 : euclideanDistance(CR,D), euclideanDistance(C'',D), euclideanDistance(C',D)

o23 = (.3206, .209381, .448105)

o23 : Sequence

Caveat

The algorithm does not produces the closest nearby complex in the euclidean norm. Instead it is a reminder to develop such function.

See also

Ways to use projectToComplex :

For the programmer

The object projectToComplex is a method function.