@@ -12,7 +12,7 @@ template<typename DATA>
1212class matrix {
1313 /*
1414 matrix abstract DS reflects properties and behaviour of a matrix
15-
15+
1616 DATA MEMEBERS:-
1717 val = flattened 2d array of type DATA in row major form
1818 row = number of rows of the matrix
@@ -117,7 +117,7 @@ class matrix {
117117 matrix<DATA> operator !();
118118 // transpose operation explicit method
119119 matrix<DATA> transpose ();
120-
120+ matrix<DATA> T (){ return this -> transpose ();};
121121
122122 // accessibility operations overload
123123 DATA operator ()(int , int );
@@ -341,20 +341,22 @@ int main() {
341341 // array2 = NULL;
342342
343343
344- int r = 10 , c = 10 ;
344+ int r = 5 , c = 4 ;
345345 int *arr1 = new int [r*c], *arr2= new int [r*c];
346346 init2dRandArray (arr1, r, c);
347- init2dRandArray (arr2, r, c );
347+ init2dRandArray (arr2, c, r );
348348
349349 matrix<int > m10 (arr1, r, c);
350- matrix<int > m11 (arr2, r, c );
350+ matrix<int > m11 (arr2, c, r );
351351 matrix<int > m12 = m10 & m11;
352352
353353 m10.display ();
354354 m11.display ();
355355 cout<<" \n Matrix Mul Result:-\n " ;
356356 m12.display ();
357357
358+ matrix<int > m11T = m11.T ();
359+ m11T.display ();
358360 delete arr1;
359361 delete arr2;
360362 arr1 = NULL ;
0 commit comments