jblas-project / jblas

Linear Algebra for Java
http://jblas.org
BSD 3-Clause "New" or "Revised" License
590 stars 149 forks source link

Optimize matrix constructor to avoid extra array allocation #38

Closed srowen closed 10 years ago

srowen commented 10 years ago

Mikio I was noodling around the matrix code to see if I could optimize a bit the parts used in Spark MLlib. I found one non-trivial optimization that avoids an extra array allocation. I couldn't help fiddling with a few other things, which you can reject.

I'm also checking the appetite for some other optimizations that might involve adding a few more methods to the API (like an "increment value" method, and "self times transpose") but that's for another time.

mikiobraun commented 10 years ago

Hi Sean,

Thanks! I'll have a look tomorrow (CET), but I don't think there will be issues. I'm also open to any API additions which don't require touching the Fortran parts ;)

-M Am 17.02.2014 18:53 schrieb "Sean Owen" notifications@github.com:

Mikio I was noodling around the matrix code to see if I could optimize a bit the parts used in Spark MLlib. I found one non-trivial optimization that avoids an extra array allocation. I couldn't help fiddling with a few other things, which you can reject.

I'm also checking the appetite for some other optimizations that might involve adding a few more methods to the API (like an "increment value"

method, and "self times transpose") but that's for another time.

You can merge this Pull Request by running

git pull https://github.com/srowen/jblas MatrixConstructorOptimization

Or view, comment on, or merge it at:

https://github.com/mikiobraun/jblas/pull/38 Commit Summary

  • Optimize matrix constructor to avoid extra array allocation, and other more trivial quick ones like not compiling regexes repeatedly in loops.

File Changes

  • M src/main/java/org/jblas/ComplexDoubleMatrix.javahttps://github.com/mikiobraun/jblas/pull/38/files#diff-0(8)
  • M src/main/java/org/jblas/ComplexFloatMatrix.javahttps://github.com/mikiobraun/jblas/pull/38/files#diff-1(8)
  • M src/main/java/org/jblas/DoubleMatrix.javahttps://github.com/mikiobraun/jblas/pull/38/files#diff-2(34)
  • M src/main/java/org/jblas/FloatMatrix.javahttps://github.com/mikiobraun/jblas/pull/38/files#diff-3(34)

Patch Links:

Reply to this email directly or view it on GitHubhttps://github.com/mikiobraun/jblas/pull/38 .