-
Notifications
You must be signed in to change notification settings - Fork 1
/
coordinate_slice.m
117 lines (68 loc) · 3.35 KB
/
coordinate_slice.m
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
% slice_points = coordinate_slice(b_input_copyme, initial_points, random_line_coefficients, slice_value, variable_index, reality_string)
%
% copyright 2015, 2016 Daniel Brake
% University of Notre Dame
% Applied and Computational Mathematics and Statistics
%
% Bertini (TM) is a registered trademark.
%
% This file is part of Bertini_tropical.
%
% Bertini_tropical is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% Bertini_tropical is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>.
function slice_points = coordinate_slice(b_input_copyme, initial_points, random_line_coefficients, slice_value, variable_index, reality_string)
if ~or(strcmp(reality_string,'real'),strcmp(reality_string,'complex'))
error('reality_string must be either ''real'' or ''complex''');
end
b_input = copy(b_input_copyme);
system_variables = b_input.variable_group;
num_vars = length(system_variables);
dirname = sprintf('coord_slice_%s_%.2e',system_variables{variable_index},slice_value);
if exist(dirname,'dir')==0
mkdir(dirname);
end
cd(dirname);
write_generic_solns(initial_points,'start');
b_input.config.userhomotopy = '2';
b_input.declare_symbols({'slice_constant_rand' 'slice_constant_here'},'constant');
b_input.set_symbol('slice_constant_rand',random_line_coefficients(1));
b_input.set_symbol('slice_constant_here',-slice_value);
b_input.declare_symbols({'slice_constant'},'subfunction');
b_input.set_symbol('slice_constant','(1-s)*slice_constant_here + s*slice_constant_rand');
for ii = 1:num_vars
b_input.declare_symbols({[system_variables{ii} '_lin']},'subfunction');
b_input.set_symbol([system_variables{ii} '_lin'], sprintf('(1-s)*%s_here + s*%s_rand',system_variables{ii},system_variables{ii}) );
b_input.declare_symbols({[char(system_variables(ii)) '_here'] [char(system_variables(ii)) '_rand']},'constant');
if ii == variable_index
b_input.set_symbol([char(system_variables(ii)) '_here'],'1');
else
b_input.set_symbol([char(system_variables(ii)) '_here'],'0');
end
b_input.set_symbol([system_variables{ii} '_rand'],random_line_coefficients(ii+1));
end
line = sym('slice_constant');
for ii=1:length(system_variables)
line = line + sym(sprintf('%s_lin',system_variables{ii})) * sym(system_variables{ii});
end
b_input.declare_symbols({'line'},'function');
b_input.set_symbol('line',char(line));
write_bertini_input_file(b_input.variable_group, b_input.functions,'filename','input_slice','options',b_input.config,'constants',b_input.constant,'subfunctions',b_input.subfunction);
bertini('filename','input_slice','startname','start','stifle','mpi',min(4,size(initial_points,2)),'rerunonfail',5); %,'showcommand'
if strcmp(reality_string,'real')
slice_points = get_generic_solns('real_finite_solutions',num_vars);
else
slice_points = get_generic_solns('finite_solutions',num_vars);
end
cd ..
end