Skip to content

Commit 62cbb55

Browse files
committed
Int64 only used where necessary
1 parent 3ce0055 commit 62cbb55

36 files changed

+662
-906
lines changed

cmake/sources.cmake

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ set(factor_highs_sources
218218
ipm/hipo/factorhighs/Numeric.cpp
219219
ipm/hipo/factorhighs/SolveHandler.cpp
220220
ipm/hipo/factorhighs/Swaps.cpp
221-
ipm/hipo/factorhighs/SymScaling.cpp
222221
ipm/hipo/factorhighs/Symbolic.cpp)
223222

224223
set(factor_highs_headers
@@ -238,7 +237,6 @@ set(factor_highs_headers
238237
ipm/hipo/factorhighs/ReturnValues.h
239238
ipm/hipo/factorhighs/SolveHandler.h
240239
ipm/hipo/factorhighs/Swaps.h
241-
ipm/hipo/factorhighs/SymScaling.h
242240
ipm/hipo/factorhighs/Symbolic.h
243241
ipm/hipo/factorhighs/Timing.h)
244242

highs/ipm/hipo/auxiliary/Auxiliary.cpp

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ void inversePerm(const std::vector<Int>& perm, std::vector<Int>& iperm) {
1414
}
1515
}
1616

17-
void subtreeSize(const std::vector<Int64>& parent, std::vector<Int64>& sizes) {
17+
void subtreeSize(const std::vector<Int>& parent, std::vector<Int>& sizes) {
1818
// Compute sizes of subtrees of the tree given by parent
1919

20-
Int64 n = parent.size();
20+
Int n = parent.size();
2121
sizes.assign(n, 1);
2222

23-
for (Int64 i = 0; i < n; ++i) {
24-
Int64 k = parent[i];
23+
for (Int i = 0; i < n; ++i) {
24+
Int k = parent[i];
2525
if (k != -1) sizes[k] += sizes[i];
2626
}
2727
}
@@ -82,36 +82,36 @@ void transpose(const std::vector<Int>& ptr, const std::vector<Int>& rows,
8282
}
8383
}
8484

85-
void childrenLinkedList(const std::vector<Int64>& parent,
86-
std::vector<Int64>& head, std::vector<Int64>& next) {
85+
void childrenLinkedList(const std::vector<Int>& parent, std::vector<Int>& head,
86+
std::vector<Int>& next) {
8787
// Create linked lists of children in elimination tree.
8888
// parent gives the dependencies of the tree,
8989
// head[node] is the first child of node,
9090
// next[head[node]] is the second child,
9191
// next[next[head[node]]] is the third child...
9292
// until -1 is reached.
9393

94-
Int64 n = parent.size();
94+
Int n = parent.size();
9595
head.assign(n, -1);
9696
next.assign(n, -1);
97-
for (Int64 node = n - 1; node >= 0; --node) {
97+
for (Int node = n - 1; node >= 0; --node) {
9898
if (parent[node] == -1) continue;
9999
next[node] = head[parent[node]];
100100
head[parent[node]] = node;
101101
}
102102
}
103103

104-
void reverseLinkedList(std::vector<Int64>& head, std::vector<Int64>& next) {
104+
void reverseLinkedList(std::vector<Int>& head, std::vector<Int>& next) {
105105
// Reverse the linked list of children of each node.
106106
// If a node has children (a -> b -> c -> -1), the reverse list contains
107107
// children (c -> b -> a -> -1).
108108

109-
const Int64 n = head.size();
109+
const Int n = head.size();
110110

111-
for (Int64 node = 0; node < n; ++node) {
112-
Int64 prev_node = -1;
113-
Int64 curr_node = head[node];
114-
Int64 next_node = -1;
111+
for (Int node = 0; node < n; ++node) {
112+
Int prev_node = -1;
113+
Int curr_node = head[node];
114+
Int next_node = -1;
115115

116116
while (curr_node != -1) {
117117
next_node = next[curr_node];
@@ -124,18 +124,18 @@ void reverseLinkedList(std::vector<Int64>& head, std::vector<Int64>& next) {
124124
}
125125
}
126126

127-
void dfsPostorder(Int64 node, Int64& start, std::vector<Int64>& head,
128-
const std::vector<Int64>& next, std::vector<Int>& order) {
127+
void dfsPostorder(Int node, Int& start, std::vector<Int>& head,
128+
const std::vector<Int>& next, std::vector<Int>& order) {
129129
// Perform depth first search starting from root node and order the nodes
130130
// starting from the value start. head and next contain the linked list of
131131
// children.
132132

133-
std::stack<Int64> stack;
133+
std::stack<Int> stack;
134134
stack.push(node);
135135

136136
while (!stack.empty()) {
137-
const Int64 current = stack.top();
138-
const Int64 child = head[current];
137+
const Int current = stack.top();
138+
const Int child = head[current];
139139

140140
if (child == -1) {
141141
// no children left to order,
@@ -151,9 +151,9 @@ void dfsPostorder(Int64 node, Int64& start, std::vector<Int64>& head,
151151
}
152152
}
153153

154-
void processEdge(Int64 j, Int64 i, const std::vector<Int64>& first,
155-
std::vector<Int64>& maxfirst, std::vector<Int64>& delta,
156-
std::vector<Int64>& prevleaf, std::vector<Int64>& ancestor) {
154+
void processEdge(Int j, Int i, const std::vector<Int>& first,
155+
std::vector<Int>& maxfirst, std::vector<Int>& delta,
156+
std::vector<Int>& prevleaf, std::vector<Int>& ancestor) {
157157
// Process edge of skeleton matrix.
158158
// Taken from Tim Davis "Direct Methods for Sparse Linear Systems".
159159

@@ -166,21 +166,21 @@ void processEdge(Int64 j, Int64 i, const std::vector<Int64>& first,
166166
maxfirst[i] = first[j];
167167

168168
// previous leaf of ith row subtree
169-
Int64 jprev = prevleaf[i];
169+
Int jprev = prevleaf[i];
170170

171171
// A(i,j) is in the skeleton matrix
172172
delta[j]++;
173173

174174
if (jprev != -1) {
175175
// find least common ancestor of jprev and j
176-
Int64 q = jprev;
176+
Int q = jprev;
177177
while (q != ancestor[q]) {
178178
q = ancestor[q];
179179
}
180180

181181
// path compression
182-
Int64 sparent;
183-
for (Int64 s = jprev; s != q; s = sparent) {
182+
Int sparent;
183+
for (Int s = jprev; s != q; s = sparent) {
184184
sparent = ancestor[s];
185185
ancestor[s] = q;
186186
}
@@ -193,16 +193,16 @@ void processEdge(Int64 j, Int64 i, const std::vector<Int64>& first,
193193
prevleaf[i] = j;
194194
}
195195

196-
Int64 getDiagStart(Int64 n, Int64 k, Int64 nb, Int64 n_blocks,
196+
Int64 getDiagStart(Int n, Int k, Int nb, Int n_blocks,
197197
std::vector<Int64>& start, bool triang) {
198198
// start position of diagonal blocks for blocked dense formats
199199
start.assign(n_blocks, 0);
200-
for (Int64 i = 1; i < n_blocks; ++i) {
200+
for (Int i = 1; i < n_blocks; ++i) {
201201
start[i] = start[i - 1] + nb * (n - (i - 1) * nb);
202202
if (triang) start[i] -= nb * (nb - 1) / 2;
203203
}
204204

205-
Int64 jb = std::min(nb, k - (n_blocks - 1) * nb);
205+
Int jb = std::min(nb, k - (n_blocks - 1) * nb);
206206
Int64 result = start.back() + (n - (n_blocks - 1) * nb) * jb;
207207
if (triang) result -= jb * (jb - 1) / 2;
208208
return result;

highs/ipm/hipo/auxiliary/Auxiliary.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@
1212
namespace hipo {
1313

1414
void inversePerm(const std::vector<Int>& perm, std::vector<Int>& iperm);
15-
void subtreeSize(const std::vector<Int64>& parent, std::vector<Int64>& sizes);
15+
void subtreeSize(const std::vector<Int>& parent, std::vector<Int>& sizes);
1616
void transpose(const std::vector<Int>& ptr, const std::vector<Int>& rows,
1717
std::vector<Int>& ptrT, std::vector<Int>& rowsT);
1818
void transpose(const std::vector<Int>& ptr, const std::vector<Int>& rows,
1919
const std::vector<double>& val, std::vector<Int>& ptrT,
2020
std::vector<Int>& rowsT, std::vector<double>& valT);
21-
void childrenLinkedList(const std::vector<Int64>& parent,
22-
std::vector<Int64>& head, std::vector<Int64>& next);
23-
void reverseLinkedList(std::vector<Int64>& head, std::vector<Int64>& next);
24-
void dfsPostorder(Int64 node, Int64& start, std::vector<Int64>& head,
25-
const std::vector<Int64>& next, std::vector<Int>& order);
26-
void processEdge(Int64 j, Int64 i, const std::vector<Int64>& first,
27-
std::vector<Int64>& maxfirst, std::vector<Int64>& delta,
28-
std::vector<Int64>& prevleaf, std::vector<Int64>& ancestor);
29-
Int64 getDiagStart(Int64 n, Int64 k, Int64 nb, Int64 n_blocks,
21+
void childrenLinkedList(const std::vector<Int>& parent, std::vector<Int>& head,
22+
std::vector<Int>& next);
23+
void reverseLinkedList(std::vector<Int>& head, std::vector<Int>& next);
24+
void dfsPostorder(Int node, Int& start, std::vector<Int>& head,
25+
const std::vector<Int>& next, std::vector<Int>& order);
26+
void processEdge(Int j, Int i, const std::vector<Int>& first,
27+
std::vector<Int>& maxfirst, std::vector<Int>& delta,
28+
std::vector<Int>& prevleaf, std::vector<Int>& ancestor);
29+
Int64 getDiagStart(Int n, Int k, Int nb, Int n_blocks,
3030
std::vector<Int64>& start, bool triang = false);
3131

3232
template <typename T>
@@ -49,14 +49,14 @@ template <typename T>
4949
void permuteVector(std::vector<T>& v, const std::vector<Int>& perm) {
5050
// Permute vector v according to permutation perm.
5151
std::vector<T> temp_v(v);
52-
for (Int64 i = 0; i < v.size(); ++i) v[i] = temp_v[perm[i]];
52+
for (Int i = 0; i < v.size(); ++i) v[i] = temp_v[perm[i]];
5353
}
5454

5555
template <typename T>
5656
void permuteVectorInverse(std::vector<T>& v, const std::vector<Int>& iperm) {
5757
// Permute vector v according to inverse permutation iperm.
5858
std::vector<T> temp_v(v);
59-
for (Int64 i = 0; i < v.size(); ++i) v[iperm[i]] = temp_v[i];
59+
for (Int i = 0; i < v.size(); ++i) v[iperm[i]] = temp_v[i];
6060
}
6161

6262
template <typename T>

highs/ipm/hipo/auxiliary/IntConfig.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ typedef int64_t Int64;
1616
// kHighsIInf nonzero entries. Metis works with the same type as Int, so it must
1717
// be compiled accordingly.
1818
//
19-
// The factorisation uses Int64 everywhere, apart from where it interfaces with
20-
// the matrix stored using Int.
19+
// The factorisation uses a combination of Int and Int64. Int64 is used only
20+
// where needed, i.e. when dealing with nonzeros of the factor or when checking
21+
// overflows.
2122
// BLAS is 32-bit, so the vectors used by BLAS must be addressable with 32-bit
2223
// integers.
2324
//

highs/ipm/hipo/auxiliary/mycblas.h

Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@
66
// Provide definition for cblas functions
77
// Based on Netlib implementation
88

9-
// NB:
10-
// Blas is declared as using 64-bit integers.
11-
// The library that gets actually linked may use 32- or 64-bit integers,
12-
// depending on the integer model.
13-
149
enum CBLAS_ORDER { CblasRowMajor = 101, CblasColMajor = 102 };
1510
enum CBLAS_TRANSPOSE {
1611
CblasNoTrans = 111,
@@ -25,61 +20,63 @@ enum CBLAS_SIDE { CblasLeft = 141, CblasRight = 142 };
2520
extern "C" {
2621
#endif
2722

23+
typedef int32_t blasint;
24+
2825
// level 1
2926

30-
void cblas_daxpy(const hipo::Int64 n, const double alpha, const double* x,
31-
const hipo::Int64 incx, double* y, const hipo::Int64 incy);
32-
void cblas_dcopy(const hipo::Int64 n, const double* x, const hipo::Int64 incx,
33-
double* y, const hipo::Int64 incy);
34-
void cblas_dscal(const hipo::Int64 n, const double alpha, double* x,
35-
const hipo::Int64 incx);
36-
void cblas_dswap(const hipo::Int64 n, double* x, const hipo::Int64 incx,
37-
double* y, const hipo::Int64 incy);
27+
void cblas_daxpy(const blasint n, const double alpha, const double* x,
28+
const blasint incx, double* y, const blasint incy);
29+
void cblas_dcopy(const blasint n, const double* x, const blasint incx,
30+
double* y, const blasint incy);
31+
void cblas_dscal(const blasint n, const double alpha, double* x,
32+
const blasint incx);
33+
void cblas_dswap(const blasint n, double* x, const blasint incx, double* y,
34+
const blasint incy);
3835

3936
// level 2
4037

4138
void cblas_dgemv(const enum CBLAS_ORDER order,
42-
const enum CBLAS_TRANSPOSE transa, const hipo::Int64 M,
43-
const hipo::Int64 n, const double alpha, const double* A,
44-
const hipo::Int64 lda, const double* x, const hipo::Int64 incx,
45-
const double beta, double* y, const hipo::Int64 incy);
39+
const enum CBLAS_TRANSPOSE transa, const blasint M,
40+
const blasint n, const double alpha, const double* A,
41+
const blasint lda, const double* x, const blasint incx,
42+
const double beta, double* y, const blasint incy);
4643

4744
void cblas_dtpsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO uplo,
4845
const enum CBLAS_TRANSPOSE transa, const enum CBLAS_DIAG diag,
49-
const hipo::Int64 n, const double* ap, double* x,
50-
const hipo::Int64 incx);
46+
const blasint n, const double* ap, double* x,
47+
const blasint incx);
5148

5249
void cblas_dtrsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO uplo,
5350
const enum CBLAS_TRANSPOSE transa, const enum CBLAS_DIAG diag,
54-
const hipo::Int64 n, const double* a, const hipo::Int64 lda,
55-
double* x, const hipo::Int64 incx);
51+
const blasint n, const double* a, const blasint lda, double* x,
52+
const blasint incx);
5653

57-
void cblas_dger(const enum CBLAS_ORDER order, const hipo::Int64 m,
58-
const hipo::Int64 n, const double alpha, const double* x,
59-
const hipo::Int64 incx, const double* y, const hipo::Int64 incy,
60-
double* A, const hipo::Int64 lda);
54+
void cblas_dger(const enum CBLAS_ORDER order, const blasint m, const blasint n,
55+
const double alpha, const double* x, const blasint incx,
56+
const double* y, const blasint incy, double* A,
57+
const blasint lda);
6158

6259
// level 3
6360

6461
void cblas_dgemm(const enum CBLAS_ORDER order,
6562
const enum CBLAS_TRANSPOSE transa,
66-
const enum CBLAS_TRANSPOSE transb, const hipo::Int64 m,
67-
const hipo::Int64 n, const hipo::Int64 k, const double alpha,
68-
const double* A, const hipo::Int64 lda, const double* B,
69-
const hipo::Int64 ldb, const double beta, double* C,
70-
const hipo::Int64 ldc);
63+
const enum CBLAS_TRANSPOSE transb, const blasint m,
64+
const blasint n, const blasint k, const double alpha,
65+
const double* A, const blasint lda, const double* B,
66+
const blasint ldb, const double beta, double* C,
67+
const blasint ldc);
7168

7269
void cblas_dsyrk(const enum CBLAS_ORDER order, const enum CBLAS_UPLO uplo,
73-
const enum CBLAS_TRANSPOSE trans, const hipo::Int64 n,
74-
const hipo::Int64 k, const double alpha, const double* a,
75-
const hipo::Int64 lda, const double beta, double* C,
76-
const hipo::Int64 ldc);
70+
const enum CBLAS_TRANSPOSE trans, const blasint n,
71+
const blasint k, const double alpha, const double* a,
72+
const blasint lda, const double beta, double* C,
73+
const blasint ldc);
7774

7875
void cblas_dtrsm(const enum CBLAS_ORDER order, const enum CBLAS_SIDE side,
7976
const enum CBLAS_UPLO uplo, const enum CBLAS_TRANSPOSE transa,
80-
const enum CBLAS_DIAG diag, const hipo::Int64 m,
81-
const hipo::Int64 n, const double alpha, const double* a,
82-
const hipo::Int64 lda, double* b, const hipo::Int64 ldb);
77+
const enum CBLAS_DIAG diag, const blasint m, const blasint n,
78+
const double alpha, const double* a, const blasint lda,
79+
double* b, const blasint ldb);
8380

8481
#ifdef __cplusplus
8582
}

0 commit comments

Comments
 (0)