hughperkins / jeigen

Java wrapper for Eigen C++ fast matrix library
Other
106 stars 31 forks source link

Compatibility MAC #8

Closed joerupen closed 8 years ago

joerupen commented 9 years ago

Hi,

I am getting the following error when I try to use the eigen solver:

UnsatisfiedLinkError Unable to load library 'jeigen-linux-64': Native library (darwin/libjeigen-linux-64.dylib) not found in resource path

I can see the file ~/.jeigen/native2/libeigen-linux-64.so being extracted for linux, but no version for the MAC. Are you considering to support the MAC or can give any hint how to solve it?

hughperkins commented 9 years ago

I think you would need to modify the lines at https://github.com/hughperkins/jeigen/blob/master/src/java/jeigen/JeigenJna.java#L39-L57 to search for a mac .dylib at an appropriate location.

You'll first need to build the .dylib , which I think you can do by building the CMakeLists.txt file at https://github.com/hughperkins/jeigen/blob/master/src/native/CMakeLists.txt , ie something like:

cd src/native
mkdir build
cd build
ccmake ..
make -j 4

This should create either a .so file or a .dylib (not sure which :-P ), which you can then reference from the JeigenJna.java file.

(PS if you can solve this somehow, I'd love to have a pull request for this. I support Mac in the sense of eg trying to answer issues on it; unfortunately I dont have access to a Mac, so I cant actually test things, or build binaries, myself)

joerupen commented 9 years ago

I would like to contribute a patch for the MAC. However, in the meanwhile I got it up and running on Linux, trying to solve Ax=b. The problem for me is that I get wrong results with JEigen. The matrix is quite large (11k*11k). With python/scipy or Matlab I get correct results, but not with JEigen, nor with JBLAS. So for me this is a blocker atm. I know that the Matrix might be poorly conditioned and I could try to scale rows in a particular way prior to solving the problem, but for now the scipy solutions works well for me (even if I have to call a bash script from java). Are you aware of some numerical limitations to JEigen, or am I the first one to report this issue?

hughperkins commented 9 years ago

You're the first person to report this issue :-) But note that there are different types of solvers in eigen, with different characteristics:

http://eigen.tuxfamily.org/dox/group__TutorialLinearAlgebra.html

I dont remember which one Jeigen is using: you'll need to check the code. I would reckon it's using some compromise between accurate but slow, and fast but inaccurate.

joerupen commented 9 years ago

Thanks for the answer. I have tried the accurate and slow solver, but I will give it another try. Maybe it's an error on my side so I don't want to open a issue for this problem. The solver issue seems more related to the matlab hack (http://icl.cs.utk.edu/lapack-forum/viewtopic.php?p=497&) trying to solve underdetermined systems. I don't have much influence on the matrix that I am trying to solve. I get it from a provider, only knowing how the intended solution looks like. I just want to make sure that in the first place I get the same results. Probably the provider uses matlab himself, but I couldn't find a java-lib that calculates the same result.

hughperkins commented 9 years ago

Hmmm, interesting. I reckon that the scope of Jeigen should be to wrap existing implementations in Eigen, rather than provide original implementations, so I reckon that if you want to add additional functionality, ie solvers for under-determined systems, you should first request this implementation in the underlying Eigen library. Once it is implemented in Eigen, I can look at adding a wrapper for that.

hughperkins commented 8 years ago

I think this issue has strayed from the original title. jeigen works on mac now. I will close this issue.