如何通过指针访问三维数组?目前我有这段代码,试图得到相同的结果。我需要通过指针访问才能使用 OpenCL 中数组中的值。
for (l = 0; l < NumberOfLayers - 1; l++) {
for (i = 0; i < NeuronsPerLayer[l]; i++) {
for (j = 0; j < NeuronsPerLayer[l + 1] - bias[l + 1]; j++) {
cout<<Synweights[l][i][j]<<endl;
cout<<*(*Synweights[0]+l*NumberOfLayers + i * NeuronsPerLayer[l] + j)<<endl;
}
}
}
Synweights
声明为:
double ***Synweights
Synweights = (double ** *)malloc((NumberOfLayers - 1) * sizeof(double **));
for (l = 0; l < NumberOfLayers - 1; l++) {
Synweights[l] = (double **)malloc(NeuronsPerLayer[l] * sizeof(double *));
for (i = 0; i < NeuronsPerLayer[l]; i++) {
Synweights[l][i] = (double *)malloc((NeuronsPerLayer[l + 1] - bias[l + 1]) * sizeof(double));
}
}