Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How can I multiply 3 matrices?

I would like to multiply 3 matrices(same size). For eample, NM=(-0.5)HSH where H,S are matrices having same size. Here is my code, but it produces nan output. How can i multiply 3 matrices?

int main()
int count_row=1000;
 vector <vector <float> >g;
//do some calculation on g

Mat M(count_row,count_row,CV_32F);
for(int i=0;i<count_row;i++)
     for(int j=0;j<count_row;j++)


Mat I = Mat::eye(count_row, count_row, CV_32F);

Mat H(count_row,count_row,CV_32F);

Mat S(count_row,count_row,CV_32F);

Mat normalized_M(count_row,count_row,CV_32F);

cout<<normalized_M<<endl;// error: produce nan output