tensor: permute_index_groups and some necessary static casts

This commit is contained in:
2024-04-24 17:43:11 +02:00
parent 0ff55b66bb
commit da0b3116f6
3 changed files with 121 additions and 25 deletions

30
t.cc
View File

@@ -3200,7 +3200,7 @@ cout <<d;
}
if(1)
if(0)
{
INDEXGROUP g;
g.number=3;
@@ -3243,4 +3243,32 @@ cout <<epsilon.data;
cout <<epsilon;
}
if(1)
{
int n=3;
NRVec<INDEXGROUP> s(4);
for(int i=0; i<4; ++i)
{
s[i].number=1;
s[i].symmetry=0;
s[i].offset=0;
s[i].range=n;
}
Tensor<double> t(s);
t.randomize(1.);
cout <<t;
NRPerm<int> p({3,1,4,2});
Tensor<double> tt=t.permute_index_groups(p);
cout <<tt;
for(int i=0; i<n; ++i)
for(int j=0; j<n; ++j)
for(int k=0; k<n; ++k)
for(int l=0; l<n; ++l)
{
if(t(i,j,k,l)!=tt(k,i,l,j)) laerror("error in permute_index_groups");
}
}
}