Previously I had this implemented and it worked:
int *train_X = (int *)mxGetData(IN_a);// pointer to 6th argument matrix train_X
for (int i = 0; i < 6; i++)
{
for (int j = 0; j < 6; j++)
{
cout << train_X[6 * i + j] << endl;
}
}
int sizeTrain_X1 = mxGetM(IN_a);
int sizeTrain_X2 = mxGetN(IN_a);
I could even manage to check if i get the correct sizes with the following and it was all good.
cout <<"Training input NumOfCollum:\n"<< sizeTrain_X1 << endl;
cout << "Training input NumOfRows:\n"<<sizeTrain_X2 << endl;
but then when trying my entire program with the following initialization i get a compilation error:
for (int epoch = 0; epoch<training_epochs; epoch++)
{
for (int i = 0; i<train_S; i++)
{
rbm.contrastive_divergence(train_X[i], learning_rate, k);
}
}
Here is the error message:
RBM.cpp: In function ‘void mexFunction(int, mxArray**, int, const mxArray**)’: RBM.cpp:570:64: error: invalid conversion from ‘int’ to ‘int*’ [-fpermissive] RBM.cpp:81:6: error: initializing argument 1 of ‘void RBM::contrastive_divergence(int*, double, int)’ [-fpermissive] RBM.cpp:615:32: error: invalid types ‘int[int]’ for array subscript
train_X
is an int*
. When you do train_X[i]
you now get an int
. contrastive_divergence()
though wants an int*
. Since you cannot convert an int
to an int*
you are getting the subsequent error. You either need to pass the address of train_X[i]
as &train_X[i]
or just pass train_X