Determinant Calculation of a NxN Matrix Using AT - PowerPoint PPT Presentation

1 / 7
About This Presentation
Title:

Determinant Calculation of a NxN Matrix Using AT

Description:

where Msub(N-1)x(N-1) is a sub-matrix of the matrix M whose dimension is (N-1)x ... For each matrix element M(1,i), need to determine the sub-matrix that does not ... – PowerPoint PPT presentation

Number of Views:73
Avg rating:3.0/5.0
Slides: 8
Provided by: william321
Category:

less

Transcript and Presenter's Notes

Title: Determinant Calculation of a NxN Matrix Using AT


1
Determinant Calculation of a NxN Matrix Using
ATT Assembly Syntax
  • Algorithm
  • High-level language implementation
  • ATT assembly language implementation
  • Image of the stack before and after a function is
    called

2
Algorithm
  • Suppose we have a 3x3 matrix
  • Use the recursive expansion by minors method
  • Or in general, for a matrix M of NxN dimensions

where Msub(N-1)x(N-1) is a sub-matrix of the
matrix M whose dimension is (N-1)x(N-1) and does
not contain the first row and i column
3
Algorithm (cont.)
  • Observations
  • If N2, compute determinant directly (base case)
  • If Ngt2, recursive calls must be done successively
    until N2
  • For each matrix element M(1,i), need to determine
    the sub-matrix that does not contain the first
    row and ith column of the currently computing
    matrix.

4
High-level Language Implementation C
int det(int M, int N) if (N2)
return (M0M3 - M1M2)
else int
new_dimension (N-1) int
tdet0 int temp new
int(N-1)(N-1)
for (int ref_ele0 ref_eleltNref_ele)
int counter0
for (int i0iltNi)
for (int j0jltNj)
if ( (j!
ref_ele) (i!0))
tempcounter M(Ni
j)
counter
int t det(temp,
new_dimension) if
((ref_ele 2) ! 0)
t (-1)t tdet
Mref_elet
return tdet
5
ATT Assembly Language Implementation
  • Specification of the determinant function det
    in the assembly language implementation. The
    following steps must be done successively
  • All elements of the matrix M must be PUSHED
    onto the stack, in the major-row ordered, before
    the det function is called
  • The dimension N of the matrix M must also be
    PUSHED onto the stack
  • A variable that will hold the result of the
    determinant of the currently computing matrix
    must also be PUSHED onto the stack (make space
    for the return result)
  • A variable that will hold an error flag, if ever
    occurs, must also be PUSHED onto the stack
    (make space for the return error)
  • See attachment sheets for the program.

6
The Image of the Stack Just Before the det
Function Is Called
Stack pointer esp
7
The Image of the Stack Just AFTER the det
Function Is Called
Stack pointer esp
Write a Comment
User Comments (0)
About PowerShow.com