Re: [Haskell-cafe] How to use arrays efficiently?

2008-05-16 Thread Don Stewart
You'd have to write a wrapper that implements an array of triples as a triple of arrays. This isn't too hard. There's a new library in the works that should make this a lot easier -- Don abhay.parvate: >As far as I know, you can't. It needs machine representable types, such as >Int, Doub

Re[2]: [Haskell-cafe] How to use arrays efficiently?

2008-05-16 Thread Bulat Ziganshin
Hello Lauri, Friday, May 16, 2008, 5:45:50 PM, you wrote: > Yes, of course. How blind of me. Here is one more question. > If you change IOUArray to IOArray and add $! in front of the two > summations in the previous code, it still works correctly. > But can you do similar trick with Array and a

Re[2]: [Haskell-cafe] How to use arrays efficiently?

2008-05-16 Thread Bulat Ziganshin
Hello Ketil, Friday, May 16, 2008, 5:27:29 PM, you wrote: > I guess it would be possible to have UArray Int (# Double, Double, > Double #) - packing all three Doubles unboxed into the array, but I've > no clue how to go about automating that. unoxed tuple doesn't have a box so it cannot be insta

Re: [Haskell-cafe] How to use arrays efficiently?

2008-05-16 Thread Lauri Oksanen
Yes, of course. How blind of me. Here is one more question. If you change IOUArray to IOArray and add $! in front of the two summations in the previous code, it still works correctly. But can you do similar trick with Array and accumArray? I have tried to put $! in different places in the first cod

Re: [Haskell-cafe] How to use arrays efficiently?

2008-05-16 Thread Ketil Malde
"Lauri Oksanen" <[EMAIL PROTECTED]> writes: > Thanks for help. I did some tests with UArray and it does the trick. > The problem remaining is, how to implement UArray Int (Double, Double, > Double)? As (UArray Int Double, UArray Int Double, UArray Int Double). Or as UArray Int Double, but with a

Re: [Haskell-cafe] How to use arrays efficiently?

2008-05-16 Thread Henning Thielemann
On Fri, 16 May 2008, Lauri Oksanen wrote: Thanks for help. I did some tests with UArray and it does the trick. The problem remaining is, how to implement UArray Int (Double, Double, Double)? Maybe an (UArray (Int,Int) Double) could help, where the second index range is fixed to (0,2). _

Re: [Haskell-cafe] How to use arrays efficiently?

2008-05-16 Thread Lauri Oksanen
Thanks again. Here is my solution in case that somebody else runs into similar problem. This isn't very elegant and I would be interested to know if somebody has a better solution. Surely many people have encountered this kind of problem where you want to force evaluation of some expression at give

Re[2]: [Haskell-cafe] How to use arrays efficiently?

2008-05-16 Thread Bulat Ziganshin
Hello Lauri, Friday, May 16, 2008, 3:44:19 PM, you wrote: impossible. you can try parallel arrays > Thanks for help. I did some tests with UArray and it does the trick. > The problem remaining is, how to implement UArray Int (Double, Double, > Double)? > UArray source code is far too cryptic f

Re: [Haskell-cafe] How to use arrays efficiently?

2008-05-16 Thread Abhay Parvate
As far as I know, you can't. It needs machine representable types, such as Int, Double, Char, etc. But making a tuple of three UArray Int Double may help. 2008/5/16 Lauri Oksanen <[EMAIL PROTECTED]>: > Thanks for help. I did some tests with UArray and it does the trick. > The problem remaining is

Re: [Haskell-cafe] How to use arrays efficiently?

2008-05-16 Thread Lauri Oksanen
Thanks for help. I did some tests with UArray and it does the trick. The problem remaining is, how to implement UArray Int (Double, Double, Double)? UArray source code is far too cryptic for me. Regards, Lauri On Fri, May 16, 2008 at 11:37 AM, Bulat Ziganshin <[EMAIL PROTECTED]> wrote: > Hello L

Re: [Haskell-cafe] How to use arrays efficiently?

2008-05-16 Thread Bulat Ziganshin
Hello Lauri, Friday, May 16, 2008, 12:19:29 PM, you wrote: >     pixelArray :: Array Int Color it's boxed array which means that its elements are stored as thunks computed only when you actually use them. try UArray instead: http://haskell.org/haskellwiki/Modern_array_libraries -- Best rega

[Haskell-cafe] How to use arrays efficiently?

2008-05-16 Thread Lauri Oksanen
Hi, I have a list of index-value pairs and I want to get a list which is sorted by the index and which contains index-wise sums of all the values. Here is a function that does this (and a bit more). --- pixelHistogram samples = let index s t = let x = round $ (fromIntegral imageWidth)