Image Interpolation with Geometric Contour Stencils
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
svd2x2.c
Go to the documentation of this file.
1 
16 #include <math.h>
17 
18 
85 void Svd2x2(double *Theta, double *Sigma1, double *Sigma2,
86  double *Phi, int *Sign1, int *Sign2, double A[2][2])
87 {
88  double Temp, U[2][2], W[2][2];
89 
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]));
96 
97  U[0][0] = cos(*Theta);
98  U[1][0] = sin(*Theta);
99  U[0][1] = -U[1][0];
100  U[1][1] = U[0][0];
101 
102  W[0][0] = cos(*Phi);
103  W[1][0] = sin(*Phi);
104  W[0][1] = -W[1][0];
105  W[1][1] = W[0][0];
106 
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;
111 
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;
116 }