2 4ti2 -- A software package for algebraic, geometric and combinatorial
3 problems on linear spaces.
5 Copyright (C) 2006 4ti2 team.
6 Main author(s): Matthias Walter.
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 #include "varproperties.h"
30 VariableProperties
createVariableProperties(int size
)
32 VariableProperties var
;
37 var
= (VariableProperties
)malloc(size
*sizeof(variableproperty_t
));
41 fprintf(stderr
, "Fatal Error (%s/%d): Could not allocate memory for VariableProperties!\n", __FILE__
, __LINE__
);
45 for (i
=0; i
<size
; i
++)
48 var
[i
].Upper
= MAXINT
;
49 var
[i
].Lower
= -MAXINT
;
58 void deleteVariableProperties(VariableProperties var
)
66 bool checkVariableSymmetry(VariableProperties var
, int id
)
71 return var
[id
].Lower
+var
[id
].Upper
==0;
76 bool checkVariableFree(VariableProperties var
, int id
)
86 bool checkVariableBounds(VariableProperties var
, int id
, int num
)
91 return var
[id
].Lower
<=num
&& num
<=var
[id
].Upper
;
96 void swapVariableProperties(VariableProperties var
, int a
, int b
)
110 void fprintVariableProperties(FILE *stream
, VariableProperties var
, int size
)
114 for (i
=0; i
<size
; i
++)
115 fprintf(stream
, "%d %d %d %d\n", var
[i
].Column
, var
[i
].Lower
, var
[i
].Upper
, var
[i
].Free
);
120 void readVariableProperties(FILE *stream
, VariableProperties var
, int size
)
127 for (i
=0; i
<size
; i
++)
128 fscanf(stream
, "%d %d %d %d", &(var
[i
].Column
), &(var
[i
].Lower
), &(var
[i
].Upper
), &(var
[i
].Free
));