implemented partial trace for density matrices