1

I'm trying rewrite matlab eigs function as C++ wrapper of ARPACK because arpack++ (C++ wrapper for arpack) is very slow in regular mode, shift-invert mode doesn't work properly. But I'm in stuck and I need a kick. :)

LU Factorization

Matlab function:

function [L,U,pp,qq,dgAsB] = LUfactor
    AsB = A;
    [L,U,pp,qq,dgAsB] = lu(AsB);
end

Is it any library for c++ which return me output like code above? And I'd like ask what does mean qq and dgAsB. Meaning L and U is clear and pp too, I learned it at uni but I don't know what is meaning others.

Arpack OP

function [v] = AminusSigmaBsolve (u)

     v = qq*(U \ (L \ (pp*(dgAsB \ u))));

end

Arpack OP for shift invert mode is defined (A - sigma*I )^-1*I*u. First I can't understand how matlab code is related to Arpack OP. And I'd like to ask if exists any library for C++ with which I can write efficiency code of AminusSigmaBsolve in C++.

Thank you for your answers because I'd like to use program as efficient as Matlab in C++.

user47779
  • 411
  • 1
  • 4
  • 9
  • I'm confused. Do you want to do eigen solving, or LU decomposition. – David Heffernan Mar 04 '14 at 22:33
  • I also am sceptical of your claims that arpack++ does not work. Respectfully I think it more likely that it works fine but that you are perhaps misusing it one way or another. – David Heffernan Mar 04 '14 at 22:39
  • Both. LU decomposition is tool for compute inverse matrix in Arpack OP. – user47779 Mar 04 '14 at 22:39
  • Do you really want to compute the inverse? Usually that's something that should not be done. Usually you use LU to solve Ax=b for the unknown x. And LU and eigen solve are different. If you want to do LU, which library do you want to use? – David Heffernan Mar 04 '14 at 22:42
  • As for the return values of `LUFactor`, the docs explain them: http://www.mathworks.co.uk/help/matlab/ref/lu.html – David Heffernan Mar 04 '14 at 22:52
  • Ok, fine. Arpack works in few modes regular it solve clasical problem A*x = lambda*x and shift-invert (A - sigma*I)^-1*x = lamdba*x. Mode which matlab use for solving smallest eigenvalues of spectra is shift-invert small-eigenvalues became largest a it very quick converge. LU decomposition is used for inversion. Next I'm using arpack++ right now but solving is very slowly for matrixes about 14000x14000. I computation k smallest eigenvalues. – user47779 Mar 04 '14 at 22:52
  • arpack++ just has plain old ARPACK underneath. So clearly you are asking a different problem in your code when compared to your MATLAB code. But arpack++ does work. Don't give up on it. The LU factorization will need to be done by something other than ARPACK. I think MATLAB uses UMFPACK for sparse LU. If your product is commercial then you'll want to look for something other than UMFPACK . Or pay up! – David Heffernan Mar 04 '14 at 22:55
  • My arpack++ code is: ARluSymMatrix matrix( this->L->rows, this->L->m->nnz(), matrix2csr.vals, matrix2csr.colIndx, matrix2csr.rowIndx ); ARluSymStdEig problem( 120, matrix, "SM" ); problem.SetRegularMode(); problem.ChangeMaxit( iter ); But in matlab solving takes about 10s and in c++ takes about 15minutes. – user47779 Mar 04 '14 at 22:55
  • No my product is not commercial it is my thesis but my suvervisor can't give me any advice so I trying it on internet and I little bit confused too. – user47779 Mar 04 '14 at 22:59
  • Problem must be in your code. Surely. Presumably arpack++ comes with examples. Anyway, I don't think this can be done in comments. Your question asks for alternatives to arpack++ but I think that's a mistake. – David Heffernan Mar 04 '14 at 23:00
  • Ok. I'll be very happy that I haven't to write new software and I can use Arpack++. So your advice is use umfpack arpack++ function instead SuperLU? – user47779 Mar 04 '14 at 23:06
  • No. SuperLU is good. Arpack++ is good. UMFPACK is good. You've picked SuperLU for the LU part, and arpack++ for the eigen solve. Both fine libraries. Stick with them, and debug your code. Don't give up on the libraries and hope that picking different libraries will solve the problem. The problem is in your code and you just need to stay with it and debug it. That's my opinion. – David Heffernan Mar 04 '14 at 23:08
  • Hello David, I'm trying your advice. Example arpack++ shift-invert works fine in example using for factorization SuperLU. Maybe I make mistake in definition of matrix, so I try rewrite CSC format by myself and debug it now I use boost matrix for creating sparse row format, but in regular mode it works fine but very slowly. Next I tried compile example shift-invert example with use UMFPACK for factorization and I got this error. http://pastebin.com/7YFyJ5R3 undefined reference to `umd21i_' – user47779 Mar 05 '14 at 15:03
  • Replacing SuperLU with UMFPACK won't help. I can't debug this in comments. Sorry. – David Heffernan Mar 05 '14 at 15:11
  • UMFPACK worked perfectly for me for sparse LU integrated in a commercial C++ project, you need to provide BLAS and check the licenses (version <= 5.1 is LGPL). – Iban Cereijo Mar 13 '14 at 10:01

0 Answers0