From 866adf0cf163ecb9e263ba6d79058977d862c4bb Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sat, 23 Jul 2022 08:21:28 -0700 Subject: [PATCH] sfdpgen get_stress: remove 'weighted' parameter that is always 1 --- lib/sfdpgen/post_process.c | 16 ++++++---------- lib/sfdpgen/post_process.h | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/lib/sfdpgen/post_process.c b/lib/sfdpgen/post_process.c index 2d681bc66..973113782 100644 --- a/lib/sfdpgen/post_process.c +++ b/lib/sfdpgen/post_process.c @@ -545,7 +545,7 @@ static void get_edge_label_matrix(relative_position_constraints data, int m, int *rhs = x00; } -double get_stress(int m, int dim, int *iw, int *jw, double *w, double *d, double *x, double scaling, int weighted){ +double get_stress(int m, int dim, int *iw, int *jw, double *w, double *d, double *x, double scaling){ int i, j; double res = 0., dist; /* we use the fact that d_ij = w_ij*graph_dist(i,j). Also, d_ij and x are scalinged by *scaling, so divide by it to get actual unscaled streee. */ @@ -555,11 +555,7 @@ double get_stress(int m, int dim, int *iw, int *jw, double *w, double *d, double continue; } dist = d[j]/w[j];/* both negative*/ - if (weighted){ - res += -w[j]*(dist - distance(x, dim, i, jw[j]))*(dist - distance(x, dim, i, jw[j])); - } else { - res += (dist - distance(x, dim, i, jw[j]))*(dist - distance(x, dim, i, jw[j])); - } + res += -w[j]*(dist - distance(x, dim, i, jw[j]))*(dist - distance(x, dim, i, jw[j])); } } return 0.5*res/scaling/scaling; @@ -616,7 +612,7 @@ double StressMajorizationSmoother_smooth(StressMajorizationSmoother sm, int dim, iw = Lw->ia; jw = Lw->ja; #ifdef DEBUG_PRINT - if (Verbose) fprintf(stderr, "initial stress = %f\n", get_stress(m, dim, iw, jw, w, d, x, sm->scaling, 1)); + if (Verbose) fprintf(stderr, "initial stress = %f\n", get_stress(m, dim, iw, jw, w, d, x, sm->scaling)); #else (void)iw; (void)jw; @@ -699,7 +695,7 @@ double StressMajorizationSmoother_smooth(StressMajorizationSmoother sm, int dim, #ifdef DEBUG_PRINT if (Verbose) { - fprintf(stderr, "stress1 = %g\n",get_stress(m, dim, iw, jw, w, d, x, sm->scaling, 1)); + fprintf(stderr, "stress1 = %g\n",get_stress(m, dim, iw, jw, w, d, x, sm->scaling)); } #endif @@ -712,7 +708,7 @@ double StressMajorizationSmoother_smooth(StressMajorizationSmoother sm, int dim, if (flag) goto RETURN; #ifdef DEBUG_PRINT - if (Verbose) fprintf(stderr, "stress2 = %g\n",get_stress(m, dim, iw, jw, w, d, y, sm->scaling, 1)); + if (Verbose) fprintf(stderr, "stress2 = %g\n",get_stress(m, dim, iw, jw, w, d, y, sm->scaling)); #endif diff = total_distance(m, dim, x, y)/sqrt(vector_product(m*dim, x, x)); #ifdef DEBUG_PRINT @@ -730,7 +726,7 @@ double StressMajorizationSmoother_smooth(StressMajorizationSmoother sm, int dim, #endif #ifdef DEBUG_PRINT - if (Verbose) fprintf(stderr, "iter = %d, final stress = %f\n", iter, get_stress(m, dim, iw, jw, w, d, x, sm->scaling, 1)); + if (Verbose) fprintf(stderr, "iter = %d, final stress = %f\n", iter, get_stress(m, dim, iw, jw, w, d, x, sm->scaling)); #endif RETURN: diff --git a/lib/sfdpgen/post_process.h b/lib/sfdpgen/post_process.h index 45462d391..245d3888f 100644 --- a/lib/sfdpgen/post_process.h +++ b/lib/sfdpgen/post_process.h @@ -81,6 +81,6 @@ SparseStressMajorizationSmoother SparseStressMajorizationSmoother_new(SparseMatr double SparseStressMajorizationSmoother_smooth(SparseStressMajorizationSmoother sm, int dim, double *x, int maxit_sm, double tol); -double get_stress(int m, int dim, int *iw, int *jw, double *w, double *d, double *x, double scaling, int weighted); +double get_stress(int m, int dim, int *iw, int *jw, double *w, double *d, double *x, double scaling); /*--------------------------------------------------------------*/ -- 2.40.0