How recovering matric well

Hello
I have difficulties to recover a matrix very well

numElems = 1
l = 1
mesh = RectangleMesh(Point(0,0),Point(l,l), numElems, numElems,"left")

K = as_matrix([[ 1.0,0.0],[0.0,4.0]])        # thermal conductivity
V = FunctionSpace(mesh, "CG", 1)

v = TestFunction(V)
u = TrialFunction(V) 

ke = inner(grad(v),K*grad(u))*dx 

KE = assemble(ke)
print(KE.array())

The matrix I must have is

KE =[[ 2.5 -0.5  -2.  0. ]
 [-0.5   2.5  0.  -2.]
 [-2  0.   2.5 -2. ]
 [ 0.  -2 -0.5   2.5]]

but the recovery gives other things with print(KE.array()) which is

KE=[[ 2.5 -2.  -0.5  0. ]
 [-2.   2.5  0.  -0.5]
 [-0.5  0.   2.5 -2. ]
 [ 0.  -0.5 -2.   2.5]]

I have looked for another way to do it but I can’t find it.
I want to know if there is a way to do it?

Why are you claiming that your matrix should be of the form:

To me it seems like you want another dof-ordering than what dolfin uses.
You can inspect the dof ordering by printing V.tabulate_dof_coordinates(), whose $i$th row will give you the coordinate of the $i$th dof.

Thanks
I say this after discretization and assembly by the finite element method. The calculation was consistent with a C++ code in a book. I have double-checked the calculation several times
That’s why I tried to check if it’s a problem of recovery or related to the operation performed
My idea is to make sure that all the calculations are well done since in what I do the final value does not exactly match with what is done with C++ code, hence my question of whether it is a bad recovery.

Since your K is a diagonal matrix, the matrix

Should be symmetric, which the matrix you are claiming is the correct matrix is not.

Please also note that to get the same matrix as a book, the dofs has to be numbered in the same way, which you can verify by looking at the dof coordinates (as I said in the previous post)