dsytri
clapack_dgetri
I have Lapcack3.1.1 clapack blas and atlas
Could you tell me which functions safely(without errors) invert matrix.. I would be glad to see some working code - mayby there is a mistake in my code.
Firstly 7 dimentional, then something easier(2 dim). Below I Show some code how I tried to invert matrix 2 times to get initial matrix.
In case of 2x2 matrix(in dsytri) element (0,0) was not written in correct place in memory but ealier - in *(tmp-lda-1) place.
After it there is some examples of single inverse
i is an information number - it is 0 so function dsytri dont show error.
- Code: Select all
tmp_m=malloc(sizeof(double)*4);
/*easy matrix*/
*tmp_m=2;
*(tmp_m+3)=2;
*(tmp_m+1)=1;
*(tmp_m+2)=1;
dim=2;lda=2;
print_matrix(2, 2,2, tmp_m,"tmp");
dsytri_("U", &dim, tmp_m,&lda, ipiv,work,&intinfo);
print_matrix(2, 2,2, tmp_m,"tmp-1");
dsytri_("U", &dim,tmp_m,&lda, ipiv,work,&intinfo);
print_matrix(2, 2,2, tmp_m,"tmp-1-1");
- Code: Select all
/* with dgetri*/
clapack_dgetri(ORDER, 2, tmp_m,2, ipiv);
clapack_dgetri(ORDER, 2, tmp_m, 2, ipiv);
/*if I used uplo U - more up-diaagonals became Nan
if I used L - elements under diagonal where Nan*/
S AO before
0.99 -0.21 -0.00 0.09 0.00 -0.10 0.00
-0.21 0.82 0.00 -0.28 0.00 0.61 -0.00
-0.00 0.00 0.77 0.00 0.00 0.00 -0.15
0.09 -0.28 0.00 1.06 0.00 -0.35 0.00
0.00 0.00 0.00 0.00 1.00 0.00 0.00
-0.10 0.61 0.00 -0.35 0.00 2.61 -0.00
0.00 0.00 -0.15 0.00 0.00 0.00 2.37
i=0
S AO-1
2.00 -0.21 -0.00 0.09 0.00 -0.10 0.04
0.00 1.29 0.00 -0.28 0.00 0.61 0.16
0.00 0.28 1.07 0.00 0.00 0.00 nan
-0.18 0.37 -0.15 nan 0.00 -0.35 nan
0.00 -0.00 -0.00 nan nan 0.00 nan
0.13 -0.66 -0.22 nan 0.00 nan -0.00
0.00 0.00 0.00 nan 0.00 nan nan
S AObefore
0.99 -0.21 -0.00 0.09 0.00 -0.10 0.00
-0.21 0.82 0.00 -0.28 0.00 0.61 -0.00
-0.00 0.00 0.77 0.00 0.00 0.00 -0.15
0.09 -0.28 0.00 1.06 0.00 -0.35 0.00
0.00 0.00 0.00 0.00 1.00 0.00 0.00
-0.10 0.61 0.00 -0.35 0.00 2.61 -0.00
0.00 0.00 -0.15 0.00 0.00 0.00 2.37
i=0
S AO-1
nan nan nan nan nan nan nan
-0.21 nan 0.00 nan -0.04 -0.19 0.00
0.00 0.00 0.00 0.00 nan 0.00 -0.00
0.09 -0.28 0.00 nan -0.15 0.14 -0.00
0.00 0.00 -0.15 0.00 0.00 0.00 0.42
-0.10 0.61 0.00 -0.35 0.00 0.38 0.00
2.00 2.00 2.00 2.00 0.00 0.00 2.00
S AObefore
1.63 0.09 -0.72 0.56 -0.35 0.00 -0.16
0.09 1.07 -0.34 0.00 -0.04 0.00 0.09
-0.72 -0.34 1.76 0.00 0.35 0.00 -0.72
0.56 0.00 0.00 1.34 0.00 0.00 -0.56
-0.35 -0.04 0.35 0.00 1.17 0.00 -0.35
0.00 0.00 0.00 0.00 0.00 1.00 0.00
-0.16 0.09 -0.72 -0.56 -0.35 0.00 1.63
i=0
S AO1
nan nan nan nan nan nan nan
0.09 nan -0.16 nan nan nan nan
-0.35 -0.04 -0.35 0.00 nan nan nan
0.56 0.00 0.00 nan -0.72 nan 1.11
-0.16 0.09 -0.72 -0.56 0.00 0.00 nan
0.00 0.00 0.00 0.00 0.00 nan -0.35
2.00 2.00 2.00 2.00 0.00 0.00 2.00

