Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot convert double [] [] to double **

Tags:

c++

double

I ve got a function that takes 3 parameteres, first one is **double.

 normalizeDataZeroMeanUnitSD(double ** trainingActions, int numberOfTrainingActions, int descriptorDimension)

When I call it from main, I am trying to use normalizeDataZeroMeanUnitSD(data, 681, 24); however, I am receiving

cannot convert parameter 1 from 'double [681][24]' to 'double **'

This is how I construct the data array:

fstream infile;
infile.open("gabor\\Data.txt");

double data[681][24];

while (!infile.eof()) 
     {
        for(int j=0;j<681;j++) 
        {
            for(int k=0; k<24;k++) 
            {

                infile >> data[j][k];

           }

        }

 } 
 infile.close();

Is there a way to do the same using **data?

like image 1000
snake plissken Avatar asked Nov 27 '22 21:11

snake plissken


1 Answers

The error is pretty clear: Datatype double [681][24] is not the same as double **. While it's true that double[681] can decay to a pointer to its first element (thus, double*), that does not imply that double[681][24] can decay to double**.

Think about it this way: double** implies a pointer to many pointers. But double[][] does not have ANY pointers in it. At best, an array of ANY dimensions still only has, at very most, one pointer: to the beginning of its contiguous storage.

like image 168
tenfour Avatar answered Dec 09 '22 11:12

tenfour