lundi 21 décembre 2015

How to set a random matrix in this case?

Recently I saw link on this site

Sweeping through a 2d arrays using pointers with boundary conditions

Here, in "answers", is a code of boundary conditions in Ising Model. This code generate a matrix with all spins up:

for (i=0; i<Lattice_Size; i++)  {  
    for (j=0; j<Lattice_Size; j++) {
        *ptr++ = spin_up;   // initializing to parallel spins,      
                            // where spin_up is an integer number
                            // taking value = +1.
    }
}

My question is: How one can set up a random configuration (matrix) with random distribution of spin_up / spin_down spins?

I thought it might be done with the help of function random(...), but I figured out that I don't understand well how it works :(




Aucun commentaire:

Enregistrer un commentaire