• To: eigen@xxxxxxxxxxxxxxxxxxx
• Subject: [eigen] Problem with conjugate gradient.
• From: Billy Araujo <billyaraujo@xxxxxxxxx>
• Date: Sat, 21 Mar 2015 17:26:14 +0000
• Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=2yS9boKZv178L9A3DrQ7gnoXtS3vp6jEbsBMRrV9Z7o=; b=t86AicQ3zGa1LTtAe9s8zMNLe0DkE8himbKVnWGQY1l4aliTMXusslKLArPcEI+XYd w04YetUkJc+3UKz5JImYlPrDFlfO6Ovz2h9mkfKTr+2XRaPGClKqURcu0GIApywWg0Lx A3iosyGfAaGvfQCLwLzqozXmOSyP1IEQsdWSk8Tr1YX05/DIGX1KSQHT6YBCCa7gVlaU DDKfDpPUOWrzXjY5tT5XtdRPu9QUoiO3Tq+g7El3OCnV8T5FllsiPDc1O/ciWFwZtLxn Y4io0KeWsqiQTGuHoPp1VUEHEWVGIw+/AquTT5xwOYSVMGfriWje3Xe6b5HqquwQ76eO 1Cpg==

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:

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:

Attachment: A.mat
Description: Binary data

Attachment: b.vec
Description: Binary data