tensor: index names in merge_indices
This commit is contained in:
9
t.cc
9
t.cc
@@ -4048,16 +4048,17 @@ NRVec<INDEXGROUP> shape(3);
|
||||
|
||||
|
||||
Tensor<double> x(shape); x.randomize(1.);
|
||||
cout <<"x= "<<x.shape;
|
||||
x.defaultnames();
|
||||
cout <<"x= "<<x.shape << " "<<x.names<<endl;
|
||||
Tensor<double> xf=x.flatten(1);
|
||||
cout <<"xf= "<<xf.shape;
|
||||
cout <<"xf= "<<xf.shape << " "<<xf.names<<endl;
|
||||
Tensor<double> xxx=x.unwind_index_group(1);
|
||||
cout <<"xxx= "<<xxx.shape<<endl;
|
||||
cout <<"xxx= "<<xxx.shape<<" "<<xxx.names<<endl;
|
||||
|
||||
INDEXLIST il(r);
|
||||
for(int i=0; i<r; ++i) il[i]= {1+i,0};
|
||||
Tensor<double> xx = xf.merge_indices(il,sym);
|
||||
cout <<"xx = "<<xx.shape;
|
||||
cout <<"xx = "<<xx.shape<< " "<<xx.names<<endl;
|
||||
cout <<"Error = "<<(xx-xxx).norm()<<endl;
|
||||
|
||||
}
|
||||
|
||||
@@ -1746,6 +1746,7 @@ else
|
||||
|
||||
Tensor<T> r(newshape);
|
||||
r.apply_permutation_algebra(*this,pa,false,(T)1/(T)pa.size(),0);
|
||||
if(is_named()) r.names=names.permuted(basicperm,true);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
4
tensor.h
4
tensor.h
@@ -132,6 +132,10 @@ bool upperindex;
|
||||
std::ostream & operator<<(std::ostream &s, const INDEXGROUP &x);
|
||||
std::istream & operator>>(std::istream &s, INDEXGROUP &x);
|
||||
|
||||
std::ostream & operator<<(std::ostream &s, const INDEXNAME &x);
|
||||
std::istream & operator>>(std::istream &s, INDEXNAME &x);
|
||||
|
||||
|
||||
|
||||
|
||||
template<>
|
||||
|
||||
Reference in New Issue
Block a user