Commit 479eedef authored by Alois SCHLOEGL's avatar Alois SCHLOEGL

avoid storing extra (Bernoulli) matrix - but do the Bernoulli conversion only...

avoid storing extra (Bernoulli) matrix - but do the Bernoulli conversion only when writing the matrix
parent fdd2036c
......@@ -86,7 +86,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 ", (int) gsl_matrix_get(W,i,j));
fprintf(fhnd, "%i ", gsl_matrix_get(W,i,j)>1.0);
}
fprintf(fhnd,"\n");
}
......
......@@ -207,30 +207,7 @@ gsl_matrix* secorder_rec_1p(int N_nodes, double p,
}
////////////////////////////////////////////////////////////
// Step 5: Calculate Bernoulli matrix
// Simply make the Bernoulli variable be 1
// if the Gaussian variable is greater than 1
////////////////////////////////////////////////////////////
cout << "Generating Bernoulli matrix...";
cout.flush();
// calculate bernoulli matrix
gsl_matrix *W_ber = gsl_matrix_alloc(N_nodes, N_nodes);
for(int i=0; i<N_nodes; i++) {
for(int j=0; j<N_nodes; j++) {
gsl_matrix_set(W_ber,i,j,gsl_matrix_get(W_gaus,i,j)>1.0);
}
}
// free Gaussian matrix
gsl_matrix_free(W_gaus);
cout << "done\n";
cout.flush();
// return Bernoulli matrix
return W_ber;
return W_gaus;
}
......
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