-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tier1.sac
58 lines (53 loc) · 1.56 KB
/
Tier1.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
56
57
58
module Tier1;
use Structures: all;
export all;
/**
* Generates an array of complex numbers of shape `[yres, xres]`,
* with linearly increasing/decreasing values from cmin to cmax.
*
* The element at index [0,0] should be `cmin`.
* The element at index [yres,xres] should be `cmin + cmax`.
*
* Note that the first axis holds the y-values, and thus corresponds to the imaginary values.
* Whereas the second axis holds the x-values, and thus corresponds to the real values.
*/
inline
complex[yres,xres] genComplexArray(int xres, int yres,
complex cmin, complex cmax)
{
// TODO
}
/**
* 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.
*
* Note that besides `norm` there exists `normSq` which computes `|val|^2`.
* As opposed to `norm`, it does not contain a square root.
*/
inline
int escapeTime(complex c, int depth)
{
// TODO
}
/**
* Computes the escape times of an array of complex numbers.
*/
inline
int[2:shp] escapeTime(complex[2:shp] arr, int depth)
{
// TODO
}
/**
* Converts non-negative integer values into color values using
* a logarithmic 256 element clut from black to red.
*/
inline
color[2:shp] intArrayToMonochrome(int[2:shp] arr)
{
clut = genLogarithmicClut(0.4d, 0.9d, black(), red());
// Convert to a range [0,256)
arr = (arr * 255) / maxval(arr);
// Get color value at each index from the clut
return { iv -> clut[arr[iv]] };
}