determinant analysis in c++ using data structures
TRANSCRIPT
Group 2:• Members:• Muhammad Umair Qadir 2014-cs-4• Hamza Mazhar 2014-cs- 9• Ghulam Murtaza 2014-cs-10• Anees Akhtar 2014-cs-15
Determinant Analysis
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
Methods to solve Determinants:
• Gauss Elimination O(N^3)• Leibniz Formula O(n! . n)• Laplace Expansion O(n!)• Condensation Methods • Decomposition Methods
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
Diagonalization• Convert matrix into left and right diagonal • Calculate these diagonal• Subtract left into right• Result is determinant of the matrix
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();};
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
Methodology:
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}
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).
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)
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();};
Conclusion:• Dynamic Arrays an attractive tool for building cache-
friendly data structures.• More efficient as compared with other Data-Structures.• Facilitate over Static Array
THANK YOU !