scarf.cc: use barvinok_options instead of MaxRays
[barvinok.git] / mat_util.cc
blob396a08a0f51a3a892683c5c91d1436c50633f963
1 #include <assert.h>
2 #include <NTL/vec_ZZ.h>
3 #include <NTL/mat_ZZ.h>
4 #include "mat_util.h"
6 int lex_cmp(vec_ZZ& a, vec_ZZ& b)
8 assert(a.length() == b.length());
10 for (int j = 0; j < a.length(); ++j)
11 if (a[j] != b[j])
12 return a[j] < b[j] ? -1 : 1;
13 return 0;
16 void lex_order_rows(mat_ZZ& mat)
18 for (int i = 0; i < mat.NumRows(); ++i) {
19 int m = i;
20 for (int j = i+1; j < mat.NumRows(); ++j)
21 if (lex_cmp(mat[j], mat[m]) < 0)
22 m = j;
23 if (m != i) {
24 vec_ZZ tmp = mat[m];
25 mat[m] = mat[i];
26 mat[i] = tmp;