Matrix Library
A simple Matrix operation library to perform Matrix Multiplication and find the transpose of a Matrix.
MATOPS Namespace Reference

The main matrix.h namespace named MATOPS- MATrix OPerations. It contains 2 Matrix classes, namely class Matrix and class BigMatrix to perform matrix operations. The class Matrix uses the naive O(n^3) solution to perform matrix multiplication and the class BigMatrix uses a mixture of Strassesn's algorithm and Naive O(n^3) solution to perform Matrix multiplication. Both the classes perform matrix transpose in similar fashion, i.e. by swapping the off diagonal elements. More...

Classes

class  BigMatrix
 This is the Class for handling Large Matrices. It takes in large Matrices stored as comma-separated values (CSV) files and perform both Multiplication (Strassan's Algorithm) and transpose. It contains all the important functions namely ,matmul function, StrassanMultiply function and other helper functions that are needed for smooth functioning of the library. This class also contains blocks of code that are gated by the SET_LEAF_SIZE flag, for example the set_LEAF_SIZE() function and the set_configerd_Leaf_size() function. When matrix.h is compiled with the SET_LEAF_SIZE flag raised the set_LEAF_SIZE() function is active and set_configerd_Leaf_size() function is inactive. And the vice-versa happens when matrix.h is compiled without the SET_LEAF_SIZE flag. More...
 
class  Matrix
 This class is for matrices of smaller size. The user can define a Matrix A of size m x n of Datatype T as follows: MATOPS::Matrix<T,m,n> A. More...
 

Functions

template<typename Data2 >
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 by matmul and Transpose function (with Data2:= int, float etc) to store the Resultant BigMatrix from the memory to a CSV file. More...
 
template<typename My_data >
My_data convert_to (const std::string &str)
 Function template to convert variable type from string to int,float, double or any other Datatype spcified by My_data. More...
 

Detailed Description

The main matrix.h namespace named MATOPS- MATrix OPerations. It contains 2 Matrix classes, namely class Matrix and class BigMatrix to perform matrix operations. The class Matrix uses the naive O(n^3) solution to perform matrix multiplication and the class BigMatrix uses a mixture of Strassesn's algorithm and Naive O(n^3) solution to perform Matrix multiplication. Both the classes perform matrix transpose in similar fashion, i.e. by swapping the off diagonal elements.

Function Documentation

◆ convert_to()

template<typename My_data >
My_data MATOPS::convert_to ( const std::string &  str)

Function template to convert variable type from string to int,float, double or any other Datatype spcified by My_data.

Template Parameters
My_data= Datatype into which we want to convert the string inputs parsed from CSV files.
Parameters
str= String input from the Csv file.
Returns
Returns Converted number from string to My_data.
309  {
310  std::istringstream ss(str);
311 
312  My_data num;
313 
314  ss>>num;
315  return num;
316  }

◆ store_csv()

template<typename Data2 >
void MATOPS::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 by matmul and Transpose function (with Data2:= int, float etc) to store the Resultant BigMatrix from the memory to a CSV file.

Template Parameters
Data2
Parameters
C= A Pointer pointing to the 2D BigMatrix in the memory
m_1= No. of Rows of the Resultant BigMatrix
n_2= No. of Columns of the Resultant BigMatrix
path= "path to destination csv file"
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  }