Repository navigation
Expand file tree
/
Copy pathexample.cpp
More file actions
59 lines (39 loc) · 1.53 KB
/
Copy pathexample.cpp
File metadata and controls
59 lines (39 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
* @file example.cpp
* @brief A simple example code illustrating how to use the Library
* @date Jan 24, 2021
* @author Shiladitya Biswas
*
*
* This is an example code illustrating how to use the matrix.h library.
*
*/
//============================================================================
// Name : example.cpp
// Author : Shiladitya Biswas
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include<iostream>
#include "matrix.h"
#include<vector>
using namespace std;
using namespace MATOPS; //namespace for matrix.h
int main() {
// Define matrices of size 2x4 and 2x2 of type double
Matrix<double,2,2> A{{1,2},{3,4}};
Matrix<double,2,4> B{{1,2,4,5},{4,6,7,8}};
// Print the Matrices A and B followed by Product A*B and transpose of A
cout<<A<<"\n \n"<<B<<"\n \n"<< A*B<<"\n\n"<<A.transpose()<<"\n\n";
BigMatrix<float> MatObj; // Define float object for Big Matrix
// Multiply two Matrices in .csv format and save the result in Ans.csv file.
MatObj.matmul("/path/to/A.csv","/path/to/B.csv","/path/to/Ans.csv");
// Read Matrix A from A.csv, find its Transpose and save it in A_trans.csv
MatObj.Transpose("/path/to/A.csv", "/path/to/A_trans.csv");
// In-place Transpose: Read Matrix A from A.csv, find its Transpose and overwrite A.csv
MatObj.Transpose("/path/to/A.csv");
// print Matrix in file A.csv
MatObj.Mat_print("/path/to/matrix/to/print");
return 0;
}