# Extract/Project IQTensor on a QN subspace

Hi all,

I am fairly new to ITensor and C++.
Thus if you have any advice that can be easier implemented in Julia I could take it into account, too.

First let me describe the system I am dealing with:
I consider a Bosonic chain of N sites: Boson(N,{"ConserveQNs=",true,"MaxOcc",1})).
I would like to construct the reduced density matrix of the system and project it on a given subspace.
In formulas, given the reduced density matrix @@\rho_A=Tr(|\psi><\psi|)@@
I would like
$$\rho_A(q)=\frac{P_q \rho_A P_q}{Tr(\rho_A P_q)}$$
Where @@P_q@@ is the projector on the subspace with a given number of particles
$$\sum_{i=1}^{l}n_i=q.$$
Here @@n_i@@ is the number of Bosons at site i and l is the length of the subsystem.

The question is the following: is there a way to do obtain @@\rho_A(q)@@, using IQTensor, without computing explicitly the reduced density matrix and the projector, since it is very inefficient?

I saw in the source code of qutil.h the function getBlock, but I'm not used to C++ and I could not deduce its functionalities.

Best,
Vittorio

commented by (51.6k points)
Hi Vittorio, yes I think there should be a good way to do this, with mostly tools we have available in the code already. (Yes it would be easier to do some of this with the Julia version since it is more flexible and offers more low-level tools to manipulate QN blocks.)

I assume your state |psi> is an MPS correct?

Best,
Miles
commented by (120 points)
Yes, It is an MPS.

Vittorio