x404.co.uk http://www.x404.co.uk/forum/ |
|
Recursive methods and concurrency http://www.x404.co.uk/forum/viewtopic.php?f=4&t=17038 |
Page 1 of 1 |
Author: | forquare1 [ Sun Aug 19, 2012 12:55 am ] | ||||||||||||||||||
Post subject: | Recursive methods and concurrency | ||||||||||||||||||
Evening all, Using Obj-C, I'm working out all the permutations of 0 and 1 for a given number of elements in an array. For example, if you had an array length of 4, the permutations would be:
Now, I'm trying to do the same with an array with the size 49152, and it's going to take a while...I've got four cores in this iMac, so why not use them? It's been ages since I've done anything about concurrency, and it was only really touched on in Java with regards to GUI programming. The methods I'm using looks something like this:
So, two questions: 1) Is this type of work possible to do concurrently? 2) How might a concurrent way look? I'm presumably going to be doing some blocks/GCD stuff... Many thanks, Ben |
Author: | Fogmeister [ Sun Aug 19, 2012 7:52 am ] |
Post subject: | Recursive methods and concurrency |
The first thing I would ask is what is the underlying problem you are trying to solve. With recursive functions of that size you might find you run into problems of memory overflow. There could possibly be another way around the problem. If not I'll try to find the WWDC that explains what you need. |
Author: | forquare1 [ Sun Aug 19, 2012 11:45 am ] |
Post subject: | Re: Recursive methods and concurrency |
I'm just sort of fiddling around with permutations. Thought it could be fun programming idea, then perhaps choose a random permutation and colour in the pixels, with 0 being one colour, and 1 being a different colour. 49152 is the amount of pixels in an image sized 256x192. So there would be two separate programs, the second is only sort of a thought. Recursion seemed a fun way to do it, but without thinking too much, a two loops, one inside the other, in calculate() would probably do a good job. Thanks for taking a look though ![]() |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |