-
Notifications
You must be signed in to change notification settings - Fork 108
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
Can't use toBinary method on large matrices #282
Comments
As a workaround, you can traverse the matrix manually and write it into the file. |
Thanks for the response. I suppose I could do that, but then wouldn't I lose the "sparsity" of it. Well, I guess I could encode a value (say -1) for the "empty cells", but that seems a bit ugly. How difficult would it be for these classes to be serializable? Do you think the default writeObject() and readObject() methods would work? Howard |
Why losing sparsity? You can convert sparse matrices Also feel free to send a PR with the solution - I'm happy to merge that in. |
BTW, you're trying to allocate 2gb matrix on a 800mb heap. |
Are you sure? Here's my command line: /usr/java/jdk1.7.0_51/bin/java -Xmx8000m -cp .:./la4j-0.6.0.jar Howard On 9/28/16 4:22 PM, Vladimir Kostyukov wrote:
Howard Lander mailto:[email protected] |
Ahh I see. Actually, this looks like an integer overflow. Your cardinality is already pretty close to Int.MaxValue (15000 * 15000) and when we're trying to allocatate the output array we multiply that by 8 (as per a single double value) and get the negative result. One solution to this would be to use |
Hi Vladimir I'm was unaware of Matrix Market. It looks interesting. I'll definitely As far as the dense matrix goes, that was just my way of testing. We I was definitely considering trying to make these classes serializable FYI: here's the code I was testing. I was wondering what would happen if
Howard On 9/28/16 4:21 PM, Vladimir Kostyukov wrote:
Howard Lander mailto:[email protected] |
I think if you swap to a dense (from CRS) you should be fine in that test. It's cheaper to write 15000x15000 dense matrix than to write 15000x15000 sparse matrix (with |
See below. On 9/28/16 4:30 PM, Vladimir Kostyukov wrote:
Howard
Howard Lander mailto:[email protected] |
Matrices/Vectors are used to be serializeable. I decided to not do that by the same reason no one else should do that. Java's serialization is completely broken (both performance-wise and security-wise). You should look at Jackson instead. |
I'm afraid not, there is no easy fix to that. |
I don't doubt what you are saying. What happens when I have a sparse Are the security issues you mentioned in your other message the reason Howard On 9/28/16 4:33 PM, Vladimir Kostyukov wrote:
Howard Lander mailto:[email protected] |
Potentially uninformed question: Is Jackson better than Gson? I've used On 9/28/16 4:35 PM, Vladimir Kostyukov wrote:
Howard Lander mailto:[email protected] |
Thre is a limit on a max sparse matrix size in la4j. It's
Looking at this comparison table (which I'm quite sceptical about): https://java-matrix.org/ you can try MTJ and Parallel Colt and see if their limits are true for sparse matrices (16gb and 64gb correspondingly). |
Thanks for the info. I probably should have said by now that I really The largest matrix that we have currently is about 18600 by 18600, but I may just live with the limitation for now. I do have a workaround Thanks Howard On 9/28/16 4:52 PM, Vladimir Kostyukov wrote:
Howard Lander mailto:[email protected] |
Yeah, you should be fine with 18600x18600 matrices. I admit there is a bug in In the meantime, I'd advice to shove your matrices into Jackson and see if it works (it should!). You don't need Java's standard serialization for that. Jackson (If you're ok with JSON) or Kryo (for binary format). These libraries will do the trick much better (and faster and safer). |
The following code fails test class fails on a fairly small (but not sparse) matrix:
Here's the invocation:
/usr/java/jdk1.7.0_51/bin/java -Xmx8000m -cp .:./la4j-0.6.0.jar MatrixTestBug
java.lang.IllegalArgumentException
at java.nio.ByteBuffer.allocate(ByteBuffer.java:330)
at org.la4j.matrix.sparse.CRSMatrix.toBinary(CRSMatrix.java:1007)
at MatrixTestBug.main(MatrixTestBug.java:13)
and here's the code (MatrixTestBug.java)
import java.io.;
import org.la4j.;
public class MatrixTestBug {
}
One possible work around (at least for me) for this would be to restore the writeExternal and readExternal methods to the matrix classes. I suspect I could also ignore this problem if the matrix classes were serializable, as the only reason I am doing this is to write the matrix (and some other data) to a file. Any ideas?
Thanks
Howard
The text was updated successfully, but these errors were encountered: