// the part of main function int main(void) { // Defines variables to receive inputs and to work with later unsigned long int i, j, out; unsigned long int xpoints, ypoints; long double xmin, xmax, ymin, ymax, creal, cimag; COMPLEX c, z; CPLANE a; // Receives inputs printf("Please give me the minimum value for x-axis: "); scanf("%Lf", &xmin); printf("\n"); printf("Please give me the maximum value for x-axis: "); scanf("%Lf", &xmax); printf("\n"); printf("Please give me the minimum value for y-axis: "); scanf("%Lf", &ymin); printf("\n"); printf("Please give me the maximum value for y-axis: "); scanf("%Lf", &ymax); printf("\n"); printf("Please give me the number of points for x-axis: "); scanf("%ld", &xpoints); printf("\n"); printf("Please give me the number of points for y-axis: "); scanf("%ld", &ypoints); printf("\n"); printf("Please give me the value for the real part of c: "); scanf("%Lf", &creal); printf("\n"); printf("Please give me the value for the imaginary part of c: "); scanf("%Lf", &cimag); printf("\n"); // we make the desirable cplane a = constructor(xmin, xmax, ymin, ymax, xpoints, ypoints); // we make the complex c set_complex(&c, creal, cimag); // Receives and prints the output of the cplane printf("x, y, out\n"); for(i=0; i<ypoints; i++){ for(j=0; j<xpoints; j++){ z = get(&a, i, j); out = iterate(z, &c); printf("%Lf, %Lf, %ld\n", z.x, z.y, out); } } // Destructs matrix when done delete_cplane(a); return 0; }
// Starts the main function int main(void) { // Defines variables to receive inputs and to work with later INT i, j, out; INT xpoints, ypoints; VALUE xmin, xmax, ymin, ymax, creal, cimag; COMPLEX c, z; CPLANE a; // Receives inputs printf("Enter the minimum value for x-axis: "); scanf("%Lf", &xmin); printf("\n"); printf("Enter the maximum value for x-axis: "); scanf("%Lf", &xmax); printf("\n"); printf("Enter the minimum value for y-axis: "); scanf("%Lf", &ymin); printf("\n"); printf("Enter the maximum value for y-axis: "); scanf("%Lf", &ymax); printf("\n"); printf("Enter the number of points that will be taken in x-axis: "); scanf("%ld", &xpoints); printf("\n"); printf("Enter the number of points that will be taken in y-axis: "); scanf("%ld", &ypoints); printf("\n"); printf("Enter the value for the real part of c: "); scanf("%Lf", &creal); printf("\n"); printf("Enter the value for the imaginary part of c: "); scanf("%Lf", &cimag); printf("\n"); // Constructs the desirable cplane a = constructor(xmin, xmax, ymin, ymax, xpoints, ypoints); // Constructs the complex c set_complex(&c, creal, cimag); // Receives and prints the output of the iterate function for each element of the cplane printf("x, y, out\n"); for(i=0; i<ypoints; i++){ for(j=0; j<xpoints; j++){ z = get(&a, i, j); out = iterate(z, &c); printf("%Lf, %Lf, %ld\n", z.x, z.y, out); } } // Destructs matrix when done delete_cplane(a); return 0; }
int main(int argc, char **argv) { /************************************************************************************ * Function: int main() * Input : xmin, xmax, ymin, ymax, xpoints, ypoints, creal, and cimag * Output : Returns 0 on success * Procedure: Performs operations on complex numbers and prints results. ************************************************************************************/ // check for input parameters if ( argc != 9) { printf ( " The program is expecting 8 input parameters, you entered :%d \n", argc -1); return(-1); } // Initialize all the parameters CPLANE cp; int MAXITER=256; char *e; INDEX rows,cols; complex c, z, v; VALUE xmin = strtold(argv[1], &e); VALUE xmax = strtold(argv[2], &e); VALUE ymin = strtold(argv[3], &e); VALUE ymax = strtold(argv[4], &e); INDEX xpoints = strtoul(argv[5], &e, 0); INDEX ypoints = strtoul(argv[6], &e,0); VALUE creal = strtold(argv[7], &e); VALUE cimag = strtold(argv[8], &e); c.x = creal; c.y = cimag; // create a new plane cp = new_cplane(xmin,xmax,ymin,ymax,xpoints,ypoints); // print_matrix(&cp); // Traverse through the plane for(rows=0; rows<ypoints; rows++) { for(cols=0; cols<xpoints; cols++) { v = get ( &cp, rows,cols); z.x = v.x; z.y = v.y; int m = 0; while (1) { // printf("The absolute values is %d \n", abs(z.x+z.y)); z = juliamap(z,c); m = ++m; if (abs(z.x+z.y) > 2) { printf("%Lf,%Lf,%d \n", v.x, v.y, m); break; } else if ( m >= MAXITER) { printf("%Lf,%Lf,%d \n", v.x, v.y, 0); break; } } /* end of while loop */ } /* end of cols */ } /* end of rows */ // clean up memory delete_cplane(cp); return 0; }