Home / Expert Answers / Computer Science / please-help-with-34-code-here-parts-34-for-a-mandelbrot-fractal-include-include-include-34-image-pa891

(Solved): Please help with "code here parts" for a mandelbrot fractal. #include #include #include "image. ...



Please help with "code here parts" for a mandelbrot fractal. #include #include #include "image.h" __device__ int mandelbrot(float cx, float cy) { int count = 0; int max_iterations = 32; float zx = 0.0; float zy = 0.0; float temp = 0.0; float lengthsquared = 0.0; do { temp = zx * zx - zy * zy + cx; zy = 2 * zx * zy + cy; zx = temp; lengthsquared = zx * zx + zy * zy; count++; } while ((lengthsquared < 4.0) && (count < max_iterations)); return count - 1; } __global__ void mandelbrot_kernel(unsigned char *pixel, int width, int height) { /******************/ /* Your code here */ /******************/ /* Calculate indices */ /* If indices is in range then */ /* compute cx and cy */ /* call mandelbrot and save result to appropriate array location */ } void process_data(image *photo) { /******************/ /* Your code here */ /******************/ /* Extract image properties */ /* Declare variables for grid and block dimensions */ /* Declare device memory */ /* Allocate device memory */ /* Invoke kernel */ /* Copy result from device to host */ /* Free device memory */ } image *setup(int argc, char **argv) { if (argc < 3) { fprintf(stderr, "Usage: %s \n\n", argv[0]); return NULL; } int size = atoi(argv[2]); return create_image(size, size, 31); } void cleanup(image *photo, char **argv) { int rc = write_image(argv[1], photo); if (!rc) { fprintf(stderr, "Unable to write output file %s\n\n", argv[1]); } clear_image(photo); } int main(int argc, char **argv) { image *photo = setup(argc, argv); process_data(photo); cleanup(photo, argv); return 0; }



We have an Answer from Expert

View Expert Answer

Expert Answer


We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe