diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2018-04-23 18:32:49 -0400 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2018-04-23 18:32:49 -0400 |
commit | fbbc4d9655835c0d6fdf58f231e59d7007a99407 (patch) | |
tree | cf534240022ef4f3f39f3e865dbfa6032666f04e /lib | |
parent | c9f253b3987ee3e5ae88a99ddd2757801026efb2 (diff) | |
download | c++-fbbc4d9655835c0d6fdf58f231e59d7007a99407.tar.gz c++-fbbc4d9655835c0d6fdf58f231e59d7007a99407.tar.bz2 c++-fbbc4d9655835c0d6fdf58f231e59d7007a99407.zip |
lots of changes
Diffstat (limited to 'lib')
-rw-r--r-- | lib/cluster.h | 8 | ||||
-rw-r--r-- | lib/convex.c | 1 | ||||
-rw-r--r-- | lib/measurement.h | 2 | ||||
-rw-r--r-- | lib/yule_walker.c | 41 | ||||
-rw-r--r-- | lib/yule_walker.h | 12 |
5 files changed, 63 insertions, 1 deletions
diff --git a/lib/cluster.h b/lib/cluster.h index 2de17e5..d118735 100644 --- a/lib/cluster.h +++ b/lib/cluster.h @@ -22,6 +22,7 @@ #include "orthogonal.h" #include "dihedral.h" #include "dihinf.h" +#include "yule_walker.h" typedef struct { graph_t *g; @@ -62,6 +63,13 @@ typedef struct { q_t n; } vector_state_t; +typedef enum { + VECTOR, + MODULATED, + CUBIC, + QUADRATIC +} vector_field_t; + v_t flip_cluster(ising_state_t *s, v_t v0, q_t s1, gsl_rng *r); v_t flip_cluster_vector(vector_state_t *s, v_t v0, double *rot, gsl_rng *r); diff --git a/lib/convex.c b/lib/convex.c index df506f9..7255ad4 100644 --- a/lib/convex.c +++ b/lib/convex.c @@ -93,7 +93,6 @@ double *get_convex_minorant(count_t n, double *Gammas) { while (L != NULL) { free(L->p); - list_t *L_save = L; L = L->next; free(L); } diff --git a/lib/measurement.h b/lib/measurement.h index a24df9f..eaa260b 100644 --- a/lib/measurement.h +++ b/lib/measurement.h @@ -1,4 +1,6 @@ +#pragma once + #include <math.h> #include <stdlib.h> diff --git a/lib/yule_walker.c b/lib/yule_walker.c new file mode 100644 index 0000000..77b3e96 --- /dev/null +++ b/lib/yule_walker.c @@ -0,0 +1,41 @@ + +#include "yule_walker.h" + +double yule_walker(const autocorr_t *a) { + gsl_vector *rhos = gsl_vector_alloc(a->W); + gsl_matrix *mat = gsl_matrix_alloc(a->W, a->W); + gsl_vector *phis = gsl_vector_alloc(a->W); + + for (count_t i = 0; i < a->W; i++) { + gsl_vector_set(rhos, i, rho(a, i)); + } + + for (count_t i = 0; i < a->W; i++) { + gsl_matrix_set(mat, i, i, 1.0); + + for (count_t j = 0; j < i; j++) { + gsl_matrix_set(mat, i, j, gsl_vector_get(rhos, i - 1 - j)); + } + + for (count_t j = 0; j < a->W - 1 - i; j++) { + gsl_matrix_set(mat, i, i + 1 + j, gsl_vector_get(rhos, j)); + } + } + + int out = gsl_linalg_cholesky_solve(mat, rhos, phis); + + double rhophi = 0; + double onephi = 0; + + for (count_t i = 0; i < a->W; i++) { + rhophi += gsl_vector_get(rhos, i) * gsl_vector_get(phis, i); + onephi += gsl_vector_get(phis, i); + } + + gsl_vector_free(rhos); + gsl_matrix_free(mat); + gsl_vector_free(phis); + + return (1 - rhophi) / pow(1 - onephi, 2); +} + diff --git a/lib/yule_walker.h b/lib/yule_walker.h new file mode 100644 index 0000000..883ea03 --- /dev/null +++ b/lib/yule_walker.h @@ -0,0 +1,12 @@ + +#pragma once + +#include <gsl/gsl_linalg.h> +#include <gsl/gsl_matrix.h> +#include <gsl/gsl_vector.h> + +#include "types.h" +#include "measurement.h" + +double yule_walker(const autocorr_t *a); + |