Commit 0fe5e345 authored by Alois SCHLOEGL's avatar Alois SCHLOEGL

convert matrix from double to float in order to save 50% memory

parent 6e71e8d2
......@@ -10,7 +10,7 @@
////////////////////////////////////////////////////////////////////
int calc_phat_alphahat_1p(gsl_matrix *W, int N_nodes,
int calc_phat_alphahat_1p(gsl_matrix_float *W, int N_nodes,
double &phat,
double &alphahat_recip,
double &alphahat_conv,
......@@ -43,12 +43,12 @@ int calc_phat_alphahat_1p(gsl_matrix *W, int N_nodes,
// network adjacency matrix W with N_node nodes
////////////////////////////////////////////////////////////////////
int calc_N_motifs(gsl_matrix *W, int N_nodes,
int calc_N_motifs(gsl_matrix_float *W, int N_nodes,
double &N_edge, double &N_recip,
double &N_conv, double &N_div, double &N_chain,
double &N_other) {
double *thedata = W->data;
float *thedata = W->data;
size_t tda = W->tda;
double row_sums[N_nodes];
......
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_matrix_float.h>
int calc_phat_alphahat_1p(gsl_matrix *W, int N_nodes,
int calc_phat_alphahat_1p(gsl_matrix_float *W, int N_nodes,
double &phat,
double &alphahat_recip,
double &alphahat_conv,
double &alphahat_div,
double &alphahat_chain,
double &alphahat_other);
int calc_N_motifs(gsl_matrix *W, int N_nodes,
int calc_N_motifs(gsl_matrix_float *W, int N_nodes,
double &N_edge, double &N_recip,
double &N_conv, double &N_div, double &N_chain,
double &N_other);
......@@ -55,7 +55,7 @@ int main(int argc, char *argv[]) {
else
gsl_rng_set(rng, time(NULL));
gsl_matrix *W;
gsl_matrix_float *W;
W=secorder_rec_1p(N_nodes,p, alpha_recip, alpha_conv, alpha_div, alpha_chain,
rng);
......@@ -87,7 +87,7 @@ int main(int argc, char *argv[]) {
for(int i=0; i<N_nodes;i++) {
for(int j=0; j<N_nodes; j++) {
fprintf(fhnd, "%i ", gsl_matrix_get(W,i,j)>1.0);
fprintf(fhnd, "%i ", gsl_matrix_float_get(W,i,j)>1.0);
}
fprintf(fhnd,"\n");
}
......@@ -99,7 +99,7 @@ int main(int argc, char *argv[]) {
size_t nnz=0;
for(int i=0; i<N_nodes; i++) {
for(int j=0; j<N_nodes; j++) {
nnz += gsl_matrix_get(W,i,j)>1.0;
nnz += gsl_matrix_float_get(W,i,j)>1.0;
}
}
strcat(FN,".sparse");
......@@ -112,7 +112,7 @@ int main(int argc, char *argv[]) {
fwrite(&nnz,8,1,fhnd);
for (int32_t i=0; i<N_nodes; i++) {
for (int32_t j=0; j<N_nodes; j++) {
if (gsl_matrix_get(W,i,j) > 1.0) {
if (gsl_matrix_float_get(W,i,j) > 1.0) {
fwrite(&i, 4, 1, fhnd);
fwrite(&j, 4, 1, fhnd);
}
......
......@@ -13,9 +13,9 @@ using namespace std;
// declare auxiliary functions
int gen_corr_gaussian(const int N_nodes, double sqrt_diag, double sqrt_recip,
double sqrt_conv, double sqrt_div, double sqrt_chain,
double sqrt_noshare, gsl_matrix *thevars, gsl_rng *rng);
int calc_gaus_covs(gsl_matrix *W_gaus, int N_nodes,
double sqrt_conv, double sqrt_div, double sqrt_chain,
double sqrt_noshare, gsl_matrix_float *thevars, gsl_rng *rng);
int calc_gaus_covs(gsl_matrix_float *W_gaus, int N_nodes,
double &sigma, double &cov_recip,
double &cov_conv, double &cov_div,
double &cov_chain, double &cov_other);
......@@ -49,8 +49,8 @@ int calc_gaus_covs(gsl_matrix *W_gaus, int N_nodes,
// connection from node j onto node i
////////////////////////////////////////////////////////////////////////
gsl_matrix* secorder_rec_1p(int N_nodes, double p,
double alpha_recip, double alpha_conv,
gsl_matrix_float* secorder_rec_1p(int N_nodes, double p,
double alpha_recip, double alpha_conv,
double alpha_div, double alpha_chain,
gsl_rng *rng) {
......@@ -164,7 +164,7 @@ gsl_matrix* secorder_rec_1p(int N_nodes, double p,
////////////////////////////////////////////////////////////
gsl_matrix *W_gaus = gsl_matrix_alloc(N_nodes, N_nodes);
gsl_matrix_float *W_gaus = gsl_matrix_float_alloc(N_nodes, N_nodes);
cout << "Generating gaussian matrix...";
cout.flush();
......@@ -224,10 +224,10 @@ gsl_matrix* secorder_rec_1p(int N_nodes, double p,
////////////////////////////////////////////////////////////
int gen_corr_gaussian(const int N_nodes, double sqrt_diag, double sqrt_recip,
double sqrt_conv, double sqrt_div, double sqrt_chain,
double sqrt_noshare, gsl_matrix *thevars, gsl_rng *rng) {
double sqrt_noshare, gsl_matrix_float *thevars, gsl_rng *rng) {
gsl_matrix_set_zero(thevars);
double *thedata = thevars->data;
gsl_matrix_float_set_zero(thevars);
float *thedata = thevars->data;
size_t tda=thevars->tda;
// for speed we'll access the gsl_matrix entries directly
......
#include <gsl/gsl_rng.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_matrix_float.h>
gsl_matrix* secorder_rec_1p(int N_nodes, double p,
gsl_matrix_float* secorder_rec_1p(int N_nodes, double p,
double alpha_recip, double alpha_conv,
double alpha_div, double alpha_chain,
gsl_rng *rng);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment