| 20 | using std::abs; |
| 21 | |
| 22 | array complex_grid(int width, int height, float zoom, float center[2]) { |
| 23 | // Generate sequences of length width, height |
| 24 | array X = |
| 25 | (iota(dim4(1, height), dim4(width, 1)) - (float)height / 2.0) / zoom + |
| 26 | center[0]; |
| 27 | array Y = |
| 28 | (iota(dim4(width, 1), dim4(1, height)) - (float)width / 2.0) / zoom + |
| 29 | center[1]; |
| 30 | |
| 31 | // Return the locations as a complex grid |
| 32 | return complex(X, Y); |
| 33 | } |
| 34 | |
| 35 | array mandelbrot(const array &in, int iter, float maxval) { |
| 36 | array C = in; |