diff --git a/t.cc b/t.cc index 0a53081..f28f4df 100644 --- a/t.cc +++ b/t.cc @@ -3683,7 +3683,7 @@ cin>>r>>n; INDEXGROUP shape; { shape.number=r; - shape.symmetry= -1; + shape.symmetry= 1; shape.range=n; shape.offset=0; } diff --git a/tensor.cc b/tensor.cc index b520d8b..4414497 100644 --- a/tensor.cc +++ b/tensor.cc @@ -802,10 +802,30 @@ template Tensor Tensor::flatten(int group) const { if(group>=shape.size()) laerror("too high group number in flatten"); -if(is_flat()) return *this; +if(is_flat()) + { + if(has_symmetry()) //get rid of formal symemtry + { + Tensor r(*this); + r.shape.copyonwrite(); + for(int g=0; g=0) //single group { - if(shape[group].number==1) return *this; + if(shape[group].number==1) + { + if(shape[group].symmetry==0) return *this; + else + { + Tensor r(*this); + r.shape[group].symmetry=0; + return r; + } + } if(shape[group].symmetry==0) { Tensor r(*this); @@ -816,7 +836,11 @@ if(group>=0) //single group if(group<0 && !is_compressed()) { Tensor r(*this); - for(int g=0; g1) r.split_index_group(g); + for(int g=0; g1) r.split_index_group(g); + } + for(int g=0; g NRVec > Tensor::Tucker(typename LA_traits::normtype thr, bool inverseorder) @@ -1314,9 +1338,9 @@ for(int i=0; i um; NRVec ushape; { - Tensor u=unwind_index(I); - ushape=u.shape; ushape.copyonwrite(); - um=u.matrix(); + Tensor uu=unwind_index(I); + ushape=uu.shape; //ushape.copyonwrite(); should not be needed + um=uu.matrix(); } int mini=um.nrows(); if(um.ncols() u(um.nrows(),mini),vt(mini,um.ncols()); diff --git a/tensor.h b/tensor.h index 45a2c08..221822f 100644 --- a/tensor.h +++ b/tensor.h @@ -47,6 +47,7 @@ //@@@ will not be particularly efficient // //@@@conversions to/from fourindex, optional negarive range for beta spin handling +//@@@use the fact that fourindex_dense is inherited from Mat/SMat and construct tensor from the (unsymmetrized) NRMat sharing data, just rewrite then the shape // //@@@?general permutation of individual indices - check the indices in sym groups remain adjacent, calculate result's shape, loopover the result and permute using unwind_callback // @@ -173,6 +174,7 @@ public: bool is_flat() const {for(int i=0; i1) return false; return true;}; bool is_compressed() const {for(int i=0; i1&&shape[i].symmetry!=0) return true; return false;}; + bool has_symmetry() const {for(int i=0; i