# Computing the schur norm of a matrix

using the CVX package in Matlab the following code will compute the Schur norm of matrix T.

``````T = [1 2;3 4];

n = length(T);
cvx_begin sdp quiet
cvx_precision high;
variable Y0(n,n) hermitian
variable Y1(n,n) hermitian
minimize max(diag(Y0))/2 + max(diag(Y1))/2
subject to
[Y0, T; T', Y1] >= 0;
Y0 >= 0;
Y1 >= 0;
cvx_end
cvx_optval

Does anybody have an idea how to translate this using Convex.jl

Jean-Pierre``````

Is this what you wanted?

``````julia> using Convex, SCS

julia> T = [1 2;3 4]
2Γ2 Matrix{Int64}:
1  2
3  4

julia> n = size(T,1)
2

julia> Yβ = Semidefinite(n)
Variable
size: (2, 2)
sign: real
vexity: affine
id: 454β¦141

julia> Yβ = Semidefinite(n)
Variable
size: (2, 2)
sign: real
vexity: affine
id: 146β¦599

julia> problem = minimize(maximum(diag(Yβ))/2 + maximum(diag(Yβ))/2)
minimize
ββ + (convex; real)
ββ * (convex; real)
β  ββ maximum (convex; real)
β  β  ββ β¦
β  ββ 0.5
ββ * (convex; real)
ββ maximum (convex; real)
β  ββ β¦
ββ 0.5

status: `solve!` not called yet

julia> problem.constraints += ([Yβ T; T' Yβ] βͺ° 0)
1-element Vector{Constraint}:
sdp constraint (affine)
ββ transpose (affine; real)
ββ hcat (affine; real)
ββ transpose (affine; real)
β  ββ β¦
ββ transpose (affine; real)
ββ β¦

julia> solver = SCS.Optimizer()
SCS.Optimizer

julia> solve!(problem, solver)
------------------------------------------------------------------
SCS v3.2.0 - Splitting Conic Solver
(c) Brendan O'Donoghue, Stanford University, 2012
------------------------------------------------------------------
problem:  variables n: 11, constraints m: 29
cones:    z: primal zero / dual free vars: 9
l: linear vars: 4
s: psd vars: 16, ssize: 3
settings: eps_abs: 1.0e-04, eps_rel: 1.0e-04, eps_infeas: 1.0e-07
alpha: 1.50, scale: 1.00e-01, adaptive_scale: 1
max_iters: 100000, normalize: 1, rho_x: 1.00e-06
acceleration_lookback: 10, acceleration_interval: 10
lin-sys:  sparse-direct
nnz(A): 31, nnz(P): 0
------------------------------------------------------------------
iter | pri res | dua res |   gap   |   obj   |  scale  | time (s)
------------------------------------------------------------------
0| 7.07e+00  1.00e+00  1.91e+01  9.37e-02  1.00e-01  9.23e-05
100| 1.51e-06  4.22e-06  4.90e-05  4.00e+00  1.00e-01  1.64e-03
------------------------------------------------------------------
status:  solved
timings: total: 1.86e-03s = setup: 2.05e-04s + solve: 1.66e-03s
lin-sys: 1.12e-04s, cones: 1.34e-03s, accel: 1.27e-05s
------------------------------------------------------------------
objective = 3.999977
------------------------------------------------------------------

julia> problem.status
OPTIMAL::TerminationStatusCode = 1

julia> problem.optval
4.0000017440202935
``````

I am not familiar with this particular problem and therefore I just translated your code without much insight. What confused me was the line `n = length(T);` which then means that `Y0` and `Y1` are 4x4 matrices, but this does not fit then, does it?

4 Likes

Dear ZdenΔk HurΓ‘k

This is extremely helpful, thank you.
the statement lenght(T) gives the dimension of the matrix which is 2.
Jean-Pierre Schoch

1 Like