File indexing completed on 2024-04-06 12:04:43
0001
0002 template<unsigned int D>
0003 struct RowOffsets {
0004 inline RowOffsets() {
0005 int v[D];
0006 v[0]=0;
0007 for (unsigned int i=1; i<D; ++i)
0008 v[i]=v[i-1]+i;
0009 for (unsigned int i=0; i<D; ++i) {
0010 for (unsigned int j=0; j<=i; ++j)
0011 fOff[i*D+j] = v[i]+j;
0012 for (unsigned int j=i+1; j<D; ++j)
0013 fOff[i*D+j] = v[j]+i ;
0014 }
0015 }
0016 inline int operator()(unsigned int i, unsigned int j) const { return fOff[i*D+j]; }
0017 inline int apply(unsigned int i) const { return fOff[i]; }
0018 int fOff[D*D];
0019 };
0020
0021 #include