-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vector in Eigen Library is indeed much faster #197
Comments
I have just tried boost::ublas. For dense vector, it is slightly faster than our own |
I think |
Yes, it compiles, but then the whole program is slower than using our own sparse vector. I am not sure about whether it is because of |
I have modified the source code of Eigen. Now I can do arithematics among dense and sparse vector without using However, I am not sure if my modification is correct, although my program gives reasonable results with my modified Eigen. |
Oh, forgot to update the issue there. I submitted a pull request to Eigen to solve the problem about arithmetic among dense and sparse vector here, but the original author said that it is not a good fix and made his own fix here. So, the problem will be gone in next stable release I guess. Before that, using this, which is the stable version with the fix, may also work. |
I suggest to file a bug in their issues tracker first: http://eigen.tuxfamily.org/bz/. 👍 |
@kygx-legend It is already fixed at https://bitbucket.org/eigen/eigen/commits/043094f17aae |
I see. I mean the next time. |
Related to issue husky-team#197 Add a new set of vector operations with prefix sorted, namely, sorted_XXX. This set of APIs should only be used when the input sparse vectors are sorted ascendingly according to the feature number.
@Kelvin-Ng how's the status? |
We thought that it is slow before. I think it was because we did not use it correctly. See Lazy Evaluation and Writing Functions Taking Eigen Types as Parameters to understand how to use it correctly.
I have tried with my own program of dense vector version of SVRG (single machine only). After changing from our own
Vector
toVectorXd
in Eigen, the speed has improved from about 20 seconds to 8 seconds.However, there are some problems about the interface.
First, sparse and dense vector in Eigen do not have the same iterator interface, but I have managed to solve it by some tricks.
Second, I face some problems in arithmetics among sparse and dense vectors. I have not found a solution yet.
For
dvec + svec
andsvec + dvec
works fine. However, something like10 * dvec + 20 * svec
does not compile. To make it compile, we must write something ugly like10 * dvec + (20 * svec).eval()
. It means that we must compute20 * svec
into a sparse vector instead of a lazy update expression. So, the benefit of lazy update is lost. Also,(10 * dvec).eval() + 20 * svec
does not work.Despite the difficulty, due to the much higher performance, I think it worth spending some time to see how to make it work.
I don't want to write our own Vector with similar functionality as Eigen as this is a really tedious job.
The text was updated successfully, but these errors were encountered: