[eigen] Re: Problem with conjugate gradient.

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Just a minor correction:

Laspack gives 25 values:

[1] 0.096709627074711618 double
[2] 0.041738859730487146 double
[3] 0.00067511123237074346 double
[4] -0.040388637958504281 double
[5] -0.095359407662660600 double
[6] 0.050941442361153874 double
[7] 0.027508948358719330 double
[8] 0.00067511042278063161 double
[9] -0.026158728561469002 double
[10] -0.049591224744352222 double
[11] 0.028279326736092902 double
[12] 0.016767643972775401 double
[13] 0.00067510968097885340 double
[14] -0.015417425476270046 double
[15] -0.026929109622622786 double
[16] 0.017154602993941025 double
[17] 0.010635301124244559 double
[18] 0.00067510921541819892 double
[19] -0.0092850833115109520 double
[20] -0.015804386045630902 double
[21] 0.012553916220840610 double
[22] 0.0079532300763286365 double
[23] 0.00067510900276445361 double
[24] -0..0066030125504719286 double
[25] -0.011203699327577501 double

Steps to reproduce in Matlab (quick reference):

A = mmread('A.mat')
b = mmread('b.vec')
x = A\b




On Sat, Mar 21, 2015 at 5:26 PM, Billy Araujo <billyaraujo@xxxxxxxxx> wrote:

I have solved a system using Laspack using conjugate gradient and ILU preconditioner (tol. 1E-12) and it gives the following solution:

[1] 0.096709627074711618 double
[2] 0.041738859730487146 double
[3] 0.00067511123237074346 double
[4] -0.040388637958504281 double
[5] -0.095359407662660600 double
[6] 0.050941442361153874 double
[7] 0.027508948358719330 double
[8] 0.00067511042278063161 double
[9] -0.026158728561469002 double
[10] -0.049591224744352222 double
[11] 0.028279326736092902 double
[12] 0.016767643972775401 double
[13] 0.00067510968097885340 double
[14] -0.015417425476270046 double
[15] -0.026929109622622786 double
[16] 0.017154602993941025 double
[17] 0.010635301124244559 double
[18] 0.00067510921541819892 double
[19] -0.0092850833115109520 double
[20] -0.015804386045630902 double
[21] 0.012553916220840610 double
[22] 0.0079532300763286365 double
[23] 0.00067510900276445361 double
[24] -0.0066030125504719286 double

I have attached A and b files and in Matlab the solution of x = A\b gives:

   0.0963
    0.0411
   -0.0000
   -0.0411
   -0.0963
    0.0502
    0.0268
   -0.0000
   -0.0268
   -0.0502
    0.0275
    0.0161
   -0.0000
   -0.0161
   -0.0275
    0.0164
    0.0099
   -0.0000
   -0.0099
   -0.0164
    0.0119
    0.0073
   -0.0000
   -0.0073
   -0.0119 

In Eigen however the solution of the same system using ConjugateGradient and ILU preconditioner is:

            ConjugateGradient<SparseMatrix<Real>, Lower, IncompleteLUT<Real> > solver(A);

            solver.setTolerance(1E-12);
            x = solver.solve(b);

x:

0.552865
0.497742
0.456608
0.415474
0.360351
0.506762
0.483425
0.456608
0.429791
0.406454
0.484156
0.472678
0.456608
0.440538
0.429060
0.473055
0.466551
0.456608
0.446665
0.440161
0.468464
0.463873
0.456608
0.449343
0.444752

This is very different from Matlab and Laspack. What am I doing wrong? Am I calling Eigen correctly?

Please find in attachment the files to reproduce the solution. Steps:
 




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/