# Effective method to obtain subsector matrix

**URL:** <https://itensor.discourse.group/t/effective-method-to-obtain-subsector-matrix/996>\
**Category:** ITensor Julia Questions\
**Tags:** julia\
**Created:** [July 3, 2023, 7:45am UTC](https://itensor.discourse.group/t/effective-method-to-obtain-subsector-matrix/996 "2023-07-03T07:45:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mozhik](https://avatars.discourse-cdn.com/v4/letter/m/dfb087/32.png) [@mozhik](https://itensor.discourse.group/u/mozhik)\
**Post date:** [July 3, 2023, 7:45am UTC](https://itensor.discourse.group/t/effective-method-to-obtain-subsector-matrix/996/1 "2023-07-03T07:45:01Z")

</div>

Hello,  
I’m currently facing the following issue:  
Suppose I have a qn-conserving ITensor (matrix) with incoming and outgoing legs. Each Index has the same set of QNs; How to get effectively the matrix in array format for a given QN, for example for QN(0)? Is it possible to delete all other QN sectors with the corresponding data, except of the given one?  
EDITED:  
I found the following solution:  
Q=Array(ITensors.blockview(ITensors.tensor(R),nzblocks(R)[1]))

Thank you,  
Best regards,  
Murod

---

<div class="post-metadata">

**Author:** ![miles](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/miles/32/6_2.png) [@miles](https://itensor.discourse.group/u/miles)\
**Post date:** [July 23, 2023, 2:54am UTC](https://itensor.discourse.group/t/effective-method-to-obtain-subsector-matrix/996/2 "2023-07-23T02:54:41Z")

</div>

Glad you figured it out! In the future, we hope to have a better interface for things like this (tensor slicing and related operations).

---

<div class="post-metadata">

**Author:** ![JanReimers](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/janreimers/32/171_2.png) [@JanReimers](https://itensor.discourse.group/u/JanReimers)\
**Post date:** [July 23, 2023, 1:26pm UTC](https://itensor.discourse.group/t/effective-method-to-obtain-subsector-matrix/996/3 "2023-07-23T13:26:23Z")

</div>

Hi Miles, I am interested in taking this on if someone is willing to help plan and spec it out and code review the PR. I can start by summarizing the previous discussion.

Regards  
Jan
