~verifypn-cpn/verifypn/col_weight_fix

« back to all changes in this revision

Viewing changes to lpsolve/lp_utils.h

  • Committer: Jonas Finnemann Jensen
  • Date: 2013-10-19 05:57:48 UTC
  • Revision ID: jopsen@gmail.com-20131019055748-ujmf009kwz6k6x3v
Support for osx32 and osx64 bit builds, we now have ugly binaries in source tree

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef HEADER_lp_utils
 
2
#define HEADER_lp_utils
 
3
 
 
4
#ifdef FORTIFY
 
5
 
 
6
#include "lp_fortify.h"
 
7
 
 
8
#define allocCHAR allocCHAR_FORTIFY
 
9
#define allocMYBOOL allocMYBOOL_FORTIFY
 
10
#define allocINT allocINT_FORTIFY
 
11
#define allocREAL allocREAL_FORTIFY
 
12
#define allocLREAL allocLREAL_FORTIFY
 
13
 
 
14
#endif
 
15
 
 
16
#include "lp_types.h"
 
17
 
 
18
/* Temporary data storage arrays */
 
19
typedef struct _workarraysrec
 
20
{
 
21
  lprec     *lp;
 
22
  int       size;
 
23
  int       count;
 
24
  char      **vectorarray;
 
25
  int       *vectorsize;
 
26
} workarraysrec;
 
27
 
 
28
typedef struct _LLrec
 
29
{
 
30
  int       size;               /* The allocated list size */
 
31
  int       count;              /* The current entry count */
 
32
  int       firstitem;
 
33
  int       lastitem;
 
34
  int       *map;               /* The list of forward and backward-mapped entries */
 
35
} LLrec;
 
36
 
 
37
typedef struct _PVrec
 
38
{
 
39
  int       count;              /* The allocated list item count */
 
40
  int       *startpos;          /* Starting index of the current value */
 
41
  REAL      *value;             /* The list of forward and backward-mapped entries */
 
42
  struct   _PVrec *parent;     /* The parent record in a pushed chain */
 
43
} PVrec;
 
44
 
 
45
 
 
46
#ifdef __cplusplus
 
47
extern "C" {
 
48
#endif
 
49
 
 
50
/* Put function headers here */
 
51
STATIC MYBOOL allocCHAR(lprec *lp, char **ptr, int size, MYBOOL clear);
 
52
STATIC MYBOOL allocMYBOOL(lprec *lp, MYBOOL **ptr, int size, MYBOOL clear);
 
53
STATIC MYBOOL allocINT(lprec *lp, int **ptr, int size, MYBOOL clear);
 
54
STATIC MYBOOL allocREAL(lprec *lp, REAL **ptr, int size, MYBOOL clear);
 
55
STATIC MYBOOL allocLREAL(lprec *lp, LREAL **ptr, int size, MYBOOL clear);
 
56
STATIC MYBOOL allocFREE(lprec *lp, void **ptr);
 
57
REAL *cloneREAL(lprec *lp, REAL *origlist, int size);
 
58
MYBOOL *cloneMYBOOL(lprec *lp, MYBOOL *origlist, int size);
 
59
int *cloneINT(lprec *lp, int *origlist, int size);
 
60
 
 
61
int comp_bits(MYBOOL *bitarray1, MYBOOL *bitarray2, int items);
 
62
 
 
63
STATIC workarraysrec *mempool_create(lprec *lp);
 
64
STATIC char *mempool_obtainVector(workarraysrec *mempool, int count, int unitsize);
 
65
STATIC MYBOOL mempool_releaseVector(workarraysrec *mempool, char *memvector, MYBOOL forcefree);
 
66
STATIC MYBOOL mempool_free(workarraysrec **mempool);
 
67
 
 
68
STATIC void roundVector(LREAL *myvector, int endpos, LREAL roundzero);
 
69
STATIC REAL normalizeVector(REAL *myvector, int endpos);
 
70
 
 
71
STATIC void swapINT(int *item1, int *item2);
 
72
STATIC void swapREAL(REAL *item1, REAL *item2);
 
73
STATIC void swapPTR(void **item1, void **item2);
 
74
STATIC REAL restoreINT(REAL valREAL, REAL epsilon);
 
75
STATIC REAL roundToPrecision(REAL value, REAL precision);
 
76
 
 
77
STATIC int searchFor(int target, int *attributes, int size, int offset, MYBOOL absolute);
 
78
 
 
79
STATIC MYBOOL isINT(lprec *lp, REAL value);
 
80
STATIC MYBOOL isOrigFixed(lprec *lp, int varno);
 
81
STATIC void chsign_bounds(REAL *lobound, REAL *upbound);
 
82
STATIC REAL rand_uniform(lprec *lp, REAL range);
 
83
 
 
84
/* Doubly linked list routines */
 
85
STATIC int createLink(int size, LLrec **linkmap, MYBOOL *usedpos);
 
86
STATIC MYBOOL freeLink(LLrec **linkmap);
 
87
STATIC int sizeLink(LLrec *linkmap);
 
88
STATIC MYBOOL isActiveLink(LLrec *linkmap, int itemnr);
 
89
STATIC int countActiveLink(LLrec *linkmap);
 
90
STATIC int countInactiveLink(LLrec *linkmap);
 
91
STATIC int firstActiveLink(LLrec *linkmap);
 
92
STATIC int lastActiveLink(LLrec *linkmap);
 
93
STATIC MYBOOL appendLink(LLrec *linkmap, int newitem);
 
94
STATIC MYBOOL insertLink(LLrec *linkmap, int afteritem, int newitem);
 
95
STATIC MYBOOL setLink(LLrec *linkmap, int newitem);
 
96
STATIC MYBOOL fillLink(LLrec *linkmap);
 
97
STATIC int nextActiveLink(LLrec *linkmap, int backitemnr);
 
98
STATIC int prevActiveLink(LLrec *linkmap, int forwitemnr);
 
99
STATIC int firstInactiveLink(LLrec *linkmap);
 
100
STATIC int lastInactiveLink(LLrec *linkmap);
 
101
STATIC int nextInactiveLink(LLrec *linkmap, int backitemnr);
 
102
STATIC int prevInactiveLink(LLrec *linkmap, int forwitemnr);
 
103
STATIC int removeLink(LLrec *linkmap, int itemnr);
 
104
STATIC LLrec *cloneLink(LLrec *sourcemap, int newsize, MYBOOL freesource);
 
105
STATIC int compareLink(LLrec *linkmap1, LLrec *linkmap2);
 
106
STATIC MYBOOL verifyLink(LLrec *linkmap, int itemnr, MYBOOL doappend);
 
107
 
 
108
/* Packed vector routines */
 
109
STATIC PVrec  *createPackedVector(int size, REAL *values, int *workvector);
 
110
STATIC void   pushPackedVector(PVrec *PV, PVrec *parent);
 
111
STATIC MYBOOL unpackPackedVector(PVrec *PV, REAL **target);
 
112
STATIC REAL   getvaluePackedVector(PVrec *PV, int index);
 
113
STATIC PVrec  *popPackedVector(PVrec *PV);
 
114
STATIC MYBOOL freePackedVector(PVrec **PV);
 
115
 
 
116
#ifdef __cplusplus
 
117
 }
 
118
#endif
 
119
 
 
120
#endif /* HEADER_lp_utils */
 
121
 
 
122
#ifdef FORTIFY
 
123
 
 
124
#if defined CODE_lp_utils && !defined CODE_lp_utils_
 
125
int _Fortify_ret;
 
126
#else
 
127
extern int _Fortify_ret;
 
128
#endif
 
129
 
 
130
#ifdef CODE_lp_utils
 
131
#define CODE_lp_utils_
 
132
#else
 
133
# undef allocCHAR
 
134
# undef allocMYBOOL
 
135
# undef allocINT
 
136
# undef allocREAL
 
137
# undef allocLREAL
 
138
# define allocCHAR(lp, ptr, size, clear) (Fortify_LINE(__LINE__), Fortify_FILE(__FILE__), _Fortify_ret = allocCHAR_FORTIFY(lp, ptr, size, clear), Fortify_LINE(0), Fortify_FILE(NULL), _Fortify_ret)
 
139
# define allocMYBOOL(lp, ptr, size, clear) (Fortify_LINE(__LINE__), Fortify_FILE(__FILE__), _Fortify_ret = allocMYBOOL_FORTIFY(lp, ptr, size, clear), Fortify_LINE(0), Fortify_FILE(NULL), _Fortify_ret)
 
140
# define allocINT(lp, ptr, size, clear) (Fortify_LINE(__LINE__), Fortify_FILE(__FILE__), _Fortify_ret = allocINT_FORTIFY(lp, ptr, size, clear), Fortify_LINE(0), Fortify_FILE(NULL), _Fortify_ret)
 
141
# define allocREAL(lp, ptr, size, clear) (Fortify_LINE(__LINE__), Fortify_FILE(__FILE__), _Fortify_ret = allocREAL_FORTIFY(lp, ptr, size, clear), Fortify_LINE(0), Fortify_FILE(NULL), _Fortify_ret)
 
142
# define allocLREAL(lp, ptr, size, clear) (Fortify_LINE(__LINE__), Fortify_FILE(__FILE__), _Fortify_ret = allocLREAL_FORTIFY(lp, ptr, size, clear), Fortify_LINE(0), Fortify_FILE(NULL), _Fortify_ret)
 
143
#endif
 
144
 
 
145
#endif
 
146