Originally Posted by

**Kevin Breslin**
Code:

float dot_product(double *, double *, size_t);
float
dot_product(double * weights[6][16], double * X[16], size_t n)
{
float Net[6]={0,0,0,0,0,0};
size_t i;
for (i = 1; i < 16; i++) {
Net[1] += weights[1][i] * X[i];
Net[2] += weights[2][i] * X[i];
Net[3] += weights[3][i] * X[i];
Net[4] += weights[4][i] * X[i];
Net[5] += weights[5][i] * X[i];
Net[6] += weights[6][i] * X[i];
}
return Net[6];
}

First, always keep declaration and definition same (copy-pasting is legitimate here):

Code:

float
dot_product(double * weights[6][16], double * X[16], size_t n);
float
dot_product(double * weights[6][16], double * X[16], size_t n)
{
/* ... */
}

You should read more about array/pointer declarations. The first parameter "weights" is a two-dimensional array of "pointers to doubles" - not just "doubles". The second parameter isn't better.

The first dimension of array parameter is meaningless, because user can always pass an array which is larger or smaller. However, you can keep it to make it a bit self-documenting.

The thing necessary to do is to remove the asterix:

Code:

float
dot_product(double weights[][16], double X[], std::size_t n);
float
dot_product(double weights[][16], double X[], std::size_t n)
{
/* ... */
}