19 const int *p,
double *
norm){
22 for (j = ia[i]; j < ia[i+1]; j++){
23 if (ja[j] == i)
continue;
24 norm[0] = fmin(
norm[0], abs(p[i] - p[ja[j]]));
26 norm[1] += abs(p[i] - p[ja[j]]);
28 if (nz > 0)
norm[1] /= nz;
38 for (i = 0; i < n; i++){
40 for (j = ia[i]; j < ia[i+1]; j++){
41 if (ja[j] == i)
continue;
42 norm[0] = fmin(
norm[0], abs(p[i] - p[ja[j]]));
43 norm[1] += abs(p[i] - p[ja[j]]);
44 tmp = fmin(tmp, abs(p[i] - p[ja[j]]));
55 int cnt = 1, n =
A->m, i, j, *ia =
A->ia, *ja =
A->ja;
56 double norm1[3], norm2[3], norm11[3], norm22[3];
57 clock_t start = clock();
61 fprintf(stderr,
"saving timing vs antiband data to timing_greedy\n");
62 fp = fopen(
"timing_greedy",
"w");
67 for (i = 0; i < n; i++){
69 for (j = 0; j < n; j++){
78 if (fmin(norm11[0], norm22[0]) > fmin(norm1[0], norm2[0])){
89 fprintf(fp,
"%f %f %f\n", ((
double)(clock() - start)) / CLOCKS_PER_SEC,
95 fprintf(stderr,
"[%d] aband = %f, aband_avg = %f\n",
cnt++, norm1[0], norm1[2]);
96 fprintf(fp,
"%f %f %f\n", ((
double)(clock() - start)) / CLOCKS_PER_SEC,
106 int n =
A->m, i, j, jj;
108 int *ia =
A->
ia, *ja =
A->ja;
112 clock_t start, start2;
115 assert(
A->m ==
A->n);
117 ia = A2->
ia; ja = A2->
ja;
121 for (i = 0; i < n; i++){
123 for (j = ia[i]; j < ia[i+1]; j++){
143 fprintf(stderr,
"cpu time for spectral ordering (before greedy) = %f\n",
144 ((
double)(clock() - start)) / CLOCKS_PER_SEC);
150 fprintf(stderr,
"cpu time for greedy refinement = %f\n",
151 ((
double)(clock() - start2)) / CLOCKS_PER_SEC);
153 fprintf(stderr,
"cpu time for spectral + greedy = %f\n",
154 ((
double)(clock() - start)) / CLOCKS_PER_SEC);
SparseMatrix SparseMatrix_from_coordinate_format(SparseMatrix A)
SparseMatrix SparseMatrix_symmetrize(SparseMatrix A, bool pattern_symmetric_only)
SparseMatrix SparseMatrix_coordinate_form_add_entry(SparseMatrix A, int irn, int jcn, const void *val)
bool SparseMatrix_is_symmetric(SparseMatrix A, bool test_pattern_symmetry_only)
void SparseMatrix_delete(SparseMatrix A)
SparseMatrix SparseMatrix_new(int m, int n, int nz, int type, int format)
void country_graph_coloring(int seed, SparseMatrix A, int **p)
void improve_antibandwidth_by_swapping(SparseMatrix A, int *p)
static void get_12_norm(int n, int *ia, int *ja, int *p, double *norm)
static void get_local_12_norm(int n, int i, const int *ia, const int *ja, const int *p, double *norm)
static double norm(int n, const double *x)
void vector_ordering(int n, double *v, int **p)
static int cnt(Dict_t *d, Dtlink_t **set)
double * power_method(void *A, int n, int random_seed)