yingjerkao / uni10

Official Repo for Uni10
28 stars 9 forks source link

putblocks error #9

Closed rezah closed 8 years ago

rezah commented 8 years ago

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.

cylo commented 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

rezah commented 8 years ago

@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).

Uni10.cpp.zip

cylo commented 8 years ago

@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 );

rezah commented 8 years ago

@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?

Uni10.cpp.zip

cylo commented 8 years ago

@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.

rezah commented 8 years ago

@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.

yingjerkao commented 8 years ago

This is definitely a bug. We will fix it soon.

yingjerkao commented 8 years ago

@Yun-Hsuan Wonder what is the status of this bug?

Yun-Hsuan commented 8 years ago

@yingjerkao Hi, I have fixed it. More explicit illustrations are written in this file. putBlock.cpp.zip

yingjerkao commented 8 years ago

@Yun-Hsuan Please indicate the commit hash and close this issue.