I need to use a lookup table in 3 dimensions. The table itself has 73x73x73 (389017) double values.
module Hammer.Texture.Table3D where
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as U
import Data.Vector.Unboxed (Vector)
table3D :: V.Vector (V.Vector (Vector Double))
table3D = V.fromList [table0, table1, ... table72]
table0 = V.fromList $ map U.fromList [
[1.973921e+01, 0.000000e+00, ... 0.000000e+00],
.....
[1.973921e+01, 0.000000e+00, ... 0.000000e+00]]
.....
table72 = V.fromList $ map U.fromList [
[1.973921e+01, 0.000000e+00, ... 0.000000e+00],
.....
[1.973921e+01, 0.000000e+00, ... 0.000000e+00]]
The problem is that GHC can't handle this size of Vector Double or [Double], the GHC compilation takes a lot of time (~ 2 min) until, finally, the memory blows up. It seems there is a memory leak on GHC or some bug because it works fine for very large String ([Char]).
What solutions, if any, are available for creating a "large" lookup tables (Double type) using GHC?
I can think of two possibilities:
Data.Map
or even just a plain function. If necessary, you can use this sparse data structure to generate your vectors (again at runtime).If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With