apl: mandelbrot real-axis batched z=z²+c (+9 tests, 296/296)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 1m5s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 1m5s
This commit is contained in:
@@ -836,6 +836,35 @@
|
||||
(apl-eq sum-board (apl-scalar 3))
|
||||
(apl-and board (apl-eq sum-board (apl-scalar 4))))))))
|
||||
|
||||
(define
|
||||
apl-mandelbrot-step
|
||||
(fn
|
||||
(cs z counts alive iters-left)
|
||||
(if
|
||||
(= iters-left 0)
|
||||
counts
|
||||
(let
|
||||
((still-alive (apl-and alive (apl-le (apl-mul z z) (apl-scalar 4)))))
|
||||
(let
|
||||
((new-z (apl-mul still-alive (apl-add (apl-mul z z) cs))))
|
||||
(let
|
||||
((new-counts (apl-add counts still-alive)))
|
||||
(apl-mandelbrot-step
|
||||
cs
|
||||
new-z
|
||||
new-counts
|
||||
still-alive
|
||||
(- iters-left 1))))))))
|
||||
|
||||
(define
|
||||
apl-mandelbrot-1d
|
||||
(fn
|
||||
(cs max-iter)
|
||||
(let
|
||||
((zero (apl-mul cs (apl-scalar 0)))
|
||||
(ones (apl-add (apl-mul cs (apl-scalar 0)) (apl-scalar 1))))
|
||||
(apl-mandelbrot-step cs zero zero ones max-iter))))
|
||||
|
||||
(define
|
||||
apl-reduce
|
||||
(fn
|
||||
|
||||
Reference in New Issue
Block a user