Thank you for the quick answer! Here is an example of required matrix:
double S = 5. , k = 0.01 , hIk = 0.005 ; int N = (int) (2*S+1) ; double S2= S*(S+1) ;
for ( int i=0; i<N; i++ ) { m1 = S-i ; m2 = 0-m1 ; D[i] = m1*m2/S2 - k*(m1*m1+m2*m2)/(2*S2) - hIk*k*m1/S ; E[i] = sqrt ( (S2-m1*(m1-1)) * (S2-m2*(m2+1)) ) / (2*S2) ; }
S is spin. It`s ought to be interger or half-integer.
I attach full source files too. One of them (smatrixtdevdi) works well, another one (smatrixtdevdr) gives wrong answer. I intended to send their outputs, but couldn`t attach more than three files.
|