Re: color assignment in an Mathematica IFS
- To: mathgroup at smc.vnet.net
- Subject: [mg79455] Re: color assignment in an Mathematica IFS
- From: Roger Bagula <rlbagula at sbcglobal.net>
- Date: Fri, 27 Jul 2007 05:49:41 -0400 (EDT)
- References: <200707241012.GAA26515@smc.vnet.net> <f86pua$nk9$1@smc.vnet.net>
Daniel Lichtblau wrote:
>
>The primary bottleneck is in the iterative flattening of a growing list,
>inside the loop. This in effect makes it a nested loo, taking complexity
>from O(n) to O(n^2). The code below is probably equivalent and should be
>reasonably fast.
>
>dlst = RandomInteger[{1,4}, {10000}];
>
>f[j_,{x_,y_}] := 0.5*{x,y} + 0.5*Reverse[IntegerDigits[j-1,2,2]]
>
>pt = {0.5, 0.5};
>
>cr[n_] := RGBColor[Sequence[Drop[RotateLeft[{0,0,0,1},n-1],1]]]
>
>ptlst = Table[{cr[dlst[[j]]],Point[pt=f[dlst[[j]],Sequence[pt]]]},
> {j,Length[dlst]}];
>
>Show[Graphics[ptlst], AspectRatio -> Automatic, PlotRange -> All]
>
>
>Daniel Lichtblau
>Wolfram Research
>
>
>
Daniel Lichtblau
Wolfram Research
Thanks.
This works very fast here:
Clear[f, dlst, pt, cr, ptlst]
dlst = Table[ Random[Integer, {1, 4}], {n, 10000}];
f[j_, {x_, y_}] := 0.5*{x, y} + 0.5*Reverse[IntegerDigits[j - 1, 2, 2]]
pt = {0.5, 0.5};
cr[n_] = If[n - 1 == 0, RGBColor[0, 0, 1], If[n - 2 ==
0, RGBColor[0, 1, 0], If[n - 3 == 0, RGBColor[1, 0, 0], RGBColor[0, 0,
0]]]]
ptlst = Table[{cr[dlst[[j]]], Point[pt = f[dlst[[j]], Sequence[pt]]]},
{j, Length[dlst]}];
Show[Graphics[ptlst], AspectRatio -> Automatic, PlotRange -> All]
I think you are going to save me a lot of time.
Roger Bagula
- Follow-Ups:
- Re: Re: color assignment in an Mathematica IFS
- From: Daniel Lichtblau <danl@wolfram.com>
- Re: Re: color assignment in an Mathematica IFS
- References:
- color assignment in an Mathematica IFS
- From: Roger Bagula <rlbagula@sbcglobal.net>
- color assignment in an Mathematica IFS