Graphviz 15.1.1~dev.20260630.1303
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#include <stddef.h>
10
11int stress_model(int dim, SparseMatrix B, double *x, int maxit_sm) {
13 int rc = 0;
14
15 if (!SparseMatrix_is_symmetric(A, false) || A->type != MATRIX_TYPE_REAL) {
16 if (A->type == MATRIX_TYPE_REAL) {
17 A = SparseMatrix_symmetrize(A, false);
19 } else {
21 }
22 }
24
25 const size_t m = A->m;
26
28 A, dim, x); // weight the long distances
29
30 if (!sm) {
31 rc = -1;
32 goto RETURN;
33 }
34
35 sm->tol_cg = 0.1; /* we found that there is no need to solve the Laplacian
36 accurately */
39 for (size_t i = 0; i < (size_t)dim * m; i++) {
40 x[i] /= sm->scaling;
41 }
43
44RETURN:
45 if (A != B)
47 return rc;
48}
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