Closed rezah closed 8 years ago
@rezah You may need to construct T1 with complex type specified:
UniTensor(const std::string tp, const std::vector<Bond>& _bonds, const std::string& _name = "");
For the argument tp, use "C" to assign complex type
@cylo
Thanks for your comment, but it does not seem to solve the issue. I've tries to do so, but nothing different happened (please see the attached file).
@rezah Try declaring T1 with
UniTensor T1( "C", r_bond, "T1" ); T1.setLabel( Label );
To putBlock, suppose H1 is a complex uni10::Matrix,
T1.putBlock( q_2, H1 );
@cylo
Thanks again for your answer.
Your suggestion does not change anything, again the problem exists!!!
See the attached file, unfortunately, it get initialized by wrong quantum number.
I'm looking forward to hearing from you?
@rezah
// declare complex T1 with r_bond -- q=0 block 1x1, q=1 block 2x2, q=2 block 1x1
UniTensor T1( "C", r_bond, "T1" );
T1.setLabel( Label );
cout<<T1;
// declare complex 1x1 Matrix H1
complex<double> elem0[1]={{1.2, 2.3}};
Matrix H1(1, 1, elem0);
// quantum number q=2
Qnum q_2(2, PRT_EVEN);
// put H1 into T1's q=2 block
T1.putBlock(q_2, H1);
cout<<T1;
I think keywords RTYPE, CTYPE are for library internal use exclusively. My suggestion is to construct both the UniTensor and the Matrix in complex form, either using a leading argument "C" in declaration or initialize their elements with complex array. Then putBlock will be straightforward.
@cylo
Thanks a lot.
Your suggestion works. You are exactly right: initializing it with complex numbers and or forcing it to use "C" flag work!!!! (also there are some other ways to avoid such problem).
However, I don't expect to get an error by using flags RTYPE or CTYPE. So, to me, there is still a problem---note the documentation on the library's homepage is based on flags RTYPE or CTYPE.
This is definitely a bug. We will fix it soon.
@Yun-Hsuan Wonder what is the status of this bug?
@yingjerkao Hi, I have fixed it. More explicit illustrations are written in this file. putBlock.cpp.zip
@Yun-Hsuan Please indicate the commit hash and close this issue.
Uni10.cpp.zip Suppose T1 is a unitensor which has three blocks with Qnumbs {0,1,2} q_2 is defined as Qnum q_2(2,PRT_EVEN) and H_1 is complex matrix.
The following command is supposed to put H1 into blocks corresponding to q_2 T1.putBlock(CTYPE,q_2,H1);
However, results is different, H1 is placed randomly into Block with Qnumb=0.
an example code has been attached.