| 1 |
/************************************************************************* |
| 2 |
* Copyright (c) 2011 AT&T Intellectual Property |
| 3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
| 6 |
* https://www.eclipse.org/legal/epl-v10.html |
| 7 |
* |
| 8 |
* Contributors: Details at https://graphviz.org |
| 9 |
*************************************************************************/ |
| 10 |
|
| 11 |
#pragma once |
| 12 |
|
| 13 |
#include <sfdpgen/spring_electrical.h> |
| 14 |
#include <stdbool.h> |
| 15 |
|
| 16 |
enum {SM_SCHEME_NORMAL, SM_SCHEME_NORMAL_ELABEL, SM_SCHEME_STRESS}; |
| 17 |
|
| 18 |
struct StressMajorizationSmoother_struct { |
| 19 |
SparseMatrix D;/* distance matrix. The diagonal is removed hence the ia, ja structure is different from Lw and Lwd!! */ |
| 20 |
SparseMatrix Lw; ///< the weighted laplacian. with offdiag = -1 ÷ wᵢⱼ |
| 21 |
SparseMatrix Lwd; ///< the laplacian like matrix with offdiag = -scaling × dᵢⱼ ÷ wᵢⱼ. RHS in stress majorization = Lwd.x |
| 22 |
double* lambda; |
| 23 |
void (*data_deallocator)(void*); |
| 24 |
void *data; |
| 25 |
int scheme; |
| 26 |
double scaling;/* scaling. It is multiplied to Lwd. need to divide coordinate x at the end of the stress majorization process */ |
| 27 |
double tol_cg;/* tolerance and maxit for conjugate gradient that solves the Laplacian system. |
| 28 |
typically the Laplacian only needs to be solved very crudely as it is part of an |
| 29 |
outer iteration.*/ |
| 30 |
double maxit_cg; |
| 31 |
}; |
| 32 |
|
| 33 |
typedef struct StressMajorizationSmoother_struct *StressMajorizationSmoother; |
| 34 |
|
| 35 |
void StressMajorizationSmoother_delete(StressMajorizationSmoother sm); |
| 36 |
|
| 37 |
enum {IDEAL_GRAPH_DIST, IDEAL_AVG_DIST, IDEAL_POWER_DIST}; |
| 38 |
StressMajorizationSmoother StressMajorizationSmoother2_new(SparseMatrix A, int dim, double lambda, double *x, int ideal_dist_scheme); |
| 39 |
|
| 40 |
double StressMajorizationSmoother_smooth(StressMajorizationSmoother sm, int dim, double *x, int maxit); |
| 41 |
/*-------------------- triangle/neirhborhood graph based smoother ------------------- */ |
| 42 |
typedef StressMajorizationSmoother TriangleSmoother; |
| 43 |
|
| 44 |
#define TriangleSmoother_struct StressMajorizationSmoother_struct |
| 45 |
|
| 46 |
void TriangleSmoother_delete(TriangleSmoother sm); |
| 47 |
|
| 48 |
TriangleSmoother TriangleSmoother_new(SparseMatrix A, int dim, double *x, |
| 49 |
bool use_triangularization); |
| 50 |
|
| 51 |
void TriangleSmoother_smooth(TriangleSmoother sm, int dim, double *x); |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
/*------------------ spring and spring-electrical based smoother */ |
| 56 |
|
| 57 |
struct SpringSmoother_struct { |
| 58 |
SparseMatrix D; |
| 59 |
spring_electrical_control ctrl; |
| 60 |
}; |
| 61 |
|
| 62 |
typedef struct SpringSmoother_struct *SpringSmoother; |
| 63 |
|
| 64 |
SpringSmoother SpringSmoother_new(SparseMatrix A, int dim, spring_electrical_control ctrl, double *x); |
| 65 |
|
| 66 |
void SpringSmoother_delete(SpringSmoother sm); |
| 67 |
|
| 68 |
void SpringSmoother_smooth(SpringSmoother sm, SparseMatrix A, int dim, double *x); |
| 69 |
/*------------------------------------------------------------------*/ |
| 70 |
|
| 71 |
void post_process_smoothing(int dim, SparseMatrix A, spring_electrical_control ctrl, double *x); |
| 72 |
|
| 73 |
/*-------------------- sparse stress majorizationp ------------------- */ |
| 74 |
typedef StressMajorizationSmoother SparseStressMajorizationSmoother; |
| 75 |
|
| 76 |
#define SparseStressMajorizationSmoother_struct StressMajorizationSmoother_struct |
| 77 |
|
| 78 |
void SparseStressMajorizationSmoother_delete(SparseStressMajorizationSmoother sm); |
| 79 |
|
| 80 |
SparseStressMajorizationSmoother |
| 81 |
SparseStressMajorizationSmoother_new(SparseMatrix A, int dim, double *x); |
| 82 |
|
| 83 |
double SparseStressMajorizationSmoother_smooth(SparseStressMajorizationSmoother sm, int dim, double *x, int maxit_sm); |
| 84 |
|
| 85 |
/*--------------------------------------------------------------*/ |