summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--makefile2
-rw-r--r--makefile_ept2
-rw-r--r--makefile_hal2
-rw-r--r--src/big_anal_process.c147
4 files changed, 150 insertions, 3 deletions
diff --git a/makefile b/makefile
index 0355eaa..1364d06 100644
--- a/makefile
+++ b/makefile
@@ -4,7 +4,7 @@ CFLAGS = -g -Os -O3 -Wall -fno-strict-aliasing -Wstrict-overflow -Wno-missing-fi
LDFLAGS = -lc -lcblas -llapack -ldl -lpthread -lcholmod -lamd -lcolamd -lsuitesparseconfig -lcamd -lccolamd -lm -lrt -lmetis -lgsl -lprofiler -ltcmalloc
OBJ = data bound_set correlations factor_update graph_genfunc net net_voltages net_currents net_conductivity net_fracture get_dual_clusters break_edge graph_components gen_laplacian geometry gen_voltcurmat graph_create graph_free fortune/edgelist fortune/geometry fortune/heap fortune/main fortune/output fortune/voronoi fortune/memory rand
-BIN = corr_test fracture fitting_functions anal_process
+BIN = corr_test fracture fitting_functions anal_process big_anal_process
all: opt ${OBJ:%=obj/%.o} ${BIN:%=obj/%.o} ${BIN:%=bin/%}
diff --git a/makefile_ept b/makefile_ept
index c79a071..81ebb62 100644
--- a/makefile_ept
+++ b/makefile_ept
@@ -4,7 +4,7 @@ CFLAGS = -g -Os -O3 -Wall -fno-strict-aliasing -Wstrict-overflow -Wno-missing-fi
LDFLAGS = -lc -lcblas -llapack -ldl -lpthread -lcholmod -lamd -lcolamd -lsuitesparseconfig -lcamd -lccolamd -lm -lrt -lmetis -lgsl -lprofiler -ltcmalloc
OBJ = data bound_set correlations factor_update graph_genfunc net net_voltages net_currents net_conductivity net_fracture get_dual_clusters break_edge graph_components gen_laplacian geometry gen_voltcurmat graph_create graph_free fortune/edgelist fortune/geometry fortune/heap fortune/main fortune/output fortune/voronoi fortune/memory rand
-BIN = corr_test fracture anal_process
+BIN = corr_test fracture anal_process big_anal_process
all: opt ${OBJ:%=obj/%.o} ${BIN:%=obj/%.o} ${BIN:%=bin/%}
diff --git a/makefile_hal b/makefile_hal
index 1af90c4..7ebc211 100644
--- a/makefile_hal
+++ b/makefile_hal
@@ -4,7 +4,7 @@ CFLAGS = -g -Os -O3 -Wall -fno-strict-aliasing -Wstrict-overflow -Wno-missing-fi
LDFLAGS = -lc -lcblas -llapack -ldl -lpthread -lcholmod -lamd -lcolamd -lsuitesparseconfig -lcamd -lccolamd -lm -lrt -lmetis -lgsl -lprofiler #-ltcmalloc
OBJ = data bound_set correlations factor_update graph_genfunc net net_voltages net_currents net_conductivity net_fracture get_dual_clusters break_edge graph_components gen_laplacian geometry gen_voltcurmat graph_create graph_free fortune/edgelist fortune/geometry fortune/heap fortune/main fortune/output fortune/voronoi fortune/memory rand
-BIN = corr_test fracture
+BIN = corr_test fracture fitting_functions anal_process big_anal_process
all: opt ${OBJ:%=obj/%.o} ${BIN:%=obj/%.o} ${BIN:%=bin/%}
diff --git a/src/big_anal_process.c b/src/big_anal_process.c
new file mode 100644
index 0000000..8345785
--- /dev/null
+++ b/src/big_anal_process.c
@@ -0,0 +1,147 @@
+
+#include "fracture.h"
+#include <gsl/gsl_sf_erf.h>
+#include <gsl/gsl_sf_laguerre.h>
+#include <gsl/gsl_matrix.h>
+#include <gsl/gsl_vector.h>
+#include <gsl/gsl_blas.h>
+#include <sys/stat.h>
+
+void get_mean(uint_t len, double *data, double result[2]) {
+ double total = 0;
+
+ for (uint_t i = 0; i < len; i++) {
+ total += data[i];
+ }
+
+ double mean = total / len;
+ double total_sq_diff = 0;
+
+ for (uint_t i = 0; i < len; i++) {
+ total_sq_diff += pow(mean - data[i], 2);
+ }
+
+ double mean_err = sqrt(total_sq_diff) / len;
+
+ result[0] = mean;
+ result[1] = mean_err;
+}
+
+void get_mom(uint_t len, uint_t n, double *data, double mean[2], double result[2]) {
+ double total_n_diff = 0;
+ double total_n2_diff = 0;
+
+ for (uint_t i = 0; i < len; i++) {
+ total_n_diff += pow(fabs(mean[0] - data[i]), n);
+ total_n2_diff += pow(fabs(mean[0] - data[i]), 2 * n);
+ }
+
+ double mom = total_n_diff / len;
+ double mom_err = sqrt(total_n2_diff) / len;
+
+ result[0] = mom;
+ result[1] = mom_err;
+}
+
+int main(int argc, char *argv[]) {
+ uint_t nc = argc - 1;
+ uint_t *Ls_c = (uint_t *)malloc(nc * sizeof(uint_t));
+ double *betas_c = (double *)malloc(nc * sizeof(double));
+ double *vals_c1 = (double *)malloc(nc * sizeof(double));
+ double *errors_c1 = (double *)malloc(nc * sizeof(double));
+ double *vals_c2 = (double *)malloc(nc * sizeof(double));
+ double *errors_c2 = (double *)malloc(nc * sizeof(double));
+ double *vals_c3 = (double *)malloc(nc * sizeof(double));
+ double *errors_c3 = (double *)malloc(nc * sizeof(double));
+
+ char *out_filename = (char *)malloc(100 * sizeof(char));
+ uint_t out_filename_len = 0;
+
+ for (uint_t i = 0; i < nc; i++) {
+ char *fn = argv[1 + i];
+ char *buff = (char *)malloc(20 * sizeof(char));
+ uint_t pos = 0; uint_t c = 0;
+ while (c < 5) {
+ if (fn[pos] == '_') {
+ c++;
+ }
+ if (i == 0) {
+ out_filename[pos] = fn[pos];
+ out_filename_len++;
+ }
+ pos++;
+ }
+ c = 0;
+ while (fn[pos] != '_') {
+ buff[c] = fn[pos];
+ pos++;
+ c++;
+ }
+ buff[c] = '\0';
+ Ls_c[i] = atoi(buff);
+ c = 0;
+ pos++;
+ while (fn[pos] != '_') {
+ buff[c] = fn[pos];
+ pos++;
+ c++;
+ }
+ buff[c] = '\0';
+ betas_c[i] = atof(buff);
+ free(buff);
+
+ struct stat info;
+ stat(fn, &info);
+ uint_t num_bytes = info.st_size;
+ uint_t dist_len = (num_bytes * sizeof(char)) / sizeof(double);
+
+ double *dist = malloc(dist_len * sizeof(double));
+ FILE *dist_file = fopen(fn, "rb");
+ fread(dist, sizeof(double), dist_len, dist_file);
+ fclose(dist_file);
+ {
+ double mom1[2];
+ get_mean(dist_len, dist, mom1);
+ vals_c1[i] = mom1[0];
+ errors_c1[i] = mom1[1];
+
+ double mom2[2];
+ get_mom(dist_len, 2, dist, mom1, mom2);
+ vals_c2[i] = mom2[0];
+ errors_c2[i] = mom2[1];
+
+ double mom3[2];
+ get_mom(dist_len, 3, dist, mom1, mom3);
+ vals_c3[i] = mom3[0];
+ errors_c3[i] = mom3[1];
+ }
+ free(dist);
+ }
+
+ out_filename[out_filename_len-1] = '.';
+ out_filename[out_filename_len] = 't';
+ out_filename[out_filename_len+1] = 'x';
+ out_filename[out_filename_len+2] = 't';
+ out_filename[out_filename_len+3] = '\0';
+
+ FILE *out_file = fopen(out_filename, "w");
+
+ for (uint_t i = 0; i < nc; i++) {
+ fprintf(out_file, "%u %g %g %g %g %g %g %g\n", Ls_c[i], betas_c[i], vals_c1[i], errors_c1[i], vals_c2[i], errors_c2[i], vals_c3[i], errors_c3[i]);
+ }
+
+ fclose(out_file);
+
+
+ free(Ls_c);
+ free(betas_c);
+ free(vals_c1);
+ free(errors_c1);
+ free(vals_c2);
+ free(errors_c2);
+ free(vals_c3);
+ free(errors_c3);
+
+ return 0;
+}
+