<commit_before>#include <complex.h>
#include <math.h>
#include <stdio.h>
#include "ppm.h"


int compute(double x, double y, int magnitude) {
    double complex a, b;
    a = x + (y * I);
    b = 0;
    int iterations = 0;
    
    while(cabs(b) < 2 && iterations < magnitude) {
        b = (b * b) + a;
        iterations++;
        
    }
    
    return iterations;
    
}


int main(int argc, char* argv) {
    long double delta = .001;
    long double i = 0;    
    long double xStart = -3;
    long double xEnd = 3;
    long double yStart = -3;
    long double yEnd = 3;
    int max = 20;
    FILE* output = create_ppm("output.ppm", 6000, 6000, max);
    
    
    for(long double y = yEnd; y >= yStart; y -= delta) {
        i++;
        
        for(long double x = xStart; x <= xEnd; x += delta) {
            int temp = compute(x, y, 0xFFFFFF);
            write_pixel((temp >> 16) & 0xFF, (temp >> 8) & 0xFF, (temp) & 0xFF, output);  

        }
        
        printf("%Lf\n", y);
        
        /*
        if(i / 6000 > .1) {
            printf("=");
            fflush(stdout);
            i = 0;
            
        }
        */
        
    }

    printf("\n%Lf pixels written\n", i);
    return 0;
    
}<commit_msg>Added comments and pretties up mandelbrot.c<commit_after>#include <complex.h>
#include <math.h>
#include <stdio.h>
#include "ppm.h"

// desc: iterates through given coordinates and checks for divergence in the Mandelbrot set
// args:
//      x, y: x/y-coordinate
//      magnitude: max amount of iterations allowed
// return: int value for amount of iterations done before divergence. Will be magnitude if
//         the coordinates converge
int compute(double x, double y, int magnitude) {
    double complex a, b;
    // set up starting number
    a = x + (y * I);
    b = 0;
    int iterations = 0;
    
    // iterate through set, if b ever goes over 2, it diverges
    while(cabs(b) < 2 && iterations < magnitude) {
        b = (b * b) + a;
        iterations++;
        
    }
    
    return iterations;
    
}


int main(int argc, char* argv) {
    long double delta = .001;   // difference in each xy pair
    long double xStart = -3;    // starting x coordinate
    long double xEnd = 3;       // enidng x coordinate
    long double yStart = -3;    // staring y coordinate
    long double yEnd = 3;       // ending y coordinate
    int max = 20;               // max rgb digit to be written to the output file
    
    FILE* output = create_ppm("output.ppm", 6000, 6000, max);  // get file handle for output ppm
    
    // nested loops for moving through xy coordinates
    // moves from max y value to min y value, iterating via delta
    for(long double y = yEnd; y >= yStart; y -= delta) {
        
        // moves from min x value to max x value, iterating via delta
        for(long double x = xStart; x <= xEnd; x += delta) {
            int temp = compute(x, y, 0xFFFFFF);                                             // get amount of iterations before divergence
            
            // take the temp value and mask the bits to get the RGB value
            // 0xFF FF FF
            //   R  G  B
            write_pixel((temp >> 16) & 0xFF, (temp >> 8) & 0xFF, (temp) & 0xFF, output);

        }
        
        printf("%Lf\n", y);  // print finished y value. Icky debug stuff
        
    }

    printf("\n%Lf pixels written\n", i);
    return 0;
    
}
{'fraction_non_alphanumeric': 0.11592505854800937, 'fraction_numerical': 0.019028103044496487, 'mean_word_length': 1.6758026624902114, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4348665', 'n_tokens_mistral': 1136, 'n_tokens_neox': 1050, 'n_words': 390}