Graphviz 14.0.5~dev.20251117.1017
Loading...
Searching...
No Matches
stress_model.c
Go to the documentation of this file.
5#include <sparse/general.h>
6#include <stdbool.h>
7
8int stress_model(int dim, SparseMatrix B, double *x, int maxit_sm) {
10 int rc = 0;
11
12 if (!SparseMatrix_is_symmetric(A, false) || A->type != MATRIX_TYPE_REAL) {
13 if (A->type == MATRIX_TYPE_REAL) {
14 A = SparseMatrix_symmetrize(A, false);
16 } else {
18 }
19 }
21
22 const int m = A->m;
23
25 A, dim, x); // weight the long distances
26
27 if (!sm) {
28 rc = -1;
29 goto RETURN;
30 }
31
32 sm->tol_cg = 0.1; /* we found that there is no need to solve the Laplacian
33 accurately */
36 for (int i = 0; i < dim * m; i++) {
37 x[i] /= sm->scaling;
38 }
40
41RETURN:
42 if (A != B)
44 return rc;
45}
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)
SparseMatrix SparseMatrix_get_real_adjacency_matrix_symmetrized(SparseMatrix A)
SparseMatrix SparseMatrix_remove_diagonal(SparseMatrix A)
@ MATRIX_TYPE_REAL
#define A(n, t)
Definition expr.h:76
#define B
Definition hierarchy.c:118
static const int dim
StressMajorizationSmoother SparseStressMajorizationSmoother_new(SparseMatrix A, int dim, double *x)
void SparseStressMajorizationSmoother_delete(SparseStressMajorizationSmoother sm)
double SparseStressMajorizationSmoother_smooth(SparseStressMajorizationSmoother sm, int dim, double *x, int maxit_sm)
@ SM_SCHEME_STRESS
int stress_model(int dim, SparseMatrix B, double *x, int maxit_sm)
Definition stress_model.c:8
#define RETURN(v)
Definition strmatch.c:144