DataArray::CheckValueInRange(nbComp,*z,"invalid component id");
int newNbOfTuples=(int)std::distance(bgTuples,endTuples);
int newNbOfComp=(int)std::distance(bgComp,endComp);
- a->checkNbOfElems(newNbOfTuples*newNbOfComp,msg);
- if(strictCompoCompare)
- a->checkNbOfTuplesAndComp(newNbOfTuples,newNbOfComp,msg);
+ bool assignTech=true;
+ if(a->getNbOfElems()==newNbOfTuples*newNbOfComp)
+ {
+ if(strictCompoCompare)
+ a->checkNbOfTuplesAndComp(newNbOfTuples,newNbOfComp,msg);
+ }
+ else
+ {
+ a->checkNbOfTuplesAndComp(1,newNbOfComp,msg);
+ assignTech=false;
+ }
double *pt=getPointer();
const double *srcPt=a->getConstPointer();
- for(const int *w=bgTuples;w!=endTuples;w++)
- for(const int *z=bgComp;z!=endComp;z++,srcPt++)
- {
- DataArray::CheckValueInRange(nbOfTuples,*w,"invalid tuple id");
- pt[(*w)*nbComp+(*z)]=*srcPt;
- }
+ if(assignTech)
+ {
+ for(const int *w=bgTuples;w!=endTuples;w++)
+ {
+ DataArray::CheckValueInRange(nbOfTuples,*w,"invalid tuple id");
+ for(const int *z=bgComp;z!=endComp;z++,srcPt++)
+ {
+ pt[(*w)*nbComp+(*z)]=*srcPt;
+ }
+ }
+ }
+ else
+ {
+ for(const int *w=bgTuples;w!=endTuples;w++)
+ {
+ const double *srcPt2=srcPt;
+ DataArray::CheckValueInRange(nbOfTuples,*w,"invalid tuple id");
+ for(const int *z=bgComp;z!=endComp;z++,srcPt2++)
+ {
+ pt[(*w)*nbComp+(*z)]=*srcPt2;
+ }
+ }
+ }
}
/*!
DataArray::CheckValueInRange(nbComp,bgComp,"invalid begin component value");
DataArray::CheckClosingParInRange(nbComp,endComp,"invalid end component value");
int newNbOfTuples=(int)std::distance(bgTuples,endTuples);
- a->checkNbOfElems(newNbOfTuples*newNbOfComp,msg);
- if(strictCompoCompare)
- a->checkNbOfTuplesAndComp(newNbOfTuples,newNbOfComp,msg);
+ bool assignTech=true;
+ if(a->getNbOfElems()==newNbOfTuples*newNbOfComp)
+ {
+ if(strictCompoCompare)
+ a->checkNbOfTuplesAndComp(newNbOfTuples,newNbOfComp,msg);
+ }
+ else
+ {
+ a->checkNbOfTuplesAndComp(1,newNbOfComp,msg);
+ assignTech=false;
+ }
double *pt=getPointer()+bgComp;
const double *srcPt=a->getConstPointer();
- for(const int *w=bgTuples;w!=endTuples;w++)
- for(int j=0;j<newNbOfComp;j++,srcPt++)
- {
- DataArray::CheckValueInRange(nbOfTuples,*w,"invalid tuple id");
- pt[(*w)*nbComp+j*stepComp]=*srcPt;
- }
+ if(assignTech)
+ {
+ for(const int *w=bgTuples;w!=endTuples;w++)
+ for(int j=0;j<newNbOfComp;j++,srcPt++)
+ {
+ DataArray::CheckValueInRange(nbOfTuples,*w,"invalid tuple id");
+ pt[(*w)*nbComp+j*stepComp]=*srcPt;
+ }
+ }
+ else
+ {
+ for(const int *w=bgTuples;w!=endTuples;w++)
+ {
+ const double *srcPt2=srcPt;
+ for(int j=0;j<newNbOfComp;j++,srcPt2++)
+ {
+ DataArray::CheckValueInRange(nbOfTuples,*w,"invalid tuple id");
+ pt[(*w)*nbComp+j*stepComp]=*srcPt2;
+ }
+ }
+ }
}
/*!
DataArray::CheckValueInRange(nbComp,*z,"invalid component id");
int newNbOfTuples=(int)std::distance(bgTuples,endTuples);
int newNbOfComp=(int)std::distance(bgComp,endComp);
- a->checkNbOfElems(newNbOfTuples*newNbOfComp,msg);
- if(strictCompoCompare)
- a->checkNbOfTuplesAndComp(newNbOfTuples,newNbOfComp,msg);
+ bool assignTech=true;
+ if(a->getNbOfElems()==newNbOfTuples*newNbOfComp)
+ {
+ if(strictCompoCompare)
+ a->checkNbOfTuplesAndComp(newNbOfTuples,newNbOfComp,msg);
+ }
+ else
+ {
+ a->checkNbOfTuplesAndComp(1,newNbOfComp,msg);
+ assignTech=false;
+ }
int *pt=getPointer();
const int *srcPt=a->getConstPointer();
- for(const int *w=bgTuples;w!=endTuples;w++)
- for(const int *z=bgComp;z!=endComp;z++,srcPt++)
- {
- DataArray::CheckValueInRange(nbOfTuples,*w,"invalid tuple id");
- pt[(*w)*nbComp+(*z)]=*srcPt;
- }
+ if(assignTech)
+ {
+ for(const int *w=bgTuples;w!=endTuples;w++)
+ {
+ DataArray::CheckValueInRange(nbOfTuples,*w,"invalid tuple id");
+ for(const int *z=bgComp;z!=endComp;z++,srcPt++)
+ {
+ pt[(*w)*nbComp+(*z)]=*srcPt;
+ }
+ }
+ }
+ else
+ {
+ for(const int *w=bgTuples;w!=endTuples;w++)
+ {
+ const int *srcPt2=srcPt;
+ DataArray::CheckValueInRange(nbOfTuples,*w,"invalid tuple id");
+ for(const int *z=bgComp;z!=endComp;z++,srcPt2++)
+ {
+ pt[(*w)*nbComp+(*z)]=*srcPt2;
+ }
+ }
+ }
}
/*!
DataArray::CheckValueInRange(nbComp,bgComp,"invalid begin component value");
DataArray::CheckClosingParInRange(nbComp,endComp,"invalid end component value");
int newNbOfTuples=(int)std::distance(bgTuples,endTuples);
- a->checkNbOfElems(newNbOfTuples*newNbOfComp,msg);
- if(strictCompoCompare)
- a->checkNbOfTuplesAndComp(newNbOfTuples,newNbOfComp,msg);
+ bool assignTech=true;
+ if(a->getNbOfElems()==newNbOfTuples*newNbOfComp)
+ {
+ if(strictCompoCompare)
+ a->checkNbOfTuplesAndComp(newNbOfTuples,newNbOfComp,msg);
+ }
+ else
+ {
+ a->checkNbOfTuplesAndComp(1,newNbOfComp,msg);
+ assignTech=false;
+ }
int *pt=getPointer()+bgComp;
const int *srcPt=a->getConstPointer();
- for(const int *w=bgTuples;w!=endTuples;w++)
- for(int j=0;j<newNbOfComp;j++,srcPt++)
- {
- DataArray::CheckValueInRange(nbOfTuples,*w,"invalid tuple id");
- pt[(*w)*nbComp+j*stepComp]=*srcPt;
- }
+ if(assignTech)
+ {
+ for(const int *w=bgTuples;w!=endTuples;w++)
+ for(int j=0;j<newNbOfComp;j++,srcPt++)
+ {
+ DataArray::CheckValueInRange(nbOfTuples,*w,"invalid tuple id");
+ pt[(*w)*nbComp+j*stepComp]=*srcPt;
+ }
+ }
+ else
+ {
+ for(const int *w=bgTuples;w!=endTuples;w++)
+ {
+ const int *srcPt2=srcPt;
+ for(int j=0;j<newNbOfComp;j++,srcPt2++)
+ {
+ DataArray::CheckValueInRange(nbOfTuples,*w,"invalid tuple id");
+ pt[(*w)*nbComp+j*stepComp]=*srcPt2;
+ }
+ }
+ }
}
/*!
return self;
case 2:
tmp=DataArrayDouble::New();
- tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1,false);
return self;
case 3:
return self;
case 2:
tmp=DataArrayDouble::New();
- tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1,false);
return self;
case 3:
return self;
case 2:
tmp=DataArrayDouble::New();
- tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1,false);
return self;
case 3:
return self;
case 2:
tmp=DataArrayDouble::New();
- tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1,false);
return self;
case 3:
return self;
case 2:
tmp=DataArrayDouble::New();
- tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
self->setPartOfValues2(tmp,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size(),false);
return self;
case 3:
return self;
case 2:
tmp=DataArrayDouble::New();
- tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
self->setPartOfValues2(tmp,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size(),false);
return self;
case 3:
return self;
case 2:
tmp=DataArrayDouble::New();
- tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
self->setPartOfValues2(tmp,&nv[0],&nv[0]+nv.size(),&vc1[0],&vc1[0]+vc1.size(),false);
return self;
case 3:
return self;
case 2:
tmp=DataArrayDouble::New();
- tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
self->setPartOfValues2(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size(),false);
return self;
case 3:
return self;
case 2:
tmp=DataArrayDouble::New();
- tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second,false);
return self;
case 3:
return self;
case 2:
tmp=DataArrayDouble::New();
- tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second,false);
return self;
case 3:
return self;
case 2:
tmp=DataArrayInt::New();
- tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1,false);
return self;
case 3:
return self;
case 2:
tmp=DataArrayInt::New();
- tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1,false);
return self;
case 3:
return self;
case 2:
tmp=DataArrayInt::New();
- tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1,false);
return self;
case 3:
return self;
case 2:
tmp=DataArrayInt::New();
- tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1,false);
return self;
case 3:
return self;
case 2:
tmp=DataArrayInt::New();
- tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
self->setPartOfValues2(tmp,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size(),false);
return self;
case 3:
return self;
case 2:
tmp=DataArrayInt::New();
- tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
self->setPartOfValues2(tmp,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size(),false);
return self;
case 3:
return self;
case 2:
tmp=DataArrayInt::New();
- tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
self->setPartOfValues2(tmp,&nv[0],&nv[0]+nv.size(),&vc1[0],&vc1[0]+vc1.size(),false);
return self;
case 3:
return self;
case 2:
tmp=DataArrayInt::New();
- tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
self->setPartOfValues2(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size(),false);
return self;
case 3:
return self;
case 2:
tmp=DataArrayInt::New();
- tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second,false);
return self;
case 3:
return self;
case 2:
tmp=DataArrayInt::New();
- tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second,false);
return self;
case 3:
st2=da.getHiddenCppPointer()
self.assertEqual(st1,st2)
self.assertEqual([10.0, 12.5, 15.0, 14.0, 16.0, 18.0, 15.0, 16.5, 18.0, 13.0, 14.0, 15.0],da.getValues())
+ #
+ da.alloc(30,1)
+ da.iota(7.)
+ da.rearrange(3)
+ ids=DataArrayInt.New()
+ ids.setValues([3,4,7],3,1)
+ da[ids,:]=[5.,8.,9.]
+ self.assertEqual([7.,8.,9.,10.,11.,12.,13.,14.,15.,5.,8.,9.,5.,8.,9.,22.,23.,24.,25.,26.,27.,5.,8.,9.,31.,32.,33.,34.,35.,36.0],da.getValues())
+ #
+ da.rearrange(1) ; da.iota(7) ; da.rearrange(3)
+ da[ids,[1,2]]=[5,8]
+ self.assertEqual([7.,8.,9.,10.,11.,12.,13.,14.,15.,16.,5.,8.,19.,5.,8.,22.,23.,24.,25.,26.,27.,28.,5.,8.,31.,32.,33.,34.,35.,36.],da.getValues())
pass
def testSwigDAIOp(self):
st2=da.getHiddenCppPointer()
self.assertEqual(st1,st2)
self.assertEqual([4,4,3,0,4,4,3,3,0,0,2,2],da.getValues())
+ #
+ da.alloc(30,1)
+ da.iota(7)
+ da.rearrange(3)
+ ids=DataArrayInt.New()
+ ids.setValues([3,4,7],3,1)
+ da[ids,:]=[5,8,9]
+ self.assertEqual([7,8,9,10,11,12,13,14,15,5,8,9,5,8,9,22,23,24,25,26,27,5,8,9,31,32,33,34,35,36],da.getValues())
+ #
+ da.rearrange(1) ; da.iota(7) ; da.rearrange(3)
+ da[ids,[1,2]]=[5,8]
+ self.assertEqual([7,8,9,10,11,12,13,14,15,16,5,8,19,5,8,22,23,24,25,26,27,28,5,8,31,32,33,34,35,36],da.getValues())
pass
def testSwigDAIOp2(self):