determinant analysis in c++ using data structures
TRANSCRIPT
![Page 1: Determinant analysis in C++ using Data Structures](https://reader035.vdocuments.mx/reader035/viewer/2022070518/58ea3edc1a28abc4698b45b5/html5/thumbnails/1.jpg)
Group 2:• Members:• Muhammad Umair Qadir 2014-cs-4• Hamza Mazhar 2014-cs- 9• Ghulam Murtaza 2014-cs-10• Anees Akhtar 2014-cs-15
![Page 2: Determinant analysis in C++ using Data Structures](https://reader035.vdocuments.mx/reader035/viewer/2022070518/58ea3edc1a28abc4698b45b5/html5/thumbnails/2.jpg)
Determinant Analysis
![Page 3: Determinant analysis in C++ using Data Structures](https://reader035.vdocuments.mx/reader035/viewer/2022070518/58ea3edc1a28abc4698b45b5/html5/thumbnails/3.jpg)
Importance: • In Japan, Seki Takakazu is credited with the discovery
of the resultant and the determinant in 1710.• The Wronskian of solutions of a linear ODE is a
determinant• It is the basis of many development in modern
analysis• Determinant ideals play a big role in the theory of
modules over commutative rings• Used in cryptography
![Page 4: Determinant analysis in C++ using Data Structures](https://reader035.vdocuments.mx/reader035/viewer/2022070518/58ea3edc1a28abc4698b45b5/html5/thumbnails/4.jpg)
Methods to solve Determinants:
• Gauss Elimination O(N^3)• Leibniz Formula O(n! . n)• Laplace Expansion O(n!)• Condensation Methods • Decomposition Methods
![Page 5: Determinant analysis in C++ using Data Structures](https://reader035.vdocuments.mx/reader035/viewer/2022070518/58ea3edc1a28abc4698b45b5/html5/thumbnails/5.jpg)
Decomposition Method• Matrix decompose into smaller size • Process continue in recursive until touch base case• It start for and check whether it is 2*2 or more if order
is 2 it return the determinant• If order is more than 3 it decompose and make a new
array and store the values of sub determinant • Store values of determinant in new array• Finally evaluate determinant and return its value
![Page 6: Determinant analysis in C++ using Data Structures](https://reader035.vdocuments.mx/reader035/viewer/2022070518/58ea3edc1a28abc4698b45b5/html5/thumbnails/6.jpg)
Diagonalization• Convert matrix into left and right diagonal • Calculate these diagonal• Subtract left into right• Result is determinant of the matrix
![Page 7: Determinant analysis in C++ using Data Structures](https://reader035.vdocuments.mx/reader035/viewer/2022070518/58ea3edc1a28abc4698b45b5/html5/thumbnails/7.jpg)
Header file of diagonal Matrixclass matrix{ int a[10][10], n; int **temp; int findRight(int i, int j); int findleft(int i, int j); void findMat();public: matrix(); void display(); void seeMat(); int determinant(); // calculate det using array pointer
~matrix();};
![Page 8: Determinant analysis in C++ using Data Structures](https://reader035.vdocuments.mx/reader035/viewer/2022070518/58ea3edc1a28abc4698b45b5/html5/thumbnails/8.jpg)
Gauss Elimination• Apply Reduced Row operation • Get Upper tri-angular matrix• Then just multiply principle diagonal elements• In the Last return the determinant of the matrix
![Page 9: Determinant analysis in C++ using Data Structures](https://reader035.vdocuments.mx/reader035/viewer/2022070518/58ea3edc1a28abc4698b45b5/html5/thumbnails/9.jpg)
Methodology:
![Page 10: Determinant analysis in C++ using Data Structures](https://reader035.vdocuments.mx/reader035/viewer/2022070518/58ea3edc1a28abc4698b45b5/html5/thumbnails/10.jpg)
AlgorithmMake Upper( ){ If number of rows = 1 then return
For i = 1 to (number of rows – 1){For k = 0 to (i – 1){factor = e[i][k] / e[k][k]For j = (k + 1) to (number of columns – 1){e[i][j] = e[i][j] – (factor * e[k][j])}}// might have set diagonal element to zero, requiring a pivotif e[i][i] == 0
then swap column i for some column j where e[i][j] != 0and increase swap_count by 1}
if swap_count is odd return –1 else return 1// notice the lower triangle of elements is not explicitly zeroed// that could be added in}
![Page 11: Determinant analysis in C++ using Data Structures](https://reader035.vdocuments.mx/reader035/viewer/2022070518/58ea3edc1a28abc4698b45b5/html5/thumbnails/11.jpg)
Computational Efficiency:
• It requires n(n+1)/2 divisions,(2n^3+3n^2-5n)/6 multiplication and (2n^3 + 3n^2-5n)/6 subtractions for a total of 2n^3/3 operations.
• Gaussian elimination is numerically stable for diagonally dominant or positive-definite matrices.
• So complexity will be O(n^3).
![Page 12: Determinant analysis in C++ using Data Structures](https://reader035.vdocuments.mx/reader035/viewer/2022070518/58ea3edc1a28abc4698b45b5/html5/thumbnails/12.jpg)
Data Structure (Dynamic Array):• Getting or setting the value at a particular index
(constant time)• Iterating over the elements in order
(linear time, good cache performance)• Inserting or deleting an element in the middle of the
array (linear time)
• Inserting or deleting an element at the end of the array
(constant amortized time)
![Page 13: Determinant analysis in C++ using Data Structures](https://reader035.vdocuments.mx/reader035/viewer/2022070518/58ea3edc1a28abc4698b45b5/html5/thumbnails/13.jpg)
Class Overview :Header File: • class matrix{ float **mat, ratio, det; //dynamic array used for Matrix int n; // to store order of matrixpublic: matrix(); // constructor input elements of matrix from user void seeMat(); //this function prints matrix void convertuper(); //converts the Matrix to upper triangular matrix for use in //determinant calculation int determinant(); // returns the value of matrix determinant!! ~matrix();};
![Page 14: Determinant analysis in C++ using Data Structures](https://reader035.vdocuments.mx/reader035/viewer/2022070518/58ea3edc1a28abc4698b45b5/html5/thumbnails/14.jpg)
Conclusion:• Dynamic Arrays an attractive tool for building cache-
friendly data structures.• More efficient as compared with other Data-Structures.• Facilitate over Static Array
![Page 15: Determinant analysis in C++ using Data Structures](https://reader035.vdocuments.mx/reader035/viewer/2022070518/58ea3edc1a28abc4698b45b5/html5/thumbnails/15.jpg)
THANK YOU !