23static size_t zabs(
size_t a,
size_t b) {
30 const int *ja,
const size_t *p) {
32 for (
int j = ia[i]; j < ia[i+1]; j++){
33 if (ja[j] >= 0 && (
size_t)ja[j] == i)
continue;
39static void get_12_norm(
size_t n,
const int *ia,
const int *ja,
const size_t *p,
45 for (
size_t i = 0; i < n; i++){
47 for (
int j = ia[i]; j < ia[i+1]; j++){
48 if (ja[j] >= 0 && (
size_t)ja[j] == i)
continue;
50 tmp =
zmin(tmp,
zabs(p[i], p[ja[j]]));
58 int cnt = 1, *ia =
A->ia, *ja =
A->ja;
59 const size_t n =
A->m;
61 clock_t start = clock();
65 fprintf(stderr,
"saving timing vs antiband data to timing_greedy\n");
66 fp = fopen(
"timing_greedy",
"w");
69 for (
bool improved =
true; improved; ) {
71 for (
size_t i = 0; i < n; i++) {
73 for (
size_t j = 0; j < n; j++) {
76 const size_t pi = p[i];
77 const size_t pj = p[j];
82 if (
zmin(norm11, norm22) >
zmin(norm1[0], norm2)){
92 fprintf(fp,
"%f %" PRISIZE_T " %" PRISIZE_T "\n", (
double)(clock() - start) / CLOCKS_PER_SEC,
98 fprintf(stderr,
"[%d] aband = %" PRISIZE_T ", aband_avg = %" PRISIZE_T "\n",
cnt++, norm1[0], norm1[1]);
99 fprintf(fp,
"%f %" PRISIZE_T " %" PRISIZE_T "\n", (
double)(clock() - start) / CLOCKS_PER_SEC,
109 const size_t n =
A->m;
111 clock_t start = clock();
112 assert(
A->m == (
size_t)
A->n);
114 const int *
const ia = A2->
ia;
115 const int *
const ja = A2->
ja;
119 for (
size_t i = 0; i < n; i++){
121 for (
int j = ia[i]; j < ia[i+1]; j++){
122 const int jj = ja[j];
142 fprintf(stderr,
"cpu time for spectral ordering (before greedy) = %f\n",
143 ((
double)(clock() - start)) / CLOCKS_PER_SEC);
145 clock_t start2 = clock();
149 fprintf(stderr,
"cpu time for greedy refinement = %f\n",
150 ((
double)(clock() - start2)) / CLOCKS_PER_SEC);
152 fprintf(stderr,
"cpu time for spectral + greedy = %f\n",
153 ((
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
static size_t get_local_12_norm(size_t n, size_t i, const int *ia, const int *ja, const size_t *p)
void improve_antibandwidth_by_swapping(SparseMatrix A, size_t *p)
static size_t zabs(size_t a, size_t b)
size_t * country_graph_coloring(int seed, SparseMatrix A)
static void get_12_norm(size_t n, const int *ia, const int *ja, const size_t *p, size_t *norm)
static double norm(int n, const double *x)
size_t * vector_ordering(size_t n, double *v)
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)