-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmakefreq.cpp
106 lines (105 loc) · 2.39 KB
/
makefreq.cpp
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
#include<fstream>
#include<iomanip>
#include<math.h>
using namespace std;
void uniform(void);
void logarithm(double,double, int,double);
void uniform_log_uniform(double a,double b,double c,double d, int N1, int N2, int N3, double lambda);
void userdefined2(double, int,double);
int main(void)
{
// uniform();
// userdefined2(1,300,0.92);
// logarithm(-1,1,560,0.92);
// userdefined1(-0.5*0.02,0.5*0.02,60,0.7);
uniform_log_uniform(-0.2,-0.05,0.05,0.2,50,200,50,0.9);
return 0;
}
void uniform(void)
{
double a,b,c,d;
int N1,N2,N3;
double dx1,dx2,dx3;
ofstream f_freq("freqency");
a=-0.2;
b=-0.05;
c=0.05;
d=0.2;
N1=50;
N2=200;
N3=50;
/*
*a=-3.0;
*b=-0.1;
*c=0.1;
*d=3.0;
*N1=200;
*N2=400;
*N3=200;
*/
/*
*a=-7.42e-4;
*b=-3.71e-4;
*c=3.71e-4;
*d=7.42e-4;
*N1=15;
*N2=60;
*N3=15;
*/
dx1=(b-a)/N1;
dx2=(c-b)/N2;
dx3=(d-c)/N3;
f_freq << left << setw(25) << setprecision(15);
for (int i=0;i<=N1;i++){
f_freq << a+i*dx1 << endl;
}
for (int i=1;i<=N2;i++){
f_freq << b+i*dx2 << endl;
}
for (int i=1;i<=N3;i++){
f_freq << c+i*dx3 << endl;
}
}
void logarithm(double a,double b, int N, double lambda)
{
ofstream f_freq("freqency");
f_freq << left << setw(25) << setprecision(15);
for (int i=0;i<=N/2;i++){
f_freq << a*pow(lambda,i) << endl;
}
f_freq << 0 << endl;
for (int i=N/2;i>=0;i--){
f_freq << b*pow(lambda,i) << endl;
}
}
void uniform_log_uniform(double a,double b,double c,double d, int N1, int N2, int N3, double lambda)
{
double dx1,dx3;
ofstream f_freq("freqency");
f_freq << left << setw(25) << setprecision(15);
dx1=(b-a)/N1;
dx3=(d-c)/N3;
f_freq << left << setw(25) << setprecision(15);
for (int i=0;i<=N1;i++){
f_freq << a+i*dx1 << endl;
}
for (int i=1;i<=N2/2;i++){
f_freq << b*pow(lambda,i) << endl;
}
f_freq << 0 << endl;
for (int i=N2/2;i>=0;i--){
f_freq << c*pow(lambda,i) << endl;
}
for (int i=1;i<=N3;i++){
f_freq << c+i*dx3 << endl;
}
}
void userdefined2(double b, int N, double lambda)
{
ofstream f_freq("freqency");
f_freq << left << setw(25) << setprecision(15);
f_freq << 0 << endl;
for (int i=N;i>=0;i--){
f_freq << b*pow(lambda,i) << endl;
}
}