From: Matthew Fernandez Date: Thu, 10 Feb 2022 04:27:13 +0000 (+1100) Subject: sfdpgen: [nfc] remove unnecessary casts X-Git-Tag: 3.0.0~36^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=de0babc32080f1e33b35ab95fbd9ab7085e4a46f;p=graphviz sfdpgen: [nfc] remove unnecessary casts --- diff --git a/lib/sfdpgen/Multilevel.c b/lib/sfdpgen/Multilevel.c index dafa8cfe3..13d97125b 100644 --- a/lib/sfdpgen/Multilevel.c +++ b/lib/sfdpgen/Multilevel.c @@ -262,7 +262,7 @@ static void maximal_independent_edge_set_heavest_edge_pernode(SparseMatrix A, in assert(SparseMatrix_is_symmetric(A, false)); assert(A->type == MATRIX_TYPE_REAL); - a = (double*) A->a; + a = A->a; if (!randomize){ for (i = 0; i < m; i++){ first = TRUE; @@ -351,7 +351,7 @@ static void maximal_independent_edge_set_heavest_edge_pernode_leaves_first(Spars *ncluster = 0; (*clusterp)[0] = 0; nz = 0; - a = (double*) A->a; + a = A->a; if (!randomize){ for (i = 0; i < m; i++){ if (matched[i] == MATCHED || node_degree(i) != 1) continue; @@ -530,7 +530,7 @@ static void maximal_independent_edge_set_heavest_edge_pernode_supernodes_first(S *ncluster = 0; (*clusterp)[0] = 0; nz = 0; - a = (double*) A->a; + a = A->a; for (i = 0; i < nsuper; i++){ if (superp[i+1] - superp[i] <= 1) continue; @@ -632,9 +632,8 @@ static void maximal_independent_edge_set_heavest_edge_pernode_supernodes_first(S } static int scomp(const void *s1, const void *s2){ - const double *ss1, *ss2; - ss1 = (const double*) s1; - ss2 = (const double*) s2; + const double *ss1 = s1; + const double *ss2 = s2; if ((ss1)[1] > (ss2)[1]){ return -1; @@ -673,7 +672,7 @@ static void maximal_independent_edge_set_heavest_cluster_pernode_leaves_first(Sp *ncluster = 0; (*clusterp)[0] = 0; nz = 0; - a = (double*) A->a; + a = A->a; p = random_permutation(m); for (ii = 0; ii < m; ii++){ @@ -760,7 +759,7 @@ static void maximal_independent_edge_set_heavest_edge_pernode_scaled(SparseMatri assert(SparseMatrix_is_symmetric(A, false)); assert(A->type == MATRIX_TYPE_REAL); - a = (double*) A->a; + a = A->a; if (!randomize){ for (i = 0; i < m; i++){ first = TRUE; @@ -931,7 +930,8 @@ static void Multilevel_coarsen_internal(SparseMatrix A, SparseMatrix *cA, Sparse } } assert(nzc == n); - *P = SparseMatrix_from_coordinate_arrays(nzc, n, nc, irn, jcn, (void *) val, MATRIX_TYPE_REAL, sizeof(double)); + *P = SparseMatrix_from_coordinate_arrays(nzc, n, nc, irn, jcn, val, + MATRIX_TYPE_REAL, sizeof(double)); *R = SparseMatrix_transpose(*P); *cD = DistanceMatrix_restrict_cluster(ncluster, clusterp, cluster, *P, *R, D); @@ -995,7 +995,8 @@ static void Multilevel_coarsen_internal(SparseMatrix A, SparseMatrix *cA, Sparse } assert(nc == nmatch); assert(nzc == n); - *P = SparseMatrix_from_coordinate_arrays(nzc, n, nc, irn, jcn, (void *) val, MATRIX_TYPE_REAL, sizeof(double)); + *P = SparseMatrix_from_coordinate_arrays(nzc, n, nc, irn, jcn, val, + MATRIX_TYPE_REAL, sizeof(double)); *R = SparseMatrix_transpose(*P); *cA = SparseMatrix_multiply3(*R, A, *P); /* @@ -1060,7 +1061,8 @@ static void Multilevel_coarsen_internal(SparseMatrix A, SparseMatrix *cA, Sparse } } - *P = SparseMatrix_from_coordinate_arrays(nzc, n, nc, irn, jcn, (void *) val, MATRIX_TYPE_REAL, sizeof(double)); + *P = SparseMatrix_from_coordinate_arrays(nzc, n, nc, irn, jcn, val, + MATRIX_TYPE_REAL, sizeof(double)); *R = SparseMatrix_transpose(*P); *cA = SparseMatrix_multiply3(*R, A, *P); if (!*cA) goto RETURN; diff --git a/lib/sfdpgen/PriorityQueue.c b/lib/sfdpgen/PriorityQueue.c index 225f50689..671002384 100644 --- a/lib/sfdpgen/PriorityQueue.c +++ b/lib/sfdpgen/PriorityQueue.c @@ -96,7 +96,7 @@ int PriorityQueue_pop(PriorityQueue q, int *i, int *gain){ *gain = gain_max = q->gain_max; (q->count)--; l = (q->buckets)[gain_max]; - data = (int*) DoubleLinkedList_get_data(l); + data = DoubleLinkedList_get_data(l); *i = data[0]; DoubleLinkedList_delete_element(l, free, &((q->buckets)[gain_max])); diff --git a/lib/sfdpgen/post_process.c b/lib/sfdpgen/post_process.c index fc6784ab5..f372244f8 100644 --- a/lib/sfdpgen/post_process.c +++ b/lib/sfdpgen/post_process.c @@ -49,7 +49,7 @@ static SparseMatrix ideal_distance_matrix(SparseMatrix A, int dim, double *x){ D->type = MATRIX_TYPE_REAL; D->a = N_GNEW(D->nz,double); } - d = (double*) D->a; + d = D->a; mask = N_GNEW(D->m,int); for (i = 0; i < D->m; i++) mask[i] = -1; @@ -174,7 +174,8 @@ StressMajorizationSmoother StressMajorizationSmoother2_new(SparseMatrix A, int d iw = sm->Lw->ia; jw = sm->Lw->ja; - w = (double*) sm->Lw->a; d = (double*) sm->Lwd->a; + w = sm->Lw->a; + d = sm->Lwd->a; id = sm->Lwd->ia; jd = sm->Lwd->ja; iw[0] = id[0] = 0; @@ -314,7 +315,7 @@ StressMajorizationSmoother SparseStressMajorizationSmoother_new(SparseMatrix A, ia = A->ia; ja = A->ja; - a = (double*) A->a; + a = A->a; sm = MALLOC(sizeof(struct StressMajorizationSmoother_struct)); @@ -339,7 +340,8 @@ StressMajorizationSmoother SparseStressMajorizationSmoother_new(SparseMatrix A, iw = sm->Lw->ia; jw = sm->Lw->ja; id = sm->Lwd->ia; jd = sm->Lwd->ja; - w = (double*) sm->Lw->a; d = (double*) sm->Lwd->a; + w = sm->Lw->a; + d = sm->Lwd->a; iw[0] = id[0] = 0; nz = 0; @@ -609,9 +611,9 @@ double StressMajorizationSmoother_smooth(StressMajorizationSmoother sm, int dim, if (!y) goto RETURN; id = Lwd->ia; jd = Lwd->ja; - d = (double*) Lwd->a; - dd = (double*) Lwdd->a; - w = (double*) Lw->a; + d = Lwd->a; + dd = Lwdd->a; + w = Lw->a; iw = Lw->ia; jw = Lw->ja; #ifdef DEBUG_PRINT @@ -812,7 +814,8 @@ TriangleSmoother TriangleSmoother_new(SparseMatrix A, int dim, double lambda0, d iw = sm->Lw->ia; jw = sm->Lw->ja; - w = (double*) sm->Lw->a; d = (double*) sm->Lwd->a; + w = sm->Lw->a; + d = sm->Lwd->a; for (i = 0; i < m; i++){ diag_d = diag_w = 0; @@ -881,7 +884,7 @@ SpringSmoother SpringSmoother_new(SparseMatrix A, int dim, spring_electrical_con assert(SparseMatrix_is_symmetric(A, false)); ID = ideal_distance_matrix(A, dim, x); - dd = (double*) ID->a; + dd = ID->a; sm = N_GNEW(1,struct SpringSmoother_struct); mask = N_GNEW(m,int); @@ -931,7 +934,7 @@ SpringSmoother SpringSmoother_new(SparseMatrix A, int dim, spring_electrical_con } id = sm->D->ia; jd = sm->D->ja; - d = (double*) sm->D->a; + d = sm->D->a; id[0] = 0; nz = 0; diff --git a/lib/sfdpgen/sparse_solve.c b/lib/sfdpgen/sparse_solve.c index d98da8186..aa53db32e 100644 --- a/lib/sfdpgen/sparse_solve.c +++ b/lib/sfdpgen/sparse_solve.c @@ -81,7 +81,7 @@ static void Operator_matmul_delete(Operator o){ static double* Operator_diag_precon_apply(Operator o, double *x, double *y){ int i, m; - double *diag = (double*) o->data; + double *diag = o->data; m = (int) diag[0]; diag++; for (i = 0; i < m; i++) y[i] = x[i]*diag[i]; @@ -93,7 +93,7 @@ Operator Operator_uniform_stress_diag_precon_new(SparseMatrix A, double alpha){ Operator o; double *diag; int i, j, m = A->m, *ia = A->ia, *ja = A->ja; - double *a = (double*) A->a; + double *a = A->a; assert(A->type == MATRIX_TYPE_REAL); @@ -101,7 +101,7 @@ Operator Operator_uniform_stress_diag_precon_new(SparseMatrix A, double alpha){ o = MALLOC(sizeof(struct Operator_struct)); o->data = MALLOC(sizeof(double)*(m + 1)); - diag = (double*) o->data; + diag = o->data; diag[0] = m; diag++; @@ -122,7 +122,7 @@ static Operator Operator_diag_precon_new(SparseMatrix A){ Operator o; double *diag; int i, j, m = A->m, *ia = A->ia, *ja = A->ja; - double *a = (double*) A->a; + double *a = A->a; assert(A->type == MATRIX_TYPE_REAL); @@ -130,7 +130,7 @@ static Operator Operator_diag_precon_new(SparseMatrix A){ o = N_GNEW(1,struct Operator_struct); o->data = N_GNEW((A->m + 1),double); - diag = (double*) o->data; + diag = o->data; diag[0] = m; diag++; @@ -245,7 +245,9 @@ static double* jacobi(SparseMatrix A, int dim, double *x0, double *rhs, int maxi y = MALLOC(sizeof(double)*n); b = MALLOC(sizeof(double)*n); assert(A->type == MATRIX_TYPE_REAL); - ia = A->ia; ja = A->ja; a = (double*) A->a; + ia = A->ia; + ja = A->ja; + a = A->a; for (k = 0; k < dim; k++){ for (i = 0; i < n; i++) { diff --git a/lib/sfdpgen/spring_electrical.c b/lib/sfdpgen/spring_electrical.c index 807c8d3c1..2c53f19ed 100644 --- a/lib/sfdpgen/spring_electrical.c +++ b/lib/sfdpgen/spring_electrical.c @@ -352,8 +352,8 @@ static double get_angle(double *x, int dim, int i, int j){ } static int comp_real(const void *x, const void *y){ - const double *xx = (const double*) x; - const double *yy = (const double*) y; + const double *xx = x; + const double *yy = y; if (*xx > *yy){ return 1; @@ -1483,7 +1483,7 @@ void spring_electrical_spring_embedding(int dim, SparseMatrix A0, SparseMatrix D ja = A->ja; id = D->ia; jd = D->ja; - d = (double*) D->a; + d = D->a; if (ctrl->random_start){ srand(ctrl->random_seed); diff --git a/lib/sfdpgen/uniform_stress.c b/lib/sfdpgen/uniform_stress.c index ac3cd8153..cbbcb8e61 100644 --- a/lib/sfdpgen/uniform_stress.c +++ b/lib/sfdpgen/uniform_stress.c @@ -30,7 +30,7 @@ UniformStressSmoother UniformStressSmoother_new(int dim, SparseMatrix A, double UniformStressSmoother sm; int i, j, k, m = A->m, *ia = A->ia, *ja = A->ja, *iw, *jw, *id, *jd; int nz; - double *d, *w, *a = (double*) A->a; + double *d, *w, *a = A->a; double diag_d, diag_w, dist, epsilon = 0.01; assert(SparseMatrix_is_symmetric(A, false)); @@ -57,7 +57,8 @@ UniformStressSmoother UniformStressSmoother_new(int dim, SparseMatrix A, double iw = sm->Lw->ia; jw = sm->Lw->ja; id = sm->Lwd->ia; jd = sm->Lwd->ja; - w = (double*) sm->Lw->a; d = (double*) sm->Lwd->a; + w = sm->Lw->a; + d = sm->Lwd->a; iw[0] = id[0] = 0; nz = 0; @@ -117,7 +118,7 @@ static SparseMatrix get_distance_matrix(SparseMatrix A, double scaling){ } else { B = SparseMatrix_get_real_adjacency_matrix_symmetrized(A); } - val = (double*) B->a; + val = B->a; if (scaling != 1) for (i = 0; i < B->nz; i++) val[i] *= scaling; return B; }