This forum has been archived. All content is frozen. Please use KDE Discuss instead.

solving a linear sparse problem

Tags: None
(comma "," separated)
medic123
Registered Member
Posts
25
Karma
0
OS

solving a linear sparse problem

Wed Oct 12, 2011 9:05 am
Hi all,

First I have to say that i apreciate using Eigen and everything worked fine until now. The problem:

I have to solve a linear problem with a squared sparse matrix of variable size (from 20 up to 100 000 rows/col). RHS is a sparse vector (no problem to set it to dense) and the solution would be a dense vector. Matrices and vectors have been created with Eigen.
I'm working on Windows 7 64 Bit version and using visual studio 2010.

Since there is no sparse solver included in Eigen, which solver would you recommend to use? I'd like a rather fast, stable and mainly easy to implement solver for this issue (I guess everyone wishes that...^^).
I tried the UmfPack und the SuperLu so far, because of the support modules for them included in Eigen. I downloaded all needed packages, read tons of documentations but I still have no clue how "install" this packages and make them work with Eigen.

I'm grateful for any help.
medic123
Registered Member
Posts
25
Karma
0
OS

Re: solving a linear sparse problem

Wed Oct 12, 2011 1:14 pm
Update: I included all needed files now (includepath), so that the compiler stops complaining about missing files (UFconfig, AMD...) I tried your example:
Code: Select all
#define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET // if with this

#include <iostream>
/*#include<string>
#include <vector>
#include<iterator>*/


//#include<Eigen/Eigen>
//#include <Eigen/Sparse>
#include <unsupported/Eigen/UmfPackSupport>
//#include <unsupported/Eigen/SparseExtra>

using namespace std;
using namespace Eigen;



int main() {


DynamicSparseMatrix<double>  A(5,5);
   A.insert(0,0) = -1.3;
   A.insert(0,4) =  1.75;
   A.insert(1,1) =  5.28;
   A.insert(2,0) = -1.1;
   A.insert(2,3) = 23.0;
   A.insert(3,3) = 4.8;
   A.insert(4,0) = -2.3;
   A.insert(4,2) = 7.54;
   A.insert(4,4) = 2.0;

   A.finalize();

   cout << A << endl;

   VectorXd b(5), x(5);

   b << 0.0 , 1.3, 0.0, -2.5, 1.1;
   

   cout << b << endl;
   cout << x <<endl;

   // solve Ax = b using UmfPack:
SparseLU<SparseMatrix<double>,UmfPack> lu_of_A(A);
if(!lu_of_A.succeeded()) {
  // decomposiiton failed
  return 0;
}
if(!lu_of_A.solve(b,&x)) {
  // solving failed
  return 0;
}


return 0;
}


But I get compiling errors from the linker:
"1>main.obj : error LNK2001: Nicht aufgelöstes externes Symbol "_umfpack_di_free_numeric".
1>main.obj : error LNK2001: Nicht aufgelöstes externes Symbol "_umfpack_di_free_symbolic".
1>main.obj : error LNK2001: Nicht aufgelöstes externes Symbol "_umfpack_di_symbolic".
1>main.obj : error LNK2001: Nicht aufgelöstes externes Symbol "_umfpack_di_numeric".
1>main.obj : error LNK2001: Nicht aufgelöstes externes Symbol "_umfpack_di_solve".
1>H:\Visual Studio 2010\Projects\ACID3D_Prototype\Debug\ACID3D_Prototype.exe : fatal error LNK1120: 5 nicht aufgelöste externe Verweise."
Which means that this links can not be resolved.

Additional Question:
When this finaly works, I want to improve speed by using ATLAS instead of the standard implemented BLAS. How do I tell Eigen, or UMFPack to do so?

thanks, medic
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: solving a linear sparse problem

Thu Oct 13, 2011 7:01 pm
look at the devel branch, there are a conjugate gradient, a bicgstab, and a direct cholesky solver. To use umfpack you have to link your application against the umfpack library and its dependencies that depends on how your umfpack copy has been compiled...


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]