# Computing the schur norm of a matrix

**URL:** https://discourse.julialang.org/t/computing-the-schur-norm-of-a-matrix/77770
**Category:** Optimization (Mathematical)
**Created:** [March 11, 2022, 8:09pm UTC](https://discourse.julialang.org/t/computing-the-schur-norm-of-a-matrix/77770 "2022-03-11T20:09:20Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![jsch77](https://avatars.discourse-cdn.com/v4/letter/j/ad7895/32.png) [@jsch77](https://discourse.julialang.org/u/jsch77)
#### Post date: [March 11, 2022, 8:09pm UTC](https://discourse.julialang.org/t/computing-the-schur-norm-of-a-matrix/77770/1 "2022-03-11T20:09:20Z")

</div>

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

```julia
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

Thanks in advance
Jean-Pierre
```

---

<div class="post-metadata">

### Author: ![zdenek\_hurak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zdenek_hurak/32/53118_2.png) [@zdenek\_hurak](https://discourse.julialang.org/u/zdenek_hurak)
#### Post date: [March 11, 2022, 9:13pm UTC](https://discourse.julialang.org/t/computing-the-schur-norm-of-a-matrix/77770/2 "2022-03-11T21:13:49Z")

</div>

Is this what you wanted?

```julia
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?

---

<div class="post-metadata">

### Author: ![jsch77](https://avatars.discourse-cdn.com/v4/letter/j/ad7895/32.png) [@jsch77](https://discourse.julialang.org/u/jsch77)
#### Post date: [March 12, 2022, 1:11pm UTC](https://discourse.julialang.org/t/computing-the-schur-norm-of-a-matrix/77770/3 "2022-03-12T13:11:23Z")

</div>

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
