@@ -7,7 +7,7 @@ export all;
77
88/** <!--*******************************************************************-->
99 *
10- * @fn complex escapeValue (complex z, int depth)
10+ * @fn int, complex escapeTimeAndValue (complex z, int depth)
1111 *
1212 * @brief iteratively computes c = c*c + z starting from c=z.
1313 * terminates either when |c| > 2 or depth iterations
@@ -16,46 +16,34 @@ export all;
1616 *
1717 * @return final complex value
1818 *****************************************************************************/
19- int, complex escapeTimeAndValue(complex z, int depth)
19+ int, complex escapeTimeAndValue (complex z, int depth)
2020{
21- i=0; c=z;
21+ i=0; c=z;
2222
23- while( (normSq( c) <= 4d) && (i <= depth)) {
24- c=c*c+z; i++;
25- }
23+ while( (normSq( c) <= 4d) && (i <= depth)) {
24+ c=c*c+z; i++;
25+ }
2626
27- return(i, c);
27+ return(i, c);
2828}
2929
3030/** <!--*******************************************************************-->
3131 *
32- * @fn complex[*] escapeValue (complex[* ] z, int depth)
32+ * @fn int[m,n], complex[m,n] escapeTimeAndValue (complex[m,n ] z, int depth)
3333 *
3434 * @brief maps escapeValue to an entire array of complex numbers
3535 *
3636 *****************************************************************************/
3737inline
38- int[.,. ], complex[.,. ] escapeTimeAndValue( complex[.,. ] plane, int depth)
38+ int[m,n ], complex[m,n ] escapeTimeAndValue ( complex[m,n ] plane, int depth)
3939{
40- times = with {
41- ( . <= x <= .) {
42- t, v = escapeTimeAndValue( plane[x], depth);
43- } : t;
44- } : genarray( shape( plane), 0);
45-
46- values = with {
47- ( . <= x <= .) {
48- t, v = escapeTimeAndValue( plane[x], depth);
49- } : v;
50- } : genarray( shape( plane), toc(0));
51-
52- return( times, values);
40+ return { iv -> escapeTimeAndValue (plane[iv]) };
5341}
5442
5543
5644/** <!--*******************************************************************-->
5745 *
58- * @fn double normalizedIterationCount(int n, complex zn)
46+ * @fn double[d:shp] normalizedIterationCount (int[d:shp] n, complex[d:shp] zn)
5947 *
6048 * @brief normalizes the iteration counts in "n" taking the distance of the
6149 * corresponding final complex numbers from the origin into account.
@@ -66,15 +54,15 @@ int[.,.], complex[.,.] escapeTimeAndValue( complex[.,.] plane, int depth)
6654 * @return the normalized iteration counts
6755 *****************************************************************************/
6856inline
69- double[* ] normalizedIterationCount(int[* ] n, complex[* ] zn)
57+ double[d:shp ] normalizedIterationCount(int[d:shp ] n, complex[d:shp ] zn)
7058{
7159 return( where( (norm( zn) <= 2d) , 0d , tod(n+1) - log2( log2( norm( zn)))));
7260}
7361
7462
7563/** <!--*******************************************************************-->
7664 *
77- * @fn color[.,. ] doubleArrayToRGB( double[.,. ] a)
65+ * @fn color[d:shp ] doubleArrayToRGB( double[d:shp ] a)
7866 *
7967 * @brief transforms an array of doubles into RGB values, by
8068 * FIRST scaling them into values between 0.0 and 360.0, and
@@ -85,7 +73,7 @@ double[*] normalizedIterationCount(int[*] n, complex[*] zn)
8573 * @return RGB values
8674 *****************************************************************************/
8775inline
88- Color8::color[.,. ] doubleArrayToRGB( double[.,. ] a)
76+ Color8::color[d:shp ] doubleArrayToRGB( double[d:shp ] a)
8977{
9078 max = maxval( a);
9179 min = minval( a);
0 commit comments