Exemple #1
0
// 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; 
}
Exemple #2
0
int Data::order() const {
	int r=0;
	for(int i=0; i<maxDim(); ++i){
		if(size(i)>0) ++r; 
	}
	return r;
}
Exemple #3
0
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;
}
Exemple #4
0
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);
}
Exemple #5
0
Data& Data::type(Data::Type ty){
	if(type()!=ty && size()){
		resize(ty, mSizes, maxDim());
	}
	else{
		mType=ty;
	}
	return *this;
}
Exemple #6
0
Data& Data::shapeAll(int n){
	for(int i=0;i<maxDim();++i) mSizes[i]=n;
	return *this;
}