Question: I need a function to multiply a matrix by a scaler. struct _matrix { int rows; int cols; double * data; }; int nRows(matrix const
I need a function to multiply a matrix by a scaler.
struct _matrix { int rows; int cols; double * data; };
int nRows(matrix const * mtx, int * n) { if (!mtx || !n) return -1; *n = mtx->rows; return 0; }
int nCols(matrix const * mtx, int * n) { if (!mtx || !n) return -1; *n = mtx->cols; return 0; }
Exercise 6.10. Implement a function that sets a matrix to its product with a scalar: 1/Sets each element of mta to the product of that element * with s. Returns -1 if mtx is NULL and 0 otheru, ise. int scalarProduct (double s, matrix * mtx)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
