Image Interpolation with Geometric Contour Stencils
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Functions
svd2x2.c File Reference

Compute the singular value decomposition of a 2x2 matrix. More...

#include <math.h>
Include dependency graph for svd2x2.c:

Go to the source code of this file.

Functions

void Svd2x2 (double *Theta, double *Sigma1, double *Sigma2, double *Phi, int *Sign1, int *Sign2, double A[2][2])
 Compute the singular value decomposition of a 2x2 matrix. More...
 

Detailed Description

Compute the singular value decomposition of a 2x2 matrix.

Author
Pascal Getreuer getre.nosp@m.uer@.nosp@m.gmail.nosp@m..com

Copyright (c) 2010-2011, Pascal Getreuer All rights reserved.

This program is free software: you can use, modify and/or redistribute it under the terms of the simplified BSD License. You should have received a copy of this license along this program. If not, see http://www.opensource.org/licenses/bsd-license.html.

Definition in file svd2x2.c.

Function Documentation

void Svd2x2 ( double *  Theta,
double *  Sigma1,
double *  Sigma2,
double *  Phi,
int *  Sign1,
int *  Sign2,
double  A[2][2] 
)

Compute the singular value decomposition of a 2x2 matrix.

Parameters
Thetarotation of the U matrix
Sigma1,Sigma2singular values
Phirotation of the V matrix
Sign1,Sign2correction signs
Ainput 2x2 matrix

Computes the singular value decomposition of A,

\[ A = U \Sigma V^T. \]

U is a rotation by Theta,

\[ U = \begin{pmatrix} \cos \theta & -\sin \theta \\ \sin \theta & \cos \theta \end{pmatrix}. \]

Sigma is the diagonal matrix with entries Sigma1 and Sigma2, which satisfy Sigma1 >= Sigma2 >= 0. V is in general not representable by a rotation alone and is further decomposed as a rotation matrix W and a diagonal sign correction matrix C so that

\[ A = U \Sigma C W^T. \]

W is a rotation by Phi,

\[ W = \begin{pmatrix} \cos \phi & -\sin \phi \\ \sin \phi & \cos \phi \end{pmatrix}, \]

and C is

\[ C = \begin{pmatrix} \text{Sign1} & 0 \\ 0 & \text{Sign2} \end{pmatrix}, \]

where Sign1 and Sign2 are signs, values of either +1 or -1.

The matrices U and V can be computed from Theta, Phi, Sign1, Sign2 as

U[0][0] = cos(Theta);
U[1][0] = sin(Theta);
U[0][1] = -sin(Theta);
U[1][1] = code(Theta);
V[0][0] = Sign1*cos(Phi);
V[1][0] = Sign1*sin(Phi);
V[0][1] = -Sign2*sin(Phi);
V[1][1] = Sign2*cos(Phi);

The algorithm used here is based on the notes http://www.ualberta.ca/~mlipsett/ENGM541/Readings/svd_ellis.pdf. The derivation is, first, by expanding the following in terms of the components

\[ \begin{pmatrix} a & b \\ b & c \end{pmatrix} = A A^T = U \Sigma^2 U^T, \]

one can show

\[ \begin{aligned} 2b &= (\sin 2\theta)(\sigma_1^2 - \sigma_2^2), \\ a - c &= (\cos 2\theta)(\sigma_1^2 - \sigma_2^2). \end{aligned} \]

Therefore,

\[ \theta = \tfrac{1}{2} \mathrm{atan2}(2b, a - c), \]

and similarly for $ \phi $ with $ A^T A = W \Sigma^2 W^T $.

Second, now that U and W are known, the singular values and signs are obtained as

\[ \Sigma C = U^T A W \]

Definition at line 85 of file svd2x2.c.