Matrix Library
A simple Matrix operation library to perform Matrix Multiplication and find the transpose of a Matrix.
matrix.h
Go to the documentation of this file.
1 
12 #ifndef MATRIX_H_
13 #define MATRIX_H_
14 
15 #include<iostream>
16 #include<stddef.h>
17 #include<vector>
18 #include<stdexcept>
19 #include<initializer_list>
20 #include<sstream>
21 #include<fstream>
22 #include<string.h>
23 
29 namespace MATOPS
30 {
31 
41  template<typename T, size_t m, size_t n>
42  class Matrix{
43 
44  T array[m][n];
45  public:
46 
50  virtual ~Matrix() {}
51 
55  size_t cols()
56  {
57  return n;
58  }
59 
64  size_t rows()
65  {
66  return m;
67  }
68 
69 
70  // Default Matrix Initialization
75  {
76  for(size_t i=0;i<m;i++)
77  {
78  for(size_t j=0;j<n;j++)
79  {
80  array[i][j]=0;
81  }
82  }
83  }
84 
85  // Initialize Matrix from Initializer_list
90  Matrix(std::initializer_list<std::initializer_list<T>> my_list):Matrix()
91  {
92  //std::cout<<my_list(0).<<'\n';
93  try{
94  if((m!=my_list.size()))
95  {
96  throw "Wrong Matrix dimension initialized\n";
97  }
98  }catch (const char* msg)
99  {
100  std::cerr<< msg<<'\n';
101  exit(0);
102  }
103 
104 
105  int row_n=0;
106  for(std::initializer_list<T> i:my_list)
107  { int col_n=0;
108 
109  try{
110  if((n!=i.size()))
111  {
112  throw "Wrong Matrix dimension initialized\n";
113  }
114  }catch (const char* msg)
115  {
116  std::cerr<< msg<<'\n';
117  exit(0);
118  }
119 
120  for(T j : i)
121  {
122  ElementAt(row_n,col_n)=j;
123  col_n++;
124  // cout<<j<<" ";
125  }
126  row_n++;
127  //cout<<'\n';
128  }
129  }
130 
131 
132  // Initialize the Matrix from 2D Vectors
137  Matrix( std::vector<std::vector<T>>& my_vec):Matrix()
138  {
139  try{
140  if((m!=my_vec.size())||(n!=my_vec[0].size()))
141  {
142  throw "Wrong Matrix dimension initialized \n";
143  }
144  }catch (const char* msg)
145  {
146  std::cerr<< msg<<'\n';
147  exit(0);
148  }
149 
150  for(size_t i=0; i<my_vec.size(); ++i)
151  for(size_t j=0; j<my_vec[0].size(); ++j)
152  ElementAt(i,j) = my_vec[i][j];
153  }
154 
155 
156  // Transpose of Matrix
162  {
163  Matrix<T,n,m> result;
164  for(size_t i=0;i<m;++i)
165  {
166  for(size_t j=0;j<n;++j)
167  {
168  result.ElementAt(j,i)=ElementAt(i,j);
169  }
170 
171  }
172  return result;
173 
174  }
175 
176  // Matrix Multiplication without Malloc and time complexity: O(n^3)
187  template<size_t k, size_t p>
189  {
190  try{ // Throw exception if Matrix inner dimensions don't match.
191  if(n!=p)
192  {
193  throw "Matrix Inner Dimensions don't match can't multiply!!! \n";
194  }
195  }
196  catch (const char* msg)
197  {
198  std::cerr<< msg<<'\n';
199  exit(0);
200  }
201 
202  Matrix<T,m,k> result;
203 
204  for (size_t i_m = 0; i_m < m; ++i_m) {
205  for (size_t i_k = 0; i_k < k; ++i_k) {
206 
207  for (size_t i_n = 0; i_n < n; ++i_n) {
208  result.ElementAt(i_m,i_k) += A.ElementAt(i_m,i_n) * B.ElementAt(i_n,i_k);
209  }
210  }
211  }
212  return result;
213  }
214 
215  // Equal to operator Overload
219  Matrix& operator=(const Matrix& rhs) {
220  if( this != &rhs )
221  for(size_t i=0; i<m; ++i)
222  for(size_t j=0; j<n; ++j)
223  ElementAt(i,j) = rhs.ElementAt(i,j);
224  return *this;
225  }
226 
227 
234  const T& ElementAt(size_t i, size_t j) const
235  { return array[i][j]; }
236 
243  T& ElementAt(size_t i, size_t j)
244  { return array[i][j]; }
245 
246  // Ofstream operator Overloaded
251  friend std::ostream& operator<<(std::ostream& os, const Matrix& rhs)
252  {
253  for(size_t i=0; i<m; ++i)
254  {
255  for(size_t j=0; j<n; ++j)
256  {os<<rhs.ElementAt(i,j)<<" ";}
257  os<<'\n';
258  }
259  return os;
260  }
261 
262 
263  }; // Matrix Template Class Ends here !!!
264 //=====================================================================================================================================
265 
266  // CSV File storing
276  template<typename Data2>
277  void store_csv(Data2 ** C, int m_1, int n_2, std::string path)
278  {
279  std::ofstream file;
280  file.open(path);
281 
282  for(int i=0;i<m_1;i++)
283  {
284  for(int j=0;j<n_2;j++)
285  {
286  file<<C[i][j];
287  if(j<(n_2)-1)
288  {
289  file<<",";
290  }
291  else
292  {
293  file<<"\n";
294  }
295  }
296  }
297  file.close();
298 
299  }
300 
301  // Template to convert variable type from string to int,float, double or any other Datatype
308  template<typename My_data> My_data convert_to(const std::string &str)
309  {
310  std::istringstream ss(str);
311 
312  My_data num;
313 
314  ss>>num;
315  return num;
316  }
317 
318 
328  // BIG MATRIX Multiplication and Transpose
329  template<typename Data1>
330  class BigMatrix
331  {
332  int LEAF_SIZE; // Private variable LEAF_SIZE
336  private:
337 
345  Data1** Init_matrix(int n)
346  { // Calloc chunk of Memory
347 
348  Data1** M;
349  M=(Data1 **)calloc(n,sizeof(Data1*));
350  for(int i=0;i<n;i++)
351  {
352  M[i]=(Data1*)calloc(n,sizeof(Data1));
353  }
354  return M;
355  }
356 
364  // Matrix ADD ===================
365  Data1** add(Data1** M1, Data1** M2, int n)
366  {
367  Data1** temp = Init_matrix(n);
368  for(int i=0; i<n; i++)
369  for(int j=0; j<n; j++)
370  temp[i][j] = M1[i][j] + M2[i][j];
371  return temp;
372  }
373 
381  // Matrix SUBTRACT ===============
382  Data1** sub(Data1** M1, Data1** M2, int n)
383  {
384  Data1** temp = Init_matrix(n);
385  for(int i=0; i<n; i++)
386  for(int j=0; j<n; j++)
387  temp[i][j] = M1[i][j] - M2[i][j];
388  return temp;
389  }
390 
405  Data1** StrassenMultiply(Data1** A, Data1** B, int n)
406  {
407  /* Naive Strassan's Algorithm (more time consuming)
408  if(n==1)
409  {
410  Data1** C=Init_matrix(1);
411  C[0][0]=A[0][0]*B[0][0];
412  return C;
413  }*/
414 
415  // Once array size of LEAF_SIZE x LEAF_SIZE or lesser is reached we switch to the O(n^3) Matrix Multiplication solution, since after this
416  // stage the recursion calls become a burden to the whole algorithm and we end up getting high execution time. The LEAF_SIZE is set by the
417  // MATOPS::BigMatrix<Data1>::set_configerd_Leaf_size() function from witin the MATOPS::BigMatrix<Data1>::matmul() function.
418  if(n<=LEAF_SIZE)
419  {
420  Data1** C=Init_matrix(n);
421  for(int i=0;i<n;i++)
422  {
423  for(int j=0;j<n;j++)
424  {
425  for(int k=0;k<n;k++)
426  {
427  C[i][j]+=A[i][k]*B[k][j];
428  }
429  }
430  }
431  return C;
432  }
433 
434  Data1** C = Init_matrix(n); // Initialize an nxn matrix to store
435  int k = n/2;
436 
437  // Initialize the Block Matrices
438  Data1** A11 = Init_matrix(k);
439  Data1** A12 = Init_matrix(k);
440  Data1** A21 = Init_matrix(k);
441  Data1** A22 = Init_matrix(k);
442  Data1** B11 = Init_matrix(k);
443  Data1** B12 = Init_matrix(k);
444  Data1** B21 = Init_matrix(k);
445  Data1** B22 = Init_matrix(k);
446 
447  // Build the block Matrices
448  for(int i=0;i<k;i++)
449  {
450  for(int j=0;j<k;j++)
451  {
452  A11[i][j] = A[i][j];
453  A12[i][j] = A[i][k+j];
454  A21[i][j] = A[k+i][j];
455  A22[i][j] = A[k+i][k+j];
456  B11[i][j] = B[i][j];
457  B12[i][j] = B[i][k+j];
458  B21[i][j] = B[k+i][j];
459  B22[i][j] = B[k+i][k+j];
460  }
461  }
462  // Determine the Strassen's Coefficients
463  Data1** TEMP_B12_B22 = sub(B12, B22, k);
464  Data1** TEMP_A11_A12 = add(A11, A12, k);
465  Data1** TEMP_A21_A22 = add(A21, A22, k);
466  Data1** TEMP_B21_B11 = sub(B21, B11, k);
467 
468 
469  Data1** P1 = StrassenMultiply(A11, TEMP_B12_B22, k);
470  Data1** P2 = StrassenMultiply(TEMP_A11_A12, B22, k);
471  Data1** P3 = StrassenMultiply(TEMP_A21_A22, B11, k);
472  Data1** P4 = StrassenMultiply(A22, TEMP_B21_B11, k);
473 
474  Data1** TEMP_A11_A22 = add(A11, A22, k);
475  Data1** TEMP_B11_B22 = add(B11, B22, k);
476  Data1** TEMP_A12_A22 = sub(A12, A22, k);
477  Data1** TEMP_B21_B22 = add(B21, B22, k);
478  Data1** TEMP_A11_A21 = sub(A11, A21, k);
479  Data1** TEMP_B11_B12 = add(B11, B12, k);
480 
481  Data1** P5 = StrassenMultiply(TEMP_A11_A22, TEMP_B11_B22, k);
482  Data1** P6 = StrassenMultiply(TEMP_A12_A22, TEMP_B21_B22, k);
483  Data1** P7 = StrassenMultiply(TEMP_A11_A21, TEMP_B11_B12, k);
484 
485  Data1** TEMP_P5_P4 = add(P5, P4, k);
486  Data1** TEMP_P5_P4_P6 = add(TEMP_P5_P4, P6, k);
487  Data1** TEMP_P5_P1 = add(P5, P1, k);
488  Data1** TEMP_P5_P1_P3 = sub(TEMP_P5_P1, P3, k);
489 
490 
491  Data1** C11 = sub(TEMP_P5_P4_P6, P2, k);
492  Data1** C12 = add(P1, P2, k);
493  Data1** C21 = add(P3, P4, k);
494  Data1** C22 = sub(TEMP_P5_P1_P3, P7, k);
495 
496  // Building the returning C Matrix
497 
498  for(int i=0; i<k; i++)
499  {
500  for(int j=0; j<k; j++)
501  {
502  C[i][j] = C11[i][j];
503  C[i][j+k] = C12[i][j];
504  C[k+i][j] = C21[i][j];
505  C[k+i][k+j] = C22[i][j];
506  }
507  }
508 
509  // Free up all calloced memory.
510  for(int i=0; i<k; i++) {
511  free(TEMP_B12_B22[i]);
512  free(TEMP_A11_A12[i]);
513  free(TEMP_A21_A22[i]);
514  free(TEMP_B21_B11[i]);
515 
516  free(TEMP_A11_A22[i]);
517  free(TEMP_B11_B22[i]);
518  free(TEMP_A12_A22[i]);
519  free(TEMP_B21_B22[i]);
520  free(TEMP_A11_A21[i]);
521  free(TEMP_B11_B12[i]);
522 
523  free(TEMP_P5_P4[i]);
524  free(TEMP_P5_P4_P6[i]);
525  free(TEMP_P5_P1[i]);
526  free(TEMP_P5_P1_P3[i]);
527 
528  free(A11[i]);
529  free(A12[i]);
530  free(A21[i]);
531  free(A22[i]);
532  free(B11[i]);
533  free(B12[i]);
534  free(B21[i]);
535  free(B22[i]);
536  free(P1[i]);
537  free(P2[i]);
538  free(P3[i]);
539  free(P4[i]);
540  free(P5[i]);
541  free(P6[i]);
542  free(P7[i]);
543  free(C11[i]);
544  free(C12[i]);
545  free(C21[i]);
546  free(C22[i]);
547  }
548 
549  free(TEMP_B12_B22);
550  free(TEMP_A11_A12);
551  free(TEMP_A21_A22);
552  free(TEMP_B21_B11);
553 
554  free(TEMP_A11_A22);
555  free(TEMP_B11_B22);
556  free(TEMP_A12_A22);
557  free(TEMP_B21_B22);
558  free(TEMP_A11_A21);
559  free(TEMP_B11_B12);
560 
561  free(TEMP_P5_P4);
562  free(TEMP_P5_P4_P6);
563  free(TEMP_P5_P1);
564  free(TEMP_P5_P1_P3);
565 
566  free(A11);
567  free(A12);
568  free(A21);
569  free(A22);
570  free(B11);
571  free(B12);
572  free(B21);
573  free(B22);
574  free(P1);
575  free(P2);
576  free(P3);
577  free(P4);
578  free(P5);
579  free(P6);
580  free(P7);
581  free(C11);
582  free(C12);
583  free(C21);
584  free(C22);
585 
586  return C;
587  }
588 
589  // Print Matrix (internal printing)
596  void print_Mat(Data1** C, int m, int n)
597  {
598  for(int i=0;i<m;i++)
599  {
600  for(int j=0;j<n;j++)
601  {
602  std::cout<<C[i][j]<<" ";
603  }
604  std::cout<<'\n';
605  }
606  }
607 
608  // LOAD from CSV file Template
615  std::vector<std::vector<Data1>> load_CSV(const std::string &path)
616  {
617  std::ifstream indata;
618  indata.open(path);
619 
620  if(indata.fail()) // Check if File exists
621  {
622  std::cerr<<"File path: '"<<path<<"' doesn't exist\n";
623  exit(0);
624  }
625 
626  std::vector<std::vector<Data1>> dataList;
627  std::string line = "";
628 
629  while(getline(indata,line))
630  {
631  std::stringstream lineStream(line);
632  std::string cell;
633  std::vector<Data1> temp;
634  while (std::getline(lineStream,cell,','))
635  {
636  temp.push_back(convert_to<Data1>(cell)); // convert from string to Data1 and store it in an 2D array.
637  }
638  dataList.push_back(temp);
639 
640  }
641  indata.close(); // Close file
642  return dataList; // Return the 2D vector
643  }
644 
649  public:
650  void Mat_print(std::string path)
651  {
652  std::vector<std::vector<Data1>> MAT= load_CSV(path);
653 
654  for(std::vector<Data1> a: MAT)
655  {
656  for(Data1 i: a)
657  {
658  std::cout<< i <<" ";
659  }
660  std::cout<<'\n';
661  }
662  }
663 
684  #ifdef SET_LEAF_SIZE
685  void set_LEAF_SIZE(int leaf_size)
686  {
687  LEAF_SIZE=leaf_size;
688  }
689  #else
690 
697  {
698  std::ifstream indata;
699  indata.open("configure.txt");
700  std::string str="";
701  getline(indata,str);
702  indata.close();
703  LEAF_SIZE=std::stoi(str);
704  }
705  #endif
706 
707  // Matrix Multiplication from CSV files
731  void matmul(std::string file_1, std::string file_2, std::string path, bool print=false)
732 
733  {
734 
735  #ifndef SET_LEAF_SIZE
736  set_configerd_Leaf_size(); // Set the optimal LEAF_SIZE by parsing the configuration file genrated by configure_lib.cpp.
737  #endif
738  // std::cout<<"Current LEAF_SIZE value: "<<LEAF_SIZE<<'\n'; // Just a check to see what LEAF_SIZE value is being used
739 
740  // Parse the CSV files and get the Matrices to be multiplied
741 
742  std::vector<std::vector<Data1>> MAT_1= load_CSV(file_1);
743  std::vector<std::vector<Data1>> MAT_2= load_CSV(file_2);
744 
745  // Get the dimensions of both the Matrices.
746  int m_1=MAT_1.size(), n_1=MAT_1[0].size(); // Matrix 1 M,N
747  int m_2=MAT_2.size(), n_2=MAT_2[0].size(); // Matrix 2 M,N
748 
749  try{
750  if(n_1 != m_2) // Check if inner dimensions of the Matrices Match. If not then Throw error.
751  {
752  throw "Matrix Inner Dimensions don't match !!! \n";
753  }
754  }catch (const char* msg)
755  {
756  std::cerr<<msg<<'\n';
757  exit(0);
758  }
759 
760  int max_n= std::max(std::max(m_1,n_1),n_2); // Find the max of all the Matrix dimensions, to find the next highest power of 2.
761  int dim_n=1;
762 
763  // Find the next highest power of 2 using left shift operator (dim_n = Next highest power of 2).
764  // This will be used to pad zeros to both matrices A and B, and ultimately given as input to StrassenMultiply() function.
765  while(dim_n<max_n)
766  {
767  dim_n=dim_n<<1;
768  }
769 
770  // Initialize 3 pointers to point at Matrices A and B, and to store the Result of AxB into C.
771  Data1 ** A;
772  Data1 ** B;
773  Data1 ** C;
774 
775  A=Init_matrix(dim_n); // Allocate the memory for Matrix A of size dim_n
776  B=Init_matrix(dim_n); // Allocate the memory for Matrix B of size dim_n
777 
778  // Build the Zero padded square Matrices A and B by copying contents from from MAT_1 and MAT_2 into A and B respectively.
779  for(int k=0;k<m_1;k++)
780  {
781  for(int l=0;l<n_1;l++)
782  {
783  A[k][l]= MAT_1[k][l];
784  }
785  }
786 
787  for(int k=0;k<m_2;k++)
788  {
789  for(int l=0;l<n_2;l++)
790  {
791  B[k][l]= MAT_2[k][l];
792 
793  }
794 
795  }
796 
797  //Call Strassen's Algorithm function to get A x B and store in C.
798  C=StrassenMultiply(A, B, dim_n);
799 
800  if(print==true) // if print is true then print A, B and the result A.
801  {
802  std::cout<<"A: \n";
803  print_Mat(A, m_1, n_1); //Call the print_Mat function to print the Matrix
804 
805  std::cout<<"\nB: \n";
806  print_Mat(B, m_2, n_2); //Call the print_Mat function to print the Matrix
807 
808  std::cout<<"\nANSWER: \n"; //Call the print_Mat function to print the Matrix
809  print_Mat(C, m_1, n_2);
810 
811  }
812 
813  // Store the Result C into a CSV file, whose location is given by "path"
814  store_csv<Data1>(C, m_1,n_2,path);
815 
816  // Free The memory before quitting
817  for(int i=0;i<dim_n;i++)
818  {
819  free(A[i]);
820  free(B[i]);
821  free(C[i]);
822  }
823 
824  free(A);
825  free(B);
826  free(C);
827 
828 
829  } // matmul function ends here
830 
831  // Matrix Transpose function begins here
832 
840  void Transpose(std::string path, std::string str_path)
841  {
842  std::vector<std::vector<Data1>> MAT= load_CSV(path); // Load the Matrix from CSV file
843 
844  Data1** A= (Data1 **)calloc(MAT[0].size(),sizeof(Data1*));
845 
846  for(int i=0;i<MAT[0].size();i++)
847  {
848  A[i]=(Data1*)calloc(MAT.size(),sizeof(Data1));
849  }
850 
851  for(int i=0;i<MAT.size();i++)
852  {
853  for(int j=0;j<MAT[0].size();j++)
854  {
855  A[j][i]=MAT[i][j];
856  }
857  }
858 
859  store_csv<Data1>(A,MAT[0].size(),MAT.size(),str_path);
860  for(int i=0;i<MAT[0].size();i++)
861  {
862  free(A[i]);
863  }
864  free(A);
865  }
866 
871  void Transpose(std::string path)
872  {
873  std::vector<std::vector<Data1>> MAT= load_CSV(path); // Load the Matrix from CSV file
874 
875  Data1** A= (Data1 **)calloc(MAT[0].size(),sizeof(Data1*));
876 
877  for(int i=0;i<MAT[0].size();i++)
878  {
879  A[i]=(Data1*)calloc(MAT.size(),sizeof(Data1));
880  }
881 
882  for(int i=0;i<MAT.size();i++)
883  {
884  for(int j=0;j<MAT[0].size();j++)
885  {
886  A[j][i]=MAT[i][j];
887  }
888  }
889 
890  store_csv<Data1>(A,MAT[0].size(),MAT.size(),path);
891  store_csv<Data1>(A,MAT[0].size(),MAT.size(),path);
892 
893  for(int i=0;i<MAT[0].size();i++)
894  {
895  free(A[i]);
896  }
897  free(A);
898 
899  }
900 
901  };
902 
903 
904 } // MATOPS namespace ends here
905 
906 #endif /* MATRIX_H_ */
Matrix()
Default constructor to initialize the matrix with zeros.
Definition: matrix.h:74
Matrix & operator=(const Matrix &rhs)
Equal to operator overloaded to copy one matrix into another.
Definition: matrix.h:219
std::vector< std::vector< Data1 > > load_CSV(const std::string &path)
Function to load CSV file. This function is internally called by MATOPS::BigMatrix<Data1>::matmul and...
Definition: matrix.h:615
int LEAF_SIZE
Definition: matrix.h:332
This is the Class for handling Large Matrices. It takes in large Matrices stored as comma-separated v...
Definition: matrix.h:330
Data1 ** Init_matrix(int n)
Function to dynamically allocate/initialize an n x n matrix in the memory.
Definition: matrix.h:345
void set_LEAF_SIZE(int leaf_size)
This Function sets the LEAF_SIZE i.e. the array size at which we shift from Strassan&#39;s Algo to normal...
Definition: matrix.h:685
friend std::ostream & operator<<(std::ostream &os, const Matrix &rhs)
Operator overloaded to output/print an object of type Matrix.
Definition: matrix.h:251
void Transpose(std::string path)
This is a function to find the Transpose of a BigMatrix and stores it in the same csv file (In-palce ...
Definition: matrix.h:871
My_data convert_to(const std::string &str)
Function template to convert variable type from string to int,float, double or any other Datatype spc...
Definition: matrix.h:308
void print_Mat(Data1 **C, int m, int n)
This function is called from within the MATOPS::BigMatrix<Data1>::matmul function when print == True...
Definition: matrix.h:596
void store_csv(Data2 **C, int m_1, int n_2, std::string path)
Function template to Store csv file at a given destination file. This function is internally called b...
Definition: matrix.h:277
void set_configerd_Leaf_size()
When matrix.h is normally called i.e. without any SET_LEAF_SIZE flag, set_configerd_Leaf_size() funct...
Definition: matrix.h:696
const T & ElementAt(size_t i, size_t j) const
Function to read value from the (i,j)th position of the Matrix.
Definition: matrix.h:234
void matmul(std::string file_1, std::string file_2, std::string path, bool print=false)
This is the BigMatrix multiplication Function that multiplies two matrices A and B stored in A...
Definition: matrix.h:731
Matrix(std::vector< std::vector< T >> &my_vec)
Overloaded constructor to initialize the Matrix from a 2D Vector.
Definition: matrix.h:137
void Mat_print(std::string path)
Function to print a Matrix from a .csv file.
Definition: matrix.h:650
friend Matrix< T, m, k > operator*(const Matrix< T, m, n > &A, const Matrix< T, p, k > &B)
Matrix multiplication using overloaded * operator. Takes 2 Matrices of size m x n and p x k...
Definition: matrix.h:188
T array[m][n]
Definition: matrix.h:44
Matrix< T, n, m > transpose()
Take an object of type Matrix and returns its Transpose.
Definition: matrix.h:161
size_t cols()
Definition: matrix.h:55
Data1 ** sub(Data1 **M1, Data1 **M2, int n)
Function to Subtract 2 square Matrices of size n.
Definition: matrix.h:382
Data1 ** add(Data1 **M1, Data1 **M2, int n)
Function to Add 2 square Matrices of size n.
Definition: matrix.h:365
T & ElementAt(size_t i, size_t j)
Function to write value to the (i,j)th position of the Matrix.
Definition: matrix.h:243
size_t rows()
Definition: matrix.h:64
This class is for matrices of smaller size. The user can define a Matrix A of size m x n of Datatype ...
Definition: matrix.h:42
virtual ~Matrix()
Definition: matrix.h:50
Matrix(std::initializer_list< std::initializer_list< T >> my_list)
Overloaded constructor the initialize the Matrix from a 2D Initializer list.
Definition: matrix.h:90
void Transpose(std::string path, std::string str_path)
This is a function to find the Transpose of a BigMatrix and stores it in a csv file.
Definition: matrix.h:840
Data1 ** StrassenMultiply(Data1 **A, Data1 **B, int n)
The main Strassen&#39;s Algorithm function implemented using recursion. Takes in square Matrices A and B...
Definition: matrix.h:405
The main matrix.h namespace named MATOPS- MATrix OPerations. It contains 2 Matrix classes...
Definition: matrix.h:29