samedi 2 juin 2018

How to initialize double matrix with NaN element?

in my code I have a matrix of double like this:

double * * matrix=new double * [10];
for(int i=0;i<10;i++) 
    matrix[i]=new double[10];

I want to have NaN value in every cell of this matrix when I initialize it, is it possible to do automatically or the only solution is:

for(int i=0;i<10;i++)
    for(int j=0;j<10;j++)
        matrix[i][j]=nan("");

Is it possible to infer that when the matrix will costruct, it doesn't use the default constructor of double that insert, for every matrix[i][j], 0.0 value but insert nan("")?

Aucun commentaire:

Enregistrer un commentaire