void getHyperColumn(Vec<T>& v, const ConstCubeSlice<T>& s, long pos) { long m = s.getProd(1); long n = s.getDim(0); assert(pos >= 0 && pos < m); v.SetLength(n); for (long i = 0; i < n; i++) v[i] = s[pos + i*m]; }
ConstCubeSlice<T>::ConstCubeSlice(const ConstCubeSlice<T>& bigger, long i, long dOffset) { assert(dOffset >= 0 && dOffset <= bigger.getNumDims()); // allow zero-dimensional slice assert(i >= 0 && i < bigger.getProd(0, dOffset)); data = bigger.data; sig = bigger.sig; dimOffset = dOffset + bigger.dimOffset; sizeOffset = bigger.sizeOffset + i*bigger.getProd(dOffset); }
void CubeSlice<T>::copy(const ConstCubeSlice<T>& other) const { long n = this->getSize(); // we only check that the sizes match assert(n == other.getSize()); T *dst = &(*this)[0]; const T *src = &other[0]; for (long i = 0; i < n; i++) dst[i] = src[i]; }