Thank you for your helpful answerIts necessary for you to pa
Thank you for your helpful answer!(It\'s necessary for you to pay attention to the given information)
Let us define a new data type Matrix for representing 2-dimensional (extendable) array of float type using STL vector as shown below. A m-by-n matrix A is called \"skew symmetric\" if A is a square matrix (i.e. m == n) and A[i][j] == -A[j][i] for all i notequalto j. Compose an efficient function for checking if A is skew symmetric (i.e. return true if A is skew symmetric, and false otherwise). Note that data is stored at A[i][j] for i = 0..m - 1, j = 0..n - 1. You also need to fill in the parameter list of the function in an efficient way. typedef vector Matrix; bool checkSkewSymmetric}Solution
typedef vector <vector<float>>Matrix;
bool checkSkewSymmetric(const Matrix &A)
{
int rows=A.size(),cols=A[0].size;
if(rows!=cols)
return false; //not a square matirx
for( int i=0;i<rows-1;++i) {
for(int j=i+1;j<rows;++j) {
if(A[i][j]!=-A[j][i]
return false; //not a skew symmetric
}
}
return true; //skew symmetric
}
