tensor: shares_index implemented

This commit is contained in:
2026-01-28 15:36:53 +01:00
parent 375e690296
commit 097677ef3f
2 changed files with 10 additions and 0 deletions

View File

@@ -2485,6 +2485,13 @@ for(int i=0; i<I.size(); ++i) if(zero_in_index(I[i])) return true;
return false;
}
bool shares_index(const FLATINDEX &I, const FLATINDEX &J)
{
for(int i=0; i<I.size(); ++i) for(int j=0; j<J.size(); ++j)
if(I[i]==J[j]) return true;
return false;
}
template class Tensor<double>;
template class Tensor<std::complex<double> >;

View File

@@ -231,11 +231,14 @@ int flatposition(int group, int index, const NRVec<INDEXGROUP> &shape);
int flatposition(const INDEX &i, const NRVec<INDEXGROUP> &shape); //position of that index in FLATINDEX
INDEX indexposition(int flatindex, const NRVec<INDEXGROUP> &shape); //inverse to flatposition
//useful for negative offsets and 0 index excluded
bool zero_in_index(const FLATINDEX &);
bool zero_in_index(const SUPERINDEX &);
bool zero_in_index(const INDEXMATRIX &, const LA_largeindex row);
bool shares_index(const FLATINDEX &I, const FLATINDEX &J);
FLATINDEX superindex2flat(const SUPERINDEX &I);
template<typename T>