mardi 31 octobre 2017

generate a matrix with random zeros

Using C I am trying to generate a matrix which has to have more number of zero elements than non zero elements. The zero elements should be random how to generate it.

I am able to generate random numbers

int main(){
     srand(time(NULL));
     int Intarray[25];
     int i;
     for (i=0;i<s;i++){
         array[i] = rand();
     }
 }

is the generated matrix sparse matrix ? how can I understand the difference ?




Aucun commentaire:

Enregistrer un commentaire