-
Notifications
You must be signed in to change notification settings - Fork 0
/
circle-mom.C
71 lines (60 loc) · 1.28 KB
/
circle-mom.C
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
* circle-mom.C
*
* FUNCTION:
* Circle map momentum.
*
* HISTORY:
* quick hack -- Linas Vepstas November 2010
*/
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "brat.h"
/*-------------------------------------------------------------------*/
/*
* This routine computes a scatterplot of position vs momentum for
* the circle map
*/
void MakeHisto (
char *name,
float *glob,
int sizex,
int sizey,
double re_center,
double im_center,
double width,
double height,
int itermax,
double param)
{
int i,j, k, globlen;
globlen = sizex*sizey;
for (i=0; i<globlen; i++) glob [i] = 0.0;
#define SAMP 100
for (k=0; k<SAMP; k++)
{
// double omega = 0.333;
double omega = 0.1333;
double K = param;
/* OK, now start iterating the circle map */
int iter;
double x, xprev, moment;
x = rand();
x /= RAND_MAX;
xprev = 0.0;
for (iter=0; iter < itermax; iter++)
{
xprev = x;
x += omega - K * sin (2.0 * M_PI * x);
x -= floor(x);
moment = x - xprev;
moment -= floor(moment);
/* convert to pixel coords */
i = (sizex-1) * x;
j = (sizey-1) * moment;
glob [i + j*sizex] += 1.0;
}
}
}
/* --------------------------- END OF LIFE ------------------------- */