summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2018-07-24 19:15:36 -0400
committerJaron Kent-Dobias <jaron@kent-dobias.com>2018-07-24 19:15:36 -0400
commitdbae5cf4f9b80edc8d089475d5de4c13478c4f40 (patch)
tree238885928001f0ece222281dc17a8b1ca6016e27 /lib
parent96e878d2f69790dc72bb4b713c1d492fa2b4c587 (diff)
downloadc++-dbae5cf4f9b80edc8d089475d5de4c13478c4f40.tar.gz
c++-dbae5cf4f9b80edc8d089475d5de4c13478c4f40.tar.bz2
c++-dbae5cf4f9b80edc8d089475d5de4c13478c4f40.zip
removed c files that are no longer faster than the c++ ones
Diffstat (limited to 'lib')
-rw-r--r--lib/cluster_finite.c112
-rw-r--r--lib/cluster_finite.h55
-rw-r--r--lib/dihedral.c55
-rw-r--r--lib/dihedral.h24
-rw-r--r--lib/dihinf.c28
-rw-r--r--lib/dihinf.h17
-rw-r--r--lib/initial_finite.c372
-rw-r--r--lib/initial_finite.h27
-rw-r--r--lib/symmetric.c70
-rw-r--r--lib/symmetric.h19
10 files changed, 2 insertions, 777 deletions
diff --git a/lib/cluster_finite.c b/lib/cluster_finite.c
deleted file mode 100644
index 2041df0..0000000
--- a/lib/cluster_finite.c
+++ /dev/null
@@ -1,112 +0,0 @@
-
-#include "cluster_finite.h"
-
-v_t flip_cluster_finite(state_finite_t *s, v_t v0, R_t rot_ind, gsl_rng *r) {
- q_t *rot = s->transformations + s->q * s->involutions[rot_ind];
- q_t *R_inv = symmetric_invert(s->q, s->R);
- v_t nv = 0;
-
- ll_t *stack = NULL; // create a new stack
- stack_push(&stack, v0); // push the initial vertex to the stack
-
- bool *marks = (bool *)calloc(s->g->nv, sizeof(bool));
-
- while (stack != NULL) {
- v_t v = stack_pop(&stack);
-
- if (!marks[v]) {
- q_t s_old, s_new;
- q_t *R_new, *R_inv_new;
- bool external_flipped;
-
- marks[v] = true;
-
- if (v == s->g->nv - 1) {
- R_new = symmetric_compose(s->q, rot, s->R);
- R_inv_new = symmetric_invert(s->q, R_new);
- external_flipped = true;
- } else {
- s_old = s->spins[v];
- s_new = symmetric_act(rot, s_old);
- external_flipped = false;
- }
-
- v_t nn = s->g->v_i[v + 1] - s->g->v_i[v];
-
- for (v_t i = 0; i < nn; i++) {
- q_t sn, non_ghost;
- double prob;
- bool external_neighbor = false;
-
- v_t vn = s->g->v_adj[s->g->v_i[v] + i];
-
- if (vn == s->g->nv - 1) {
- external_neighbor = true;
- non_ghost = v;
- } else {
- sn = s->spins[vn];
- non_ghost = vn;
- }
-
- if (external_flipped || external_neighbor) {
- q_t rot_s_old, rot_s_new;
-
- if (external_neighbor) {
- rot_s_old = symmetric_act(R_inv, s_old);
- rot_s_new = symmetric_act(R_inv, s_new);
- } else {
- rot_s_old = symmetric_act(R_inv, sn);
- rot_s_new = symmetric_act(R_inv_new, sn);
- }
-
- prob = s->H_probs[rot_s_new * s->q + rot_s_old];
-
- s->M[rot_s_old]--;
- s->M[rot_s_new]++;
-
- for (D_t i = 0; i < s->D; i++) {
- L_t x = (non_ghost / (v_t)pow(s->L, s->D - i - 1)) % s->L;
-
- s->ReF[s->D * i + rot_s_old] -= s->precomputed_cos[i];
- s->ReF[s->D * i + rot_s_new] += s->precomputed_cos[i];
-
- s->ImF[s->D * i + rot_s_old] -= s->precomputed_sin[i];
- s->ImF[s->D * i + rot_s_new] += s->precomputed_sin[i];
- }
-
- } else {
- q_t diff_old = s->bond_with_zero_type[s->transformations[s->q * s->transform_site_to_zero[sn] + s_old]];
- q_t diff_new = s->bond_with_zero_type[s->transformations[s->q * s->transform_site_to_zero[sn] + s_new]];
-
- prob = s->J_probs[diff_new * s->n_bond_types + diff_old];
-
- s->B[diff_old]--;
- s->B[diff_new]++;
- }
-
- if (gsl_rng_uniform(r) < prob) { // and with probability ps[e]...
- stack_push(&stack, vn); // push the neighboring vertex to the stack
- }
- }
-
- if (external_flipped) {
- free(s->R);
- free(R_inv);
- s->R = R_new;
- R_inv = R_inv_new;
- } else {
- s->spins[v] = s_new;
- }
-
- if (v != s->g->nv - 1) { // count the number of non-external sites that flip
- nv++;
- }
- }
- }
-
- free(marks);
- free(R_inv);
-
- return nv;
-}
-
diff --git a/lib/cluster_finite.h b/lib/cluster_finite.h
deleted file mode 100644
index 117087e..0000000
--- a/lib/cluster_finite.h
+++ /dev/null
@@ -1,55 +0,0 @@
-
-#pragma once
-
-#include <assert.h>
-#include <fftw3.h>
-#include <float.h>
-#include <gsl/gsl_randist.h>
-#include <gsl/gsl_rng.h>
-#include <inttypes.h>
-#include <math.h>
-#include <stdbool.h>
-#include <string.h>
-#include <sys/types.h>
-
-#include "types.h"
-#include "rand.h"
-#include "stack.h"
-#include "convex.h"
-#include "graph.h"
-#include "tree.h"
-#include "measurement.h"
-#include "symmetric.h"
-#include "yule_walker.h"
-
-typedef struct {
- D_t D;
- L_t L;
- v_t nv;
- v_t ne;
- graph_t *g;
- q_t q;
- R_t n_transformations;
- q_t *transformations;
- R_t n_involutions;
- R_t *involutions;
- R_t *transform_site_to_zero;
- q_t n_bond_types;
- q_t *bond_with_zero_type;
- double T;
- double *J;
- double *H;
- double *J_probs;
- double *H_probs;
- q_t *spins;
- q_t *R;
- v_t *B;
- v_t *M;
- double *ReF;
- double *ImF;
- double *precomputed_cos;
- double *precomputed_sin;
-} state_finite_t;
-
-v_t flip_cluster_finite(state_finite_t *s, v_t v0, R_t rot, gsl_rng *r);
-
diff --git a/lib/dihedral.c b/lib/dihedral.c
deleted file mode 100644
index 8158b43..0000000
--- a/lib/dihedral.c
+++ /dev/null
@@ -1,55 +0,0 @@
-
-#include "dihedral.h"
-
-dihedral_t *dihedral_compose(q_t q, q_t g1i, const dihedral_t *g2) {
- // we only need to consider the action of reflections
- dihedral_t *g3 = (dihedral_t *)malloc(1 * sizeof(dihedral_t));
-
- g3->r = !g2->r;
- g3->i = (g1i + q - g2->i) % q;
-
- return g3;
-}
-
-q_t dihedral_act(q_t q, q_t gi, bool r, q_t s) {
- // we only need to consider the action of reflections
-
- if (r) {
- return (gi + q - s) % q;
- } else {
- return (gi + s) % q;
- }
-}
-
-q_t dihedral_inverse_act(q_t q, const dihedral_t *g, q_t s) {
- if (g->r) {
- return (q - ((q + s - g->i) % q)) % q;
- } else {
- return (q + s - g->i) % q;
- }
-}
-
-q_t *dihedral_gen_transformations(q_t q) {
- q_t *transformations = (q_t *)malloc(2 * q * q * sizeof(q_t));
-
- for (q_t i = 0; i < q; i++) {
- for (q_t j = 0; j < q; j++) {
- transformations[q * i + j] = dihedral_act(q, i, false, j);
- transformations[q * q + q * i + j] = dihedral_act(q, i, true, j);
- }
- }
-
- return transformations;
-}
-
-R_t *dihedral_gen_involutions(q_t q) {
- R_t *transformations = (R_t *)malloc(q * sizeof(R_t));
-
- for (q_t i = 0; i < q; i++) {
- transformations[i] = q + i;
- }
-
- return transformations;
-}
-
-
diff --git a/lib/dihedral.h b/lib/dihedral.h
index f67c930..f547497 100644
--- a/lib/dihedral.h
+++ b/lib/dihedral.h
@@ -1,26 +1,8 @@
-#include <stdbool.h>
-#include <stdlib.h>
+#pragma once
#include "types.h"
-
-typedef struct {
- q_t i;
- bool r;
-} dihedral_t;
-
-dihedral_t *dihedral_compose(q_t q, q_t gti, const dihedral_t *g2);
-
-q_t dihedral_act(q_t q, q_t gi, bool r, q_t s);
-
-q_t dihedral_inverse_act(q_t q, const dihedral_t *g, q_t s);
-
-q_t *dihedral_gen_transformations(q_t q);
-R_t *dihedral_gen_involutions(q_t q);
-
-R_t factorial(q_t);
-
-#ifdef __cplusplus
+#include "potts.h"
template <class T, q_t q>
struct dihedral2_t { bool is_reflection; T x; };
@@ -95,5 +77,3 @@ dihedral2_t<q_t, q> act_inverse(dihedral2_t<q_t,q> r1, dihedral2_t<q_t,q> r2) {
return r3;
}
-#endif
-
diff --git a/lib/dihinf.c b/lib/dihinf.c
deleted file mode 100644
index 4f88a7a..0000000
--- a/lib/dihinf.c
+++ /dev/null
@@ -1,28 +0,0 @@
-
-#include "dihinf.h"
-
-dihinf_t *dihinf_compose(h_t g1i, const dihinf_t *g2) {
- // we only need to consider the action of reflections
- dihinf_t *g3 = (dihinf_t *)malloc(1 * sizeof(dihinf_t));
-
- g3->r = !g2->r;
- g3->i = g1i - g2->i;
-
- return g3;
-}
-
-h_t dihinf_act(h_t gi, h_t s) {
- // we only need to consider the action of reflections
-
- return gi - s;
-}
-
-h_t dihinf_inverse_act(const dihinf_t *g, h_t s) {
- if (g->r) {
- return g->i - s;
- } else {
- return s - g->i;
- }
-}
-
-
diff --git a/lib/dihinf.h b/lib/dihinf.h
deleted file mode 100644
index 2bc7dc2..0000000
--- a/lib/dihinf.h
+++ /dev/null
@@ -1,17 +0,0 @@
-
-#include <stdbool.h>
-#include <stdlib.h>
-
-#include "types.h"
-
-typedef struct {
- h_t i;
- bool r;
-} dihinf_t;
-
-dihinf_t *dihinf_compose(h_t gti, const dihinf_t *g2);
-
-h_t dihinf_act(h_t gi, h_t s);
-
-h_t dihinf_inverse_act(const dihinf_t *g, h_t s);
-
diff --git a/lib/initial_finite.c b/lib/initial_finite.c
deleted file mode 100644
index 59e7ec4..0000000
--- a/lib/initial_finite.c
+++ /dev/null
@@ -1,372 +0,0 @@
-
-#include "initial_finite.h"
-
-double *precompute_cos(L_t L) {
- double *x = (double *)malloc(L * sizeof(double));
- for (L_t i = 0; i < L; i++) {
- x[i] = cos(2 * M_PI * (double)i / (double)L);
- }
-
- return x;
-}
-
-double *precompute_sin(L_t L) {
- double *x = (double *)malloc(L * sizeof(double));
- for (L_t i = 0; i < L; i++) {
- x[i] = sin(2 * M_PI * (double)i / (double)L);
- }
-
- return x;
-}
-
-double *Jprobs_from_J(q_t q, double T, double *J) {
- double *J_probs = (double *)calloc(pow(q, 2), sizeof(double));
-
- for (q_t i = 0; i < q; i++) {
- for (q_t j = 0; j < q; j++) {
- J_probs[q * i + j] = 1.0 - exp((J[i] - J[j]) / T);
- }
- }
-
- return J_probs;
-}
-
-q_t *initialize_R(q_t q) {
- q_t *R = (q_t *)malloc(q * sizeof(q_t));
-
- for (q_t i = 0; i < q; i++) {
- R[i] = i;
- }
-
- return R;
-}
-
-R_t *transformation_bringing_to_zero(q_t q, R_t n_transformations, q_t *transformations) {
- R_t *destination = (R_t *)malloc(q * sizeof(R_t));
-
- for (q_t i = 0; i < q; i++) {
- for (R_t j = 0; j < n_transformations; j++) {
- if (transformations[q * j + i] == 0) {
- destination[i] = j;
- }
- }
- }
-
- return destination;
-}
-
-R_t find_involutions(R_t *destination, q_t q, R_t n_transformations, q_t *transformations) {
- R_t n_involutions = 0;
-
- for (R_t i = 1; i < n_transformations; i++) {
- bool is_involution = true;
- for (q_t j = 0; j < q; j++) {
- if (j != transformations[q * i + transformations[q * i + j]]) {
- is_involution = false;
- break;
- }
- }
- if (is_involution) {
- destination[n_involutions] = i;
- n_involutions++;
- }
- }
-
- return n_involutions;
-}
-
-state_finite_t *initial_finite_prepare_ising(D_t D, L_t L, double T, double *H) {
- state_finite_t *s = (state_finite_t *)calloc(1, sizeof(state_finite_t));
-
- s->D = D;
- s->L = L;
-
- {
- graph_t *g = graph_create_square(D, L);
- s->nv = g->nv;
- s->ne = g->ne;
- s->g = graph_add_ext(g);
- graph_free(g);
- }
-
- s->q = 2;
-
- s->n_transformations = 2;
- s->transformations = (q_t *)malloc(2 * 2 * sizeof(q_t));
- s->transformations[0] = 0;
- s->transformations[1] = 1;
- s->transformations[2] = 1;
- s->transformations[3] = 0;
-
- s->n_involutions = 1;
- s->involutions = (R_t *)malloc(1 * sizeof(R_t));
- s->involutions[0] = 1;
-
- s->transform_site_to_zero = (R_t *)malloc(2 * sizeof(R_t));
- s->transform_site_to_zero[0] = 0;
- s->transform_site_to_zero[1] = 1;
-
- s->n_bond_types = 2;
- s->bond_with_zero_type = (q_t *)malloc(2 * sizeof(q_t));
- s->bond_with_zero_type[0] = 0;
- s->bond_with_zero_type[1] = 1;
-
- s->T = T;
- s->J = (double *)malloc(2 * sizeof(double));
- s->J[0] = 1.0;
- s->J[1] = -1.0;
- s->H = (double *)malloc(2 * sizeof(double));
- s->H[0] = H[0];
- s->H[1] = -H[0];
-
- s->J_probs = Jprobs_from_J(2, T, s->J);
- s->H_probs = Jprobs_from_J(2, T, s->H);
-
- s->spins = (q_t *)calloc(s->nv, sizeof(q_t));
- s->R = initialize_R(2);
-
- s->M = (v_t *)calloc(2, sizeof(v_t));
- s->M[0] = s->nv; // everyone starts in state 0, remember?
- s->B = (v_t *)calloc(2, sizeof(v_t));
- s->B[0] = s->ne;
-
- s->ReF = (double *)calloc(D * 2, sizeof(double));
- s->ImF = (double *)calloc(D * 2, sizeof(double));
-
-
- s->precomputed_cos = precompute_cos(L);
- s->precomputed_sin = precompute_sin(L);
-
- return s;
-}
-
-state_finite_t *initial_finite_prepare_potts(D_t D, L_t L, q_t q, double T, double *H) {
- state_finite_t *s = (state_finite_t *)calloc(1, sizeof(state_finite_t));
-
- s->D = D;
- s->L = L;
-
- {
- graph_t *g = graph_create_square(D, L);
- s->nv = g->nv;
- s->ne = g->ne;
- s->g = graph_add_ext(g);
- graph_free(g);
- }
-
- s->q = q;
- s->n_transformations = factorial(q);
- s->transformations = symmetric_gen_transformations(q);
- s->involutions = (R_t *)malloc(s->n_transformations * sizeof(R_t));
- s->n_involutions = find_involutions(s->involutions, q, s->n_transformations, s->transformations);
-
- s->transform_site_to_zero = transformation_bringing_to_zero(q, s->n_transformations, s->transformations);
-
- s->n_bond_types = 2;
-
- s->bond_with_zero_type = (q_t *)malloc(q * sizeof(q_t));
-
- s->bond_with_zero_type[0] = 0;
-
- for (q_t i = 1; i < q; i++) {
- s->bond_with_zero_type[i] = 1;
- }
-
- s->T = T;
- s->J = (double *)calloc(2, sizeof(double));
- s->J[0] = 1.0;
- s->J[1] = 0.0;
-
- s->H = (double *)malloc(q * sizeof(double));
- for (q_t i = 0; i < q; i++) {
- s->H[i] = H[i];
- }
-
- s->J_probs = Jprobs_from_J(s->n_bond_types, T, s->J);
- s->H_probs = Jprobs_from_J(q, T, s->H);
-
- s->spins = (q_t *)calloc(s->nv, sizeof(q_t));
- s->R = initialize_R(q);
-
- s->M = (v_t *)calloc(q, sizeof(v_t));
- s->M[0] = s->nv; // everyone starts in state 0, remember?
- s->B = (v_t *)calloc(s->n_bond_types, sizeof(v_t));
- s->B[0] = s->ne; // everyone starts in state 0, remember?
-
- s->ReF = (double *)calloc(D * q, sizeof(double));
- s->ImF = (double *)calloc(D * q, sizeof(double));
-
- s->precomputed_cos = precompute_cos(L);
- s->precomputed_sin = precompute_sin(L);
-
- return s;
-}
-
-state_finite_t *initial_finite_prepare_clock(D_t D, L_t L, q_t q, double T, double *H) {
- state_finite_t *s = (state_finite_t *)calloc(1, sizeof(state_finite_t));
-
- s->D = D;
- s->L = L;
-
- {
- graph_t *g = graph_create_square(D, L);
- s->nv = g->nv;
- s->ne = g->ne;
- s->g = graph_add_ext(g);
- graph_free(g);
- }
-
- s->q = q;
-
- s->n_transformations = 2 * q;
- s->transformations = dihedral_gen_transformations(q);
- s->n_involutions = q;
- s->involutions = dihedral_gen_involutions(q);
-
- s->transform_site_to_zero = transformation_bringing_to_zero(q, s->n_transformations, s->transformations);
- s->bond_with_zero_type = malloc(q * sizeof(q_t));
-
- s->n_bond_types = q / 2 + 1;
-
- for (q_t i = 0; i < q / 2 + 1; i++) {
- s->bond_with_zero_type[i] = i;
- }
-
- for (q_t i = 1; i < (q + 1) / 2; i++) {
- s->bond_with_zero_type[q - i] = i;
- }
-
-
- s->T = T;
- s->J = (double *)malloc(s->n_bond_types * sizeof(double));
-
- for (q_t i = 0; i < s->n_bond_types; i++) {
- s->J[i] = cos(2 * M_PI * i / ((double)q));
- }
-
-
- s->H = (double *)malloc(q * sizeof(double));
- for (q_t i = 0; i < q; i++) {
- s->H[i] = H[i];
- }
-
- s->J_probs = Jprobs_from_J(s->n_bond_types, T, s->J);
- s->H_probs = Jprobs_from_J(q, T, s->H);
-
- s->spins = (q_t *)calloc(s->nv, sizeof(q_t));
- s->R = initialize_R(q);
-
- s->M = (v_t *)calloc(q, sizeof(v_t));
- s->M[0] = s->nv; // everyone starts in state 0, remember?
- s->B = (v_t *)calloc(s->n_bond_types, sizeof(v_t));
- s->B[0] = s->ne; // everyone starts in state 0, remember?
-
- s->ReF = (double *)calloc(D * q, sizeof(double));
- s->ImF = (double *)calloc(D * q, sizeof(double));
-
- s->precomputed_cos = precompute_cos(L);
- s->precomputed_sin = precompute_sin(L);
-
- return s;
-}
-
-state_finite_t *initial_finite_prepare_dgm(D_t D, L_t L, q_t q, double T, double *H) {
- state_finite_t *s = (state_finite_t *)calloc(1, sizeof(state_finite_t));
-
- s->D = D;
- s->L = L;
-
- {
- graph_t *g = graph_create_square(D, L);
- s->nv = g->nv;
- s->ne = g->ne;
- s->g = graph_add_ext(g);
- graph_free(g);
- }
-
- s->q = q;
-
- s->n_transformations = 2 * q;
- s->transformations = dihedral_gen_transformations(q);
- s->n_involutions = q;
- s->involutions = dihedral_gen_involutions(q);
-
- s->transform_site_to_zero = transformation_bringing_to_zero(q, s->n_transformations, s->transformations);
- s->bond_with_zero_type = malloc(q * sizeof(q_t));
-
- s->n_bond_types = q / 2 + 1;
-
- for (q_t i = 0; i < q / 2 + 1; i++) {
- s->bond_with_zero_type[i] = i;
- }
-
- for (q_t i = 1; i < (q + 1) / 2; i++) {
- s->bond_with_zero_type[(int)q - (int)i] = i;
- }
-
- s->T = T;
- s->J = (double *)malloc(s->n_bond_types * sizeof(double));
-
- for (q_t i = 0; i < s->n_bond_types; i++) {
- s->J[i] = -pow(i, 2);
- }
-
- s->H = (double *)malloc(q * sizeof(double));
- for (q_t i = 0; i < q; i++) {
- s->H[i] = H[i];
- }
-
- s->J_probs = Jprobs_from_J(s->n_bond_types, T, s->J);
- s->H_probs = Jprobs_from_J(q, T, s->H);
-
- s->spins = (q_t *)calloc(s->nv, sizeof(q_t));
- s->R = initialize_R(q);
-
- s->M = (v_t *)calloc(q, sizeof(v_t));
- s->M[0] = s->nv; // everyone starts in state 0, remember?
- s->B = (v_t *)calloc(s->n_bond_types, sizeof(v_t));
- s->B[0] = s->nv; // everyone starts in state 0, remember?
-
- s->ReF = (double *)calloc(D * q, sizeof(double));
- s->ImF = (double *)calloc(D * q, sizeof(double));
-
- s->precomputed_cos = precompute_cos(L);
- s->precomputed_sin = precompute_sin(L);
-
- return s;
-}
-
-double state_finite_energy(state_finite_t *s) {
- double E = 0;
-
- for (q_t i = 0; i < s->n_bond_types; i++) {
- E += s->J[i] * s->B[i];
- }
- for (q_t i = 0; i < s->q; i++) {
- E += s->H[i] * s->M[i];
- }
-
- return -E;
-}
-
-void state_finite_free(state_finite_t *s) {
- graph_free(s->g);
- free(s->J);
- free(s->H);
- free(s->J_probs);
- free(s->H_probs);
- free(s->spins);
- free(s->R);
- free(s->M);
- free(s->B);
- free(s->transformations);
- free(s->involutions);
- free(s->transform_site_to_zero);
- free(s->bond_with_zero_type);
- free(s->ReF);
- free(s->ImF);
- free(s->precomputed_cos);
- free(s->precomputed_sin);
- free(s);
-}
-
diff --git a/lib/initial_finite.h b/lib/initial_finite.h
deleted file mode 100644
index 542f923..0000000
--- a/lib/initial_finite.h
+++ /dev/null
@@ -1,27 +0,0 @@
-
-#pragma once
-
-#include <stdbool.h>
-
-#include "types.h"
-#include "dihedral.h"
-#include "cluster_finite.h"
-
-static char *finite_model_t_strings[] = {"ISING", "POTTS", "CLOCK", "DGM"};
-
-typedef enum {
- ISING,
- POTTS,
- CLOCK,
- DGM
-} finite_model_t;
-
-state_finite_t *initial_finite_prepare_ising(D_t D, L_t L, double T, double *H);
-state_finite_t *initial_finite_prepare_potts(D_t D, L_t L, q_t q, double T, double *H);
-state_finite_t *initial_finite_prepare_clock(D_t D, L_t L, q_t q, double T, double *H);
-state_finite_t *initial_finite_prepare_dgm(D_t D, L_t L, q_t q, double T, double *H);
-
-void state_finite_free(state_finite_t *s);
-
-double state_finite_energy(state_finite_t *s);
-
diff --git a/lib/symmetric.c b/lib/symmetric.c
deleted file mode 100644
index 4487538..0000000
--- a/lib/symmetric.c
+++ /dev/null
@@ -1,70 +0,0 @@
-
-#include "symmetric.h"
-
-q_t *symmetric_compose(q_t q, const q_t *g1, const q_t *g2) {
- q_t *g3 = (q_t *)malloc(q * sizeof(q_t));
-
- for (q_t i = 0; i < q; i++) {
- g3[i] = g1[g2[i]];
- }
-
- return g3;
-}
-
-q_t symmetric_act(const q_t *g, q_t s) {
- return g[s];
-}
-
-q_t *symmetric_invert(q_t q, const q_t *g) {
- q_t *g_inv = (q_t *)malloc(q * sizeof(q_t));
-
- for (q_t i = 0; i < q; i++) {
- g_inv[g[i]] = i;
- }
-
- return g_inv;
-}
-
-void swap(q_t *q1, q_t *q2) {
- q_t temp = *q1;
- *q1 = *q2;
- *q2 = temp;
-}
-
-R_t factorial(q_t q) {
- if (q == 0) {
- return 1;
- } else {
- return q * factorial(q - 1);
- }
-}
-
-void permute(q_t *a, q_t l, q_t r, R_t pos, q_t *transformations) {
- if (l == r - 1) {
- for (q_t i = 0; i < r; i++) {
- transformations[r * pos + i] = a[i];
- }
- } else {
- for (q_t i = l; i < r; i++) {
- swap((a+l), (a+i));
- permute(a, l+1, r, pos + (i - l) * factorial(r - l - 1), transformations);
- swap((a+l), (a+i));
- }
- }
-}
-
-q_t *symmetric_gen_transformations(q_t q) {
- q_t *transformations = (q_t *)malloc(q * factorial(q) * sizeof(q_t));
- q_t *tmp = (q_t *)malloc(q * sizeof(q_t));
-
- for (q_t i = 0; i < q; i++) {
- tmp[i] = i;
- }
-
- permute(tmp, 0, q, 0, transformations);
-
- free(tmp);
-
- return transformations;
-}
-
diff --git a/lib/symmetric.h b/lib/symmetric.h
index a73b403..41c8fb6 100644
--- a/lib/symmetric.h
+++ b/lib/symmetric.h
@@ -2,27 +2,9 @@
#pragma once
#include <stdlib.h>
-
#include "types.h"
-
-#ifdef __cplusplus
#include "potts.h"
-extern "C" {
-#endif
-
-q_t *symmetric_compose(q_t q, const q_t *g1, const q_t *g2);
-
-q_t symmetric_act(const q_t *g, q_t s);
-
-q_t *symmetric_invert(q_t q, const q_t *g);
-
-q_t *symmetric_gen_transformations(q_t q);
-
-#ifdef __cplusplus
-}
-#endif
-#ifdef __cplusplus
template <q_t q>
class symmetric_t {
public:
@@ -100,5 +82,4 @@ symmetric_t<q> act_inverse(symmetric_t<q> r1, symmetric_t<q> r2) {
return r3;
}
-#endif