how to use dgetri_ routine to compute inverse of a matrix

Open discussion regarding features, bugs, issues, vendors, etc.

how to use dgetri_ routine to compute inverse of a matrix

Postby zimmerman » Thu Oct 27, 2005 10:58 pm

Can anyone help me ?
When I use this routine , I cann't get the right inverse of a matrix. If matrix is a uptriangular matrix ,the answer is right ,but when matrix is general, the answer is not correct.
How to use it ? How to set the ipiv .
Can anyone help me? Thank you!

Can anyone give me an example on how to use this routine?
Thankyou!
zimmerman
 
Posts: 2
Joined: Fri May 27, 2005 4:37 am

Postby Julien Langou » Fri Oct 28, 2005 12:15 am

Before calling DGETRI you first need to call DGETRF.

In C, the calling sequence looks like :
Code: Select all
      dgetrf_( &n, &n, a, &lda, ipiv, &info );
      if (info==0)
           dgetri_( &n, a, &lda, ipiv, work, &lwork, &info );


DGETRF will perform the LU factorization of A and take care of ipiv for you.
This piece of code works for any nonsingular matrix.

Julien

PS: Your observation is correct. If you have a upper triangular matrix: there is no pivoting, the U factor is the matrix itself and the L factor is the identity. So basically you do not need DGETRF. DGETRF on A upper triangular returns A unchanged. (Regarding the pivot in IPIV, you are a bit more lucky....)
Julien Langou
 
Posts: 733
Joined: Thu Dec 09, 2004 12:32 pm
Location: Denver, CO, USA

Thank you

Postby zimmerman » Fri Oct 28, 2005 1:53 am

Julien:
Thank you very much. With your help , I have got the right answer.
zimmerman
 
Posts: 2
Joined: Fri May 27, 2005 4:37 am


Return to User Discussion

Who is online

Users browsing this forum: Bing [Bot] and 2 guests