Re: [Haskell-cafe] Optimizing cellular automata evaluation (round 2)

2007-11-30 Thread Jon Harrop
On Friday 30 November 2007 00:31, Justin Bailey wrote: I represent the automata as an array of integers, where each bit represents a cell. Mathematica uses a single arbitrary-precision integer to represent each generation of a 1D automaton. The rules to derive the next generation are compiled

Re: [Haskell-cafe] Optimizing cellular automata evaluation (round 2)

2007-11-30 Thread Luke Palmer
On Nov 30, 2007 6:03 PM, Justin Bailey [EMAIL PROTECTED] wrote: On Nov 29, 2007 9:11 PM, Jon Harrop [EMAIL PROTECTED] wrote: Mathematica uses a single arbitrary-precision integer to represent each generation of a 1D automaton. The rules to derive the next generation are compiled into

Re: [Haskell-cafe] Optimizing cellular automata evaluation (round 2)

2007-11-30 Thread Justin Bailey
On Nov 29, 2007 9:11 PM, Jon Harrop [EMAIL PROTECTED] wrote: Mathematica uses a single arbitrary-precision integer to represent each generation of a 1D automaton. The rules to derive the next generation are compiled into arithmetic operations on the integer. The offloads all such work onto

Re: [Haskell-cafe] Optimizing cellular automata evaluation (round 2)

2007-11-30 Thread Justin Bailey
On Nov 29, 2007 4:45 PM, Felipe Lessa [EMAIL PROTECTED] wrote: Why don't you use an UArray of Bools? They're implemented as bit arrays internally, AFAIK (e.g. see http://www.haskell.org/haskellwiki/Shootout/Nsieve ). And then you would get rid of a lot of shifts and masks in your code --

Re: [Haskell-cafe] Optimizing cellular automata evaluation (round 2)

2007-11-30 Thread Laurent Deniau
Justin Bailey wrote: On Nov 29, 2007 9:11 PM, Jon Harrop [EMAIL PROTECTED] wrote: Mathematica uses a single arbitrary-precision integer to represent each generation of a 1D automaton. The rules to derive the next generation are compiled into arithmetic operations on the integer. The offloads

[Haskell-cafe] Optimizing cellular automata evaluation (round 2)

2007-11-29 Thread Justin Bailey
I posted awhile back asking for help improving my cellular automata program. I am competing with a C program which evolves CAs using a fairly simple genetic algorithm. The algorithm involves evaluating 100 rules on 100 CAs, 100 times. In C this takes about 1 second. In my Haskell version, it takes

Re: [Haskell-cafe] Optimizing cellular automata evaluation (round 2)

2007-11-29 Thread Felipe Lessa
On Nov 29, 2007 10:31 PM, Justin Bailey [EMAIL PROTECTED] wrote: I represent the automata as an array of integers, where each bit represents a cell. Why don't you use an UArray of Bools? They're implemented as bit arrays internally, AFAIK (e.g. see