-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathpolygon_integrals_prb.cpp
168 lines (154 loc) · 3.35 KB
/
polygon_integrals_prb.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# include <cstdlib>
# include <iostream>
# include <iomanip>
# include <cmath>
# include <ctime>
using namespace std;
# include "polygon_integrals.hpp"
int main ( );
void test01 ( );
//****************************************************************************80
int main ( )
//****************************************************************************80
//
// Purpose:
//
// MAIN is the main program for POLYGON_INTEGRALS_PRB.
//
// Discussion:
//
// POLYGON_INTEGRALS_PRB tests POLYGON_INTEGRALS.
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 03 October 2012
//
// Author:
//
// John Burkardt
//
{
timestamp ( );
cout << "\n";
cout << "POLYGON_INTEGRALS_PRB:\n";
cout << " C++ version\n";
cout << " Test the POLYGON_INTEGRALS library.\n";
test01 ( );
//
// Terminate.
//
cout << "\n";
cout << "POLYGON_INTEGRALS_PRB:\n";
cout << " Normal end of execution.\n";
cout << "\n";
timestamp ( );
return 0;
}
//****************************************************************************80
void test01 ( )
//****************************************************************************80
//
// Purpose:
//
// TEST01 carries out a test on a rectangle.
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 03 October 2012
//
// Author:
//
// John Burkardt
//
{
double alpha_exact[6] = {
1.0,
5.0, 4.0,
30.66666666666667, 22.0, 18.66666666666666 };
double alpha_pq;
int k;
double mu_exact[6] = {
1.0,
0.0, 0.0,
5.666666666666667, 2.0, 2.666666666666667 };
double mu_pq;
int n = 4;
double nu_exact[6] = {
40.0,
200.0, 160.0,
1226.66666666666667, 880.0, 746.66666666666666 };
double nu_pq;
int p;
int q;
int s;
double x[4] = {
2.0, 10.0, 8.0, 0.0 };
double y[4] = {
0.0, 4.0, 8.0, 4.0 };
cout << "\n";
cout << "TEST01\n";
cout << " Check normalized moments of a rectangle.\n";
cout << "\n";
cout << " P Q Nu(P,Q)\n";
cout << " Computed Exact\n";
cout << "\n";
k = 0;
for ( s = 0; s <= 2; s++ )
{
for ( p = s; 0 <= p; p-- )
{
q = s - p;
nu_pq = moment ( n, x, y, p, q );
cout << " " << setw(2) << p
<< " " << setw(2) << q
<< " " << setw(14) << nu_pq
<< " " << setw(14) << nu_exact[k] << "\n";
k = k + 1;
}
}
cout << "\n";
cout << " P Q Alpha(P,Q)\n";
cout << " Computed Exact\n";
cout << "\n";
k = 0;
for ( s = 0; s <= 2; s++ )
{
for ( p = s; 0 <= p; p-- )
{
q = s - p;
alpha_pq = moment_normalized ( n, x,y, p, q );
cout << " " << setw(2) << p
<< " " << setw(2) << q
<< " " << setw(14) << alpha_pq
<< " " << setw(14) << alpha_exact[k] << "\n";
k = k + 1;
}
}
cout << "\n";
cout << " P Q Mu(P,Q)\n";
cout << " Computed Exact\n";
cout << "\n";
k = 0;
for ( s = 0; s <= 2; s++ )
{
for ( p = s; 0 <= p; p-- )
{
q = s - p;
mu_pq = moment_central ( n, x, y , p, q );
cout << " " << setw(2) << p
<< " " << setw(2) << q
<< " " << setw(14) << mu_pq
<< " " << setw(14) << mu_exact[k] << "\n";
k = k + 1;
}
}
return;
}