/* A program that prints the transpose of a given matrix. Task: compute the trace of a matrix i.e. sum of the diagonal entries of a matrix. Task: Frobenius product of two matrices A and B: i.e. trace of the matrix A*transpose(B). */ #include using namespace std; double trace( double A[2][2] ) { double trace = 0.0; for (unsigned int i =0 ; i < 2 ; ++i) { trace += A[i][i]; }//for-i return trace ; } //end of the trace function. int main() { double A[2][2] ={ {1,2},{3,4} } ; cout<< "The trace is: "<< trace (A)<< endl; return 0; }