// TODO: conform sizes to current size Data& Data::shape(const int * sizes, int n){ if(n){ if(n <= maxDim()){ for(int i=0;i<n;++i) mSizes[i]=sizes[i]; for(int i=n;i<maxDim();++i) mSizes[i]=1; } else{ for(int i=0;i<maxDim();++i) mSizes[i]=sizes[i]; } } return *this; }
int Data::order() const { int r=0; for(int i=0; i<maxDim(); ++i){ if(size(i)>0) ++r; } return r; }
Data& Data::operator= (const Data& v){ if(&v != this){ setRaw(v.mData, v.offset(), v.stride(), v.type()); for(int i=0;i<maxDim();++i) mSizes[i]=v.mSizes[i]; } return *this; }
Axes axesFromAxisZ(const Vector& z) { int i = maxDim(z); Vector u = (i == 0) ? UnitVectorY : (i == 1) ? UnitVectorZ : UnitVectorX; Vector x = unit(cross(u, z)); Vector y = unit(cross(z, x)); return Axes(x, y, z); }
Data& Data::type(Data::Type ty){ if(type()!=ty && size()){ resize(ty, mSizes, maxDim()); } else{ mType=ty; } return *this; }
Data& Data::shapeAll(int n){ for(int i=0;i<maxDim();++i) mSizes[i]=n; return *this; }