# Fancy indexing in ITensor

**URL:** <https://discourse.julialang.org/t/fancy-indexing-in-itensor/45201>\
**Category:** Numerics\
**Tags:** question, package\
**Created:** [August 19, 2020, 9:21am UTC](https://discourse.julialang.org/t/fancy-indexing-in-itensor/45201 "2020-08-19T09:21:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![volkerkarle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/volkerkarle/32/14143_2.png) [@volkerkarle](https://discourse.julialang.org/u/volkerkarle)\
**Post date:** [August 19, 2020, 9:21am UTC](https://discourse.julialang.org/t/fancy-indexing-in-itensor/45201/1 "2020-08-19T09:21:27Z")

</div>

Hi folks,

As I elaborated [here](https://www.itensor.org/support/2430/selecting-specific-rows-columns-fancy-indexing-in-itensor?state=edit-2430), I think I just missed it in the docs of ITensor, but I do not see an easy way to do “fancy” indexing. Lets us consider the following example

```
i = Index(10,"i")
j = Index(20,"j")
k = Index(30,"k")
A = randomITensor(i,j,k)
U,Σ,V = svd(A,(i,j));
u = commonind(U,Σ)
# Now I would like to select all rows where Σ is larger than 15
cn = (Σ.store .> 15)
dim_cn = sum(cn)
c = Index(dim_cn,"c")
selector = zeros(dim_cn,dim(u))
selector[:,cn].= I(dim_cn)
selector = ITensor(selector,c,u)
U_new = selector * U

```

You see what is my goal: I would like to select specific rows of U. With standard Julia syntax I could just use

```
U_new = U[:,Σ.> 15]

```

Even more so, sometimes it would be interesting to select specific rows, such as

```
U_new = U[:,1]

```

In order to loop through U. This is, of course, also possible with the above method, but still a little bit clumsy.

Thanks a lot.

Best,

v.
