Changed ALL function and file names to comply with assignment and added additional (Doxygen and normal) comments to mark which version is which

Doxygen comments are shown when hovering over function in the IDE
This commit is contained in:
Nikola
2026-07-03 15:03:55 +02:00
parent 97a8d40771
commit 8546217cf3
6 changed files with 56 additions and 17 deletions
+18 -5
View File
@@ -5,8 +5,9 @@
#include <unistd.h> // for getopt #include <unistd.h> // for getopt
#include <getopt.h> // for getopt_long #include <getopt.h> // for getopt_long
#include <string.h> // for strcpy #include <string.h> // for strcpy
#include "tricorn.h"
#include "tricorn_V0.h" #include "tricorn_V0.h"
#include "tricorn_V1.h"
#include "tricorn_V2.h"
void save_bmp(const char *filename, unsigned char *img, size_t width, ssize_t height,_Bool color); void save_bmp(const char *filename, unsigned char *img, size_t width, ssize_t height,_Bool color);
@@ -200,11 +201,23 @@ int main(int argc, char** argv)
} }
printf("yashar\n"); printf("yashar\n");
if(version_to_use == 0) { // -V0 uses optimized SIMD-Version switch (version_to_use)
{
case 0:
//Uses highly optimized SIMD version
tricorn_V0(complexA,width,height,resolution,n,colored,tempArr); tricorn_V0(complexA,width,height,resolution,n,colored,tempArr);
} break;
else if (version_to_use == 1){ // -V1 uses unoptimized version case 1:
tricorn(complexA,width,height,resolution,n,colored,tempArr); //Uses optimized SISD version
tricorn_V1(complexA,width,height,resolution,n,colored,tempArr);
break;
case 2:
//Uses unoptimised SISD comparison implementation
tricorn_V2(complexA,width,height,resolution,n,colored,tempArr);
break;
default:
break;
} }
printf("yashar\n"); printf("yashar\n");
save_bmp(output_data,tempArr,width,height,colored); save_bmp(output_data,tempArr,width,height,colored);
-5
View File
@@ -1,5 +0,0 @@
#include <complex.h>
#include <stddef.h>
#include <math.h>
#include <sys/types.h>
void tricorn(float complex start, size_t width, ssize_t height, float res, unsigned n, _Bool color, unsigned char* img);
+10 -2
View File
@@ -4,8 +4,16 @@
static unsigned converge(float c_rea, float c_imag, unsigned n); static unsigned converge(float c_rea, float c_imag, unsigned n);
// HIGHLY OPTIMIZED SIMD VERSION /**
* @brief Generates a Tricorn fractal image using highly optimized SSE/SIMD instructions.
* @param start The starting complex coordinate (bottom-left or top-left depending on height sign).
* @param width The width of the target image in pixels.
* @param height The height of the target image. A negative height reverses the Y-axis calculation.
* @param res The step size (resolution) per pixel in the complex plane.
* @param n The maximum number of mathematical iterations per pixel.
* @param color If true, generates a 24-bit RGB image. If false, writes a grayscale image.
* @param img Pointer to the pre-allocated memory buffer where the bitmap data will be stored.
*/
void tricorn_V0(float complex start, size_t width, ssize_t height, float res, unsigned n, _Bool color, unsigned char* img){ void tricorn_V0(float complex start, size_t width, ssize_t height, float res, unsigned n, _Bool color, unsigned char* img){
int bytesPerColor = color ? 3 : 1; int bytesPerColor = color ? 3 : 1;
+10 -2
View File
@@ -4,8 +4,16 @@ static const float convergenceLimit = 2.0f; // Mandelbrot set limit
static unsigned converge(float complex position,unsigned n); static unsigned converge(float complex position,unsigned n);
// OPTIMIZED SISD VERSION /**
* @brief Generates a Tricorn fractal image using an optimized SISD implementation.
* @param start The starting complex coordinate (bottom-left or top-left depending on height sign).
* @param width The width of the target image in pixels.
* @param height The height of the target image. A negative height reverses the Y-axis calculation.
* @param res The step size (resolution) per pixel in the complex plane.
* @param n The maximum number of mathematical iterations per pixel.
* @param color If true, generates a 24-bit RGB image. If false, writes a grayscale image.
* @param img Pointer to the pre-allocated memory buffer where the bitmap data will be stored.
*/
void tricorn_V1(float complex start, size_t width, ssize_t height, float res, unsigned n, _Bool color, unsigned char* img){ void tricorn_V1(float complex start, size_t width, ssize_t height, float res, unsigned n, _Bool color, unsigned char* img){
// Absolute height for iteration purposes // Absolute height for iteration purposes
@@ -1,9 +1,19 @@
#include "tricorn.h" #include "tricorn_V2.h"
static const float convergenceLimit = 2.0f; // Mandelbrot set limit static const float convergenceLimit = 2.0f; // Mandelbrot set limit
static unsigned converge(float complex position,unsigned n); static unsigned converge(float complex position,unsigned n);
void tricorn(float complex start, size_t width, ssize_t height, float res, unsigned n, _Bool color, unsigned char* img){ /**
* @brief Generates a Tricorn fractal image using the standard, unoptimized scalar implementation for benchmarking comparison (Version 2).
* @param start The starting complex coordinate (bottom-left or top-left depending on height sign).
* @param width The width of the target image in pixels.
* @param height The height of the target image. A negative height reverses the Y-axis calculation.
* @param res The step size (resolution) per pixel in the complex plane.
* @param n The maximum number of mathematical iterations per pixel.
* @param color If true, generates a 24-bit RGB image. If false, writes a grayscale image.
* @param img Pointer to the pre-allocated memory buffer where the bitmap data will be stored.
*/
void tricorn_V2(float complex start, size_t width, ssize_t height, float res, unsigned n, _Bool color, unsigned char* img){
// Absolute height for iteration purposes // Absolute height for iteration purposes
height = height < 0 ? height*-1 : height; height = height < 0 ? height*-1 : height;
+5
View File
@@ -0,0 +1,5 @@
#include <complex.h>
#include <stddef.h>
#include <math.h>
#include <sys/types.h>
void tricorn_V2(float complex start, size_t width, ssize_t height, float res, unsigned n, _Bool color, unsigned char* img);