-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adjusted L8 to TP and TC #1
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ export all; | |
|
||
/** <!--*******************************************************************--> | ||
* | ||
* @fn : complex[.,.] genComplexArray( int[2] shp, complex cmin, complex cmax) | ||
* @fn : complex[2:shp] genComplexArray( int[2] shp, complex cmin, complex cmax) | ||
* | ||
* @brief generates an array of complex numbers with shape "shp" and | ||
* linearly increasing/decreasing values between "cmin" and "cmax". | ||
|
@@ -17,13 +17,12 @@ export all; | |
* | ||
*****************************************************************************/ | ||
inline | ||
complex[.,.] genComplexArray( int[2] shp, complex cmin, complex cmax) | ||
complex[2:shp] genComplexArray( int[2] shp, complex cmin, complex cmax) | ||
{ | ||
res = with { | ||
( . <= iv <= .) : cmin + toc( reverse( (tod(iv) / tod(shp)) | ||
* reverse( todv(cmax-cmin)))); | ||
} : genarray( shp, toc( 0,0)); | ||
return( res); | ||
diff = cmax - cmin; | ||
delta = [imag (diff) / tod( shp[0]) , real (diff) / tod (shp[1])]; | ||
|
||
return { iv -> cmin + toc (tod (iv) * delta) | iv < shp }; | ||
} | ||
|
||
|
||
|
@@ -41,31 +40,27 @@ complex[.,.] genComplexArray( int[2] shp, complex cmin, complex cmax) | |
inline | ||
int escapeTime(complex z, int depth) | ||
{ | ||
i=0; c=z; | ||
i=0; c=z; | ||
|
||
while( (normSq( c) <= 4d) && (i <= depth)) { | ||
c=c*c+z; i++; | ||
} | ||
while( (normSq( c) <= 4d) && (i <= depth)) { | ||
c=c*c+z; i++; | ||
} | ||
|
||
return(i); | ||
return(i); | ||
} | ||
|
||
/** <!--*******************************************************************--> | ||
* | ||
* @fn int[*] escapeTime(complex[*] z, int depth) | ||
* @fn int[n:shp] escapeTime(complex[n:shp] z, int depth) | ||
* | ||
* @brief maps escapeTime to an entire array of complex numbers | ||
* | ||
*****************************************************************************/ | ||
|
||
inline | ||
int[*] escapeTime( complex[*] plane, int depth) | ||
int[n:shp] escapeTime( complex[n:shp] plane, int depth) | ||
{ | ||
values = with { | ||
( . <= iv <= .) : escapeTime( plane[iv], depth); | ||
} : genarray( shape( plane), 0); | ||
|
||
return( values); | ||
return { iv -> escapeTime (plane[iv], depth) }; | ||
} | ||
|
||
/** <!--*******************************************************************--> | ||
|
@@ -78,13 +73,11 @@ int[*] escapeTime( complex[*] plane, int depth) | |
inline | ||
Color8::color[.,.] intArrayToMonochrome( int[.,.] a) | ||
{ | ||
clut = genLogarithmicClut( 0.4d, 0.9d, Color8::black(), Color8::red()); | ||
clut = genLogarithmicClut( 0.4d, 0.9d, Color8::black(), Color8::red()); | ||
|
||
a = (a * 255) / maxval(a); | ||
a = (a * 255) / maxval(a); | ||
|
||
d = with { | ||
( .<= iv <= .) : clut[ a[ iv]]; | ||
} : genarray( shape(a), Color8::black()); | ||
return { iv -> clut[ a[ iv]] }; | ||
|
||
return( d); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. return( d); needs to be deleted |
||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,20 +8,20 @@ export all; | |
|
||
/** <!--*******************************************************************--> | ||
* | ||
* @fn : complex[.,.] genComplexArray( int[2] shp, complex cmin, complex cmax) | ||
* @fn : complex[2:shp] genComplexArray( int[2] shp, complex cmin, complex cmax) | ||
* | ||
* @brief generates an array of complex numbers with shape "shp" and | ||
* linearly increasing/decreasing values between "cmin" and "cmax". | ||
* The element at index [0,0] should be "cmin". Increases in the | ||
* The element at index [0,0] should be "cmin". Increases in the | ||
* 2nd index (!) should reflect increases in the real values! | ||
* | ||
*****************************************************************************/ | ||
inline | ||
complex[.,.] genComplexArray( int[2] shp, complex cmin, complex cmax) | ||
complex[2:shp] genComplexArray( int[2] shp, complex cmin, complex cmax) | ||
{ | ||
/** | ||
* fill in here... | ||
*/ | ||
/** | ||
* fill in here... | ||
*/ | ||
} | ||
|
||
|
||
|
@@ -39,24 +39,25 @@ complex[.,.] genComplexArray( int[2] shp, complex cmin, complex cmax) | |
inline | ||
int escapeTime(complex z, int depth) | ||
{ | ||
/** | ||
* fill in here... | ||
*/ | ||
/** | ||
* fill in here... | ||
*/ | ||
} | ||
|
||
/** <!--*******************************************************************--> | ||
* | ||
* @fn int[*] escapeTime(complex[*] z, int depth) | ||
* @fn int[n:shp] escapeTime(complex[n:shp] z, int depth) | ||
* | ||
* @brief maps escapeTime to an entire array of complex numbers | ||
* | ||
*****************************************************************************/ | ||
|
||
inline int[*] escapeTime( complex[*] plane, int depth) | ||
inline | ||
int[n:shp] escapeTime( complex[n:shp] plane, int depth) | ||
{ | ||
/** | ||
* fill in here... | ||
*/ | ||
/** | ||
* fill in here... | ||
*/ | ||
} | ||
|
||
/** <!--*******************************************************************--> | ||
|
@@ -69,13 +70,11 @@ inline int[*] escapeTime( complex[*] plane, int depth) | |
inline | ||
Color8::color[.,.] intArrayToMonochrome( int[.,.] a) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe add type patterns here as well?
|
||
{ | ||
clut = genLogarithmicClut( 0.4d, 0.9d, Color8::black(), Color8::red()); | ||
clut = genLogarithmicClut( 0.4d, 0.9d, Color8::black(), Color8::red()); | ||
|
||
a = (a * 256) / maxval(a); | ||
a = (a * 255) / maxval(a); | ||
|
||
d = with { | ||
( .<= iv <= .) : clut[ a[ iv]]; | ||
} : genarray( shape(a), Color8::black()); | ||
return { iv -> clut[ a[ iv]] }; | ||
|
||
return( d); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ export all; | |
|
||
/** <!--*******************************************************************--> | ||
* | ||
* @fn complex escapeValue(complex z, int depth) | ||
* @fn int, complex escapeTimeAndValue (complex z, int depth) | ||
* | ||
* @brief iteratively computes c = c*c + z starting from c=z. | ||
* terminates either when |c| > 2 or depth iterations | ||
|
@@ -16,46 +16,34 @@ export all; | |
* | ||
* @return final complex value | ||
*****************************************************************************/ | ||
int, complex escapeTimeAndValue(complex z, int depth) | ||
int, complex escapeTimeAndValue (complex z, int depth) | ||
{ | ||
i=0; c=z; | ||
i=0; c=z; | ||
|
||
while( (normSq( c) <= 4d) && (i <= depth)) { | ||
c=c*c+z; i++; | ||
} | ||
while( (normSq( c) <= 4d) && (i <= depth)) { | ||
c=c*c+z; i++; | ||
} | ||
|
||
return(i, c); | ||
return(i, c); | ||
} | ||
|
||
/** <!--*******************************************************************--> | ||
* | ||
* @fn complex[*] escapeValue(complex[*] z, int depth) | ||
* @fn int[m,n], complex[m,n] escapeTimeAndValue (complex[m,n] z, int depth) | ||
* | ||
* @brief maps escapeValue to an entire array of complex numbers | ||
* | ||
*****************************************************************************/ | ||
inline | ||
int[.,.], complex[.,.] escapeTimeAndValue( complex[.,.] plane, int depth) | ||
int[m,n], complex[m,n] escapeTimeAndValue ( complex[m,n] plane, int depth) | ||
{ | ||
times = with { | ||
( . <= x <= .) { | ||
t, v = escapeTimeAndValue( plane[x], depth); | ||
} : t; | ||
} : genarray( shape( plane), 0); | ||
|
||
values = with { | ||
( . <= x <= .) { | ||
t, v = escapeTimeAndValue( plane[x], depth); | ||
} : v; | ||
} : genarray( shape( plane), toc(0)); | ||
|
||
return( times, values); | ||
return { iv -> escapeTimeAndValue (plane[iv]) }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does not compile for 3 reasons: parser cannot handle the implicated 2 return arguments, escapeTimeAndValue also needs depth, and iv will become an int[3] instead of int[2] as complex[m, n] is typedef'd to double[m, n, 2] currently. This works
|
||
} | ||
|
||
|
||
/** <!--*******************************************************************--> | ||
* | ||
* @fn double normalizedIterationCount(int n, complex zn) | ||
* @fn double[d:shp] normalizedIterationCount (int[d:shp] n, complex[d:shp] zn) | ||
* | ||
* @brief normalizes the iteration counts in "n" taking the distance of the | ||
* corresponding final complex numbers from the origin into account. | ||
|
@@ -66,15 +54,15 @@ int[.,.], complex[.,.] escapeTimeAndValue( complex[.,.] plane, int depth) | |
* @return the normalized iteration counts | ||
*****************************************************************************/ | ||
inline | ||
double[*] normalizedIterationCount(int[*] n, complex[*] zn) | ||
double[d:shp] normalizedIterationCount(int[d:shp] n, complex[d:shp] zn) | ||
{ | ||
return( where( (norm( zn) <= 2d) , 0d , tod(n+1) - log2( log2( norm( zn))))); | ||
} | ||
|
||
|
||
/** <!--*******************************************************************--> | ||
* | ||
* @fn color[.,.] doubleArrayToRGB( double[.,.] a) | ||
* @fn color[d:shp] doubleArrayToRGB( double[d:shp] a) | ||
* | ||
* @brief transforms an array of doubles into RGB values, by | ||
* FIRST scaling them into values between 0.0 and 360.0, and | ||
|
@@ -85,7 +73,7 @@ double[*] normalizedIterationCount(int[*] n, complex[*] zn) | |
* @return RGB values | ||
*****************************************************************************/ | ||
inline | ||
Color8::color[.,.] doubleArrayToRGB( double[.,.] a) | ||
Color8::color[d:shp] doubleArrayToRGB( double[d:shp] a) | ||
{ | ||
max = maxval( a); | ||
min = minval( a); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,12 +17,9 @@ use Fractal_tier2 : all; | |
use Stencil_tier3 : all; | ||
|
||
inline | ||
color[.,.] stretchRgb( color[.,.] pic, int stretch) | ||
color[ms,ns] stretchRgb( color[m,n] pic, int stretch) | ||
{ | ||
res = with { | ||
(. <= iv <= .): pic[ iv / stretch]; | ||
} : genarray( shape(pic) * stretch, black()); | ||
return( res); | ||
return { iv -> pic[ iv / stretch] | iv < shape(pic) * stretch }; | ||
} | ||
|
||
/* Main ******************************************************************** */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It is then used outside of this do-while loop in:
Which seems to be problematic.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ???? as you correctly noticed, this is outside the do-loop..... so plane should be at maximum size here anyways.... how can this be "problematic"???? |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add type patterns here as well?