ran into a problem
i know this is asking for me to calculate the product of a coulmn and row but im not sure where to begin.
I know that rowData tells us the value in a row and nRows specifies the number of rowData and the same with nCols and colData, however i do not understand how to multiply these to get their product... do I use a loop or where should i begin?

int multiply( double rowData[ ], int nRows, double colData[ ], int nCols,
double product[ ][ MAXCOLS ] );

Calculates the matrix multiplication of an nRows x 1 column vector(rowData )times a 1 x nCols row vector ( columnData ) to yield an nRows x nCols matrix,
where product[ r ][ c ] = rowData[ r ] * colData[ c ], as shown in the diagram below.
( Note that the rowData vector contains data for each row but is actually a column
vector, and vice versa. )

I use vectors. Here's a way to do it:

void computeProduct(vector<vector<double> >&x,vector<vector<double> >&y,vector<vector<double> >& prod)
{
double sum =0;
for(int i=0; i<(int)prod.size(); i++)
{
for(int j=0; j<(int)prod[0].size(); j++)
{   for(int k=0; k<(int)x[0].size(); k++)
sum += x[i][k]*y[k][j];
prod[i][j]=sum;
sum = 0;
}
}
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.