Cannot set a non-diagonal index in a Hermitian matrix

Is there a way to set a non-diagonal entry in a Hermitian matrix? For example, if I set H[i,j], I’d expect the implementation to automatically set H[j,i] as well, to maintain hermiticity.

You can do it yourself by changing the underlying array. Note that the displayed matrix only displays the upper or lower triangle of the underlying array (depending on how you constructed the Hermitian matrix), and so you only need to modify the value in the active triangle.

julia> H = Hermitian(rand(4,4))
4×4 Hermitian{Float64,Array{Float64,2}}:
 0.763319  0.610173   0.726294    0.299563
 0.610173  0.459978   0.0105791   0.995507
 0.726294  0.0105791  0.00780527  0.418519
 0.299563  0.995507   0.418519    0.769661

julia> H.data[2,3] = 1
1

julia> H
4×4 Hermitian{Float64,Array{Float64,2}}:
 0.763319  0.610173  0.726294    0.299563
 0.610173  0.459978  1.0         0.995507
 0.726294  1.0       0.00780527  0.418519
 0.299563  0.995507  0.418519    0.769661

julia> H.data
4×4 Array{Float64,2}:
 0.763319  0.610173  0.726294    0.299563
 0.456174  0.459978  1.0         0.995507
 0.554286  0.987036  0.00780527  0.418519
 0.171225  0.227228  0.055119    0.769661
1 Like