AhmedSadek60 / AsuMathLabG19

A c++ program for carrying out matrix operations.
4 stars 2 forks source link

Matrix C++ Project

a c++ program for carrying out matrix operations.

Environment

coded with c++ and compiled with g++. works on linux os, tested on ubuntu 16.04 LTS

Project phases

Installation & Setup

For Windows Users :

For Linux Users :

Cloning Project :

Code example

creating a 2 x 3 matrix without displaying it:

a = [1 2 3; 4 5 6];

if you want to display it, leave out the semicolon:

b = [ 1 2 1; 1 4 4]

doing some operations:

c // Uninitialized Matrix
c = b[transpose]; // Make it Like That c = b' because of single qoute escape doesn't work here
c    // displays c
d = a * b    //error, invalid dimensions
d = c * a
e = c / a
f = 1 ./ a
g = [ 1 1 2; 1 1 1];
h = c / g   //error, g is not invertible (not a square matrix)
g = [ 1 1 1 ; 1 1 1; 1 1 1];
h = [1 2 3; 4 5 6; 7 8 9]
i = h / g   //error, g is not invertible (determinant of g is zero)

.or you can use an input file with operations stored in it:

./matrix example.m

6.3 2.5 8.1 3.1

6.4 2.8 7.1 8.1

3.2 5.1 7.2 8.9

###################################################### C = 10.1 13 8.2 3.8

8.6 9 17 6.2

11.3 6.6 9.1 15.6

13 8.5 8.2 17.8


### supported operations
- add ( + )
- sub ( - )
- mult ( * )
- div ( / )
- elementWiseDiv ( ./ )
- elmentWisePow  ( .^ )
- elmentWiseAdd  ( .+ )
- elmentWiseSubtract  ( .- )
- elmentWiseMultiply  ( .* )

## debugging and enhancements

### Profiling 
- For Profiling We Use The <a href="http://gnuwin32.sourceforge.net/packages/gprof.htm"><b>Gprof Profiler</b></a> <br />
- You Will Find profiling results for the Two Files [ example.m , bigexample.m ] :
```code
- profilingexamplefile.txt
- profilingbigexamplefile.txt
- profilingbigexample2file.txt
- profilingadvexamplefile.txt
- profilingtrickyexamplefile.txt
- profilingerrorexamplefile.txt

Outputs Form Files

Code Style

[ Function Name ] : isInsideMatrix() [ Returned Type ] : int [ inherited Function from CMatrix Class ] : getName() - [ Inside File : CMatrix.cpp , Line : 167 ] [ Functionality ] : To Get the Index of Parameter Matrix inside the Matrix vector so we can get the index and use the matrix in this index anywhere else

*/

int isInsideMatrix(vector matricesArray,string target) { bool found = false; int index = -1; for(int i =0;i < matricesArray.size();i++) { if(matricesArray[i].getName() == target) { found = true; index = i; } } return index;

}