-
Notifications
You must be signed in to change notification settings - Fork 0
/
synmap-main.c
123 lines (97 loc) · 3.45 KB
/
synmap-main.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
DESCRIPTION: This Code creates an time series
AUTHOR: Daniel Mejia Raigosa
DATE:
VERSION: 0.0.1
*/
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include "commonroutines.c"
#define ARGS 8 // Number of Maximum Arguments (1 means no arguments!)
#define TITLESCN "Syntetic Map Time Series"
#define LIMITP 500 //limit for minumun points
void syntiterate(double xi, double yi,double zi,double *Xi, double *Yi,double *Zi, double a, double b,double c,int N)
{
*Xi=a+b*pow(yi,2)+c*zi;
*Yi=xi;
*Zi=yi;
}
main(int argc,char *argv[]) // for input arguments, remeber argv[0]=program name argv[1]= first argument and so on */
{
// This section is made for argument validation
if (argc > ARGS)
{
printf("Too many arguments supplied.\n");
printf(" Usage\n \'%s\' N a b c xo yo zo\n",argv[0]);
printf(" N - Number of points\n a,b,c - Parameters(use a=1.76 b=-1 c=-0.1)\n xo,yo,zo Initial conditions");
exit(1);
}
else if (argc<ARGS)
{
printf("Some arguments expected.\n");
printf(" Usage\n \'%s\' N a b c xo yo zo\n",argv[0]);
printf(" N - Number of points\n a,b,c - Parameters(use a=1.76 b=-1 c=-0.1)\n xo,yo,zo Initial conditions\n\n");
exit(1);
}
pimpi(TITLESCN,25);
int points,i,select;
double x,y,z,xi,yi,zi,a,b,c;
char salida[CHAPER];
FILE *dataxayaz;
FILE *datax;
FILE *datay;
FILE *dataz;
FILE *dataxyz;
points=atoi(argv[1]);
if (points<LIMITP)
{
printf(" [!] Invalid points number \'%d\' (negative or less than %d), changing number of points to %d...\n",points,LIMITP,LIMITP);
points=LIMITP;
}
else if(points==0)
{
printf(" [!] points=0 set the number of points to 1e9...\n");
points=1000000000;
}
a=atof(argv[2]);
b=atof(argv[3]);
c=atof(argv[4]);
xi=atof(argv[5]);
yi=atof(argv[6]);
zi=atof(argv[7]);
dataxayaz=fopen("syntetic-xyz.txt","w");
datax=fopen("syntetic-x.txt","w");
datay=fopen("syntetic-y.txt","w");
dataz=fopen("syntetic-z.txt","w");
dataxyz=fopen("syntetic-x+y+z.txt","w");
fprintf(dataxayaz,"### Syntetic Map : X_{n+1}=a+b*Y_{n}^2+c*Z_{n} Y_{n+1}=Y_{n} Z_{n+1}=Y_{n}\n### a= %lf \t b=%lf c= %lf X_0= %lf \t Y_0=%lf\n",a,b,c,xi,yi,zi);
fprintf(datax,"### Syntetic Map : X_{n+1}=a+b*Y_{n}^2+c*Z_{n} Y_{n+1}=Y_{n} Z_{n+1}=Y_{n}\n### a= %lf \t b=%lf c= %lf X_0= %lf \t Y_0=%lf\n",a,b,c,xi,yi,zi);
fprintf(datay,"### Syntetic Map : X_{n+1}=a+b*Y_{n}^2+c*Z_{n} Y_{n+1}=Y_{n} Z_{n+1}=Y_{n}\n### a= %lf \t b=%lf c= %lf X_0= %lf \t Y_0=%lf\n",a,b,c,xi,yi,zi);
fprintf(dataz,"### Syntetic Map : X_{n+1}=a+b*Y_{n}^2+c*Z_{n} Y_{n+1}=Y_{n} Z_{n+1}=Y_{n}\n### a= %lf \t b=%lf c= %lf X_0= %lf \t Y_0=%lf\n",a,b,c,xi,yi,zi);
fprintf(dataxyz,"### Syntetic Map : X_{n+1}=a+b*Y_{n}^2+c*Z_{n} Y_{n+1}=Y_{n} Z_{n+1}=Y_{n}\n### a= %lf \t b=%lf c= %lf X_0= %lf \t Y_0=%lf\n",a,b,c,xi,yi,zi);
fprintf(dataxayaz,"### X_n \t Y_n \t Z_n\n");
fprintf(datax,"### X_n\n");
fprintf(datay,"### Y_n\n");
fprintf(datay,"### Z_n\n");
fprintf(dataxyz,"### X_n + Y_n + Z_n\n");
for(i=0;i<points;i=i++)
{
syntiterate(xi,yi,zi,&x,&y,&z,a,b,c,points);
fprintf(dataxayaz,"%E \t %E \t %E\n",x,y,z);
fprintf(datax,"%E\n",pow(x,2));
fprintf(datay,"%E\n",y);
fprintf(dataz,"%E\n",z);
fprintf(dataxyz,"%E\n",x+y);
zi=yi;
xi=x;
yi=y;
}
fclose(dataxayaz);
fclose(datax);
fclose(datay);
fclose(dataz);
fclose(dataxyz);
pimpe(TITLESCN,25);
exit(0);
} //End of Main Code