Graphviz 14.1.3~dev.20260126.0926
Loading...
Searching...
No Matches
stress_model.c
Go to the documentation of this file.
1#include "config.h"
2
7#include <sparse/general.h>
8#include <stdbool.h>
9
10int stress_model(int dim, SparseMatrix B, double *x, int maxit_sm) {
12 int rc = 0;
13
14 if (!SparseMatrix_is_symmetric(A, false) || A->type != MATRIX_TYPE_REAL) {
15 if (A->type == MATRIX_TYPE_REAL) {
16 A = SparseMatrix_symmetrize(A, false);
18 } else {
20 }
21 }
23
24 const int m = A->m;
25
27 A, dim, x); // weight the long distances
28
29 if (!sm) {
30 rc = -1;
31 goto RETURN;
32 }
33
34 sm->tol_cg = 0.1; /* we found that there is no need to solve the Laplacian
35 accurately */
38 for (int i = 0; i < dim * m; i++) {
39 x[i] /= sm->scaling;
40 }
42
43RETURN:
44 if (A != B)
46 return rc;
47}
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:120
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)
#define RETURN(v)
Definition strmatch.c:146