diff --git a/t.cc b/t.cc index 4185717..2a069b5 100644 --- a/t.cc +++ b/t.cc @@ -4440,6 +4440,7 @@ for(int i=0; i x(shape); x.randomize(1.); +x.defaultnames(); cout< x0(x); x0.copyonwrite(); diff --git a/tensor.cc b/tensor.cc index a8202ab..a3993d9 100644 --- a/tensor.cc +++ b/tensor.cc @@ -1723,6 +1723,7 @@ if(r==1) //create an analogous output for the trivial case //loop over all indices; relies on the fact that unwinding does not change order of remaining indices //for inverseorder=false, to avoid inverting order by permute_index_groups we repeatedly unwind the LAST index, and all indices rotate at this position with the first one in the last iteration due to the unwind! +NRVec names_saved = names; for(int i=0; i newdata(umnew); umnew.resize(0,0);//deallocate *this = Tensor(ushape,newdata); + names=names_saved; } } if(!is_flat()) laerror("this should not happen"); +if(inverseorder) + { + NRPerm p(rank()); p.identity(); + names=names_saved.permuted(p.reverse()); + } +else + names=names_saved; return ret; } @@ -1776,6 +1785,7 @@ template Tensor Tensor::inverseTucker(const NRVec > &x, bool inverseorder) const { if(rank()!=x.size()) laerror("input of inverseTucker does not match rank"); +NRVec names_saved = names; Tensor tmp(*this); Tensor r; if(!is_flat()) laerror("inverseTucker only for flat tensors as produced by Tucker"); @@ -1805,6 +1815,13 @@ for(int i=rank()-1; i>=0; --i) } } } +if(inverseorder) + { + NRPerm p(rank()); p.identity(); + r.names=names_saved.permuted(p.reverse()); + } +else + r.names=names_saved; return r; }