Skip to content

Commit 41329f5

Browse files
committed
some more operations added
1 parent 4e5a430 commit 41329f5

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

ADT/miscellaneous/Readme.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,7 @@ A matrix data structure. I am still building it up. It makes use of a single poi
4242
The matrix operations currently implemented so far:-
4343
* addition [x]
4444
* subtraction [x]
45-
* multiplication [ ]
46-
* transpose [x]
45+
* multiplication [x]
46+
* scalar multiplication [x]
47+
* transpose [x]
48+
* inverse [ ]

ADT/miscellaneous/matrix.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ template<typename DATA>
1212
class 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<<"\nMatrix 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

Comments
 (0)