Jump to content
at3s

Delphi implementation of Aberth–Ehrlich method and precision problem

Recommended Posts

3 hours ago, at3s said:

Can you please suggest libraries for the eigenvalues\eigenvectors finding?

Is it possible to use them in Delphi code?

ARPACK is recommended for extracting a small number of eigen vectors from a huge problem.

 

LAPACK has effective methods for extracting all solutions using a direct method. 

 

Neither are easy to use from Delphi. I have done so but it isn't for the faint of heart. Especially ARPACK. 

 

The famous C++ Eigen library is very capable though and easy to use. I'd suggest you wrap that in a DLL. 

 

Start in Matlab to prove that it can do the calculation sufficiently quickly for a typical matrix that you will work with. 

 

Then write a C++ program in Eigen to solve the same problems. Does that work effectively? 

 

Then, and only then, try to wrap it up to be called from Delphi. 

Edited by David Heffernan
  • Like 3
  • Thanks 1

Share this post


Link to post
On 8/20/2020 at 10:10 PM, David Heffernan said:

ARPACK is recommended for extracting a small number of eigen vectors from a huge problem.

 

LAPACK has effective methods for extracting all solutions using a direct method. 

 

Neither are easy to use from Delphi. I have done so but it isn't for the faint of heart. Especially ARPACK. 

 

The famous C++ Eigen library is very capable though and easy to use. I'd suggest you wrap that in a DLL. 

 

Start in Matlab to prove that it can do the calculation sufficiently quickly for a typical matrix that you will work with. 

 

Then write a C++ program in Eigen to solve the same problems. Does that work effectively? 

 

Then, and only then, try to wrap it up to be called from Delphi. 

I've noticed that Eigen::ComplexEigenSolver works much slower for large matrices than LAPACKE_zgeev from OpenBLAS library.

Share this post


Link to post
2 hours ago, at3s said:

I've noticed that Eigen::ComplexEigenSolver works much slower for large matrices than LAPACKE_zgeev from OpenBLAS library.

That would be surprising. I wouldn't want to comment without seeing what options you used when calling the functions. 

Share this post


Link to post
2 minutes ago, David Heffernan said:

That would be surprising. I wouldn't want to comment without seeing what options you used when calling the functions.  

Actually I did not make a wrapper for Eigen library yet, but rather ran within the VC++ code:

Eigen::MatrixXcd A(n, n);
Eigen::ComplexEigenSolver<Eigen::MatrixXcd> es_c(A);

And simple calling of function from the libopenblas.dll within the Delphi:

LAPACKE_zgeev(101, 'N', 'V', n, a, lda, w, vl, ldvl, vr, ldvr);

It was tested for the same 150x150 matrix with the complex values.

VC++ ComplexEigenSolver: 19.0 s

Delphi LAPACKE_zgeev:          1.5 s
 

Share this post


Link to post
15 minutes ago, David Heffernan said:

Your lapack call does not calculate eigen vectors. The eigen call does. 

Nope, it does.

Truth is that it doesn't compute "left" eigenvectors (vl array), but "right" yes (vr array).

Share this post


Link to post

OK, I see. We'll, I don't really know. It seems odd because they use the same algorithm as I understand it. I imagine there is a good explanation. But there'd need to be more detail. 

Share this post


Link to post
2 minutes ago, David Heffernan said:

OK, I see. We'll, I don't really know. It seems odd because they use the same algorithm as I understand it. I imagine there is a good explanation. But there'd need to be more detail.  

I geuss the difference is because LAPACK is based on Fortran math.

And probably one of reason is Fortran is faster in calculations.

The other one could be difference in algorythm as well.

I'm interesting, if it's possible to call a Fortran function within the Delphi code like libopenblas.dll does?

Share this post


Link to post
14 minutes ago, at3s said:

I geuss the difference is because LAPACK is based on Fortran math.

That isn't it. 

 

14 minutes ago, at3s said:

And probably one of reason is Fortran is faster in calculations.

Not true. C++ compilers can perform just as well. 

 

15 minutes ago, at3s said:

The other one could be difference in algorythm as well.

Possible. But I doubt it. I bet you are asking different questions, and not comparing like with like. 

 

16 minutes ago, at3s said:

I'm interesting, if it's possible to call a Fortran function within the Delphi code like libopenblas.dll does?

Quite simple to call libopenblas from delphi. I do just that. 

Share this post


Link to post
9 hours ago, David Heffernan said:

Possible. But I doubt it. I bet you are asking different questions, and not comparing like with like. 

I just trying to check if it's possible to find eigenvalues\eigenvectors using Eigen library so fast as libopenblas.dll does.

 

9 hours ago, David Heffernan said:

Quite simple to call libopenblas from delphi. I do just that.

I am as well.

Share this post


Link to post
1 minute ago, at3s said:

I just trying to check if it's possible to find eigenvalues\eigenvectors using Eigen library so fast as libopenblas.dll does.

I'd be astounded if that was not the case. Eigen has a very good reputation. Certainly for basic matrix arithmetic performance is excellent. And I'd be astonished if it could not match openblas for eigensolves.

 

1 minute ago, at3s said:

I am as well.

Then I don't know why you asked if it was possible to do something that you were already doing.

Share this post


Link to post
1 hour ago, David Heffernan said:

Then I don't know why you asked if it was possible to do something that you were already doing.

I'm interesting in eigen tasks solving has been implemented in my project.

Since an implementation of Aberth–Ehrlich method was fail, I've implemented libopenblas.dll function calling.
And now I'm trying to implement Eigen library usage as you proposed.
But speed of calculation is a top priority requirement for me.

Share this post


Link to post
16 hours ago, at3s said:

I'm interesting, if it's possible to call a Fortran function within the Delphi code like libopenblas.dll does?

When you said that I thought you meant that you were not able to call libopenblas from Delphi.  But then you later said that you were doing that.  So I still don't understand that statement.

 

Notwithstanding, I am sure you will be able to work out which library is best suited to your needs.

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×