-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tier2.sac
55 lines (51 loc) · 1.64 KB
/
Tier2.sac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
module Tier2;
use Structures: all;
use Numerical: { log2 };
export all;
/**
* Iteratively computes `val = val * val + c` starting from `val = c`.
* Terminates either when `|val| > 2` (`norm(val) > 2`), or when depth iterations have been performed.
* Returns the number of iterations done, and the corresponding complex value.
*/
inline
int, complex escapeTimeAndValue(complex c, int depth)
{
// TODO
}
/**
* Computes the escape times and values of an array of complex numbers.
*/
inline
int[2:shp], complex[2:shp] escapeTimeAndValue(complex[2:shp] arr, int depth)
{
// TODO
}
/**
* Normalizes the iteration counts in `times`, taking the distance of the
* corresponding final complex numbers from the origin into account.
*
* For corresponding elements `t` in `times` and `c` in `values`, we have:
* 0.0 iff |c| <= 2
* (t + 1) - log2(log2(|c|)) otherwise
*
* You can use the standard library function `where` here.
* Arguments can be scalar or arrays, you might want to use the following case:
* double[d:shp] where(bool[d:shp] predicate, double trueCase, double[d:shp] falseCase)
* If the predicate holds, the scalar value from the true case is used,
* otherwise the element at the corresponding index in the false case is used.
*/
inline
double[2:shp] normalizedIterationCount(int[2:shp] times, complex[2:shp] values)
{
// TODO
}
/**
* Transforms an array of doubles into RGB values.
* Feel free to play around with this function to generate some beautiful results.
*/
inline
color[2:shp] doubleArrayToRGB(double[2:shp] arr)
{
scaled_vals = toi(arr * 360d) % 360;
return Hsb2Rgb(scaled_vals, 60, 80);
}