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. )

7 Years
Discussion Span
Last Post by axed

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];
            sum = 0;
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.