- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hello everyone,
I'm testing the inversion of a symmetric matrix, in order to do that, I wrote this code:
Complex[,] c = (Complex[,])a.Clone(); //I need to use it later Complex[,] d = (Complex[,])a.Clone(); //I need to use it later int n = a.GetLength(0); int lda = n; int info = 1; int[] ipiv = new int; info = MKLWrapper.LAPACKE_zsytrf(LAPACK_ROW_MAJOR, UPLO_U, n, c, lda, ipiv); info = MKLWrapper.LAPACKE_zsytri(LAPACK_ROW_MAJOR, UPLO_U, n, c, lda, ipiv); ipiv = new int ; info = MKLWrapper.LAPACKE_zsytrf(LAPACK_ROW_MAJOR, UPLO_L, n, d, lda, ipiv); info = MKLWrapper.LAPACKE_zsytri(LAPACK_ROW_MAJOR, UPLO_L, n, d, lda, ipiv); for (int i = 1; i <= a.GetLength(0); i++) { for (int j = 1; j <= a.GetLength(1); j++) { if (i > j) c[i, j] = d[i, j]; } }
This code works, but I'm not sure this is the right way to obtain my aim.
Is there anyone that can help me?
Thank you very much
Gianluca
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The solution is easy!
The inverted matrix of a symmetrical matrix is symmetrical too. So the right code is:
Complex[,] c = (Complex[,])a.Clone(); int n = a.GetLength(0); int lda = n; int info = 1; int[] ipiv = new int; info = MKLWrapper.LAPACKE_zsytrf(LAPACK_ROW_MAJOR, UPLO_U, n, c, lda, ipiv); info = MKLWrapper.LAPACKE_zsytri(LAPACK_ROW_MAJOR, UPLO_U, n, c, lda, ipiv); for (int i = 1; i <= a.GetLength(0); i++) { for (int j = 1; j <= a.GetLength(1); j++) { if (i > j) c[i, j] = c[j, i]; } } if (info == 0) return c; else return null;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Gianluca G,
You are right, you can use get the inversion like that. Thank you for sharing.
Thanks
Ying

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page