determinant analysis in c++ using data structures

15
Group 2: Members: Muhammad Umair Qadir 2014-cs-4 Hamza Mazhar 2014-cs- 9 Ghulam Murtaza 2014-cs-10 Anees Akhtar 2014-cs-15

Upload: muhammad-umair-qadir

Post on 09-Apr-2017

46 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Determinant analysis in C++ using Data Structures

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

Determinant Analysis

Page 3: Determinant analysis in C++ using Data Structures

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

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

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

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

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

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

Methodology:

Page 10: Determinant analysis in C++ using Data Structures

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

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

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

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

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

THANK YOU !