[clean-list] Efficient unboxed 2D array creation
Shivkumar Chandrasekaran
shiv@ece.ucsb.edu
Wed, 19 Sep 2001 13:53:10 -0700
Hi,
I am looking for an efficient version to create unboxed 2D arrays (of
Real and Complex types). The usual approach:
createUnboxedRealArr2D :: !Int !Int !Real -> !*{#*{#Real}}
createUnboxedRealArr2D m n x = {createUnboxedRealArr n x \\ i <- r}
where
r = [0..m-1]
seems to be pathetically slow. I seem to recall this being discussed on
this list once before. I looked at htoclean to see if I can use C
somehow. But unfortunately that does not seem to be possible as htoclean
does not support arrays. I did notice the documentation mentioning
something about the ccall ABC instruction supporting arrays, but I
couldn't figure out how to use it. There does not seem to be anything in
StdEnv and StdLib of any use either (createArray_u does not seem to have
the appropriate instance).
Can someone please tell me how to do this efficiently? I hate to fake 2D
arrays with 1D arrays. Thanks,
--shiv--
PS: m and n are fairly large for me (in the 100s).