I need a function that I could use to check if I could multiply two matrices. In it, I should check if the matrices are the same dimension, if not function returns -1, else returns 1. Later, function below multiplies matrices and returns **matrix previously declared.
//function prototype
double** matrixMultiply(double** M1, int r1, int c1, double** M2, int r2, int c2);
//I need to check if M1 and M2 have the same number of rows and cols, but I dont know how
double** matrixElementwiseMultiply(double** M1, double** M2, int rows, int columns)
Error message should be -1, else the function should carry on. I would use a flag.
Thanks, it works now. Checking wheather or not the matrices were same dimension (meaning that matrix 1 dimensions x*y is the same dimension of matrix 2) wasn't actually being tested in the program, and I all had to check is if the number of columns in matrix one is equal to number of rows in matrix two (if c1==r2).