85 void Svd2x2(
double *Theta,
double *Sigma1,
double *Sigma2,
86 double *Phi,
int *Sign1,
int *Sign2,
double A[2][2])
88 double Temp, U[2][2], W[2][2];
90 *Theta = 0.5*atan2(2*(A[0][0]*A[1][0] + A[0][1]*A[1][1]),
91 (A[0][0]*A[0][0] + A[0][1]*A[0][1])
92 - (A[1][0]*A[1][0] + A[1][1]*A[1][1]));
93 *Phi = 0.5*atan2(2*(A[0][0]*A[0][1] + A[1][0]*A[1][1]),
94 (A[0][0]*A[0][0] + A[1][0]*A[1][0])
95 - (A[0][1]*A[0][1] + A[1][1]*A[1][1]));
97 U[0][0] = cos(*Theta);
98 U[1][0] = sin(*Theta);
107 Temp = U[0][0]*(A[0][0]*W[0][0] + A[0][1]*W[1][0])
108 + U[1][0]*(A[1][0]*W[0][0] + A[1][1]*W[1][0]);
109 *Sigma1 = fabs(Temp);
110 *Sign1 = (Temp < 0) ? -1 : 1;
112 Temp = U[0][1]*(A[0][0]*W[0][1] + A[0][1]*W[1][1])
113 + U[1][1]*(A[1][0]*W[0][1] + A[1][1]*W[1][1]);
114 *Sigma2 = fabs(Temp);
115 *Sign2 = (Temp < 0) ? -1 : 1;