Last active
February 24, 2016 05:03
-
-
Save gkthiruvathukal/4bb286f33f3966ecb9e9 to your computer and use it in GitHub Desktop.
Scala multidimensional array (problems)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // This takes forever and seems to use a lot more memory than expected | |
| Array.ofDim[Double](2048, 2048, 2048) | |
| // This seems to work faster and uses less memory. | |
| def get1d(d1 : Int, init : Double) = Stream.continually(init) take d1 toArray | |
| def get2d(d1 : Int, d2 : Int, init : Double) = Stream.continually( get1d(d2, init) ) take d1 toArray | |
| def get3d(d1 : Int, d2 : Int, d3 : Int, init : Double) = Stream.continually( get2d(d2, d3, init) ) take d1 toArray | |
| // More testing is needed. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment