-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtotal_test_para.cpp
More file actions
130 lines (93 loc) · 3.29 KB
/
Copy pathtotal_test_para.cpp
File metadata and controls
130 lines (93 loc) · 3.29 KB
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
#include <vector>
#include <armadillo>
#include <stdio.h>
#include "saye_utils.h"
#include "saye_algorithm.h"
#include "level_set_plot.h"
#include "rbf_network.h"
#include "grad_descent.h"
int main()
{
char energy_str[50];
char filename_str[50];
double box_size = 3;
double true_coeffs[6] = {1, 1, 0, -box_size, -box_size, (box_size/2)*(box_size/2)};
double this_symdiff_err;
// Domain
// Guess type (parabolic)
char guess_type = 'l';
// maximum number of iterations
int max_iter = 500;
// error tolerances
double error_tols[4] = {1e-7, 1e-7, 1e-7, 1e-4};
////////////// test /////////////////
/*
double txL[2] = { -1, -1 };
double txU[2] = { 1, 1 };
Box tU( txL, txU, 2 );
double test_coeffs[6] = {0, 0, 0, 0, 0, 0};
double test_refs[6] = {1.0/3.0, 1.0/3.0, 0.25, -0.5, -0.5, 1};
parabolic_MOF( test_refs, tU, 'l', error_tols, test_coeffs, max_iter );
return 0;
*/
/////////////////////////////////////
//parabolic_MOF( refs, U, guess_type, error_tols, final_coeffs, max_iter );
// Do 32 x 32 test
int k;
int N = 3;
double final_coeffs[N*N][6];
double init_guesses[N*N][6];
double refs[N*N][6];
double xL[2] = { 0, 0};
double xU[2] = { 1, 1};
Box U( xL, xU, 2 );
//get_refs( U, true_coeffs, refs[0] );
//parabolic_MOF( refs[0], U, guess_type, error_tols, final_params[0], max_iter );
// return 0;
// Get reference data
for( int i = 0; i < N; i++ )
{
for( int j = 0; j < N; j++ )
{
k = N*i + j;
xL[0] = i * box_size / N;
xL[1] = j * box_size / N;
xU[0] = (i+1) * box_size / N;
xU[1] = (j+1) * box_size / N;
U = Box( xL, xU, 2 );
get_refs( U, true_coeffs, refs[k] );
}
}
k = 15;
xL[0] = 3;
xL[1] = 3;
xU[0] = 4;
xU[1] = 4;
U = Box( xL, xU, 2 );
//parabolic_MOF( refs[k], U, guess_type, error_tols, final_coeffs[k], max_iter );
this_symdiff_err = quad_symdiff( true_coeffs, final_coeffs[k] );
sprintf(filename_str, "rbf_data2/MOF_%d.png", k);
sprintf(energy_str, "Sym Diff: %.6f", this_symdiff_err);
//plot_2D_reference( true_coeffs, final_coeffs[k], U, energy_str, filename_str );
//return 0;
// Test on the box
for( int i = 0; i < N; i++ )
{
for( int j = 0; j < N; j++ )
{
k = N*i + j;
xL[0] = i * box_size / N;
xL[1] = j * box_size / N;
xU[0] = (i+1) * box_size / N;
xU[1] = (j+1) * box_size / N;
printf("MOF number %d: [%f, %f] x [%f, %f]\n", k, xL[0], xU[0], xL[1], xU[1]);
U = Box( xL, xU, 2 );
parabolic_MOF( refs[k], U, guess_type, error_tols, final_coeffs[k], max_iter, init_guesses[k] );
this_symdiff_err = quad_symdiff( true_coeffs, final_coeffs[k] );
sprintf(filename_str, "rbf_data2/MOF_%d.png", k);
sprintf(energy_str, "Sym Diff: %.6f", this_symdiff_err);
plot_level_sets_3( true_coeffs, final_coeffs[k], init_guesses[k], U, energy_str, filename_str );
}
}
return 0;
}