+1 vote
asked by (220 points)

Hi,
I'm trying to calculate the negativity (see section VI of this paper) for 1D systems. To this end I need to find the eigenvalues of the partial transpose of a tensor. In simple words, if my tensor has 4 indexes (i,j,i',j'), then I need to find the eigenvalues of the matrix whose indexes are (i, j') and (i',j) (instead of (i,j) and (i',j')).
Now in order to use the method diagHermitian I have to change the prime level of the indexes, so what I've done is this:

//The indexes of the tensor E12 to be swapped:
auto icl = commonIndex(E12 , psi.A(rlim1+1));
auto iclp = commonIndex(E12, prime(dag(psi.A(rlim1+1)),Link));
//I guess I could've done: auto iclp=prime(icl); as well.
//Now I have the indexes, and I want to swap the prime level:
E12.prime(icl,4);
icl.prime(4);//This is necessary for icl being related to the corresponding index in E12.
E12.prime(iclp,-1);
iclp.prime(-1);
E12.prime(icl,-3);
icl.prime(-3);
         //Now the left index of E12 is swapped:
         //the prime level (0,1) --> (1,0).
         //The index named iclp is not primed, and icl is primed.
IQTensor U,D;
diagHermitian(E12,U,D);

Now this looks quite cumbersome to me. So my (least important) questions are:
1. Is there a better way to swap the indexes? swapPrime wouldn't help, because I have another index (of the same type, namely j,j') which must stay untouched.
2. Is there a simple way to force diagHermitian to group the indexes as I wish instead of the usual way? This will make the swapping unnecessary, of course.

Now my more pressing question is about a case where the tensor to be partially transposed is a product of two diagonal matrices (the S matrix of a svd). The product is supposed to be such that the result will have 4 indexes, because only that way the partial transpose is defined. So my question is:
3. Is there a simple way to convert a diag matrix to a dense one? Alternately, is there a way to do diag*diag --> dense (with 4 indexes) ?

Thanks a lot for all the wonderful work!
I'm really enjoying this library, although I have no former experience in c++!
Yishai

related to an answer for: Contraction of two sparse tensors

1 Answer

+1 vote
answered by (70.1k points)

Hi Yishai,
Thanks for the kind words about ITensor. Also this is an interesting question. I agree the prime level manipulations could be better in ITensor. In a future version we (me and a new developer who was recently hired, more info to come) have been discussing more flexible ways to tag and manipulate indices.

But for now, there is a powerful index manipulation function you may not know about which I think will help in your case. It is a variant of the "mapprime" function and I made it to handle cases a lot like yours. The full documentation of it is on this page: http://itensor.org/docs.cgi?page=classes/indexset
Look for the version of mapprime that takes a "VArgs" argument and read the description and check out the example.

But here is how you can use it:

E12.mapprime(j,0,1,j,1,0);

Here "j" needs to be replaced by the copy of the index you are transposing. I couldn't tell so easily from your example what it was but I think icl ?

What this function call does is, in words "map the prime level of index j having prime level 0 to 1, and simultaneously map the level of index j with level 1 to level 0". It's designed so that the order of the arguments you pass doesn't matter, other than that the arguments have to be in groups of three: (index, old prime level, new prime level). Also instead of a specific index you can put an IndexType.

Finally, for your sparse case, I would actually recommend just obtaining the numbers from the two different diagonal SVD tensors and putting them into a matrix in a loop then diagonalizing the matrix, or even working out by hand what the negativity is given the special sparse structure. It might not be too bad to code. But let me know if it's blocking you and I can see about defining a sparse*sparse product. Mainly I was trying to avoid defining that case because I didn't want to make it too easy for people to do things that were inefficient by accident.

Miles

commented by (220 points)
Thanks a lot.
Indeed, I wasn't aware of this variant of "mapprime".
Welcome to ITensor Support Q&A, where you can ask questions and receive answers from other members of the community.

Formatting Tips:
  • To format code, indent by four spaces
  • To format inline LaTeX, surround it by @@ on both sides
  • To format LaTeX on its own line, surround it by $$ above and below
  • For LaTeX, it may be necessary to backslash-escape underscore characters to obtain proper formatting. So for example writing \sum\_i to represent a sum over i.
If you cannot register due to firewall issues (e.g. you cannot see the capcha box) please email Miles Stoudenmire to ask for an account.

To report ITensor bugs, please use the issue tracker.

Categories

...