diff --git a/cs677/final/FatouComputation.cc b/cs677/final/FatouComputation.cc index 29afaf9..12bcf53 100644 --- a/cs677/final/FatouComputation.cc +++ b/cs677/final/FatouComputation.cc @@ -1,7 +1,8 @@ #include /* sqrt() */ -#include /* complex, I, creal(), cimag() */ +#include #include "FatouComputation.h" +using namespace std; #define LEEWAY 0.001 #define ITERATIONS 100 @@ -12,13 +13,13 @@ static unsigned int colors[] = {0xFF0000, 0x00FF00, 0x0000FF}; unsigned int FatouComputation::compute(double x, double y) { - double complex z = 0.1; - double complex p = x + I * y; + complex z(0.1); + complex p(x, y); for (int iter = 0; iter < ITERATIONS; iter++) { - z = p * (1 - z) * z; - if (cabs(z) > 2.0) + z = p * (complex(1) - z) * z; + if (abs(z) > 2.0) { return colors[iter % (sizeof(colors)/sizeof(colors[0]))]; } diff --git a/cs677/final/NewtonComputation.cc b/cs677/final/NewtonComputation.cc index dbdc5ad..501c371 100644 --- a/cs677/final/NewtonComputation.cc +++ b/cs677/final/NewtonComputation.cc @@ -1,12 +1,13 @@ #include /* sqrt() */ -#include /* complex, I, creal(), cimag() */ +#include #include "NewtonComputation.h" +using namespace std; #define LEEWAY 0.001 #define ITERATIONS 32 #define CLOSE_ENOUGH(z, x, y) \ - (fabs(creal(z) - (x)) < LEEWAY && fabs(cimag(z) - (y)) < LEEWAY) + (fabs(real(z) - (x)) < LEEWAY && fabs(imag(z) - (y)) < LEEWAY) /* * This Computation class generates a design in the complex plane @@ -15,7 +16,7 @@ */ unsigned int NewtonComputation::compute(double x, double y) { - double complex rootGuess = x + I * y; + complex rootGuess(x, y); static double halfRoot3 = sqrt(3) / 2.0; for (int iter = 0; iter < ITERATIONS; iter++) @@ -61,6 +62,6 @@ unsigned int NewtonComputation::compute(double x, double y) * More information can be found at: * http://www.willamette.edu/~sekino/fractal/fractal.htm */ - rootGuess -= (cpow(rootGuess, 6.0) - 1.0) / (6.0 * cpow(rootGuess, 5.0)); + rootGuess -= (pow(rootGuess, 6.0) - 1.0) / (6.0 * pow(rootGuess, 5.0)); } } diff --git a/cs677/final/mpi-fractals.cc b/cs677/final/mpi-fractals.cc index 9a31fab..6670617 100644 --- a/cs677/final/mpi-fractals.cc +++ b/cs677/final/mpi-fractals.cc @@ -147,6 +147,8 @@ int main(int argc, char * argv[]) /* slave loop */ for (;;) { + // DEBUG: + cout << "MPI node " << my_rank << " waiting for command." << endl; /* wait for a redraw or quit command */ MPI_Recv(&window_vals[0], 4, MPI_DOUBLE, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, NULL); @@ -155,6 +157,9 @@ int main(int argc, char * argv[]) x_center = window_vals[1]; y_center = window_vals[2]; zoom = window_vals[3]; + // DEBUG: + cout << "MPI node " << my_rank << " received (" + << x_center << ", " << y_center << "), zoom " << zoom << endl; draw(my_rank, world_size, nprocs, width, height, NULL, taskVals, computation); } @@ -226,6 +231,8 @@ void getSizes(int * rank, int * size, int * nprocs) void draw(int rank, int world_size, int nprocs, int width, int height, Uint32 * pixels, Uint32 * taskVals, Computation * computation) { + // DEBUG: + cout << "In draw() with rank " << rank << endl; MPI_Status mpi_status; if (world_size == 1) { @@ -302,6 +309,8 @@ void draw(int rank, int world_size, int nprocs, int width, int height, void sendWindowVals(double * winVals, int world_size) { + // DEBUG: + cout << "Master sending out new window values" << endl; for (int to_proc = 1; to_proc < world_size; to_proc++) { MPI_Send(winVals, 4, MPI_DOUBLE, to_proc,