Closest Toeplitz SDP search.

% This script finds a Toeplitz Hermitian PSD matrix that is closest to a
% given Hermitian matrix, as measured by the Frobenius norm. That is, for
% a given matrix P, it solves:
%    minimize   || Z - P ||_F
%    subject to Z >= 0
%
% Adapted from an example provided in the SeDuMi documentation. Notice
% the use of SDP mode to simplify the semidefinite constraint.

% The data. P is Hermitian, but is neither Toeplitz nor PSD.
P = [ 4,     1+2*j,     3-j       ; ...
      1-2*j, 3.5,       0.8+2.3*j ; ...
      3+j,   0.8-2.3*j, 4         ];

% Construct and solve the model
n = size( P, 1 );
cvx_begin sdp
    variable Z(n,n) hermitian toeplitz
    dual variable Q
    minimize( norm( Z - P, 'fro' ) )
    Z >= 0 : Q;
cvx_end

% Display resuls
disp( 'The original matrix, P: ' );
disp( P )
disp( 'The optimal point, Z:' );
disp( Z )
disp( 'min( eig( Z ) ) (should be nonnegative):' );
disp( min( eig( Z ) ) )
disp( 'The optimal value, || Z - P ||_F:' );
disp( norm( Z - P, 'fro' ) );
disp( 'Complementary slackness: Z * Q, should be near zero:' );
disp( Z * Q )
 
Calling SeDuMi: 18 variables (0 free), 12 equality constraints
------------------------------------------------------------------------
SeDuMi 1.1 by AdvOL, 2005 and Jos F. Sturm, 1998, 2001-2003.
Alg = 2: xz-corrector, Adaptive Step-Differentiation, theta = 0.250, beta = 0.500
eqs m = 12, order n = 6, dim = 28, blocks = 3
nnz(A) = 24 + 0, nnz(ADA) = 136, nnz(L) = 74
 it :     b*y       gap    delta  rate   t/tP*  t/tD*   feas cg cg  prec
  0 :            8.37E+000 0.000
  1 :  2.29E+000 1.59E+000 0.000 0.1899 0.9000 0.9000   1.31  1  1  9.0E-001
  2 :  1.24E+000 1.44E-001 0.000 0.0904 0.9900 0.9900   1.25  1  1  1.3E-001
  3 :  1.45E+000 3.68E-003 0.000 0.0256 0.9900 0.9900   0.95  1  1  3.4E-003
  4 :  1.45E+000 7.45E-004 0.000 0.2023 0.9000 0.9000   1.00  1  1  6.8E-004
  5 :  1.45E+000 1.50E-004 0.000 0.2014 0.9000 0.9000   1.00  1  1  1.4E-004
  6 :  1.45E+000 1.01E-005 0.027 0.0672 0.9900 0.8828   1.00  1  1  8.8E-006
  7 :  1.45E+000 1.80E-006 0.368 0.1790 0.9112 0.9000   1.00  1  1  1.4E-006
  8 :  1.45E+000 3.41E-007 0.174 0.1894 0.9252 0.9000   1.00  1  1  2.4E-007
  9 :  1.45E+000 1.18E-008 0.000 0.0347 0.9900 0.9698   1.00  2  2  1.2E-008

iter seconds digits       c*x               b*y
  9      0.4   9.1  1.4508035696e+000  1.4508035684e+000
|Ax-b| =  1.9e-009, [Ay-c]_+ =  6.4E-009, |x|= 9.4e+000, |y|= 1.4e+000

Detailed timing (sec)
   Pre          IPM          Post
2.504E-001    4.306E-001    3.004E-002    
Max-norms: ||b||=5.656854e+000, ||c|| = 1,
Cholesky |add|=0, |skip| = 0, ||L.L|| = 2.89741.
------------------------------------------------------------------------
Status: Solved
Optimal value (cvx_optval): +1.4508
The original matrix, P: 
   4.0000             1.0000 + 2.0000i   3.0000 - 1.0000i
   1.0000 - 2.0000i   3.5000             0.8000 + 2.3000i
   3.0000 + 1.0000i   0.8000 - 2.3000i   4.0000          

The optimal point, Z:
   4.2828             0.8079 + 1.7342i   2.5575 - 0.7938i
   0.8079 - 1.7342i   4.2828             0.8079 + 1.7342i
   2.5575 + 0.7938i   0.8079 - 1.7342i   4.2828          

min( eig( Z ) ) (should be nonnegative):
  3.6312e-008

The optimal value, || Z - P ||_F:
    1.4508

Complementary slackness: Z * Q, should be near zero:
  1.0e-005 *

  -0.2364 - 0.0840i  -0.0281 + 0.2142i   0.2458 - 0.0223i
  -0.1175 + 0.5282i   0.4689 + 0.0000i  -0.1175 - 0.5282i
   0.2458 + 0.0223i  -0.0281 - 0.2142i  -0.2364 + 0.0840i