Algorithm Search⌘K

Algorithmresearch

PhaseLift

Phase retrieval as a convex problem. Lift x to the matrix X = x x^*, in which the data are linear, and find a positive semidefinite X that fits them with the least trace.

Time
O(K (m n^2 + n^3)) worst
Space
O(n^2) extra
Where
K = the number of iterations; m = the number of measurements; n = the length of the signal
Properties
deterministicnot exactnot in placeoffline
Origin
Emmanuel Candès, Thomas Strohmer, Vladislav Voroninski, 2013

PhaseLift is a convex method for phase retrieval with known sampling vectors. The data yr=∣ar∗x∣2y_r = |a_r^* x|^2 are quadratic in xx, but they are linear in the matrix X=xx∗X = x x^*, because ∣ar∗x∣2=ar∗Xar|a_r^* x|^2 = a_r^* X a_r. The method looks for XX in place of xx. The condition that XX has rank one is not convex, so PhaseLift keeps only the condition that XX is positive semidefinite, and uses the trace to prefer matrices of low rank:

minimize tr⁡Xsubject to ar∗Xar=yr (r=1,…,m),X⪰0.\text{minimize } \operatorname{tr} X \quad \text{subject to } a_r^* X a_r = y_r \ (r = 1, \dots, m), \quad X \succeq 0 .

This is a semidefinite program. Candès, Strohmer and Voroninski (2013) proved that for about nlog⁡nn \log n Gaussian vectors its only solution is xx∗x x^*. Candès and Li (2014) brought the number down to the order of nn, and showed that then xx∗x x^* is the only feasible point. The signal is the top eigenvector of XX, up to a global phase.

In plain words

The unknown is a list of complex numbers, and each measurement gives a squared size, which mixes the numbers in pairs. That makes the equations hard: there are many false answers, and a search can get stuck in one.

The trick is to treat each product of two unknowns as a new unknown of its own. Put all these products in a square table. Then every measurement is a simple sum over the table, and simple sums are easy. The price is that the table has many more entries than the list, and a true table has a special form. The method keeps a weaker property of that form, which turns the search into one with a single best answer. With enough random measurements, that answer is the true table, and the list can be read off from it.

The problem

The input is mm vectors ar∈Cna_r \in \mathbb{C}^n and the values yr=∣ar∗x∣2y_r = |a_r^* x|^2. The output is a zz with a small dist⁡(z,x)=min⁡φ∥z−eiφx∥\operatorname{dist}(z, x) = \min_\varphi \|z - e^{i\varphi} x\|; no method can find the global phase. Write A(X)=(ar∗Xar)r=1m\mathcal{A}(X) = (a_r^* X a_r)_{r=1}^m for the linear map on the Hermitian matrices.

The algorithm

The semidefinite program can be solved by any SDP method, such as an interior point method for small nn. The implementation here uses projected gradient descent on the penalized form

F(X)=12∥A(X)−y∥2+λtr⁡Xover X⪰0,F(X) = \tfrac12 \|\mathcal{A}(X) - y\|^2 + \lambda \operatorname{tr} X \quad \text{over } X \succeq 0,

with λ=0\lambda = 0 by default. When xx∗x x^* is the only feasible point, as in the theorem of Candès and Li, the minimizer of FF with λ=0\lambda = 0 is xx∗x x^*, and the trace does not matter.

  1. PHASELIFT(a₁, …, a_m, y, K, λ)
  2. 1L ← ‖𝒜‖² ▷ or any bound L ≥ ‖𝒜‖², such as Σ_r ‖a_r‖⁴
  3. 2X ← 0 (n × n)
  4. 3for k ← 1 to K do
  5. 4ρ ← 𝒜(X) − y ▷ ρ_r = a_r* X a_r − y_r
  6. 5G ← Σ_r ρ_r a_r a_r* + λ I
  7. 6X ← P₊(X − G / L) ▷ set the negative eigenvalues to 0
  8. 7return X

Then z=w1 u1z = \sqrt{w_1}\, u_1 from the top eigenpair (w1,u1)(w_1, u_1) of XX. Line L5 is the gradient A∗(ρ)+λI\mathcal{A}^*(\rho) + \lambda I. Line L6 is the projection onto the positive semidefinite matrices: write X=∑kwkukuk∗X = \sum_k w_k u_k u_k^* and replace each wkw_k by max⁡(wk,0)\max(w_k, 0). The implementation does this on the real symmetric form (B−CCB)\begin{pmatrix} B & -C \\ C & B \end{pmatrix} of X=B+iCX = B + iC, with the Jacobi eigenvalue method of the shared helper. It gets ∥A∥\|\mathcal{A}\| from the singular values of the m×n2m \times n^2 real matrix of A\mathcal{A}.

Example

A case by hand. Take x=(1,1+i)x = (1, 1 + i) and the four vectors e1e_1, e2e_2, e1+e2e_1 + e_2 and e1+ie2e_1 + i e_2. Write X=(pssˉq)X = \begin{pmatrix} p & s \\ \bar s & q \end{pmatrix} with real pp and qq. The four values ar∗Xara_r^* X a_r are

p,q,p+q+2Re⁡s,p+q−2Im⁡s,p, \qquad q, \qquad p + q + 2 \operatorname{Re} s, \qquad p + q - 2 \operatorname{Im} s,

and the data are y=(1,2,5,5)y = (1, 2, 5, 5). These four linear equations give p=1p = 1, q=2q = 2 and s=1−is = 1 - i, so

X=(11−i1+i2)=xx∗.X = \begin{pmatrix} 1 & 1 - i \\ 1 + i & 2 \end{pmatrix} = x x^* .

Its eigenvalues are 33 and 00, and 3\sqrt3 times the top unit eigenvector is xx up to a phase. Here the four real numbers of a 2×22 \times 2 Hermitian matrix are fixed by four equations, so the lifted problem has one solution. The implementation starts from X=0X = 0 with F=27.5F = 27.5, and reaches ∥X−xx∗∥=0.0065\|X - x x^*\| = 0.0065 after 100 steps and 8⋅10−118 \cdot 10^{-11} after 500 steps.

Random measurements. Take n=4n = 4, m=32m = 32, a unit x∈C4x \in \mathbb{C}^4 and complex Gaussian vectors, all from seed 1, with λ=0\lambda = 0 (measurements of the implementation):

step kk 0 10 50 100 200 300
dist⁡(zk,x)\operatorname{dist}(z_k, x) 1 0.22 0.034 0.0053 1.4e-4 3.8e-6
∥Xk−xx∗∥\|X_k - x x^*\| 1 0.35 0.065 0.010 2.5e-4 6.5e-6
F(Xk)F(X_k) 28 0.47 0.011 2.7e-4 1.7e-7 1.1e-10

Here ∥A∥2=146\|\mathcal{A}\|^2 = 146, and the cheap bound ∑r∥ar∥4=518\sum_r \|a_r\|^4 = 518 is 3.55 times larger. With that bound the step is shorter, and after 300 steps dist⁡\operatorname{dist} is only 0.00980.0098. With λ=0.05\lambda = 0.05 the result has rank one and trace 0.99850.9985, and dist⁡=0.0013\operatorname{dist} = 0.0013: the penalty adds a small bias toward a smaller trace.

Correctness

The proof page shows these facts.

  • Lifting. ar∗Xar=⟨arar∗,X⟩a_r^* X a_r = \langle a_r a_r^*, X \rangle is linear in XX, and A(xx∗)=y\mathcal{A}(x x^*) = y. The top eigenpair of xx∗x x^* gives xx up to a phase.
  • The projection. Clipping the eigenvalues at 00 gives the unique nearest positive semidefinite matrix, and the real form gives the same result.
  • The rate. With the step 1/L1/L and L≥∥A∥2L \ge \|\mathcal{A}\|^2, F(Xk)F(X_k) does not increase, ∥Xk−X∗∥\|X_k - X^*\| does not increase, and F(Xk)−F∗≤L∥X0−X∗∥2/(2k)F(X_k) - F^* \le L \|X_0 - X^*\|^2 / (2k).
  • Recovery. If xx∗x x^* is the only positive semidefinite matrix that fits the data, then Xk→xx∗X_k \to x x^* and zk→xz_k \to x up to a phase.

Candès and Li (2014, Theorem 1.2) show that for m≥c0 nm \ge c_0\, n Gaussian vectors, with probability at least 1−O(e−γm)1 - O(e^{-\gamma m}), PhaseLift recovers every xx at once, and their Lemma 2.2 gives the unique feasible point. This is cited, not proved here.

Proof: The lifted linear map, the projection onto the semidefinite cone, and the rate of projected gradientfull

Matrices are n×nn \times n Hermitian, with the real inner product ⟨P,Q⟩=Re⁡tr⁡(P∗Q)\langle P, Q \rangle = \operatorname{Re} \operatorname{tr}(P^* Q) and the Frobenius norm. X⪰0X \succeq 0 means positive semidefinite, and S+S_+ is the set of these matrices. The data are yr=∣ar∗x∣2y_r = |a_r^* x|^2 for r=1,…,mr = 1, \dots, m. Put

A(X)r=ar∗Xar,F(X)=12∥A(X)−y∥2+λtr⁡X,λ≥0.\mathcal{A}(X)_r = a_r^* X a_r, \qquad F(X) = \tfrac12 \|\mathcal{A}(X) - y\|^2 + \lambda \operatorname{tr} X, \qquad \lambda \ge 0 .

The implementation runs Xk+1=PS+(Xk−∇F(Xk)/L)X_{k+1} = P_{S_+}\bigl(X_k - \nabla F(X_k) / L\bigr) from X0=0X_0 = 0 with L≥∥A∥2L \ge \|\mathcal{A}\|^2 (lines L1 to L6), and then takes w1 u1\sqrt{w_1}\, u_1 from the top eigenpair of the result. The claim of correctness has four parts: the data are linear in X=xx∗X = x x^* (Lemma 1), the projection step is the exact projection onto S+S_+ (Lemmas 2 and 3), the iteration converges to the minimum of FF at the rate O(1/k)O(1/k) (Lemma 4), and when the feasible set is the single point xx∗x x^* the iterates and the extracted vector converge to the signal (Lemma 5). When the feasible set is a single point is the result of Candès and Li (2014), which is cited and not proved here.

Lemma 1 (lifting). A\mathcal{A} is real linear, A(xx∗)=y\mathcal{A}(x x^*) = y, and its adjoint is A∗(v)=∑rvrarar∗\mathcal{A}^*(v) = \sum_r v_r a_r a_r^*. If X=xx∗X = x x^* with x≠0x \neq 0, its top eigenvalue is ∥x∥2\|x\|^2 with the eigenvector x/∥x∥x / \|x\|, and w1 u1=eiφx\sqrt{w_1}\, u_1 = e^{i\varphi} x for some real φ\varphi.

Proof. ar∗Xar=tr⁡(arar∗X)=⟨arar∗,X⟩a_r^* X a_r = \operatorname{tr}(a_r a_r^* X) = \langle a_r a_r^*, X \rangle, which is real for Hermitian XX and linear in XX. For X=xx∗X = x x^* it is (ar∗x)(x∗ar)=∣ar∗x∣2(a_r^* x)(x^* a_r) = |a_r^* x|^2. Then ∑rvrA(X)r=∑rvr⟨arar∗,X⟩=⟨∑rvrarar∗,X⟩\sum_r v_r \mathcal{A}(X)_r = \sum_r v_r \langle a_r a_r^*, X \rangle = \langle \sum_r v_r a_r a_r^*, X \rangle for real vv. Finally xx∗x=∥x∥2xx x^* x = \|x\|^2 x and xx∗w=0x x^* w = 0 for w⊥xw \perp x, so the top eigenvalue is ∥x∥2\|x\|^2 with a one dimensional eigenspace; a unit eigenvector is eiφx/∥x∥e^{i\varphi} x / \|x\|. □\square

So the quadratic equations in xx become linear equations in XX, with the two extra conditions X⪰0X \succeq 0 and rank⁡X=1\operatorname{rank} X = 1. PhaseLift keeps the first condition and drops the second.

Lemma 2 (projection onto S+S_+). Let X=Udiag⁡(w)U∗X = U \operatorname{diag}(w) U^* with UU unitary. Then X+=Udiag⁡(max⁡(w,0))U∗X_+ = U \operatorname{diag}(\max(w, 0)) U^* is the unique nearest point of S+S_+ to XX. It satisfies ⟨X−X+,Z−X+⟩≤0\langle X - X_+, Z - X_+ \rangle \le 0 for all Z∈S+Z \in S_+, and X+(X+−X)=0X_+ (X_+ - X) = 0.

Proof. For Z∈S+Z \in S_+ put M=U∗ZUM = U^* Z U, which is also positive semidefinite, so Mkk≥0M_{kk} \ge 0. The norm does not change under unitary maps, so

∥X−Z∥2=∥diag⁡(w)−M∥2≥∑k(wk−Mkk)2≥∑k:wk<0wk2=∥X−X+∥2.\|X - Z\|^2 = \|\operatorname{diag}(w) - M\|^2 \ge \sum_k (w_k - M_{kk})^2 \ge \sum_{k : w_k < 0} w_k^2 = \|X - X_+\|^2 .

The second inequality uses Mkk≥0M_{kk} \ge 0 for each kk with wk<0w_k < 0. So X+∈S+X_+ \in S_+ is a nearest point. S+S_+ is closed and convex, so the nearest point is unique and is characterized by the variational inequality. Also X+−X=Udiag⁡(max⁡(−w,0))U∗X_+ - X = U \operatorname{diag}(\max(-w, 0)) U^*, and max⁡(wk,0)max⁡(−wk,0)=0\max(w_k, 0) \max(-w_k, 0) = 0 for each kk. □\square

Lemma 3 (the real form). For X=B+iCX = B + iC with real BB and CC, put ϕ(X)=(B−CCB)\phi(X) = \begin{pmatrix} B & -C \\ C & B \end{pmatrix}. Then ϕ(X+Y)=ϕ(X)+ϕ(Y)\phi(X + Y) = \phi(X) + \phi(Y), ϕ(XY)=ϕ(X)ϕ(Y)\phi(XY) = \phi(X)\phi(Y), ϕ(X∗)=ϕ(X)T\phi(X^*) = \phi(X)^T, and ∥ϕ(X)∥2=2∥X∥2\|\phi(X)\|^2 = 2\|X\|^2. If XX is Hermitian, ϕ(X)\phi(X) is real symmetric with the same eigenvalues, each twice, and ϕ(X+)=ϕ(X)+\phi(X_+) = \phi(X)_+, the clipping of ϕ(X)\phi(X).

Proof. The first three are direct computations with (B+iC)(D+iE)=(BD−CE)+i(BE+CD)(B + iC)(D + iE) = (BD - CE) + i(BE + CD). Each of BB and CC appears twice in ϕ(X)\phi(X), which gives the norm. If Xu=wuX u = w u with u=p+iqu = p + iq, then ϕ(X)\phi(X) maps (p,q)(p, q) to w(p,q)w (p, q) and (−q,p)(-q, p) to w(−q,p)w(-q, p), which is the eigenvector for iui u. These two real vectors are orthogonal, and an orthonormal basis u1,…,unu_1, \dots, u_n of Cn\mathbb{C}^n gives an orthonormal basis of R2n\mathbb{R}^{2n} in this way. So the eigenvalues of ϕ(X)\phi(X) are those of XX, each twice. Let pp be a real polynomial with p(wk)=max⁡(wk,0)p(w_k) = \max(w_k, 0) for every eigenvalue wkw_k of XX. Then X+=p(X)X_+ = p(X) and ϕ(X)+=p(ϕ(X))\phi(X)_+ = p(\phi(X)), because both matrices have the same eigenvalues. By the rules above, p(ϕ(X))=ϕ(p(X))=ϕ(X+)p(\phi(X)) = \phi(p(X)) = \phi(X_+). □\square

The implementation computes ϕ(X)+=∑wk>0wkqkqkT\phi(X)_+ = \sum_{w_k > 0} w_k q_k q_k^T from the eigenvectors qkq_k of the Jacobi method, and reads X+=B++iC+X_+ = B_+ + i C_+ off its blocks. Each block appears twice, so it takes the mean of the two copies.

Lemma 4 (projected gradient). FF is convex on S+S_+, ∇F(X)=A∗(A(X)−y)+λI\nabla F(X) = \mathcal{A}^*(\mathcal{A}(X) - y) + \lambda I, and for all XX and YY

F(Y)=F(X)+⟨∇F(X),Y−X⟩+12∥A(Y−X)∥2≤F(X)+⟨∇F(X),Y−X⟩+L2∥Y−X∥2.F(Y) = F(X) + \langle \nabla F(X), Y - X \rangle + \tfrac12 \|\mathcal{A}(Y - X)\|^2 \le F(X) + \langle \nabla F(X), Y - X \rangle + \tfrac{L}{2} \|Y - X\|^2 .

Let F∗F^* be the minimum of FF over S+S_+ and X∗X^* a minimizer. A minimizer exists when λ>0\lambda > 0, because then F(X)≥λtr⁡X≥λ∥X∥F(X) \ge \lambda \operatorname{tr} X \ge \lambda \|X\| on S+S_+, and when λ=0\lambda = 0 and the data are exact, because then F(xx∗)=0F(x x^*) = 0. Then the iterates satisfy F(Xk+1)≤F(Xk)−L2∥Xk+1−Xk∥2F(X_{k+1}) \le F(X_k) - \frac{L}{2}\|X_{k+1} - X_k\|^2, ∥Xk+1−X∗∥≤∥Xk−X∗∥\|X_{k+1} - X^*\| \le \|X_k - X^*\|, and

F(Xk)−F∗≤L∥X0−X∗∥22k(k≥1).F(X_k) - F^* \le \frac{L \|X_0 - X^*\|^2}{2k} \qquad (k \ge 1).

Proof. FF is a convex quadratic plus a linear term, so the expansion is exact: the linear terms give ∇F\nabla F by Lemma 1, and the quadratic term is 12∥A(Y−X)∥2≤L2∥Y−X∥2\frac12 \|\mathcal{A}(Y - X)\|^2 \le \frac{L}{2}\|Y - X\|^2. Fix XX, put G=∇F(X)G = \nabla F(X) and X+=PS+(X−G/L)X^+ = P_{S_+}(X - G/L). By Lemma 2 with the point X−G/LX - G/L, every Z∈S+Z \in S_+ has ⟨X−G/L−X+,Z−X+⟩≤0\langle X - G/L - X^+, Z - X^+ \rangle \le 0, that is ⟨G,X+−Z⟩≤L⟨X−X+,X+−Z⟩\langle G, X^+ - Z \rangle \le L \langle X - X^+, X^+ - Z \rangle. Convexity gives F(X)≤F(Z)−⟨G,Z−X⟩F(X) \le F(Z) - \langle G, Z - X \rangle. With the expansion for Y=X+Y = X^+,

F(X+)≤F(Z)+⟨G,X+−Z⟩+L2∥X+−X∥2≤F(Z)+L⟨X−X+,X+−Z⟩+L2∥X+−X∥2.F(X^+) \le F(Z) + \langle G, X^+ - Z \rangle + \tfrac{L}{2}\|X^+ - X\|^2 \le F(Z) + L \langle X - X^+, X^+ - Z \rangle + \tfrac{L}{2}\|X^+ - X\|^2 .

The right side equals F(Z)+L2(∥X−Z∥2−∥X+−Z∥2)F(Z) + \frac{L}{2}\bigl(\|X - Z\|^2 - \|X^+ - Z\|^2\bigr), by the expansion of ∥(X−X+)+(X+−Z)∥2\|(X - X^+) + (X^+ - Z)\|^2. With Z=XZ = X this is the decrease of FF. With Z=X∗Z = X^* and F(X+)≥F∗F(X^+) \ge F^* it gives ∥X+−X∗∥≤∥X−X∗∥\|X^+ - X^*\| \le \|X - X^*\|. Add the inequalities for Z=X∗Z = X^* over the steps 0,…,k−10, \dots, k - 1: the right sides telescope, so ∑j=1k(F(Xj)−F∗)≤L2∥X0−X∗∥2\sum_{j=1}^{k} (F(X_j) - F^*) \le \frac{L}{2}\|X_0 - X^*\|^2. F(Xj)F(X_j) does not increase, so the left side is at least k(F(Xk)−F∗)k (F(X_k) - F^*). □\square

The implementation takes L=∥A∥2(1+10−9)L = \|\mathcal{A}\|^2 (1 + 10^{-9}), where ∥A∥\|\mathcal{A}\| is the largest singular value of the m×n2m \times n^2 real matrix of A\mathcal{A} in the orthonormal basis EjjE_{jj}, (Ejk+Ekj)/2(E_{jk} + E_{kj})/\sqrt2, i(Ejk−Ekj)/2i(E_{jk} - E_{kj})/\sqrt2 of the Hermitian matrices. The cheaper bound L=∑r∥ar∥4L = \sum_r \|a_r\|^4 is also valid, because ⟨arar∗,X⟩2≤∥arar∗∥2∥X∥2=∥ar∥4∥X∥2\langle a_r a_r^*, X \rangle^2 \le \|a_r a_r^*\|^2 \|X\|^2 = \|a_r\|^4 \|X\|^2 by the Cauchy-Schwarz inequality.

Lemma 5 (recovery when the feasible point is unique). Let λ=0\lambda = 0 and suppose that {X∈S+:A(X)=y}={xx∗}\{X \in S_+ : \mathcal{A}(X) = y\} = \{x x^*\}. Then Xk→xx∗X_k \to x x^*, and dist⁡(w1(Xk) u1(Xk),x)→0\operatorname{dist}(\sqrt{w_1(X_k)}\, u_1(X_k), x) \to 0, where dist⁡(z,x)=min⁡φ∥z−eiφx∥\operatorname{dist}(z, x) = \min_\varphi \|z - e^{i\varphi} x\|.

Proof. F≥0F \ge 0 and F(xx∗)=0F(x x^*) = 0, so F∗=0F^* = 0, and the minimizers are exactly the feasible points, so X∗=xx∗X^* = x x^* is the only one. By Lemma 4, F(Xk)→0F(X_k) \to 0 and ∥Xk−X∗∥\|X_k - X^*\| does not increase, so the sequence is bounded. Every limit point Xˉ\bar X of the sequence lies in the closed set S+S_+ and has F(Xˉ)=0F(\bar X) = 0 by continuity, so Xˉ=X∗\bar X = X^*. A bounded sequence with a single limit point converges to it. For the vector, w1w_1 is a continuous function of XX, so w1(Xk)→∥x∥2w_1(X_k) \to \|x\|^2. The top eigenvalue of xx∗x x^* is simple, so the projection u1u1∗u_1 u_1^* onto its eigenspace is continuous at xx∗x x^*, and w1u1u1∗→xx∗w_1 u_1 u_1^* \to x x^*. For z=w1 u1z = \sqrt{w_1}\, u_1 this says zz∗→xx∗z z^* \to x x^*. Then ∣x∗z∣2=x∗zz∗x→∥x∥4|x^* z|^2 = x^* z z^* x \to \|x\|^4 and ∥z∥2→∥x∥2\|z\|^2 \to \|x\|^2, so dist⁡2(z,x)=∥z∥2+∥x∥2−2∣x∗z∣→0\operatorname{dist}^2(z, x) = \|z\|^2 + \|x\|^2 - 2|x^* z| \to 0. □\square

The cited results. Candès, Strohmer and Voroninski (2013) take the problem "minimize tr⁡X\operatorname{tr} X subject to A(X)=y\mathcal{A}(X) = y and X⪰0X \succeq 0" and show that, for m≥c0 nlog⁡nm \ge c_0\, n \log n Gaussian vectors and a fixed xx, its unique solution is xx∗x x^* with high probability (Theorem 1.1 in the statement of Candès and Li). Candès and Li (2014, Theorem 1.2) show the same for m≥c0 nm \ge c_0\, n, with probability at least 1−O(e−γm)1 - O(e^{-\gamma m}), and for all xx at once. Their proof shows that xx∗x x^* is the only feasible point (their Lemma 2.2), so the condition of Lemma 5 holds and the trace does not matter. In that case the projected gradient with λ=0\lambda = 0 finds xx.

What is not claimed. The probabilistic results above are cited, not proved. With λ>0\lambda > 0 the minimizer of FF is not in general xx∗x x^*; the penalty pulls the trace down, which helps with noise but adds a bias. The rate O(1/k)O(1/k) is the worst case; the faster, linear decrease in the example on the main page is a measurement. The tests check Lemmas 1 to 4 on random data, and they measure the recovery on fixed seeds without a theorem for those sizes.

Complexity

One step computes A(X)\mathcal{A}(X) and A∗(ρ)\mathcal{A}^*(\rho) in O(mn2)O(m n^2) time and an eigenvalue decomposition in O(n3)O(n^3) time, so KK steps cost O(K(mn2+n3))O(K(m n^2 + n^3)). The extra space is O(n2)O(n^2) for the matrices. The exact ∥A∥\|\mathcal{A}\| costs more than one step, because it works with an m×n2m \times n^2 matrix; the bound ∑r∥ar∥4\sum_r \|a_r\|^4 costs O(mn)O(m n). For coded diffraction patterns the products with the ara_r are fast Fourier transforms, but the matrix still has n2n^2 entries. This size is the main limit of PhaseLift: a signal of 10410^4 samples gives a matrix of 10810^8 entries.

Properties

  • Convex. There are no false local minima, and the result does not depend on a start.
  • Up to a global phase. The lifted matrix xx∗x x^* does not change when xx is replaced by eiφxe^{i\varphi} x.
  • Order nn measurements are enough for Gaussian vectors, by Candès and Li (2014).
  • Universal. For one draw of the vectors, the result of Candès and Li holds for all signals at once.
  • Expensive. The unknown has n2n^2 entries in place of nn.

Variants and improvements

  • Noisy data. Candès and Li (2014, problem (1.6)) fit the data in the ℓ1\ell_1 norm over the positive semidefinite matrices, and bound the error by a constant times ∥w∥1/m\|w\|_1 / m for the noise ww (Theorem 1.3).
  • Feasibility only. When the feasible point is unique, the trace can be dropped, as in the implementation here. Candès and Li note a similar argument by Demanet and Hand.
  • Other solvers. ADMM, accelerated gradient methods, or a factored form X=ZZ∗X = Z Z^* with few columns, which gives up convexity to save memory.
  • Nonconvex methods. Wirtinger flow works with xx itself, from a spectral start. It needs about nlog⁡nn \log n Gaussian measurements in its theorem, but each step costs only O(mn)O(m n).

When to use it

Use PhaseLift for small or medium nn, when a guarantee that does not depend on a start matters, and when the vectors are random, as in Gaussian or coded diffraction measurements. It is also a good reference to test nonconvex methods against. For large images use Wirtinger flow or other nonconvex methods. For the classical Fourier problem with a support, the theory does not apply.

Pitfalls

  • Memory. The matrix has n2n^2 entries. Do not form A\mathcal{A} as an m×n2m \times n^2 matrix for large nn.
  • A step that is too long. The step 1/L1/L needs L≥∥A∥2L \ge \|\mathcal{A}\|^2. An estimate of ∥A∥\|\mathcal{A}\| from a few power steps is a lower bound and can be too small.
  • Rank above one. With noise or with too few measurements, the result can have rank above one. Take the top eigenpair, and check how large the second eigenvalue is.
  • Too few measurements. If the data do not fix xx up to a phase, no relaxation can help. Balan, Casazza and Edidin showed that 4n−24n - 2 generic measurements fix xx (see the complement property), and the theorem of PhaseLift needs a larger multiple of nn.
  • The trace weight. A large λ\lambda shrinks the result; the trace is a convex stand-in for the rank, not the rank itself.

Implementations

Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.

imgla.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Shared helper of the imaging and inverse problems pages of https://algorithm.tamnd.com/. The authors are listed in prov/.
"""Dense linear algebra on lists of rows (float, complex or Fraction entries).

A matrix is a list of rows. A vector is a list of numbers. The inner product
is <u, v> = sum_i conj(u_i) v_i, linear in the second argument, so that the
adjoint A^H satisfies <A x, y> = <x, A^H y>.
"""

import math


def _flat(x):
    """Flatten a list of rows (an image) into one list; a vector is returned as is."""
    if x and isinstance(x[0], (list, tuple)):
        return [v for row in x for v in row]
    return x


def zeros(m, n):
    """The m x n zero matrix."""
    return [[0.0] * n for _ in range(m)]


def eye(n):
    """The n x n identity matrix."""
    out = zeros(n, n)
    for i in range(n):
        out[i][i] = 1.0
    return out


def transpose(a):
    """A^T."""
    return [list(col) for col in zip(*a)]


def conj_transpose(a):
    """A^H, the conjugate transpose."""
    return [[v.conjugate() for v in col] for col in zip(*a)]


def matmul(a, b):
    """The product A B."""
    bt = list(zip(*b))
    return [[sum(x * y for x, y in zip(row, col)) for col in bt] for row in a]


def matvec(a, x):
    """The product A x."""
    return [sum(v * w for v, w in zip(row, x)) for row in a]


def rmatvec(a, y):
    """The product A^H y."""
    n = len(a[0]) if a else 0
    out = [0.0] * n
    for row, yi in zip(a, y):
        if yi == 0:
            continue
        for j, v in enumerate(row):
            out[j] += v.conjugate() * yi
    return out


def dot(u, v):
    """<u, v> = sum_i conj(u_i) v_i. Images (lists of rows) are flattened."""
    return sum(a.conjugate() * b for a, b in zip(_flat(u), _flat(v)))


def norm2(x):
    """The Euclidean norm. Images (lists of rows) are flattened."""
    return math.sqrt(sum(abs(v) ** 2 for v in _flat(x)))


def solve(a, b):
    """Solve A x = b by Gaussian elimination with partial pivoting.

    b is a vector or a matrix (a list of rows). A must be square and
    nonsingular; a zero pivot raises ValueError. Fractions stay exact.
    """
    n = len(a)
    vec = not (b and isinstance(b[0], (list, tuple)))
    rhs = [[bi] for bi in b] if vec else [list(r) for r in b]
    m = [list(row) + rhs[i] for i, row in enumerate(a)]
    w = len(m[0])
    for c in range(n):
        p = max(range(c, n), key=lambda r: abs(m[r][c]))
        if m[p][c] == 0:
            raise ValueError("singular matrix")
        m[c], m[p] = m[p], m[c]
        piv = m[c][c]
        for r in range(c + 1, n):
            f = m[r][c] / piv
            if f != 0:
                mr, mc = m[r], m[c]
                for j in range(c, w):
                    mr[j] -= f * mc[j]
    x = [[0.0] * (w - n) for _ in range(n)]
    for r in range(n - 1, -1, -1):
        for j in range(w - n):
            s = m[r][n + j] - sum(m[r][k] * x[k][j] for k in range(r + 1, n))
            x[r][j] = s / m[r][r]
    return [row[0] for row in x] if vec else x


def cholesky(a):
    """Lower triangular L with A = L L^H for a Hermitian positive definite A."""
    n = len(a)
    low = zeros(n, n)
    for j in range(n):
        d = a[j][j] - sum(abs(low[j][k]) ** 2 for k in range(j))
        d = d.real if isinstance(d, complex) else d
        if not d > 0:
            raise ValueError("matrix is not positive definite")
        ljj = math.sqrt(d)
        low[j][j] = ljj
        for i in range(j + 1, n):
            s = a[i][j] - sum(low[i][k] * low[j][k].conjugate() for k in range(j))
            low[i][j] = s / ljj
    return low


def cho_solve(low, b):
    """Solve (L L^H) x = b, with L from cholesky."""
    n = len(low)
    z = [0.0] * n
    for i in range(n):
        z[i] = (b[i] - sum(low[i][k] * z[k] for k in range(i))) / low[i][i]
    x = [0.0] * n
    for i in range(n - 1, -1, -1):
        s = z[i] - sum(low[k][i].conjugate() * x[k] for k in range(i + 1, n))
        x[i] = s / low[i][i].conjugate()
    return x


def _rot_params(app, aqq, apq):
    """c, s of the Jacobi rotation that zeroes the (p, q) entry of [[app, apq], [apq, aqq]]."""
    theta = (aqq - app) / (2.0 * apq)
    t = (1.0 if theta >= 0 else -1.0) / (abs(theta) + math.sqrt(theta * theta + 1.0))
    c = 1.0 / math.sqrt(1.0 + t * t)
    return c, c * t


def sym_eig(a, tol=1e-15, max_sweeps=100):
    """Eigenvalues (ascending) and eigenvectors (as columns) of a real symmetric matrix.

    Cyclic Jacobi method. Returns (w, Q) with A = Q diag(w) Q^T.
    """
    n = len(a)
    m = [[float(v) for v in row] for row in a]
    q = eye(n)
    for _ in range(max_sweeps):
        off = sum(m[i][j] ** 2 for i in range(n) for j in range(n) if i != j)
        scale = sum(m[i][i] ** 2 for i in range(n)) + off
        if off <= (tol * tol) * scale or off == 0.0:
            break
        for p in range(n - 1):
            for r in range(p + 1, n):
                apq = m[p][r]
                if apq == 0.0:
                    continue
                c, s = _rot_params(m[p][p], m[r][r], apq)
                for k in range(n):
                    mkp, mkr = m[k][p], m[k][r]
                    m[k][p] = c * mkp - s * mkr
                    m[k][r] = s * mkp + c * mkr
                mp, mr = m[p], m[r]
                for k in range(n):
                    mpk, mrk = mp[k], mr[k]
                    mp[k] = c * mpk - s * mrk
                    mr[k] = s * mpk + c * mrk
                m[p][r] = m[r][p] = 0.0
                for k in range(n):
                    qkp, qkr = q[k][p], q[k][r]
                    q[k][p] = c * qkp - s * qkr
                    q[k][r] = s * qkp + c * qkr
    order = sorted(range(n), key=lambda i: m[i][i])
    w = [m[i][i] for i in order]
    qs = [[q[k][i] for i in order] for k in range(n)]
    return w, qs


def _complete(cols, m):
    """Replace zero columns of an m-row column list by unit vectors orthogonal to the others."""
    for idx, col in enumerate(cols):
        if any(v != 0.0 for v in col):
            continue
        for e in range(m):
            cand = [0.0] * m
            cand[e] = 1.0
            for _ in range(2):
                for jdx, other in enumerate(cols):
                    if jdx == idx or not any(v != 0.0 for v in other):
                        continue
                    h = sum(a * b for a, b in zip(other, cand))
                    cand = [a - h * b for a, b in zip(cand, other)]
            nrm = math.sqrt(sum(v * v for v in cand))
            if nrm > 0.5:
                cols[idx] = [v / nrm for v in cand]
                break
    return cols


def svd(a, tol=1e-15, max_sweeps=100):
    """Thin SVD of a real m x n matrix by one-sided Jacobi (Hestenes).

    Returns (U, S, V) with p = min(m, n): U is m x p, S a list of p values in
    descending order, V is n x p, U^T U = I, V^T V = I and A = U diag(S) V^T.
    """
    m, n = len(a), len(a[0])
    if m < n:
        v, s, u = svd(transpose(a), tol, max_sweeps)
        return u, s, v
    cols = [[float(a[i][j]) for i in range(m)] for j in range(n)]
    vcols = [[1.0 if i == j else 0.0 for i in range(n)] for j in range(n)]
    for _ in range(max_sweeps):
        rotated = False
        for p in range(n - 1):
            for r in range(p + 1, n):
                cp, cr = cols[p], cols[r]
                alpha = sum(x * x for x in cp)
                beta = sum(x * x for x in cr)
                gamma = sum(x * y for x, y in zip(cp, cr))
                if gamma == 0.0 or abs(gamma) <= tol * math.sqrt(alpha * beta):
                    continue
                rotated = True
                c, s = _rot_params(alpha, beta, gamma)
                cols[p] = [c * x - s * y for x, y in zip(cp, cr)]
                cols[r] = [s * x + c * y for x, y in zip(cp, cr)]
                vp, vr = vcols[p], vcols[r]
                vcols[p] = [c * x - s * y for x, y in zip(vp, vr)]
                vcols[r] = [s * x + c * y for x, y in zip(vp, vr)]
        if not rotated:
            break
    sig = [math.sqrt(sum(x * x for x in col)) for col in cols]
    # A column below 1e-150 times the largest one is zero to working precision;
    # its squares underflow, so its direction carries no information.
    floor = max(sig) * 1e-150 if sig else 0.0
    sig = [t if t > floor and t > 1e-150 else 0.0 for t in sig]
    order = sorted(range(n), key=lambda j: -sig[j])
    s_out = [sig[j] for j in order]
    ucols = [[x / sig[j] for x in cols[j]] if sig[j] > 0.0 else [0.0] * m for j in order]
    ucols = _complete(ucols, m)
    u = [[ucols[j][i] for j in range(n)] for i in range(m)]
    v = [[vcols[j][i] for j in order] for i in range(n)]
    return u, s_out, v


def adjoint_gap(apply_a, apply_ah, x, y):
    """|<A x, y> - <x, A^H y>| / (||A x|| ||y||) for given functions A and A^H.

    x and y may be vectors or images (lists of rows). If the denominator is
    zero, the absolute gap is returned.
    """
    ax = apply_a(x)
    gap = abs(dot(ax, y) - dot(x, apply_ah(y)))
    den = norm2(ax) * norm2(y)
    return gap / den if den > 0.0 else gap
phaselift.py 224 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/phaselift/. The authors are listed in prov/K3F300.jsonl.

"""PhaseLift for phase retrieval (Candes, Strohmer and Voroninski 2013).

The data are y_r = |a_r^H x|^2 = a_r^H (x x^H) a_r, which are linear in the
lifted matrix X = x x^H. PhaseLift replaces the rank one condition by
X >= 0 (positive semidefinite) and solves

    minimize tr(X)  subject to  A(X) = y,  X >= 0,   A(X)_r = a_r^H X a_r.

This file solves the penalized form

    minimize F(X) = (1/2) ||A(X) - y||^2 + lam tr(X)  over X >= 0

by projected gradient steps with the step 1 / L, L = sum_r ||a_r||^4 >= ||A||^2.
With lam = 0 it finds a point of {X >= 0 : A(X) = y}; Candes and Li (2014)
show that for m >= c0 n Gaussian vectors this set is the single point x x^H.
The estimate of x is the top eigenvector of X times the root of its eigenvalue.

Hermitian matrices are lists of rows of complex numbers. The projection onto
the positive semidefinite cone uses the real form [[B, -C], [C, B]] of
X = B + iC and the Jacobi eigenvalue method of the shared helper.
"""

import math
import random

from imgla import svd, sym_eig


def gaussian_design(rng, m, n):
    """m sampling vectors with entries N(0, 1/2) + i N(0, 1/2)."""
    s = math.sqrt(0.5)
    return [[complex(rng.gauss(0.0, s), rng.gauss(0.0, s)) for _ in range(n)] for _ in range(m)]


def inner(a, v):
    """<a, v> = a^H v."""
    return sum(complex(u).conjugate() * w for u, w in zip(a, v))


def norm(v):
    """The Euclidean norm of a vector."""
    return math.sqrt(sum(abs(w) ** 2 for w in v))


def measure(a_rows, x):
    """The phaseless data y_r = |a_r^H x|^2."""
    return [abs(inner(a, x)) ** 2 for a in a_rows]


def lift(x):
    """The rank one matrix x x^H."""
    return [[complex(u) * complex(v).conjugate() for v in x] for u in x]


def apply_a(a_rows, mat):
    """A(X)_r = a_r^H X a_r, a real number for Hermitian X."""
    out = []
    for a in a_rows:
        xa = [sum(row[j] * a[j] for j in range(len(a))) for row in mat]
        out.append(inner(a, xa).real)
    return out


def apply_a_adjoint(a_rows, v):
    """A^*(v) = sum_r v_r a_r a_r^H."""
    n = len(a_rows[0])
    out = [[0j] * n for _ in range(n)]
    for a, vr in zip(a_rows, v):
        for i in range(n):
            c = vr * a[i]
            row = out[i]
            for j in range(n):
                row[j] += c * a[j].conjugate()
    return out


def frob_inner(p, q):
    """Re tr(P^H Q), the real inner product of matrices."""
    return sum((complex(u).conjugate() * v).real for rp, rq in zip(p, q) for u, v in zip(rp, rq))


def frob_norm(p):
    """The Frobenius norm."""
    return math.sqrt(sum(abs(v) ** 2 for row in p for v in row))


def trace(p):
    """The trace, a real number for Hermitian P."""
    return sum(p[i][i] for i in range(len(p))).real


def hermitian_eig(mat):
    """Eigenvalues (ascending) and unit eigenvectors of a Hermitian matrix.

    The real form R = [[B, -C], [C, B]] of X = B + iC has each eigenvalue of X
    twice; the eigenvector (p, q) of R gives the eigenvector p + iq of X. One
    vector of each pair is kept, by a Gram-Schmidt test.
    """
    n = len(mat)
    real_form = [[mat[i][j].real for j in range(n)] + [-mat[i][j].imag for j in range(n)] for i in range(n)]
    real_form += [[mat[i][j].imag for j in range(n)] + [mat[i][j].real for j in range(n)] for i in range(n)]
    w, q = sym_eig(real_form)
    vals, vecs = [], []
    for k in sorted(range(2 * n), key=lambda t: -w[t]):
        v = [complex(q[i][k], q[i + n][k]) for i in range(n)]
        for u in vecs:
            c = inner(u, v)
            v = [vi - c * ui for vi, ui in zip(v, u)]
        s = norm(v)
        if s > 0.5 and len(vecs) < n:
            vecs.append([vi / s for vi in v])
            vals.append(w[k])
    order = sorted(range(n), key=lambda t: vals[t])
    return [vals[t] for t in order], [vecs[t] for t in order]


def psd_project(mat):
    """The nearest positive semidefinite matrix in the Frobenius norm.

    Spectral clipping X+ = sum_k max(w_k, 0) u_k u_k^H, done on the real form:
    R+ = Q diag(max(w, 0)) Q^T has the same block form, and X+ = R+_11 + i R+_21.
    """
    n = len(mat)
    real_form = [[mat[i][j].real for j in range(n)] + [-mat[i][j].imag for j in range(n)] for i in range(n)]
    real_form += [[mat[i][j].imag for j in range(n)] + [mat[i][j].real for j in range(n)] for i in range(n)]
    w, q = sym_eig(real_form)
    keep = [k for k in range(2 * n) if w[k] > 0.0]
    out = [[0j] * n for _ in range(n)]
    for i in range(n):
        for j in range(n):
            b = sum(w[k] * (q[i][k] * q[j][k] + q[i + n][k] * q[j + n][k]) for k in keep) / 2.0
            c = sum(w[k] * (q[i + n][k] * q[j][k] - q[i][k] * q[j + n][k]) for k in keep) / 2.0
            out[i][j] = complex(b, c)
    return out


def real_rows(a_rows):
    """The m x n^2 real matrix of A in an orthonormal basis of the Hermitian matrices.

    The basis is E_ii, (E_ij + E_ji) / sqrt 2 and i (E_ij - E_ji) / sqrt 2 for
    i < j, orthonormal for Re tr(P^H Q). The coordinates of a a^H are |a_i|^2,
    sqrt 2 Re(a_i conj(a_j)) and sqrt 2 Im(a_i conj(a_j)).
    """
    n = len(a_rows[0])
    out = []
    for a in a_rows:
        row = [abs(a[i]) ** 2 for i in range(n)]
        for i in range(n):
            for j in range(i + 1, n):
                p = a[i] * a[j].conjugate()
                row += [math.sqrt(2.0) * p.real, math.sqrt(2.0) * p.imag]
        out.append(row)
    return out


def op_norm_sq(a_rows):
    """||A||^2, the largest eigenvalue of A^* A, from the singular values of real_rows."""
    _, s, _ = svd(real_rows(a_rows))
    return s[0] ** 2


def objective(a_rows, y, mat, lam=0.0):
    """F(X) = (1/2) ||A(X) - y||^2 + lam tr(X)."""
    r = [u - v for u, v in zip(apply_a(a_rows, mat), y)]
    return 0.5 * sum(t * t for t in r) + lam * trace(mat)


def phaselift(a_rows, y, iters, lam=0.0, x0=None, record=None, big_l=None):
    """Projected gradient for min F(X) over X >= 0. Returns X.

    The step is 1 / L with L = ||A||^2 (times 1 + 1e-9 against rounding) unless
    big_l is given; any L >= ||A||^2, such as sum_r ||a_r||^4, is safe. x0 is the
    start matrix (zero by default). If record is a list, X_0 .. X_iters are
    appended to it.
    """
    n = len(a_rows[0])
    if big_l is None:
        big_l = op_norm_sq(a_rows) * (1.0 + 1e-9)  # @line L1
    mat = [[0j] * n for _ in range(n)] if x0 is None else [list(row) for row in x0]  # @line L2
    if record is not None:
        record.append(mat)
    for _ in range(iters):  # @line L3
        resid = [u - v for u, v in zip(apply_a(a_rows, mat), y)]  # @line L4
        grad = apply_a_adjoint(a_rows, resid)  # @line L5
        for i in range(n):
            grad[i][i] += lam
        step = [[mat[i][j] - grad[i][j] / big_l for j in range(n)] for i in range(n)]
        mat = psd_project(step)  # @line L6
        if record is not None:
            record.append(mat)
    return mat  # @line L7


def extract(mat):
    """The vector sqrt(w_max) u_max from the top eigenpair of X."""
    w, v = hermitian_eig(mat)
    return [math.sqrt(max(w[-1], 0.0)) * c for c in v[-1]]


def dist(z, x):
    """min over phi of ||z - e^{i phi} x||."""
    c = inner(x, z)
    phase = c / abs(c) if abs(c) > 0.0 else 1.0
    return norm([u - phase * v for u, v in zip(z, x)])


def random_hermitian(rng, n):
    """A random Hermitian matrix, for tests."""
    g = [[complex(rng.gauss(0, 1), rng.gauss(0, 1)) for _ in range(n)] for _ in range(n)]
    return [[(g[i][j] + g[j][i].conjugate()) / 2.0 for j in range(n)] for i in range(n)]


def demo(seed=1, n=4, m=24, iters=300):
    """dist(extract(X_k), x) for a random unit x; a small measurement."""
    rng = random.Random(seed)
    x = [complex(rng.gauss(0, 1), rng.gauss(0, 1)) for _ in range(n)]
    s = norm(x)
    x = [v / s for v in x]
    a = gaussian_design(rng, m, n)
    mat = phaselift(a, measure(a, x), iters)
    return dist(extract(mat), x), frob_norm([[u - v for u, v in zip(r1, r2)] for r1, r2 in zip(mat, lift(x))])
test_phaselift.py 143 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/phaselift/. The authors are listed in prov/K3F300.jsonl.

import random

from phaselift import (apply_a, apply_a_adjoint, dist, extract, frob_inner, frob_norm, gaussian_design,
                       hermitian_eig, lift, measure, norm, objective, op_norm_sq, phaselift, psd_project,
                       random_hermitian, real_rows, trace)


def unit_signal(rng, n):
    x = [complex(rng.gauss(0, 1), rng.gauss(0, 1)) for _ in range(n)]
    s = norm(x)
    return [v / s for v in x]


def sub(p, q):
    return [[u - v for u, v in zip(rp, rq)] for rp, rq in zip(p, q)]


def matmul(p, q):
    return [[sum(p[i][k] * q[k][j] for k in range(len(q))) for j in range(len(q[0]))] for i in range(len(p))]


def test_lifted_data_are_linear() -> None:
    rng = random.Random(1)
    x = unit_signal(rng, 4)
    a = gaussian_design(rng, 10, 4)
    assert max(abs(u - v) for u, v in zip(apply_a(a, lift(x)), measure(a, x))) < 1e-12


def test_adjoint() -> None:
    rng = random.Random(2)
    a = gaussian_design(rng, 9, 4)
    for _ in range(3):
        mat = random_hermitian(rng, 4)
        v = [rng.gauss(0, 1) for _ in range(9)]
        left = sum(u * w for u, w in zip(apply_a(a, mat), v))
        right = frob_inner(mat, apply_a_adjoint(a, v))
        assert abs(left - right) < 1e-10 * max(1.0, abs(left))


def test_hermitian_eig_reconstructs() -> None:
    rng = random.Random(3)
    mat = random_hermitian(rng, 4)
    w, v = hermitian_eig(mat)
    back = [[sum(w[k] * v[k][i] * v[k][j].conjugate() for k in range(4)) for j in range(4)] for i in range(4)]
    assert frob_norm(sub(back, mat)) < 1e-10
    assert all(u <= t for u, t in zip(w, w[1:]))


def test_psd_projection_is_the_nearest_point() -> None:
    rng = random.Random(4)
    for _ in range(3):
        mat = random_hermitian(rng, 4)
        proj = psd_project(mat)
        w, _ = hermitian_eig(proj)
        assert w[0] > -1e-10
        for i in range(4):
            for j in range(4):
                assert abs(proj[i][j] - proj[j][i].conjugate()) < 1e-12
        # The parts X+ and X+ - X are orthogonal: X+ (X+ - X) = 0.
        assert frob_norm(matmul(proj, sub(proj, mat))) < 1e-10
        # Variational inequality <X - X+, Y - X+> <= 0 for every PSD Y.
        for _ in range(5):
            g = random_hermitian(rng, 4)
            psd = matmul(g, g)
            assert frob_inner(sub(mat, proj), sub(psd, proj)) < 1e-10
        # A PSD matrix is its own projection.
        assert frob_norm(sub(psd_project(proj), proj)) < 1e-10


def test_operator_norm() -> None:
    rng = random.Random(5)
    a = gaussian_design(rng, 12, 3)
    big_l = op_norm_sq(a)
    fourth = sum(norm(r) ** 4 for r in a)
    assert fourth / 3 <= big_l * (1 + 1e-12) and big_l <= fourth * (1 + 1e-12)
    rows = real_rows(a)
    mat = random_hermitian(rng, 3)
    coords = [mat[i][i].real for i in range(3)]
    for i in range(3):
        for j in range(i + 1, 3):
            coords += [2 ** 0.5 * mat[i][j].real, 2 ** 0.5 * mat[i][j].imag]
    direct = apply_a(a, mat)
    via_rows = [sum(u * v for u, v in zip(row, coords)) for row in rows]
    assert max(abs(u - v) for u, v in zip(direct, via_rows)) < 1e-10
    assert sum(t * t for t in direct) <= big_l * frob_norm(mat) ** 2 * (1 + 1e-9)


def test_hand_example_two_by_two() -> None:
    # x = (1, 1 + i), vectors e1, e2, e1 + e2, e1 + i e2: A is one to one on 2 x 2 Hermitian matrices.
    a = [[1, 0], [0, 1], [1, 1], [1, 1j]]
    a = [[complex(v) for v in row] for row in a]
    x = [1 + 0j, 1 + 1j]
    y = measure(a, x)
    assert max(abs(u - v) for u, v in zip(y, [1.0, 2.0, 5.0, 5.0])) < 1e-12
    rec = []
    mat = phaselift(a, y, 1000, record=rec)
    want = [[1, 1 - 1j], [1 + 1j, 2]]
    assert frob_norm(sub(mat, want)) < 1e-9
    w, _ = hermitian_eig(mat)
    assert abs(w[-1] - 3.0) < 1e-9 and abs(w[0]) < 1e-9
    assert dist(extract(mat), x) < 1e-9


def test_monotone_and_rate_bound() -> None:
    # F(X_k) - F* <= L ||X_0 - X*||^2 / (2 k), with X* = x x^H, F* = 0 and X_0 = 0.
    rng = random.Random(6)
    n = 3
    x = unit_signal(rng, n)
    a = gaussian_design(rng, 18, n)
    y = measure(a, x)
    big_l = op_norm_sq(a) * (1.0 + 1e-9)
    rec = []
    phaselift(a, y, 60, record=rec)
    values = [objective(a, y, mat) for mat in rec]
    assert all(v <= u + 1e-12 for u, v in zip(values, values[1:]))
    for k in range(1, len(values)):
        assert values[k] <= big_l * 1.0 / (2 * k) + 1e-12


def test_trace_penalty_is_monotone() -> None:
    rng = random.Random(7)
    n = 3
    x = unit_signal(rng, n)
    a = gaussian_design(rng, 18, n)
    y = measure(a, x)
    rec = []
    phaselift(a, y, 40, lam=0.5, record=rec)
    values = [objective(a, y, mat, 0.5) for mat in rec]
    assert all(v <= u + 1e-12 for u, v in zip(values, values[1:]))
    assert trace(rec[-1]) < 1.0


def test_recovery_measurement() -> None:
    # Measurement, not a theorem: n = 3, m = 8 n, complex Gaussian design, 300 steps.
    for seed in range(1, 4):
        rng = random.Random(seed)
        x = unit_signal(rng, 3)
        a = gaussian_design(rng, 24, 3)
        mat = phaselift(a, measure(a, x), 300)
        assert dist(extract(mat), x) < 5e-3

History

Candès, Eldar, Strohmer and Voroninski, in a paper on phase retrieval through matrix completion, and Candès, Strohmer and Voroninski (2013) proposed to lift the problem to X=xx∗X = x x^* and to replace the rank by the trace. The second paper proved exact recovery from about nlog⁡nn \log n Gaussian measurements for a fixed signal. Candès and Li (2014) removed the logarithm, made the result hold for all signals at once, and gave the error bound for noisy data. The use of the trace as a convex stand-in for the rank links PhaseLift to low rank matrix recovery and matrix completion.

References

  1. Emmanuel J. Candès, Thomas Strohmer and Vladislav Voroninski, PhaseLift, exact and stable signal recovery from magnitude measurements via convex programming, Communications on Pure and Applied Mathematics 66(8), 2013, 1241 to 1274, the trace minimization relaxation and its exact recovery theorem for m of order n log n, as restated in Theorem 1.1 of Candès and Li (2014)
  2. Emmanuel J. Candès and Xiaodong Li, Solving quadratic equations via PhaseLift when there are about as many equations as unknowns, Foundations of Computational Mathematics 14(5), 2014, 1017 to 1026, problem (1.2) (PhaseLift), Theorem 1.2 (m >= c_0 n, all signals at once), Lemma 2.2 (the lifted signal as the unique feasible point), problem (1.6) and Theorem 1.3 (noisy data) (preprint arXiv 1208.6247)

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH1 sketch
  • a full proof of time.worst
  • a full proof of space.extra
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
Code (python)I0 not checked yet
  • the tests did not run in this build
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • at least three sources
  • a scene preset for the example