[petsc-users] Matrix Construction Question

Barry Smith bsmith at mcs.anl.gov
Wed Jul 6 18:23:46 CDT 2011


  Adam,

    I think you must be misunderstanding something. I have modified the program to multiply the original matrix by the solution and get back the identity so it is finding  the inverse (also got rid of the c++ isms and changed it to match petsc-dev). Attached is the new program. 

    Please explain why you think the true inverse is the transpose of what the code generates.

   Barry
[see attached file: ex1.c]

Matrix Object: 1 MPI processes
  type: seqaij
row 0: (0, 10)  (1, 4)  (2, 6)  (3, 9)  (4, 9)  (5, 5)  (6, 1)  (7, 7)  (8, 2)  (9, 2)  (10, 10)  (11, 4) 
row 1: (0, 0)  (1, 2)  (2, 5)  (3, 9)  (4, 3)  (5, 3)  (6, 2)  (7, 9)  (8, 6)  (9, 1)  (10, 9)  (11, 5) 
row 2: (0, 5)  (1, 9)  (2, 5)  (3, 5)  (4, 9)  (5, 10)  (6, 8)  (7, 0)  (8, 9)  (9, 3)  (10, 6)  (11, 2) 
row 3: (0, 9)  (1, 7)  (2, 10)  (3, 7)  (4, 6)  (5, 3)  (6, 4)  (7, 6)  (8, 2)  (9, 1)  (10, 1)  (11, 2) 
row 4: (0, 3)  (1, 3)  (2, 2)  (3, 7)  (4, 3)  (5, 7)  (6, 7)  (7, 3)  (8, 9)  (9, 9)  (10, 1)  (11, 7) 
row 5: (0, 7)  (1, 3)  (2, 4)  (3, 6)  (4, 4)  (5, 1)  (6, 7)  (7, 8)  (8, 8)  (9, 4)  (10, 6)  (11, 2) 
row 6: (0, 7)  (1, 6)  (2, 9)  (3, 0)  (4, 10)  (5, 9)  (6, 2)  (7, 2)  (8, 7)  (9, 6)  (10, 7)  (11, 4) 
row 7: (0, 6)  (1, 0)  (2, 9)  (3, 4)  (4, 8)  (5, 5)  (6, 3)  (7, 1)  (8, 8)  (9, 9)  (10, 10)  (11, 3) 
row 8: (0, 7)  (1, 5)  (2, 8)  (3, 1)  (4, 0)  (5, 2)  (6, 7)  (7, 9)  (8, 1)  (9, 8)  (10, 1)  (11, 0) 
row 9: (0, 9)  (1, 9)  (2, 9)  (3, 0)  (4, 8)  (5, 10)  (6, 1)  (7, 10)  (8, 7)  (9, 10)  (10, 8)  (11, 10) 
row 10: (0, 0)  (1, 6)  (2, 2)  (3, 1)  (4, 1)  (5, 8)  (6, 4)  (7, 8)  (8, 6)  (9, 2)  (10, 3)  (11, 9) 
row 11: (0, 4)  (1, 7)  (2, 2)  (3, 0)  (4, 7)  (5, 6)  (6, 0)  (7, 2)  (8, 5)  (9, 6)  (10, 7)  (11, 1) 
Matrix Object: 1 MPI processes
  type: seqdense
1.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 
0.0000000000000000e+00 1.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 
0.0000000000000000e+00 0.0000000000000000e+00 1.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 
0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 1.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 
0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 1.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 
0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 1.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 
0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 1.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 
0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 1.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 
0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 1.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 
0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 1.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 
0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 1.0000000000000000e+00 0.0000000000000000e+00 
0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 1.0000000000000000e+00 
Matrix Object: 1 MPI processes
  type: seqaij
row 0: (0, 0.1)  (1, 4)  (2, 6)  (3, 9)  (4, 9)  (5, 5)  (6, 1)  (7, 7)  (8, 2)  (9, 2)  (10, 10)  (11, 4) 
row 1: (0, 0)  (1, 0.5)  (2, 5)  (3, 9)  (4, 3)  (5, 3)  (6, 2)  (7, 9)  (8, 6)  (9, 1)  (10, 9)  (11, 5) 
row 2: (0, 0.5)  (1, 3.5)  (2, -0.0645161)  (3, -31)  (4, -6)  (5, -3)  (6, 0.5)  (7, -35)  (8, -13)  (9, -1.5)  (10, -30.5)  (11, -17.5) 
row 3: (0, 0.9)  (1, 1.7)  (2, 0.251613)  (3, -0.116279)  (4, -5.69032)  (5, -5.84516)  (6, -0.425806)  (7, -6.79355)  (8, -6.72903)  (9, -2.12258)  (10, -15.6258)  (11, -5.69677) 
row 4: (0, 0.3)  (1, 0.9)  (2, 0.277419)  (3, -0.55814)  (4, -0.255658)  (5, 0.369842)  (6, 4.52363)  (7, -1.28207)  (8, 2.85071)  (9, 6.73143)  (10, -10.3601)  (11, 2.97524) 
row 5: (0, 0.7)  (1, 0.1)  (2, 0.0451613)  (3, -0.0232558)  (4, 0.629267)  (5, -0.329687)  (6, 3.22094)  (7, 4.42942)  (8, 4.63675)  (9, -1.71749)  (10, 5.63329)  (11, -2.51438) 
row 6: (0, 0.7)  (1, 1.6)  (2, 0.206452)  (3, 1.66279)  (4, -2.45445)  (5, -3.93857)  (6, 0.0444568)  (7, 15.5209)  (8, 35.1319)  (9, 16.5966)  (10, 14.638)  (11, 3.68495) 
row 7: (0, 0.6)  (1, -1.2)  (2, -0.735484)  (3, 1.55814)  (4, -2.72363)  (5, -4.45356)  (6, 1.44469)  (7, -0.0727551)  (8, -7.41708)  (9, -2.08795)  (10, -7.56138)  (11, -5.81272) 
row 8: (0, 0.7)  (1, 1.1)  (2, 0.109677)  (3, 1.37209)  (4, 0.289988)  (5, -1.13475)  (6, 0.309978)  (7, -0.578186)  (8, -0.141142)  (9, -1.67585)  (10, 9.37253)  (11, -6.7832) 
row 9: (0, 0.9)  (1, 2.7)  (2, 0.63871)  (3, 1.46512)  (4, -1.01477)  (5, -2.72166)  (6, 0.371714)  (7, -1.21452)  (8, -0.0857132)  (9, 0.347749)  (10, 8.07184)  (11, -0.411052) 
row 10: (0, 0)  (1, 3)  (2, 0.83871)  (3, 4.13106e-16)  (4, 0.758727)  (5, -0.407335)  (6, -0.201814)  (7, -1.1833)  (8, 0.431543)  (9, -1.37252)  (10, 0.0782676)  (11, 1.62437) 
row 11: (0, 0.4)  (1, 2.7)  (2, 0.896774)  (3, 0.0116279)  (4, -0.190928)  (5, 0.419064)  (6, -0.299173)  (7, -0.648141)  (8, -0.570316)  (9, 2.96665)  (10, -1.34839)  (11, 6.34192) 
Matrix Object: 1 MPI processes
  type: seqdense
-9.6555301489395196e-01 5.2560254734804284e+00 7.1846440184462583e+00 -6.1331699956450372e+00 6.4983079560540347e-01 3.4596941129901471e-01 1.0107504375266285e+00 -6.8628221518606729e+00 7.5964800479384031e-01 9.9409527390937242e+00 -1.1538273684377408e+01 -8.7812172713296324e+00 
2.0776013031269080e-02 -6.2847383863353556e-01 -6.6052840736344010e-01 8.0956641284817366e-01 -1.6685804755341449e-01 -6.9558502635303610e-02 -4.7043374819017370e-01 8.8565458307188294e-01 -1.4371117297291947e-01 -9.3869998563905455e-01 1.2914077666714618e+00 1.0574136681100246e+00 
-2.3457711527316882e-01 9.1412301356649039e-01 1.1920152012252558e+00 -9.3204325120013032e-01 6.1684149677475715e-02 -5.5669152161757513e-03 1.5331009643936852e-01 -1.0495531120351829e+00 1.3707009393529770e-01 1.6438364660096838e+00 -1.8889315346051050e+00 -1.4754676224028302e+00 
-2.7270521239062756e-01 1.5893219146430135e+00 2.0634754873336365e+00 -1.7209959749076202e+00 2.5337782971752582e-01 2.9994338843454111e-02 2.5534077638214847e-01 -1.9835560388079614e+00 2.1919306261832680e-01 2.8264140536952880e+00 -3.3585356810562166e+00 -2.4823956307658124e+00 
1.7809631276633557e+00 -9.1417366043401938e+00 -1.2382493173582191e+01 1.0476797534295141e+01 -1.0702242259054311e+00 -4.4257528541486152e-01 -1.5514634845537427e+00 1.1648521003544433e+01 -1.3496709122035624e+00 -1.7047888183523145e+01 1.9724452609789598e+01 1.4992041216496093e+01 
-9.8718243165411523e-01 5.8306164576852701e+00 7.6462462368614474e+00 -6.7409300641732255e+00 8.2470796373523481e-01 2.4183044407138940e-01 1.5018770736493510e+00 -7.5966352267475976e+00 9.5172226504897151e-01 1.0477013653074360e+01 -1.2424746738008650e+01 -9.4366200444961059e+00 
1.0136311908130891e+00 -5.2691310897505188e+00 -6.8579746975031277e+00 5.9224590762975922e+00 -6.9910423550554868e-01 -2.6032159562560986e-01 -1.1422819623877292e+00 6.7605747527325546e+00 -7.2292745381698886e-01 -9.5958819114572318e+00 1.1268446709048680e+01 8.4067370921887932e+00 
2.2091262060824907e-01 -8.3435384842300975e-01 -1.3941401244916276e+00 9.8039662735021815e-01 -3.8000873314291278e-02 8.9523733294413765e-03 1.4913622793099915e-01 9.8067426906640520e-01 -5.9946728984266576e-02 -1.8517463266334733e+00 1.9784368072815006e+00 1.5366714023840424e+00 
-1.0121118595265313e+00 4.8899231637686178e+00 6.4363614363996273e+00 -5.5352594765178100e+00 6.3588032578740750e-01 3.6692073791888746e-01 1.0886795922616135e+00 -6.2890108659346788e+00 6.4878885440659029e-01 8.9338546663354137e+00 -1.0480724683245333e+01 -7.8880863422387675e+00 
3.4828232494328459e-01 -1.8956049209699504e+00 -2.5686607685099623e+00 2.1723348669813345e+00 -1.8046993568519984e-01 -1.4627336724353771e-01 -4.3324999763575017e-01 2.4726324401858575e+00 -2.4110495922156525e-01 -3.4910576517078957e+00 4.0543680896562346e+00 3.1697497725756127e+00 
-7.9100624200083347e-02 4.5467040831090605e-01 7.8405305146143733e-01 -5.8064262143845780e-01 -6.7175618016896713e-02 1.8327382703008988e-03 -1.7759194277182197e-01 -4.5740681002782790e-01 6.1885044052317102e-02 1.0071945338473738e+00 -1.0089198716799244e+00 -8.0628484740612849e-01 
7.2503137134149309e-01 -4.0345450207039040e+00 -5.1688665129699460e+00 4.5837925160863282e+00 -5.6171429205502965e-01 -2.2648736352508647e-01 -1.1066305876267444e+00 5.2407359063046410e+00 -6.8000756820565422e-01 -7.0772451277993547e+00 8.5513959650299824e+00 6.3419246076729259e+00 
anlextwls002-241:Downloads barrysmith$ ./ex1 
Matrix Object: 1 MPI processes
  type: seqaij
row 0: (0, 10)  (1, 4)  (2, 6)  (3, 9)  (4, 9)  (5, 5)  (6, 1)  (7, 7)  (8, 2)  (9, 2)  (10, 10)  (11, 4) 
row 1: (0, 0)  (1, 2)  (2, 5)  (3, 9)  (4, 3)  (5, 3)  (6, 2)  (7, 9)  (8, 6)  (9, 1)  (10, 9)  (11, 5) 
row 2: (0, 5)  (1, 9)  (2, 5)  (3, 5)  (4, 9)  (5, 10)  (6, 8)  (7, 0)  (8, 9)  (9, 3)  (10, 6)  (11, 2) 
row 3: (0, 9)  (1, 7)  (2, 10)  (3, 7)  (4, 6)  (5, 3)  (6, 4)  (7, 6)  (8, 2)  (9, 1)  (10, 1)  (11, 2) 
row 4: (0, 3)  (1, 3)  (2, 2)  (3, 7)  (4, 3)  (5, 7)  (6, 7)  (7, 3)  (8, 9)  (9, 9)  (10, 1)  (11, 7) 
row 5: (0, 7)  (1, 3)  (2, 4)  (3, 6)  (4, 4)  (5, 1)  (6, 7)  (7, 8)  (8, 8)  (9, 4)  (10, 6)  (11, 2) 
row 6: (0, 7)  (1, 6)  (2, 9)  (3, 0)  (4, 10)  (5, 9)  (6, 2)  (7, 2)  (8, 7)  (9, 6)  (10, 7)  (11, 4) 
row 7: (0, 6)  (1, 0)  (2, 9)  (3, 4)  (4, 8)  (5, 5)  (6, 3)  (7, 1)  (8, 8)  (9, 9)  (10, 10)  (11, 3) 
row 8: (0, 7)  (1, 5)  (2, 8)  (3, 1)  (4, 0)  (5, 2)  (6, 7)  (7, 9)  (8, 1)  (9, 8)  (10, 1)  (11, 0) 
row 9: (0, 9)  (1, 9)  (2, 9)  (3, 0)  (4, 8)  (5, 10)  (6, 1)  (7, 10)  (8, 7)  (9, 10)  (10, 8)  (11, 10) 
row 10: (0, 0)  (1, 6)  (2, 2)  (3, 1)  (4, 1)  (5, 8)  (6, 4)  (7, 8)  (8, 6)  (9, 2)  (10, 3)  (11, 9) 
row 11: (0, 4)  (1, 7)  (2, 2)  (3, 0)  (4, 7)  (5, 6)  (6, 0)  (7, 2)  (8, 5)  (9, 6)  (10, 7)  (11, 1) 
Matrix Object: 1 MPI processes
  type: seqdense
1.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 
0.0000000000000000e+00 1.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 
0.0000000000000000e+00 0.0000000000000000e+00 1.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 
0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 1.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 
0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 1.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 
0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 1.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 
0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 1.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 
0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 1.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 
0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 1.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 
0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 1.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 
0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 1.0000000000000000e+00 0.0000000000000000e+00 
0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 1.0000000000000000e+00 
Matrix Object: 1 MPI processes
  type: seqaij
row 0: (0, 0.1)  (1, 4)  (2, 6)  (3, 9)  (4, 9)  (5, 5)  (6, 1)  (7, 7)  (8, 2)  (9, 2)  (10, 10)  (11, 4) 
row 1: (0, 0)  (1, 0.5)  (2, 5)  (3, 9)  (4, 3)  (5, 3)  (6, 2)  (7, 9)  (8, 6)  (9, 1)  (10, 9)  (11, 5) 
row 2: (0, 0.5)  (1, 3.5)  (2, -0.0645161)  (3, -31)  (4, -6)  (5, -3)  (6, 0.5)  (7, -35)  (8, -13)  (9, -1.5)  (10, -30.5)  (11, -17.5) 
row 3: (0, 0.9)  (1, 1.7)  (2, 0.251613)  (3, -0.116279)  (4, -5.69032)  (5, -5.84516)  (6, -0.425806)  (7, -6.79355)  (8, -6.72903)  (9, -2.12258)  (10, -15.6258)  (11, -5.69677) 
row 4: (0, 0.3)  (1, 0.9)  (2, 0.277419)  (3, -0.55814)  (4, -0.255658)  (5, 0.369842)  (6, 4.52363)  (7, -1.28207)  (8, 2.85071)  (9, 6.73143)  (10, -10.3601)  (11, 2.97524) 
row 5: (0, 0.7)  (1, 0.1)  (2, 0.0451613)  (3, -0.0232558)  (4, 0.629267)  (5, -0.329687)  (6, 3.22094)  (7, 4.42942)  (8, 4.63675)  (9, -1.71749)  (10, 5.63329)  (11, -2.51438) 
row 6: (0, 0.7)  (1, 1.6)  (2, 0.206452)  (3, 1.66279)  (4, -2.45445)  (5, -3.93857)  (6, 0.0444568)  (7, 15.5209)  (8, 35.1319)  (9, 16.5966)  (10, 14.638)  (11, 3.68495) 
row 7: (0, 0.6)  (1, -1.2)  (2, -0.735484)  (3, 1.55814)  (4, -2.72363)  (5, -4.45356)  (6, 1.44469)  (7, -0.0727551)  (8, -7.41708)  (9, -2.08795)  (10, -7.56138)  (11, -5.81272) 
row 8: (0, 0.7)  (1, 1.1)  (2, 0.109677)  (3, 1.37209)  (4, 0.289988)  (5, -1.13475)  (6, 0.309978)  (7, -0.578186)  (8, -0.141142)  (9, -1.67585)  (10, 9.37253)  (11, -6.7832) 
row 9: (0, 0.9)  (1, 2.7)  (2, 0.63871)  (3, 1.46512)  (4, -1.01477)  (5, -2.72166)  (6, 0.371714)  (7, -1.21452)  (8, -0.0857132)  (9, 0.347749)  (10, 8.07184)  (11, -0.411052) 
row 10: (0, 0)  (1, 3)  (2, 0.83871)  (3, 4.13106e-16)  (4, 0.758727)  (5, -0.407335)  (6, -0.201814)  (7, -1.1833)  (8, 0.431543)  (9, -1.37252)  (10, 0.0782676)  (11, 1.62437) 
row 11: (0, 0.4)  (1, 2.7)  (2, 0.896774)  (3, 0.0116279)  (4, -0.190928)  (5, 0.419064)  (6, -0.299173)  (7, -0.648141)  (8, -0.570316)  (9, 2.96665)  (10, -1.34839)  (11, 6.34192) 
Matrix Object: 1 MPI processes
  type: seqdense
-9.6555301489395196e-01 5.2560254734804284e+00 7.1846440184462583e+00 -6.1331699956450372e+00 6.4983079560540347e-01 3.4596941129901471e-01 1.0107504375266285e+00 -6.8628221518606729e+00 7.5964800479384031e-01 9.9409527390937242e+00 -1.1538273684377408e+01 -8.7812172713296324e+00 
2.0776013031269080e-02 -6.2847383863353556e-01 -6.6052840736344010e-01 8.0956641284817366e-01 -1.6685804755341449e-01 -6.9558502635303610e-02 -4.7043374819017370e-01 8.8565458307188294e-01 -1.4371117297291947e-01 -9.3869998563905455e-01 1.2914077666714618e+00 1.0574136681100246e+00 
-2.3457711527316882e-01 9.1412301356649039e-01 1.1920152012252558e+00 -9.3204325120013032e-01 6.1684149677475715e-02 -5.5669152161757513e-03 1.5331009643936852e-01 -1.0495531120351829e+00 1.3707009393529770e-01 1.6438364660096838e+00 -1.8889315346051050e+00 -1.4754676224028302e+00 
-2.7270521239062756e-01 1.5893219146430135e+00 2.0634754873336365e+00 -1.7209959749076202e+00 2.5337782971752582e-01 2.9994338843454111e-02 2.5534077638214847e-01 -1.9835560388079614e+00 2.1919306261832680e-01 2.8264140536952880e+00 -3.3585356810562166e+00 -2.4823956307658124e+00 
1.7809631276633557e+00 -9.1417366043401938e+00 -1.2382493173582191e+01 1.0476797534295141e+01 -1.0702242259054311e+00 -4.4257528541486152e-01 -1.5514634845537427e+00 1.1648521003544433e+01 -1.3496709122035624e+00 -1.7047888183523145e+01 1.9724452609789598e+01 1.4992041216496093e+01 
-9.8718243165411523e-01 5.8306164576852701e+00 7.6462462368614474e+00 -6.7409300641732255e+00 8.2470796373523481e-01 2.4183044407138940e-01 1.5018770736493510e+00 -7.5966352267475976e+00 9.5172226504897151e-01 1.0477013653074360e+01 -1.2424746738008650e+01 -9.4366200444961059e+00 
1.0136311908130891e+00 -5.2691310897505188e+00 -6.8579746975031277e+00 5.9224590762975922e+00 -6.9910423550554868e-01 -2.6032159562560986e-01 -1.1422819623877292e+00 6.7605747527325546e+00 -7.2292745381698886e-01 -9.5958819114572318e+00 1.1268446709048680e+01 8.4067370921887932e+00 
2.2091262060824907e-01 -8.3435384842300975e-01 -1.3941401244916276e+00 9.8039662735021815e-01 -3.8000873314291278e-02 8.9523733294413765e-03 1.4913622793099915e-01 9.8067426906640520e-01 -5.9946728984266576e-02 -1.8517463266334733e+00 1.9784368072815006e+00 1.5366714023840424e+00 
-1.0121118595265313e+00 4.8899231637686178e+00 6.4363614363996273e+00 -5.5352594765178100e+00 6.3588032578740750e-01 3.6692073791888746e-01 1.0886795922616135e+00 -6.2890108659346788e+00 6.4878885440659029e-01 8.9338546663354137e+00 -1.0480724683245333e+01 -7.8880863422387675e+00 
3.4828232494328459e-01 -1.8956049209699504e+00 -2.5686607685099623e+00 2.1723348669813345e+00 -1.8046993568519984e-01 -1.4627336724353771e-01 -4.3324999763575017e-01 2.4726324401858575e+00 -2.4110495922156525e-01 -3.4910576517078957e+00 4.0543680896562346e+00 3.1697497725756127e+00 
-7.9100624200083347e-02 4.5467040831090605e-01 7.8405305146143733e-01 -5.8064262143845780e-01 -6.7175618016896713e-02 1.8327382703008988e-03 -1.7759194277182197e-01 -4.5740681002782790e-01 6.1885044052317102e-02 1.0071945338473738e+00 -1.0089198716799244e+00 -8.0628484740612849e-01 
7.2503137134149309e-01 -4.0345450207039040e+00 -5.1688665129699460e+00 4.5837925160863282e+00 -5.6171429205502965e-01 -2.2648736352508647e-01 -1.1066305876267444e+00 5.2407359063046410e+00 -6.8000756820565422e-01 -7.0772451277993547e+00 8.5513959650299824e+00 6.3419246076729259e+00 
Matrix Object: 1 MPI processes
  type: seqdense
9.9999999999999889e-01 7.1054273576010019e-15 -3.5527136788005009e-15 1.4210854715202004e-14 -1.3322676295501878e-15 2.2204460492503131e-16 8.8817841970012523e-16 1.0658141036401503e-14 -1.3322676295501878e-15 -1.4210854715202004e-14 2.1316282072803006e-14 -2.1316282072803006e-14 
0.0000000000000000e+00 1.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 2.2204460492503131e-16 8.8817841970012523e-16 0.0000000000000000e+00 4.4408920985006262e-16 0.0000000000000000e+00 0.0000000000000000e+00 3.5527136788005009e-15 
4.4408920985006262e-16 -1.9539925233402755e-14 1.0000000000000160e+00 -1.7763568394002505e-15 2.2204460492503131e-15 2.7755575615628914e-16 5.7731597280508140e-15 5.3290705182007514e-15 3.9968028886505635e-15 -3.0198066269804258e-14 -3.5527136788005009e-14 -2.8421709430404007e-14 
1.5543122344752192e-15 1.0658141036401503e-14 3.7303493627405260e-14 1.0000000000000107e+00 2.4424906541753444e-15 1.4988010832439613e-15 6.6613381477509392e-15 -2.3092638912203256e-14 6.6613381477509392e-16 2.1316282072803006e-14 -3.5527136788005009e-15 -4.2632564145606011e-14 
1.7763568394002505e-15 -7.1054273576010019e-15 1.4210854715202004e-14 1.4210854715202004e-14 9.9999999999999956e-01 4.4408920985006262e-16 8.8817841970012523e-16 1.4210854715202004e-14 0.0000000000000000e+00 -3.5527136788005009e-14 2.8421709430404007e-14 2.8421709430404007e-14 
8.8817841970012523e-16 -1.2434497875801753e-14 -3.5527136788005009e-15 5.3290705182007514e-15 4.4408920985006262e-16 1.0000000000000009e+00 -4.4408920985006262e-16 7.1054273576010019e-15 -2.2204460492503131e-15 7.1054273576010019e-15 2.1316282072803006e-14 0.0000000000000000e+00 
3.5527136788005009e-15 -2.1316282072803006e-14 -3.1974423109204508e-14 5.6843418860808015e-14 -1.3322676295501878e-15 -1.2212453270876722e-15 1.0000000000000062e+00 -2.8421709430404007e-14 -2.6645352591003757e-15 1.0658141036401503e-14 -2.8421709430404007e-14 0.0000000000000000e+00 
1.7763568394002505e-15 8.8817841970012523e-15 -1.7763568394002505e-15 5.6843418860808015e-14 -8.8817841970012523e-16 -1.1102230246251565e-16 9.7699626167013776e-15 9.9999999999995204e-01 -2.2204460492503131e-15 3.9079850466805510e-14 -4.2632564145606011e-14 -1.0658141036401503e-14 
2.2204460492503131e-16 -6.2727600891321345e-15 6.5503158452884236e-15 2.9976021664879227e-15 3.5943470422239443e-15 1.9485281443909486e-15 7.5772721430666934e-15 -3.6637359812630166e-14 1.0000000000000007e+00 1.2656542480726785e-14 -1.6875389974302379e-14 -2.4313884239290928e-14 
-3.5527136788005009e-15 2.1316282072803006e-14 1.4210854715202004e-14 -2.1316282072803006e-14 3.5527136788005009e-15 1.3322676295501878e-15 1.4210854715202004e-14 -3.5527136788005009e-14 3.5527136788005009e-15 1.0000000000000000e+00 -5.6843418860808015e-14 -6.3948846218409017e-14 
1.7763568394002505e-15 -2.1316282072803006e-14 -7.1054273576010019e-15 0.0000000000000000e+00 8.8817841970012523e-16 0.0000000000000000e+00 0.0000000000000000e+00 7.1054273576010019e-15 2.6645352591003757e-15 -3.5527136788005009e-14 1.0000000000000000e+00 7.1054273576010019e-15 
-2.4424906541753444e-15 1.2434497875801753e-14 4.5297099404706387e-14 -4.6185277824406512e-14 4.1078251911130792e-15 1.5265566588595902e-15 8.4376949871511897e-15 -2.5757174171303632e-14 5.2180482157382357e-15 3.9079850466805510e-14 -7.8159700933611020e-14 9.9999999999994316e-01 



On Jul 6, 2011, at 9:53 AM, Adam Byrd wrote:

> I do not want the transpose, but that is what is coming out as the solution. Both my tests show the correct original matrix, and both yield the transpose of the solution verified against Mathematica and the website from which I pulled the 4x4 matrix in test.cpp. Could it be related to the factoring?
> 
> On Tue, Jul 5, 2011 at 4:39 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:
> 
>  MatSolve() and MatMatSolve() will not return the transpose of the solution, they will return the solution. If you want the transpose solve you can use MatSolveTranspose() for a single Vec or use MatMatSolve() for the matrix case after transposing the original matrix if you want the transpose.
> 
>   Barry
> 
> 
> On Jul 5, 2011, at 12:17 PM, Adam Byrd wrote:
> 
> > I have working code that produces the correct answer now, thank you. One (hopefully) final question, though. The solution is actually transposed. What causes this? Presumably I can use MatMatSolveTranspose to get around this, but there's no man page and I want to be sure of what will happen in all cases.
> >
> > Respectfully,
> > Adam
> >
> > On Thu, Jun 30, 2011 at 4:18 PM, Hong Zhang <hzhang at mcs.anl.gov> wrote:
> > Add
> >  ierr = MatGetOrdering(testMat,MATORDERING_ND,&isrow,&iscol);CHKERRQ(ierr);
> > before the line
> >        ierr = MatFactorInfoInitialize(&luinfo);CHKERRQ(ierr);
> >
> > Somehow, your matrix is numerically singular. With
> > MATORDERING_NATURAL
> > I get
> > [0]PETSC ERROR: Detected zero pivot in LU factorization
> >
> > even using MATDENSE matrix format, which calls lapack.
> > With MATORDERING_ND, I get useless inverseMat.
> >
> > The modified code I used is attached.
> >
> > Hong
> >
> > On Thu, Jun 30, 2011 at 2:30 PM, Adam Byrd <adam1.byrd at gmail.com> wrote:
> > > I'm trying to work through what I need to do, again by practicing with a
> > > small scale random problem. The general order of events seems to be: create
> > > a matrix, fill it, assemble it, factor it, then one can use solvers with it.
> > > When I use MatLUFactor on my matrix before using it with a solver I get this
> > > error:
> > > [0]PETSC ERROR: --------------------- Error Message
> > > ------------------------------------
> > > [0]PETSC ERROR: Null argument, when expecting valid pointer!
> > > [0]PETSC ERROR: Null Object: Parameter # 1!
> > > [0]PETSC ERROR:
> > > ------------------------------------------------------------------------
> > > [0]PETSC ERROR: Petsc Release Version 3.1.0, Patch 8, Thu Mar 17 13:37:48
> > > CDT 2011
> > > [0]PETSC ERROR: See docs/changes/index.html for recent updates.
> > > [0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.
> > > [0]PETSC ERROR: See docs/index.html for manual pages.
> > > [0]PETSC ERROR:
> > > ------------------------------------------------------------------------
> > > [0]PETSC ERROR: ./test on a osx-gnu-c named Macintosh-3.local by adambyrd
> > > Thu Jun 30 15:27:30 2011
> > > [0]PETSC ERROR: Libraries linked from
> > > /Users/adambyrd/soft/petsc-3.1-p8/osx-gnu-cpp/lib
> > > [0]PETSC ERROR: Configure run at Tue Jun 28 12:56:55 2011
> > > [0]PETSC ERROR: Configure options PETSC_ARCH=osx-gnu-cpp --with-fc=gfortran
> > > -download-f-blas-lapack=1 --download-mpich=1 --with-scalar-type=complex
> > > --with-clanguage=c++
> > > [0]PETSC ERROR:
> > > ------------------------------------------------------------------------
> > > [0]PETSC ERROR: ISInvertPermutation() line 209 in
> > > src/vec/is/interface/index.c
> > > [0]PETSC ERROR: MatLUFactorSymbolic_SeqAIJ() line 306 in
> > > src/mat/impls/aij/seq/aijfact.c
> > > [0]PETSC ERROR: MatLUFactorSymbolic() line 2534 in
> > > src/mat/interface/matrix.c
> > > [0]PETSC ERROR: MatLUFactor_SeqAIJ() line 945 in
> > > src/mat/impls/aij/seq/aijfact.c
> > > [0]PETSC ERROR: MatLUFactor() line 2417 in src/mat/interface/matrix.c
> > > [0]PETSC ERROR: main() line 62 in WDtest.cpp
> > > application called MPI_Abort(MPI_COMM_WORLD, 85) - process 0[unset]:
> > > aborting job:
> > > application called MPI_Abort(MPI_COMM_WORLD, 85) - process 0
> > > I don't understand what I'm doing wrong.
> > > Respectfully,
> > > Adam
> > > On Wed, Jun 29, 2011 at 1:26 AM, Matthew Knepley <knepley at gmail.com> wrote:
> > >>
> > >> On Tue, Jun 28, 2011 at 10:20 PM, Adam Byrd <adam1.byrd at gmail.com> wrote:
> > >>>
> > >>> Matt,
> > >>>
> > >>> Alright, that means I need to continue learning how to use
> > >>> MatSetValues(). With my 6x6 example I tried filling it with four 3x3 sub
> > >>> matrices, but when I do that I get the error 'sum of local sizes 12 does not
> > >>> equal global size.' I had 4 processors each calling MatSetValues for their
> > >>> own 3x3. Graphically, I arranged the nodes 0 1
> > >>>
> > >>>                                                                        2 3
> > >>> where process 0 had global rows 0-2 and global columns 0-2; process 1 had
> > >>> 0-2, 3-5; process 2 had 3-5, 0-2; and process 3 had 3-5, 3-5. >From the
> > >>> documentation, I think this should be correct, but I'm not sure. Also, which
> > >>> format would you recommend for storing the matrix?
> > >>
> > >> 1) With any error, send the Entire error message.
> > >> 2) PETSc matrices are divided by rows, not rows and columns, see the
> > >> manual section. Rows & columns only makes sense for dense matrices
> > >> 3) You can still set arbitrary blocks no matter how the matrix is divided
> > >> 4) The error means you tried to set both local and global dimensions, and
> > >> they do not add up correctly. Just set the global dimensions
> > >>    Matt
> > >>
> > >>>
> > >>> Jack,
> > >>>
> > >>> I'm a summer intern just getting started with this project, so I don't
> > >>> know all the details yet (I can ask though). I know I need to find the
> > >>> Green's function which will involve the trace of the inverted Hamiltonian,
> > >>> as well as the rest of the matrix. I have inquired about avoiding the
> > >>> inversion altogether, but my instructor doesn't believe there is a way
> > >>> around it. Once I've worked through the math I want to explore other options
> > >>> though.
> > >>>
> > >>> Respectfully,
> > >>> Adam
> > >>>
> > >>> On Tue, Jun 28, 2011 at 6:08 PM, Matthew Knepley <knepley at gmail.com>
> > >>> wrote:
> > >>>>
> > >>>> On Tue, Jun 28, 2011 at 5:01 PM, Adam Byrd <adam1.byrd at gmail.com> wrote:
> > >>>>>
> > >>>>> Actually, it's quite sparse. In the 3600x3600 there are only just 4
> > >>>>> nonzero entries in each row. This means it's 99.9% empty. My smaller 6x6
> > >>>>> example is dense, but it's only practice building and manipulating matrices.
> > >>>>
> > >>>> Ah, then its easy. Just call MatSetValues() with each block. Then use
> > >>>> MUMPS to do a sparse direct solve.
> > >>>>   Matt
> > >>>>
> > >>>>>
> > >>>>> Respectfully,
> > >>>>> Adam
> > >>>>>
> > >>>>> On Tue, Jun 28, 2011 at 5:55 PM, Matthew Knepley <knepley at gmail.com>
> > >>>>> wrote:
> > >>>>>>
> > >>>>>> It sounds like you have a dense matrix (from your example). Is this
> > >>>>>> true? If so, you should use Elemental (on Google Code).
> > >>>>>>   Thanks,
> > >>>>>>      Matt
> > >>>>>>
> > >>>>>> On Tue, Jun 28, 2011 at 8:55 AM, Adam Byrd <adam1.byrd at gmail.com>
> > >>>>>> wrote:
> > >>>>>>>
> > >>>>>>> Hi,
> > >>>>>>> I'm rather new to PETSc and trying to work out the best way to create
> > >>>>>>> and fill a large sparse matrix distributed over many processors. Currently,
> > >>>>>>> my goal is to create a 3600x3600 matrix in units of 12x12 blocks with
> > >>>>>>> several blocks on any given node. I'd like to create the matrix in such a
> > >>>>>>> way that each node only holds the information in it's handful of blocks and
> > >>>>>>> not the entire matrix. Eventually, this matrix is to be inverted (I know,
> > >>>>>>> inversion should be avoided, but as this is a Hamiltonian matrix from which
> > >>>>>>> I need the Green's function, I'm unaware of a way to forgo carrying out the
> > >>>>>>> inversion). Additionally, the values will be changed slightly and the matrix
> > >>>>>>> will be repeatedly inverted. It's structure will remain the same. In order
> > >>>>>>> to learn how to do this is I am starting with a small 6x6 matrix broken into
> > >>>>>>> four 3x3 blocks and distributed one block per node. I've been able to create
> > >>>>>>> a local 3x3 matrix on each node, with it's own values, and with the global
> > >>>>>>> row/column IDs correctly set to [0, 1, 2] or [3, 4, 5] depending on where
> > >>>>>>> the block is in the matrix. My problem manifests when I try to create the
> > >>>>>>> larger matrix from the individual smaller ones. When the matrix is
> > >>>>>>> constructed I'm trying to use MatSetValues and having each node pass in it's
> > >>>>>>> 3x3 block. I end up with an error that the sum of local lengths 12x12 does
> > >>>>>>> not match the global length 6x6. It appears as though this is from passing
> > >>>>>>> in four 3x3s and the program interpreting that as a 12x12 instead of as a
> > >>>>>>> 6x6 with the blocks in a grid.
> > >>>>>>> My question is then: is it possible to fill a matrix as a grid of
> > >>>>>>> blocks, or can I only fill it in groups of rows or columns? Also, am I
> > >>>>>>> approaching this problem the correct way, or are there more efficient ways
> > >>>>>>> of building this matrix with the ultimate goal of inverting it?
> > >>>>>>> I have included my copy of a modified example if it helps. I do
> > >>>>>>> apologize if this is answered somewhere in the documentation, I have been
> > >>>>>>> unable to find a solution.
> > >>>>>>> Respectfully,
> > >>>>>>> Adam
> > >>>>>>
> > >>>>>>
> > >>>>>> --
> > >>>>>> What most experimenters take for granted before they begin their
> > >>>>>> experiments is infinitely more interesting than any results to which their
> > >>>>>> experiments lead.
> > >>>>>> -- Norbert Wiener
> > >>>>>
> > >>>>
> > >>>>
> > >>>>
> > >>>> --
> > >>>> What most experimenters take for granted before they begin their
> > >>>> experiments is infinitely more interesting than any results to which their
> > >>>> experiments lead.
> > >>>> -- Norbert Wiener
> > >>>
> > >>
> > >>
> > >>
> > >> --
> > >> What most experimenters take for granted before they begin their
> > >> experiments is infinitely more interesting than any results to which their
> > >> experiments lead.
> > >> -- Norbert Wiener
> > >
> > >
> >
> 
> 
> <test.cpp><test2.cpp>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: ex1.c
Type: application/octet-stream
Size: 4036 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110706/a9a39fba/attachment-0001.obj>


More information about the petsc-users mailing list