You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
195 lines
6.5 KiB
195 lines
6.5 KiB
close all
|
|
clearvars
|
|
|
|
%% curved row1_dir1 in [0,10]x[0,10]
|
|
dataPath='C:\Users\Caich\Desktop\CAD\Projects\CNN-quad2D\data\curved\';
|
|
ansPath='C:\Users\Caich\Desktop\CAD\Projects\CNN-quad2D\data\curved_ans\';
|
|
matPath='C:\Users\Caich\Desktop\CAD\Projects\CNN-quad2D\data\curved_mat\';
|
|
sqrt3=sqrt(3);
|
|
sqrt2=sqrt(2);
|
|
|
|
CP{1,1}=[0 7/2 7 10-1.5*sqrt3 10-1.5*sqrt2 10-1.5 10 5 0;
|
|
10 5 0 1.5 1.5*sqrt2 1.5*sqrt3 3 13/2 10];
|
|
W{1,1}=ones(1,9);
|
|
Xi{1,1}=[0 0 0 1 1 2 3 4 4 5 5 5];
|
|
% res=quad2D(5,f,CP{1,1},W{1,1},Xi{1,1})
|
|
|
|
for tot=1:500
|
|
R=rand(2,3)*10;
|
|
CP{1,1}(:,4:6)=R;
|
|
save([dataPath,num2str(tot),'.mat'],'CP','W','Xi');
|
|
|
|
load([dataPath,num2str(tot),'.mat'],'CP','W','Xi');
|
|
CP{1,1}=flip(CP{1,1},2);
|
|
save([dataPath,num2str(tot),'_neg.mat'],'CP','W','Xi');
|
|
tot
|
|
end
|
|
|
|
%% curved_ans row1_dir1 in [0,10]x[0,10]
|
|
dataPath='C:\Users\Caich\Desktop\CAD\Projects\CNN-quad2D\data\curved\';
|
|
ansPath='C:\Users\Caich\Desktop\CAD\Projects\CNN-quad2D\data\curved_ans\';
|
|
matPath='C:\Users\Caich\Desktop\CAD\Projects\CNN-quad2D\data\curved_mat\';
|
|
f=@(x,y)(x^2+y^2);
|
|
for tot=1:500
|
|
load([dataPath,num2str(tot),'.mat'],'CP','W','Xi');
|
|
res=quad2D(5,f,CP{1,1},W{1,1},Xi{1,1});
|
|
save([ansPath,num2str(tot),'.mat'],'res');
|
|
l=length(Xi{1,1})-length(W{1,1});
|
|
mat=[CP{1,1} zeros(2,l);W{1,1} zeros(1,l);Xi{1,1}];
|
|
save([matPath,num2str(tot),'.mat'],'mat');
|
|
|
|
load([dataPath,num2str(tot),'_neg.mat'],'CP','W','Xi');
|
|
res=quad2D(5,f,CP{1,1},W{1,1},Xi{1,1});
|
|
save([ansPath,num2str(tot),'_neg.mat'],'res');
|
|
l=length(Xi{1,1})-length(W{1,1});
|
|
mat=[CP{1,1} zeros(2,l);W{1,1} zeros(1,l);Xi{1,1}];
|
|
save([matPath,num2str(tot),'_neg.mat'],'mat');
|
|
tot
|
|
end
|
|
|
|
%% curved row2_dir1 in [0,10]x[0,10]
|
|
dataPath='C:\Users\Caich\Desktop\CAD\Projects\CNN-quad2D\data\curved\';
|
|
ansPath='C:\Users\Caich\Desktop\CAD\Projects\CNN-quad2D\data\curved_ans\';
|
|
matPath='C:\Users\Caich\Desktop\CAD\Projects\CNN-quad2D\data\curved_mat\';
|
|
|
|
x1=rand()*10;
|
|
x2=rand()*10;
|
|
CP{1,1}=[0 x1/2 x1 7 8 9 x2 x2/2 0;
|
|
10 5 0 3 4 6 10 10 10];
|
|
W{1,1}=ones(1,9);
|
|
Xi{1,1}=[0 0 0 1 1 2 3 4 4 5 5 5];
|
|
% res=quad2D(5,f,CP{1,1},W{1,1},Xi{1,1})
|
|
|
|
for tot=1001:1500
|
|
R=rand(2,3)*10;
|
|
CP{1,1}(:,4:6)=R;
|
|
save([dataPath,num2str(tot),'.mat'],'CP','W','Xi');
|
|
|
|
load([dataPath,num2str(tot),'.mat'],'CP','W','Xi');
|
|
CP{1,1}=flip(CP{1,1},2);
|
|
save([dataPath,num2str(tot),'_neg.mat'],'CP','W','Xi');
|
|
tot
|
|
end
|
|
|
|
%% curved_ans row2_dir1 in [0,10]x[0,10]
|
|
dataPath='C:\Users\Caich\Desktop\CAD\Projects\CNN-quad2D\data\curved\';
|
|
ansPath='C:\Users\Caich\Desktop\CAD\Projects\CNN-quad2D\data\curved_ans\';
|
|
matPath='C:\Users\Caich\Desktop\CAD\Projects\CNN-quad2D\data\curved_mat\';
|
|
f=@(x,y)(x^2+y^2);
|
|
for tot=1001:1500
|
|
load([dataPath,num2str(tot),'.mat'],'CP','W','Xi');
|
|
res=quad2D(5,f,CP{1,1},W{1,1},Xi{1,1});
|
|
save([ansPath,num2str(tot),'.mat'],'res');
|
|
l=length(Xi{1,1})-length(W{1,1});
|
|
mat=[CP{1,1} zeros(2,l);W{1,1} zeros(1,l);Xi{1,1}];
|
|
save([matPath,num2str(tot),'.mat'],'mat');
|
|
|
|
load([dataPath,num2str(tot),'_neg.mat'],'CP','W','Xi');
|
|
res=quad2D(5,f,CP{1,1},W{1,1},Xi{1,1});
|
|
save([ansPath,num2str(tot),'_neg.mat'],'res');
|
|
l=length(Xi{1,1})-length(W{1,1});
|
|
mat=[CP{1,1} zeros(2,l);W{1,1} zeros(1,l);Xi{1,1}];
|
|
save([matPath,num2str(tot),'_neg.mat'],'mat');
|
|
tot
|
|
end
|
|
|
|
%% curved row3_dir1 in [0,10]x[0,10]
|
|
dataPath='C:\Users\Caich\Desktop\CAD\Projects\CNN-quad2D\data\curved\';
|
|
ansPath='C:\Users\Caich\Desktop\CAD\Projects\CNN-quad2D\data\curved_ans\';
|
|
matPath='C:\Users\Caich\Desktop\CAD\Projects\CNN-quad2D\data\curved_mat\';
|
|
|
|
y1=rand()*10;
|
|
x2=rand()*10;
|
|
CP{1,1}=[0 0 0 2 3 4 x2 x2/2 0;
|
|
10 (y1+10)/2 y1 4 6 7 10 10 10];
|
|
W{1,1}=ones(1,9);
|
|
Xi{1,1}=[0 0 0 1 1 2 3 4 4 5 5 5];
|
|
% res=quad2D(5,f,CP{1,1},W{1,1},Xi{1,1})
|
|
|
|
for tot=2001:2500
|
|
% R=rand(2,3)*10;
|
|
% CP{1,1}(:,4:6)=R;
|
|
% save([dataPath,num2str(tot),'.mat'],'CP','W','Xi');
|
|
|
|
load([dataPath,num2str(tot),'.mat'],'CP','W','Xi');
|
|
CP{1,1}=flip(CP{1,1},2);
|
|
save([dataPath,num2str(tot),'_neg.mat'],'CP','W','Xi');
|
|
tot
|
|
end
|
|
|
|
%% curved_ans row3_dir1 in [0,10]x[0,10]
|
|
dataPath='C:\Users\Caich\Desktop\CAD\Projects\CNN-quad2D\data\curved\';
|
|
ansPath='C:\Users\Caich\Desktop\CAD\Projects\CNN-quad2D\data\curved_ans\';
|
|
matPath='C:\Users\Caich\Desktop\CAD\Projects\CNN-quad2D\data\curved_mat\';
|
|
f=@(x,y)(x^2+y^2);
|
|
for tot=2001:2500
|
|
load([dataPath,num2str(tot),'.mat'],'CP','W','Xi');
|
|
res=quad2D(5,f,CP{1,1},W{1,1},Xi{1,1});
|
|
save([ansPath,num2str(tot),'.mat'],'res');
|
|
l=length(Xi{1,1})-length(W{1,1});
|
|
mat=[CP{1,1} zeros(2,l);W{1,1} zeros(1,l);Xi{1,1}];
|
|
save([matPath,num2str(tot),'.mat'],'mat');
|
|
|
|
load([dataPath,num2str(tot),'_neg.mat'],'CP','W','Xi');
|
|
res=quad2D(5,f,CP{1,1},W{1,1},Xi{1,1});
|
|
save([ansPath,num2str(tot),'_neg.mat'],'res');
|
|
l=length(Xi{1,1})-length(W{1,1});
|
|
mat=[CP{1,1} zeros(2,l);W{1,1} zeros(1,l);Xi{1,1}];
|
|
save([matPath,num2str(tot),'_neg.mat'],'mat');
|
|
tot
|
|
end
|
|
|
|
|
|
%% conventional in [0,10]x[0,10]
|
|
dataPath='C:\Users\Caich\Desktop\CAD\Projects\CNN-quad2D\data\conventional\';
|
|
x1=0;y1=0;
|
|
x2=10*rand();y2=0;
|
|
x3=0;y3=10;
|
|
CP{1,1}=[x1 (x1+x2)/2 x2 (x2+x3)/2 x3 (x3+x1)/2 x1;
|
|
y1 (y1+y2)/2 y2 (y2+y3)/2 y3 (y3+y1)/2 y1];
|
|
W{1,1}=ones(1,7);
|
|
Xi{1,1}=[0 0 0 1 1 2 2 3 3 3];
|
|
|
|
% X2=randperm(1e10,500);
|
|
% sort(X2);
|
|
% for i=2:length(X2)
|
|
% if X2(i)==X2(i-1)
|
|
% disp("same");
|
|
% break;
|
|
% end
|
|
% end
|
|
% X2=X2/1e9;
|
|
|
|
for tot=1:500
|
|
% x2=X2(tot);
|
|
% CP{1,1}(1,2)=x2/2;
|
|
% CP{1,1}(1,3)=x2;
|
|
% CP{1,1}(1,4)=x2/2;
|
|
% save([filepath,num2str(tot),'.mat'],'CP','W','Xi');
|
|
load([dataPath,num2str(tot),'.mat'],'CP','W','Xi');
|
|
CP{1,1}=flip(CP{1,1},2);
|
|
save([filepath,num2str(tot),'_neg.mat'],'CP','W','Xi');
|
|
end
|
|
|
|
|
|
%% conventional_ans fig1 in [0,10]x[0,10]
|
|
dataPath='C:\Users\Caich\Desktop\CAD\Projects\CNN-quad2D\data\conventional\';
|
|
ansPath='C:\Users\Caich\Desktop\CAD\Projects\CNN-quad2D\data\conventional_ans\';
|
|
matPath='C:\Users\Caich\Desktop\CAD\Projects\CNN-quad2D\data\conventional_mat\';
|
|
f=@(x,y)(x^2+y^2);
|
|
for tot=1:500
|
|
load([dataPath,num2str(tot),'.mat'],'CP','W','Xi');
|
|
res=quad2D(5,f,CP{1,1},W{1,1},Xi{1,1});
|
|
save([ansPath,num2str(tot),'.mat'],'res');
|
|
l=length(Xi{1,1})-length(W{1,1});
|
|
mat=[CP{1,1} zeros(2,l);W{1,1} zeros(1,l);Xi{1,1}];
|
|
save([matPath,num2str(tot),'.mat'],'mat');
|
|
|
|
load([dataPath,num2str(tot),'_neg.mat'],'CP','W','Xi');
|
|
res=quad2D(5,f,CP{1,1},W{1,1},Xi{1,1});
|
|
save([ansPath,num2str(tot),'_neg.mat'],'res');
|
|
l=length(Xi{1,1})-length(W{1,1});
|
|
mat=[CP{1,1} zeros(2,l);W{1,1} zeros(1,l);Xi{1,1}];
|
|
save([matPath,num2str(tot),'_neg.mat'],'mat');
|
|
tot
|
|
end
|
|
|