blob: b823c919c72b52b2d424261e40edaf9b01c0c532 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#pragma once
#include <stddef.h>
#include <stdio.h>
#include <stdbool.h>
#ifndef __NVCC__
#include <complex.h>
#endif
#include "precision.h"
//grid write errors
#define GRID_NO_DATA 1
#define GRID_WRITE_ERROR 2
#define GRID_MAGIC_NUMBER 0xA6005E
// hack to allow variable precision at compile time
typedef struct {
CBASE re;
CBASE im;
} complex_t;
typedef struct {
size_t x;
size_t y;
size_t size;
size_t max_iterations;
complex_t lower_left;
complex_t upper_right;
size_t* data;
} grid_t;
grid_t* create_grid(const size_t x, const size_t y, const size_t max_iterations, complex_t lower_left, complex_t upper_right);
void set_grid(grid_t* grid, const size_t val);
grid_t* copy_grid(const grid_t* grid);
void free_grid(grid_t* grid);
bool grid_equal(const grid_t* grid1, const grid_t* grid2);
bool grid_allclose(const grid_t* grid1, const grid_t* grid2, const size_t max_error);
#ifndef __NVCC__
CBASE complex grid_to_complex(const grid_t* grid, const size_t index);
#endif
void zoom_grid(grid_t* grid, const CBASE magnification);
void print_grid_info(const grid_t* grid);
void print_grid(const grid_t* grid);
int write_grid(FILE* file, const grid_t* grid);
grid_t* read_grid(FILE* file);
|