Software Engineer working at American Express. Interested in scientific computing, natural language processing, and Rust.
“A language empowering everyone to build reliable and efficient software.”
use num_complex::Complex;
fn abs(c: Complex<f64>) -> f64 {
(c * c.conj()).re
}
use num_complex::Complex;
fn abs(c: Complex<f64>) -> f64 {
(c * c.conj()).re
}
pub fn mandelbrot(
c: Complex<f64>,
threshold: f64,
max_steps: u8
) -> u8 {
let mut z = c.clone();
let mut i = 1u8;
while i < max_steps && abs(z) < threshold {
z = z * z + c;
i += 1;
}
// see: "Renormalizing the Mandelbrot Escape"
// https://linas.org/art-gallery/escape/escape.html
if i == max_steps {
max_steps
} else {
i + 1 - abs(z).log2().log10().round() as u8
}
}
mandelbrot_common
mandelbrot_py
wasm
module compiled using the same Mandelbrot crate.