24 const int *ja,
const int *p) {
26 for (
int j = ia[i]; j < ia[i+1]; j++){
27 if (ja[j] >= 0 && (
size_t)ja[j] == i)
continue;
33static void get_12_norm(
size_t n,
const int *ia,
const int *ja,
int *p,
39 for (
size_t i = 0; i < n; i++){
41 for (
int j = ia[i]; j < ia[i+1]; j++){
42 if (ja[j] >= 0 && (
size_t)ja[j] == i)
continue;
44 tmp =
zmin(tmp, (
size_t)abs(p[i] - p[ja[j]]));
52 int cnt = 1, *ia =
A->ia, *ja =
A->ja;
53 const size_t n =
A->m;
55 clock_t start = clock();
59 fprintf(stderr,
"saving timing vs antiband data to timing_greedy\n");
60 fp = fopen(
"timing_greedy",
"w");
63 for (
bool improved =
true; improved; ) {
65 for (
size_t i = 0; i < n; i++) {
67 for (
size_t j = 0; j < n; j++) {
76 if (
zmin(norm11, norm22) >
zmin(norm1[0], norm2)){
86 fprintf(fp,
"%f %" PRISIZE_T " %" PRISIZE_T "\n", (
double)(clock() - start) / CLOCKS_PER_SEC,
92 fprintf(stderr,
"[%d] aband = %" PRISIZE_T ", aband_avg = %" PRISIZE_T "\n",
cnt++, norm1[0], norm1[1]);
93 fprintf(fp,
"%f %" PRISIZE_T " %" PRISIZE_T "\n", (
double)(clock() - start) / CLOCKS_PER_SEC,
103 const size_t n =
A->m;
105 clock_t start = clock();
106 assert(
A->m == (
size_t)
A->n);
108 const int *
const ia = A2->
ia;
109 const int *
const ja = A2->
ja;
113 for (
size_t i = 0; i < n; i++){
115 for (
int j = ia[i]; j < ia[i+1]; j++){
116 const int jj = ja[j];
136 fprintf(stderr,
"cpu time for spectral ordering (before greedy) = %f\n",
137 ((
double)(clock() - start)) / CLOCKS_PER_SEC);
139 clock_t start2 = clock();
143 fprintf(stderr,
"cpu time for greedy refinement = %f\n",
144 ((
double)(clock() - start2)) / CLOCKS_PER_SEC);
146 fprintf(stderr,
"cpu time for spectral + greedy = %f\n",
147 ((
double)(clock() - start)) / CLOCKS_PER_SEC);
SparseMatrix SparseMatrix_new(size_t m, int n, size_t nz, int type, int format)
SparseMatrix SparseMatrix_from_coordinate_format(SparseMatrix A)
SparseMatrix SparseMatrix_symmetrize(SparseMatrix A, bool pattern_symmetric_only)
bool SparseMatrix_is_symmetric(SparseMatrix A, bool test_pattern_symmetry_only)
void SparseMatrix_delete(SparseMatrix A)
#define SparseMatrix_coordinate_form_add_entry(A, irn, jcn, val)
wrap SparseMatrix_coordinate_form_add_entry_ for type safety
void country_graph_coloring(int seed, SparseMatrix A, int **p)
static size_t get_local_12_norm(size_t n, size_t i, const int *ia, const int *ja, const int *p)
void improve_antibandwidth_by_swapping(SparseMatrix A, int *p)
static void get_12_norm(size_t n, const int *ia, const int *ja, int *p, size_t *norm)
static double norm(int n, const double *x)
void vector_ordering(size_t n, double *v, int **p)
static int cnt(Dict_t *d, Dtlink_t **set)
Arithmetic helper functions.
static size_t zmin(size_t a, size_t b)
minimum of two sizes
double * power_method(void *A, int n, int random_seed)