MCAuto<MEDCouplingCMesh> cm(MEDCouplingCMesh::New());
for(int i=0;i<spaceDim;i++)
{
- std::vector<int> tmp(1,i);
+ std::vector<std::size_t> tmp(1,i);
MCAuto<DataArrayDouble> elt(static_cast<DataArrayDouble*>(getCoords()->keepSelectedComponents(tmp)));
elt=elt->getDifferentValues(eps);
elt->sort(true);
//
std::set<INTERP_KERNEL::NormalizedCellType> types=mesh->getAllGeoTypes();
MCAuto<DataArrayInt> nbOfNodesPerCell=mesh->computeNbOfNodesPerCell();
- int nbTuples=nbOfNodesPerCell->accumulate(0);
+ int nbTuples=nbOfNodesPerCell->accumulate((std::size_t)0);
nbOfNodesPerCell->computeOffsetsFull();
MCAuto<DataArrayDouble> arr=DataArrayDouble::New(); arr->alloc(nbTuples,1);
ret->setArray(arr);
if(getArray()==0)
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::getWeightedAverageValue : no default array defined !");
MCAuto<MEDCouplingFieldDouble> w=buildMeasureField(isWAbs);
- double deno=w->getArray()->accumulate(0);
+ double deno=w->getArray()->accumulate((std::size_t)0);
MCAuto<DataArrayDouble> arr=getArray()->deepCopy();
arr->multiplyEqual(w->getArray());
arr->accumulate(res);
* \throw If the spatial discretization is not fully defined.
* \sa MEDCouplingField::getNumberOfTuplesExpected
*/
-std::size_t MEDCouplingFieldDouble::getNumberOfTuples() const
+mcIdType MEDCouplingFieldDouble::getNumberOfTuples() const
{
if(!_mesh)
throw INTERP_KERNEL::Exception("Impossible to retrieve number of tuples because no mesh specified !");
* \param [in] dftValue - value assigned to new values added to \a this field.
* \throw If \a this is not allocated.
*/
-void MEDCouplingFieldDouble::changeNbOfComponents(int newNbOfComp, double dftValue)
+void MEDCouplingFieldDouble::changeNbOfComponents(std::size_t newNbOfComp, double dftValue)
{
timeDiscr()->changeNbOfComponents(newNbOfComp,dftValue);
}
* \throw If a component index (\a i) is not valid:
* \a i < 0 || \a i >= \a this->getNumberOfComponents().
*/
-MEDCouplingFieldDouble *MEDCouplingFieldDouble::keepSelectedComponents(const std::vector<int>& compoIds) const
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::keepSelectedComponents(const std::vector<std::size_t>& compoIds) const
{
if(_type.isNull())
throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform keepSelectedComponents !");
ret->setMesh(getMesh());
return ret.retn();
}
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::keepSelectedComponents(const std::vector<mcIdType>& compoIds) const
+{
+ std::vector<std::size_t> ids (compoIds.size());
+ std::copy(compoIds.begin(), compoIds.end(), ids.begin());
+ return keepSelectedComponents(ids);
+}
/*!
* \throw If \a compoIds.size() != \a a->getNumberOfComponents().
* \throw If \a compoIds[i] < 0 or \a compoIds[i] > \a this->getNumberOfComponents().
*/
-void MEDCouplingFieldDouble::setSelectedComponents(const MEDCouplingFieldDouble *f, const std::vector<int>& compoIds)
+void MEDCouplingFieldDouble::setSelectedComponents(const MEDCouplingFieldDouble *f, const std::vector<std::size_t>& compoIds)
+{
+ timeDiscr()->setSelectedComponents(f->timeDiscr(),compoIds);
+}
+void MEDCouplingFieldDouble::setSelectedComponents(const MEDCouplingFieldDouble *f, const std::vector<mcIdType>& compoIds)
{
timeDiscr()->setSelectedComponents(f->timeDiscr(),compoIds);
}
MEDCOUPLING_EXPORT void applyFuncFast32(const std::string& func);
MEDCOUPLING_EXPORT void applyFuncFast64(const std::string& func);
MEDCOUPLING_EXPORT std::size_t getNumberOfComponents() const;
- MEDCOUPLING_EXPORT std::size_t getNumberOfTuples() const;
+ MEDCOUPLING_EXPORT mcIdType getNumberOfTuples() const;
MEDCOUPLING_EXPORT std::size_t getNumberOfValues() const;
MEDCOUPLING_EXPORT void updateTime() const;
MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
MEDCOUPLING_EXPORT MEDCouplingFieldDouble *deviator() const;
MEDCOUPLING_EXPORT MEDCouplingFieldDouble *magnitude() const;
MEDCOUPLING_EXPORT MEDCouplingFieldDouble *maxPerTuple() const;
- MEDCOUPLING_EXPORT void changeNbOfComponents(int newNbOfComp, double dftValue=0.);
- MEDCOUPLING_EXPORT MEDCouplingFieldDouble *keepSelectedComponents(const std::vector<int>& compoIds) const;
- MEDCOUPLING_EXPORT void setSelectedComponents(const MEDCouplingFieldDouble *f, const std::vector<int>& compoIds);
+ MEDCOUPLING_EXPORT void changeNbOfComponents(std::size_t newNbOfComp, double dftValue=0.);
+ MEDCOUPLING_EXPORT MEDCouplingFieldDouble *keepSelectedComponents(const std::vector<std::size_t>& compoIds) const;
+ MEDCOUPLING_EXPORT MEDCouplingFieldDouble *keepSelectedComponents(const std::vector<mcIdType>& compoIds) const;
+ MEDCOUPLING_EXPORT void setSelectedComponents(const MEDCouplingFieldDouble *f, const std::vector<std::size_t>& compoIds);
+ MEDCOUPLING_EXPORT void setSelectedComponents(const MEDCouplingFieldDouble *f, const std::vector<mcIdType>& compoIds);
MEDCOUPLING_EXPORT void sortPerTuple(bool asc);
MEDCOUPLING_EXPORT static MEDCouplingFieldDouble *MergeFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2);
MEDCOUPLING_EXPORT static MEDCouplingFieldDouble *MergeFields(const std::vector<const MEDCouplingFieldDouble *>& a);
_info_on_compo=other._info_on_compo;
}
-void DataArray::copyPartOfStringInfoFrom(const DataArray& other, const std::vector<int>& compoIds)
+void DataArray::copyPartOfStringInfoFrom(const DataArray& other, const std::vector<mcIdType>& compoIds)
{
- mcIdType nbOfCompoOth=ToIdType(other.getNumberOfComponents());
- mcIdType newNbOfCompo=ToIdType(compoIds.size());
- for(mcIdType i=0;i<newNbOfCompo;i++)
+ std::vector<std::size_t> ids (compoIds.size());
+ std::copy(compoIds.begin(), compoIds.end(), ids.begin());
+ copyPartOfStringInfoFrom(other, ids);
+}
+
+void DataArray::copyPartOfStringInfoFrom(const DataArray& other, const std::vector<std::size_t>& compoIds)
+{
+ std::size_t nbOfCompoOth=other.getNumberOfComponents();
+ std::size_t newNbOfCompo=compoIds.size();
+ for(std::size_t i=0;i<newNbOfCompo;i++)
if(compoIds[i]>=nbOfCompoOth || compoIds[i]<0)
{
std::ostringstream oss; oss << "Specified component id is out of range (" << compoIds[i] << ") compared with nb of actual components (" << nbOfCompoOth << ")";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- for(mcIdType i=0;i<newNbOfCompo;i++)
+ for(std::size_t i=0;i<newNbOfCompo;i++)
setInfoOnComponent(i,other.getInfoOnComponent(compoIds[i]));
}
-void DataArray::copyPartOfStringInfoFrom2(const std::vector<int>& compoIds, const DataArray& other)
+void DataArray::copyPartOfStringInfoFrom2(const std::vector<mcIdType>& compoIds, const DataArray& other)
+{
+ std::vector<std::size_t> ids (compoIds.size());
+ std::copy(compoIds.begin(), compoIds.end(), ids.begin());
+ copyPartOfStringInfoFrom2(ids, other);
+}
+
+void DataArray::copyPartOfStringInfoFrom2(const std::vector<std::size_t>& compoIds, const DataArray& other)
{
if(compoIds.size()!=other.getNumberOfComponents())
throw INTERP_KERNEL::Exception("Given compoIds has not the same size as number of components of given array !");
- mcIdType partOfCompoToSet=ToIdType(compoIds.size());
- mcIdType nbOfCompo=ToIdType(getNumberOfComponents());
- for(mcIdType i=0;i<partOfCompoToSet;i++)
+ std::size_t partOfCompoToSet=compoIds.size();
+ std::size_t nbOfCompo=getNumberOfComponents();
+ for(std::size_t i=0;i<partOfCompoToSet;i++)
if(compoIds[i]>=nbOfCompo || compoIds[i]<0)
{
std::ostringstream oss; oss << "Specified component id is out of range (" << compoIds[i] << ") compared with nb of actual components (" << nbOfCompo << ")";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- for(mcIdType i=0;i<partOfCompoToSet;i++)
+ for(std::size_t i=0;i<partOfCompoToSet;i++)
setInfoOnComponent(compoIds[i],other.getInfoOnComponent(i));
}
* \return std::string - a string containing the information on \a i-th component.
* \throw If \a i is not a valid component index.
*/
-std::string DataArray::getInfoOnComponent(int i) const
+std::string DataArray::getInfoOnComponent(std::size_t i) const
{
- if(i<(int)_info_on_compo.size() && i>=0)
+ if(i<_info_on_compo.size())
return _info_on_compo[i];
else
{
* \return std::string - a string containing the var information, or the full info.
* \throw If \a i is not a valid component index.
*/
-std::string DataArray::getVarOnComponent(int i) const
+std::string DataArray::getVarOnComponent(std::size_t i) const
{
- if(i<(int)_info_on_compo.size() && i>=0)
+ if(i<_info_on_compo.size())
{
return GetVarNameFromInfo(_info_on_compo[i]);
}
* \return std::string - a string containing the unit information, if any, or "".
* \throw If \a i is not a valid component index.
*/
-std::string DataArray::getUnitOnComponent(int i) const
+std::string DataArray::getUnitOnComponent(std::size_t i) const
{
- if(i<(int)_info_on_compo.size() && i>=0)
+ if(i<_info_on_compo.size())
{
return GetUnitFromInfo(_info_on_compo[i]);
}
* \param [in] info - the string containing the information.
* \throw If \a i is not a valid component index.
*/
-void DataArray::setInfoOnComponent(int i, const std::string& info)
+void DataArray::setInfoOnComponent(std::size_t i, const std::string& info)
{
- if(i<(int)_info_on_compo.size() && i>=0)
+ if(i<_info_on_compo.size())
_info_on_compo[i]=info;
else
{
_info_on_compo=info;
}
-void DataArray::checkNbOfTuples(int nbOfTuples, const std::string& msg) const
+void DataArray::checkNbOfTuples(mcIdType nbOfTuples, const std::string& msg) const
{
- if((int)getNumberOfTuples()!=nbOfTuples)
+ if(getNumberOfTuples()!=nbOfTuples)
{
std::ostringstream oss; oss << msg << " : mismatch number of tuples : expected " << nbOfTuples << " having " << getNumberOfTuples() << " !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
}
-void DataArray::checkNbOfComps(int nbOfCompo, const std::string& msg) const
+void DataArray::checkNbOfComps(std::size_t nbOfCompo, const std::string& msg) const
{
- if((int)getNumberOfComponents()!=nbOfCompo)
+ if (getNumberOfComponents()!=nbOfCompo)
{
std::ostringstream oss; oss << msg << " : mismatch number of components : expected " << nbOfCompo << " having " << getNumberOfComponents() << " !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
}
-void DataArray::checkNbOfTuplesAndComp(int nbOfTuples, int nbOfCompo, const std::string& msg) const
+void DataArray::checkNbOfTuplesAndComp(mcIdType nbOfTuples, std::size_t nbOfCompo, const std::string& msg) const
{
checkNbOfTuples(nbOfTuples,msg);
checkNbOfComps(nbOfCompo,msg);
checkAllocated();
if(getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayDouble::isMonotonic : only supported with 'this' array with ONE component !");
- mcIdType nbOfElements=ToIdType(getNumberOfTuples());
+ mcIdType nbOfElements(getNumberOfTuples());
const double *ptr=getConstPointer();
if(nbOfElements==0)
return true;
void DataArrayDouble::reprCppStream(const std::string& varName, std::ostream& stream) const
{
- mcIdType nbTuples=ToIdType(getNumberOfTuples());
- mcIdType nbComp=ToIdType(getNumberOfComponents());
+ mcIdType nbTuples=getNumberOfTuples();
+ std::size_t nbComp=getNumberOfComponents();
const double *data(getConstPointer());
stream.precision(17);
stream << "DataArrayDouble *" << varName << "=DataArrayDouble::New();" << std::endl;
std::size_t nbOfCompo(_info_on_compo.size());
if(nbOfCompo>=1)
{
- std::size_t nbOfTuples(getNumberOfTuples());
+ mcIdType nbOfTuples(getNumberOfTuples());
stream << "Number of tuples : " << nbOfTuples << ". Number of components : " << nbOfCompo << "." << std::endl;
reprQuickOverviewData(stream,MAX_NB_OF_BYTE_IN_REPR);
}
void DataArrayDouble::reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const
{
const double *data=begin();
- mcIdType nbOfTuples=ToIdType(getNumberOfTuples());
- mcIdType nbOfCompo=ToIdType(_info_on_compo.size());
+ mcIdType nbOfTuples(getNumberOfTuples());
+ std::size_t nbOfCompo(_info_on_compo.size());
std::ostringstream oss2; oss2 << "[";
oss2.precision(17);
std::string oss2Str(oss2.str());
if(nbOfCompo>1)
{
oss2 << "(";
- for(mcIdType j=0;j<nbOfCompo;j++,data++)
+ for(std::size_t j=0;j<nbOfCompo;j++,data++)
{
oss2 << *data;
if(j!=nbOfCompo-1) oss2 << ", ";
throw INTERP_KERNEL::Exception("DataArrayDouble::areIncludedInMe : the number of components does not match !");
MCAuto<DataArrayDouble> a=DataArrayDouble::Aggregate(this,other);
DataArrayInt *c=0,*ci=0;
- a->findCommonTuples(prec,ToIdType(getNumberOfTuples()),c,ci);
+ a->findCommonTuples(prec,getNumberOfTuples(),c,ci);
MCAuto<DataArrayInt> cSafe(c),ciSafe(ci);
int newNbOfTuples=-1;
- MCAuto<DataArrayInt> ids=DataArrayInt::ConvertIndexArrayToO2N(ToIdType(a->getNumberOfTuples()),c->begin(),ci->begin(),ci->end(),newNbOfTuples);
- MCAuto<DataArrayInt> ret1=ids->selectByTupleIdSafeSlice(ToIdType(getNumberOfTuples()),ToIdType(a->getNumberOfTuples()),1);
+ MCAuto<DataArrayInt> ids=DataArrayInt::ConvertIndexArrayToO2N(a->getNumberOfTuples(),c->begin(),ci->begin(),ci->end(),newNbOfTuples);
+ MCAuto<DataArrayInt> ret1=ids->selectByTupleIdSafeSlice(getNumberOfTuples(),a->getNumberOfTuples(),1);
tupleIds=ret1.retn();
- return newNbOfTuples==ToIdType(getNumberOfTuples());
+ return newNbOfTuples==getNumberOfTuples();
}
/*!
void DataArrayDouble::findCommonTuples(double prec, int limitTupleId, DataArrayInt *&comm, DataArrayInt *&commIndex) const
{
checkAllocated();
- mcIdType nbOfCompo=ToIdType(getNumberOfComponents());
+ std::size_t nbOfCompo=getNumberOfComponents();
if ((nbOfCompo<1) || (nbOfCompo>4)) //test before work
throw INTERP_KERNEL::Exception("DataArrayDouble::findCommonTuples : Unexpected spacedim of coords. Must be 1, 2, 3 or 4.");
- mcIdType nbOfTuples=ToIdType(getNumberOfTuples());
+ mcIdType nbOfTuples(getNumberOfTuples());
//
MCAuto<DataArrayInt> c(DataArrayInt::New()),cI(DataArrayInt::New()); c->alloc(0,1); cI->pushBackSilent(0);
switch(nbOfCompo)
double DataArrayDouble::minimalDistanceTo(const DataArrayDouble *other, int& thisTupleId, int& otherTupleId) const
{
MCAuto<DataArrayInt> part1=findClosestTupleId(other);
- mcIdType nbOfCompo=ToIdType(getNumberOfComponents());
- mcIdType otherNbTuples=ToIdType(other->getNumberOfTuples());
+ std::size_t nbOfCompo=getNumberOfComponents();
+ mcIdType otherNbTuples=other->getNumberOfTuples();
const double *thisPt(begin()),*otherPt(other->begin());
const int *part1Pt(part1->begin());
double ret=std::numeric_limits<double>::max();
for(mcIdType i=0;i<otherNbTuples;i++,part1Pt++,otherPt+=nbOfCompo)
{
double tmp(0.);
- for(mcIdType j=0;j<nbOfCompo;j++)
+ for(std::size_t j=0;j<nbOfCompo;j++)
tmp+=(otherPt[j]-thisPt[nbOfCompo*(*part1Pt)+j])*(otherPt[j]-thisPt[nbOfCompo*(*part1Pt)+j]);
if(tmp<ret)
{ ret=tmp; thisTupleId=*part1Pt; otherTupleId=i; }
oss << ", whereas number of components in other is " << other->getNumberOfComponents() << "! Should be equal !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- mcIdType nbOfTuples=ToIdType(other->getNumberOfTuples());
- mcIdType thisNbOfTuples=ToIdType(getNumberOfTuples());
+ mcIdType nbOfTuples(other->getNumberOfTuples());
+ mcIdType thisNbOfTuples(getNumberOfTuples());
MCAuto<DataArrayInt> ret=DataArrayInt::New(); ret->alloc(nbOfTuples,1);
double bounds[6];
getMinMaxPerComponent(bounds);
double xDelta(fabs(bounds[1]-bounds[0])),yDelta(fabs(bounds[3]-bounds[2])),zDelta(fabs(bounds[5]-bounds[4]));
double delta=std::max(xDelta,yDelta); delta=std::max(delta,zDelta);
double characSize=pow((delta*delta*delta)/((double)thisNbOfTuples),1./3.);
- BBTreePts<3,int> myTree(begin(),0,0,ToIdType(getNumberOfTuples()),characSize*1e-12);
+ BBTreePts<3,int> myTree(begin(),0,0,getNumberOfTuples(),characSize*1e-12);
FindClosestTupleIdAlg<3>(myTree,3.*characSize*characSize,other->begin(),nbOfTuples,begin(),thisNbOfTuples,ret->getPointer());
break;
}
double xDelta(fabs(bounds[1]-bounds[0])),yDelta(fabs(bounds[3]-bounds[2]));
double delta=std::max(xDelta,yDelta);
double characSize=sqrt(delta/(double)thisNbOfTuples);
- BBTreePts<2,int> myTree(begin(),0,0,ToIdType(getNumberOfTuples()),characSize*1e-12);
+ BBTreePts<2,int> myTree(begin(),0,0,getNumberOfTuples(),characSize*1e-12);
FindClosestTupleIdAlg<2>(myTree,2.*characSize*characSize,other->begin(),nbOfTuples,begin(),thisNbOfTuples,ret->getPointer());
break;
}
case 1:
{
double characSize=fabs(bounds[1]-bounds[0])/thisNbOfTuples;
- BBTreePts<1,int> myTree(begin(),0,0,ToIdType(getNumberOfTuples()),characSize*1e-12);
+ BBTreePts<1,int> myTree(begin(),0,0,getNumberOfTuples(),characSize*1e-12);
FindClosestTupleIdAlg<1>(myTree,1.*characSize*characSize,other->begin(),nbOfTuples,begin(),thisNbOfTuples,ret->getPointer());
break;
}
throw INTERP_KERNEL::Exception("DataArrayDouble::computeNbOfInteractionsWith : input array is NULL !");
if(!isAllocated() || !otherBBoxFrmt->isAllocated())
throw INTERP_KERNEL::Exception("DataArrayDouble::computeNbOfInteractionsWith : this and input array must be allocated !");
- std::size_t nbOfComp(getNumberOfComponents()),nbOfTuples(getNumberOfTuples());
+ std::size_t nbOfComp(getNumberOfComponents());
+ mcIdType nbOfTuples(getNumberOfTuples());
if(nbOfComp!=otherBBoxFrmt->getNumberOfComponents())
{
std::ostringstream oss; oss << "DataArrayDouble::computeNbOfInteractionsWith : this number of components (" << nbOfComp << ") must be equal to the number of components of input array (" << otherBBoxFrmt->getNumberOfComponents() << ") !";
{
case 3:
{
- BBTree<3,int> bbt(otherBBoxFrmt->begin(),0,0,ToIdType(otherBBoxFrmt->getNumberOfTuples()),eps);
- for(std::size_t i=0;i<nbOfTuples;i++,retPtr++,thisBBPtr+=nbOfComp)
+ BBTree<3,int> bbt(otherBBoxFrmt->begin(),0,0,otherBBoxFrmt->getNumberOfTuples(),eps);
+ for(mcIdType i=0;i<nbOfTuples;i++,retPtr++,thisBBPtr+=nbOfComp)
*retPtr=bbt.getNbOfIntersectingElems(thisBBPtr);
break;
}
case 2:
{
- BBTree<2,int> bbt(otherBBoxFrmt->begin(),0,0,ToIdType(otherBBoxFrmt->getNumberOfTuples()),eps);
- for(std::size_t i=0;i<nbOfTuples;i++,retPtr++,thisBBPtr+=nbOfComp)
+ BBTree<2,int> bbt(otherBBoxFrmt->begin(),0,0,otherBBoxFrmt->getNumberOfTuples(),eps);
+ for(mcIdType i=0;i<nbOfTuples;i++,retPtr++,thisBBPtr+=nbOfComp)
*retPtr=bbt.getNbOfIntersectingElems(thisBBPtr);
break;
}
case 1:
{
- BBTree<1,int> bbt(otherBBoxFrmt->begin(),0,0,ToIdType(otherBBoxFrmt->getNumberOfTuples()),eps);
- for(std::size_t i=0;i<nbOfTuples;i++,retPtr++,thisBBPtr+=nbOfComp)
+ BBTree<1,int> bbt(otherBBoxFrmt->begin(),0,0,otherBBoxFrmt->getNumberOfTuples(),eps);
+ for(mcIdType i=0;i<nbOfTuples;i++,retPtr++,thisBBPtr+=nbOfComp)
*retPtr=bbt.getNbOfIntersectingElems(thisBBPtr);
break;
}
findCommonTuples(prec,limitTupleId,c0,cI0);
MCAuto<DataArrayInt> c(c0),cI(cI0);
int newNbOfTuples=-1;
- MCAuto<DataArrayInt> o2n=DataArrayInt::ConvertIndexArrayToO2N(ToIdType(getNumberOfTuples()),c0->begin(),cI0->begin(),cI0->end(),newNbOfTuples);
+ MCAuto<DataArrayInt> o2n=DataArrayInt::ConvertIndexArrayToO2N(getNumberOfTuples(),c0->begin(),cI0->begin(),cI0->end(),newNbOfTuples);
return renumberAndReduce(o2n->getConstPointer(),newNbOfTuples);
}
* \ref py_mcdataarraydouble_setselectedcomponents "Here is a Python example".
* \endif
*/
-void DataArrayDouble::setSelectedComponents(const DataArrayDouble *a, const std::vector<int>& compoIds)
+void DataArrayDouble::setSelectedComponents(const DataArrayDouble *a, const std::vector<std::size_t>& compoIds)
{
if(!a)
throw INTERP_KERNEL::Exception("DataArrayDouble::setSelectedComponents : input DataArrayDouble is NULL !");
checkAllocated();
copyPartOfStringInfoFrom2(compoIds,*a);
std::size_t partOfCompoSz=compoIds.size();
- mcIdType nbOfCompo=ToIdType(getNumberOfComponents());
- mcIdType nbOfTuples=ToIdType(std::min(getNumberOfTuples(),a->getNumberOfTuples()));
+ std::size_t nbOfCompo=getNumberOfComponents();
+ mcIdType nbOfTuples=std::min(getNumberOfTuples(),a->getNumberOfTuples());
const double *ac=a->getConstPointer();
double *nc=getPointer();
for(mcIdType i=0;i<nbOfTuples;i++)
for(std::size_t j=0;j<partOfCompoSz;j++,ac++)
nc[nbOfCompo*i+compoIds[j]]=*ac;
}
-
+void DataArrayDouble::setSelectedComponents(const DataArrayDouble *a, const std::vector<mcIdType>& compoIds)
+{
+ std::vector<std::size_t> ids (compoIds.size());
+ std::copy(compoIds.begin(), compoIds.end(), ids.begin());
+ setSelectedComponents (a, ids);
+}
/*!
* Checks if 0.0 value is present in \a this array. If it is the case, an exception
* is thrown.
void DataArrayDouble::getMinMaxPerComponent(double *bounds) const
{
checkAllocated();
- mcIdType dim=ToIdType(getNumberOfComponents());
- for (mcIdType idim=0; idim<dim; idim++)
+ std::size_t dim=getNumberOfComponents();
+ for (std::size_t idim=0; idim<dim; idim++)
{
bounds[idim*2]=std::numeric_limits<double>::max();
bounds[idim*2+1]=-std::numeric_limits<double>::max();
}
const double *ptr=getConstPointer();
- mcIdType nbOfTuples=ToIdType(getNumberOfTuples());
+ mcIdType nbOfTuples=getNumberOfTuples();
for(mcIdType i=0;i<nbOfTuples;i++)
{
- for(mcIdType idim=0;idim<dim;idim++)
+ for(std::size_t idim=0;idim<dim;idim++)
{
if(bounds[idim*2]>ptr[i*dim+idim])
{
{
checkAllocated();
const double *dataPtr=getConstPointer();
- mcIdType nbOfCompo=ToIdType(getNumberOfComponents());
- mcIdType nbTuples=ToIdType(getNumberOfTuples());
+ std::size_t nbOfCompo=getNumberOfComponents();
+ mcIdType nbTuples=getNumberOfTuples();
MCAuto<DataArrayDouble> bbox=DataArrayDouble::New();
bbox->alloc(nbTuples,2*nbOfCompo);
double *bboxPtr=bbox->getPointer();
for(mcIdType i=0;i<nbTuples;i++)
{
- for(mcIdType j=0;j<nbOfCompo;j++)
+ for(std::size_t j=0;j<nbOfCompo;j++)
{
bboxPtr[2*nbOfCompo*i+2*j]=dataPtr[nbOfCompo*i+j]-epsilon;
bboxPtr[2*nbOfCompo*i+2*j+1]=dataPtr[nbOfCompo*i+j]+epsilon;
throw INTERP_KERNEL::Exception("DataArrayDouble::computeTupleIdsNearTuples : input pointer other is null !");
checkAllocated();
other->checkAllocated();
- mcIdType nbOfCompo=ToIdType(getNumberOfComponents());
- mcIdType otherNbOfCompo=ToIdType(other->getNumberOfComponents());
+ std::size_t nbOfCompo=getNumberOfComponents();
+ std::size_t otherNbOfCompo=other->getNumberOfComponents();
if(nbOfCompo!=otherNbOfCompo)
throw INTERP_KERNEL::Exception("DataArrayDouble::computeTupleIdsNearTuples : number of components should be equal between this and other !");
- mcIdType nbOfTuplesOther=ToIdType(other->getNumberOfTuples());
- mcIdType nbOfTuples=ToIdType(getNumberOfTuples());
+ mcIdType nbOfTuplesOther=other->getNumberOfTuples();
+ mcIdType nbOfTuples=getNumberOfTuples();
MCAuto<DataArrayInt> cArr(DataArrayInt::New()),cIArr(DataArrayInt::New()); cArr->alloc(0,1); cIArr->pushBackSilent(0);
switch(nbOfCompo)
{
void DataArrayDouble::recenterForMaxPrecision(double eps)
{
checkAllocated();
- mcIdType dim=ToIdType(getNumberOfComponents());
+ std::size_t dim=getNumberOfComponents();
std::vector<double> bounds(2*dim);
getMinMaxPerComponent(&bounds[0]);
- for(mcIdType i=0;i<dim;i++)
+ for(std::size_t i=0;i<dim;i++)
{
double delta=bounds[2*i+1]-bounds[2*i];
double offset=(bounds[2*i]+bounds[2*i+1])/2.;
if(getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayDouble::count : must be applied on DataArrayDouble with only one component, you can call 'rearrange' method before !");
const double *vals=begin();
- std::size_t nbOfTuples=getNumberOfTuples();
- for(std::size_t i=0;i<nbOfTuples;i++,vals++)
+ mcIdType nbOfTuples=getNumberOfTuples();
+ for(mcIdType i=0;i<nbOfTuples;i++,vals++)
if(fabs(*vals-value)<=eps)
ret++;
return ret;
{
if(getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayDouble::getAverageValue : must be applied on DataArrayDouble with only one component, you can call 'rearrange' method before !");
- mcIdType nbOfTuples=ToIdType(getNumberOfTuples());
+ mcIdType nbOfTuples(getNumberOfTuples());
if(nbOfTuples<=0)
throw INTERP_KERNEL::Exception("DataArrayDouble::getAverageValue : array exists but number of tuples must be > 0 !");
const double *vals=getConstPointer();
void DataArrayDouble::normMaxPerComponent(double * res) const
{
checkAllocated();
- std::size_t nbOfTuples(getNumberOfTuples());
- mcIdType nbOfCompos=ToIdType(getNumberOfComponents());
+ mcIdType nbOfTuples(getNumberOfTuples());
+ std::size_t nbOfCompos(getNumberOfComponents());
std::fill(res, res+nbOfCompos, -1.0);
const double *pt(getConstPointer());
- for(std::size_t i=0;i<nbOfTuples;i++)
- for (mcIdType j=0; j<nbOfCompos; j++, pt++)
+ for(mcIdType i=0;i<nbOfTuples;i++)
+ for (std::size_t j=0; j<nbOfCompos; j++, pt++)
{
double val(std::abs(*pt));
if(val>res[j])
{
checkAllocated();
const double *ptr=getConstPointer();
- mcIdType nbTuple=ToIdType(getNumberOfTuples());
- mcIdType nbComps=ToIdType(getNumberOfComponents());
+ mcIdType nbTuple(getNumberOfTuples());
+ std::size_t nbComps(getNumberOfComponents());
std::fill(res,res+nbComps,0.);
for(mcIdType i=0;i<nbTuple;i++)
std::transform(ptr+i*nbComps,ptr+(i+1)*nbComps,res,res,std::plus<double>());
double DataArrayDouble::distanceToTuple(const double *tupleBg, const double *tupleEnd, int& tupleId) const
{
checkAllocated();
- mcIdType nbTuple=ToIdType(getNumberOfTuples());
- mcIdType nbComps=ToIdType(getNumberOfComponents());
- if(nbComps!=(int)std::distance(tupleBg,tupleEnd))
+ mcIdType nbTuple(getNumberOfTuples());
+ std::size_t nbComps(getNumberOfComponents());
+ if(nbComps!=std::distance(tupleBg,tupleEnd))
{ std::ostringstream oss; oss << "DataArrayDouble::distanceToTuple : size of input tuple is " << std::distance(tupleBg,tupleEnd) << " should be equal to the number of components in this : " << nbComps << " !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); }
if(nbTuple==0)
throw INTERP_KERNEL::Exception("DataArrayDouble::distanceToTuple : no tuple in this ! No distance to compute !");
for(mcIdType i=0;i<nbTuple;i++)
{
double val=0.;
- for(mcIdType j=0;j<nbComps;j++,work++)
+ for(std::size_t j=0;j<nbComps;j++,work++)
val+=(*work-tupleBg[j])*((*work-tupleBg[j]));
if(val>=ret0)
continue;
* \throw If \a the condition ( 0 <= \a compId < \a this->getNumberOfComponents() ) is
* not respected.
*/
-double DataArrayDouble::accumulate(int compId) const
+double DataArrayDouble::accumulate(std::size_t compId) const
{
checkAllocated();
const double *ptr=getConstPointer();
- mcIdType nbTuple=ToIdType(getNumberOfTuples());
- mcIdType nbComps=ToIdType(getNumberOfComponents());
- if(compId<0 || compId>=nbComps)
+ mcIdType nbTuple(getNumberOfTuples());
+ std::size_t nbComps(getNumberOfComponents());
+ if(compId>=nbComps)
throw INTERP_KERNEL::Exception("DataArrayDouble::accumulate : Invalid compId specified : No such nb of components !");
double ret=0.;
for(mcIdType i=0;i<nbTuple;i++)
if(!bgOfIndex || !endOfIndex)
throw INTERP_KERNEL::Exception("DataArrayDouble::accumulatePerChunck : input pointer NULL !");
checkAllocated();
- mcIdType nbCompo=ToIdType(getNumberOfComponents());
- mcIdType nbOfTuples=ToIdType(getNumberOfTuples());
+ std::size_t nbCompo(getNumberOfComponents());
+ mcIdType nbOfTuples(getNumberOfTuples());
mcIdType sz=ToIdType(std::distance(bgOfIndex,endOfIndex));
if(sz<1)
throw INTERP_KERNEL::Exception("DataArrayDouble::accumulatePerChunck : invalid size of input index array !");
{
checkAllocated();
checkNbOfComps(1,"DataArrayDouble::cumSum : this is expected to be single component");
- mcIdType nbOfTuple=ToIdType(getNumberOfTuples());
+ mcIdType nbOfTuple(getNumberOfTuples());
MCAuto<DataArrayDouble> ret(DataArrayDouble::New()); ret->alloc(nbOfTuple+1,1);
double *ptr(ret->getPointer());
ptr[0]=0.;
std::size_t nbOfComp(getNumberOfComponents());
if(nbOfComp!=2)
throw INTERP_KERNEL::Exception("DataArrayDouble::fromPolarToCart : must be an array with exactly 2 components !");
- std::size_t nbOfTuple(getNumberOfTuples());
+ mcIdType nbOfTuple(getNumberOfTuples());
DataArrayDouble *ret(DataArrayDouble::New());
ret->alloc(nbOfTuple,2);
double *w(ret->getPointer());
const double *wIn(getConstPointer());
- for(std::size_t i=0;i<nbOfTuple;i++,w+=2,wIn+=2)
+ for(mcIdType i=0;i<nbOfTuple;i++,w+=2,wIn+=2)
{
w[0]=wIn[0]*cos(wIn[1]);
w[1]=wIn[0]*sin(wIn[1]);
std::size_t nbOfComp(getNumberOfComponents());
if(nbOfComp!=3)
throw INTERP_KERNEL::Exception("DataArrayDouble::fromCylToCart : must be an array with exactly 3 components !");
- std::size_t nbOfTuple(getNumberOfTuples());
+ mcIdType nbOfTuple(getNumberOfTuples());
DataArrayDouble *ret(DataArrayDouble::New());
ret->alloc(getNumberOfTuples(),3);
double *w(ret->getPointer());
const double *wIn(getConstPointer());
- for(std::size_t i=0;i<nbOfTuple;i++,w+=3,wIn+=3)
+ for(mcIdType i=0;i<nbOfTuple;i++,w+=3,wIn+=3)
{
w[0]=wIn[0]*cos(wIn[1]);
w[1]=wIn[0]*sin(wIn[1]);
std::size_t nbOfComp(getNumberOfComponents());
if(nbOfComp!=3)
throw INTERP_KERNEL::Exception("DataArrayDouble::fromSpherToCart : must be an array with exactly 3 components !");
- std::size_t nbOfTuple(getNumberOfTuples());
+ mcIdType nbOfTuple(getNumberOfTuples());
DataArrayDouble *ret(DataArrayDouble::New());
ret->alloc(getNumberOfTuples(),3);
double *w(ret->getPointer());
const double *wIn(getConstPointer());
- for(std::size_t i=0;i<nbOfTuple;i++,w+=3,wIn+=3)
+ for(mcIdType i=0;i<nbOfTuple;i++,w+=3,wIn+=3)
{
w[0]=wIn[0]*cos(wIn[2])*sin(wIn[1]);
w[1]=wIn[0]*sin(wIn[2])*sin(wIn[1]);
{
MCAuto<DataArrayDouble> ret(DataArrayDouble::New());
checkAllocated();
- std::size_t nbOfComp(getNumberOfComponents()),nbTuples(getNumberOfTuples());
+ std::size_t nbOfComp(getNumberOfComponents());
+ mcIdType nbTuples(getNumberOfTuples());
if(nbOfComp!=2)
throw INTERP_KERNEL::Exception("DataArrayDouble::fromCartToPolar : must be an array with exactly 2 components !");
ret->alloc(nbTuples,2);
double *retPtr(ret->getPointer());
const double *ptr(begin());
- for(std::size_t i=0;i<nbTuples;i++,ptr+=2,retPtr+=2)
+ for(mcIdType i=0;i<nbTuples;i++,ptr+=2,retPtr+=2)
{
retPtr[0]=sqrt(ptr[0]*ptr[0]+ptr[1]*ptr[1]);
retPtr[1]=atan2(ptr[1],ptr[0]);
{
MCAuto<DataArrayDouble> ret(DataArrayDouble::New());
checkAllocated();
- std::size_t nbOfComp(getNumberOfComponents()),nbTuples(getNumberOfTuples());
+ std::size_t nbOfComp(getNumberOfComponents());
+ mcIdType nbTuples(getNumberOfTuples());
if(nbOfComp!=3)
throw INTERP_KERNEL::Exception("DataArrayDouble::fromCartToCyl : must be an array with exactly 3 components !");
ret->alloc(nbTuples,3);
double *retPtr(ret->getPointer());
const double *ptr(begin());
- for(std::size_t i=0;i<nbTuples;i++,ptr+=3,retPtr+=3)
+ for(mcIdType i=0;i<nbTuples;i++,ptr+=3,retPtr+=3)
{
retPtr[0]=sqrt(ptr[0]*ptr[0]+ptr[1]*ptr[1]);
retPtr[1]=atan2(ptr[1],ptr[0]);
{
MCAuto<DataArrayDouble> ret(DataArrayDouble::New());
checkAllocated();
- std::size_t nbOfComp(getNumberOfComponents()),nbTuples(getNumberOfTuples());
+ std::size_t nbOfComp(getNumberOfComponents());
+ mcIdType nbTuples(getNumberOfTuples());
if(nbOfComp!=3)
throw INTERP_KERNEL::Exception("DataArrayDouble::fromCartToSpher : must be an array with exactly 3 components !");
ret->alloc(nbTuples,3);
double *retPtr(ret->getPointer());
const double *ptr(begin());
- for(std::size_t i=0;i<nbTuples;i++,ptr+=3,retPtr+=3)
+ for(mcIdType i=0;i<nbTuples;i++,ptr+=3,retPtr+=3)
{
retPtr[0]=sqrt(ptr[0]*ptr[0]+ptr[1]*ptr[1]+ptr[2]*ptr[2]);
retPtr[1]=acos(ptr[2]/retPtr[0]);
throw INTERP_KERNEL::Exception("DataArrayDouble::fromCartToCylGiven : input coords are NULL !");
MCAuto<DataArrayDouble> ret(DataArrayDouble::New());
checkAllocated(); coords->checkAllocated();
- std::size_t nbOfComp(getNumberOfComponents()),nbTuples(getNumberOfTuples());
+ std::size_t nbOfComp(getNumberOfComponents());
+ mcIdType nbTuples(getNumberOfTuples());
if(nbOfComp!=3)
throw INTERP_KERNEL::Exception("DataArrayDouble::fromCartToCylGiven : must be an array with exactly 3 components !");
if(coords->getNumberOfComponents()!=3)
double Ur[3],Uteta[3],Uz[3],*retPtr(ret->getPointer());
const double *coo(coords->begin()),*vectField(begin());
std::transform(vect,vect+3,Uz,std::bind2nd(std::multiplies<double>(),1./magOfVect));
- for(std::size_t i=0;i<nbTuples;i++,vectField+=3,retPtr+=3,coo+=3)
+ for(mcIdType i=0;i<nbTuples;i++,vectField+=3,retPtr+=3,coo+=3)
{
std::transform(coo,coo+3,center,Ur,std::minus<double>());
Uteta[0]=Uz[1]*Ur[2]-Uz[2]*Ur[1]; Uteta[1]=Uz[2]*Ur[0]-Uz[0]*Ur[2]; Uteta[2]=Uz[0]*Ur[1]-Uz[1]*Ur[0];
if(nbOfComp!=6)
throw INTERP_KERNEL::Exception("DataArrayDouble::doublyContractedProduct : must be an array with exactly 6 components !");
DataArrayDouble *ret=DataArrayDouble::New();
- std::size_t nbOfTuple=getNumberOfTuples();
+ mcIdType nbOfTuple=getNumberOfTuples();
ret->alloc(nbOfTuple,1);
const double *src=getConstPointer();
double *dest=ret->getPointer();
- for(std::size_t i=0;i<nbOfTuple;i++,dest++,src+=6)
+ for(mcIdType i=0;i<nbOfTuple;i++,dest++,src+=6)
*dest=src[0]*src[0]+src[1]*src[1]+src[2]*src[2]+2.*src[3]*src[3]+2.*src[4]*src[4]+2.*src[5]*src[5];
return ret;
}
{
checkAllocated();
DataArrayDouble *ret=DataArrayDouble::New();
- std::size_t nbOfTuple=getNumberOfTuples();
+ mcIdType nbOfTuple=getNumberOfTuples();
ret->alloc(nbOfTuple,1);
const double *src=getConstPointer();
double *dest=ret->getPointer();
switch(getNumberOfComponents())
{
case 6:
- for(std::size_t i=0;i<nbOfTuple;i++,dest++,src+=6)
+ for(mcIdType i=0;i<nbOfTuple;i++,dest++,src+=6)
*dest=src[0]*src[1]*src[2]+2.*src[4]*src[5]*src[3]-src[0]*src[4]*src[4]-src[2]*src[3]*src[3]-src[1]*src[5]*src[5];
return ret;
case 4:
- for(std::size_t i=0;i<nbOfTuple;i++,dest++,src+=4)
+ for(mcIdType i=0;i<nbOfTuple;i++,dest++,src+=4)
*dest=src[0]*src[3]-src[1]*src[2];
return ret;
case 9:
- for(std::size_t i=0;i<nbOfTuple;i++,dest++,src+=9)
+ for(mcIdType i=0;i<nbOfTuple;i++,dest++,src+=9)
*dest=src[0]*src[4]*src[8]+src[1]*src[5]*src[6]+src[2]*src[3]*src[7]-src[0]*src[5]*src[7]-src[1]*src[3]*src[8]-src[2]*src[4]*src[6];
return ret;
default:
if(nbOfComp!=6)
throw INTERP_KERNEL::Exception("DataArrayDouble::eigenValues : must be an array with exactly 6 components !");
DataArrayDouble *ret=DataArrayDouble::New();
- std::size_t nbOfTuple=getNumberOfTuples();
+ mcIdType nbOfTuple=getNumberOfTuples();
ret->alloc(nbOfTuple,3);
const double *src=getConstPointer();
double *dest=ret->getPointer();
- for(std::size_t i=0;i<nbOfTuple;i++,dest+=3,src+=6)
+ for(mcIdType i=0;i<nbOfTuple;i++,dest+=3,src+=6)
INTERP_KERNEL::computeEigenValues6(src,dest);
return ret;
}
if(nbOfComp!=6)
throw INTERP_KERNEL::Exception("DataArrayDouble::eigenVectors : must be an array with exactly 6 components !");
DataArrayDouble *ret=DataArrayDouble::New();
- std::size_t nbOfTuple=getNumberOfTuples();
+ mcIdType nbOfTuple=getNumberOfTuples();
ret->alloc(nbOfTuple,9);
const double *src=getConstPointer();
double *dest=ret->getPointer();
- for(std::size_t i=0;i<nbOfTuple;i++,src+=6)
+ for(mcIdType i=0;i<nbOfTuple;i++,src+=6)
{
double tmp[3];
INTERP_KERNEL::computeEigenValues6(src,tmp);
if(nbOfComp!=6 && nbOfComp!=9 && nbOfComp!=4)
throw INTERP_KERNEL::Exception("DataArrayDouble::inversion : must be an array with 4,6 or 9 components !");
DataArrayDouble *ret=DataArrayDouble::New();
- std::size_t nbOfTuple=getNumberOfTuples();
+ mcIdType nbOfTuple=getNumberOfTuples();
ret->alloc(nbOfTuple,nbOfComp);
const double *src=getConstPointer();
double *dest=ret->getPointer();
if(nbOfComp==6)
- for(std::size_t i=0;i<nbOfTuple;i++,dest+=6,src+=6)
+ for(mcIdType i=0;i<nbOfTuple;i++,dest+=6,src+=6)
{
double det=src[0]*src[1]*src[2]+2.*src[4]*src[5]*src[3]-src[0]*src[4]*src[4]-src[2]*src[3]*src[3]-src[1]*src[5]*src[5];
dest[0]=(src[1]*src[2]-src[4]*src[4])/det;
dest[5]=(src[3]*src[4]-src[1]*src[5])/det;
}
else if(nbOfComp==4)
- for(std::size_t i=0;i<nbOfTuple;i++,dest+=4,src+=4)
+ for(mcIdType i=0;i<nbOfTuple;i++,dest+=4,src+=4)
{
double det=src[0]*src[3]-src[1]*src[2];
dest[0]=src[3]/det;
dest[3]=src[0]/det;
}
else
- for(std::size_t i=0;i<nbOfTuple;i++,dest+=9,src+=9)
+ for(mcIdType i=0;i<nbOfTuple;i++,dest+=9,src+=9)
{
double det=src[0]*src[4]*src[8]+src[1]*src[5]*src[6]+src[2]*src[3]*src[7]-src[0]*src[5]*src[7]-src[1]*src[3]*src[8]-src[2]*src[4]*src[6];
dest[0]=(src[4]*src[8]-src[7]*src[5])/det;
if(nbOfComp!=6 && nbOfComp!=9 && nbOfComp!=4)
throw INTERP_KERNEL::Exception("DataArrayDouble::trace : must be an array with 4,6 or 9 components !");
DataArrayDouble *ret=DataArrayDouble::New();
- std::size_t nbOfTuple=getNumberOfTuples();
+ mcIdType nbOfTuple=getNumberOfTuples();
ret->alloc(nbOfTuple,1);
const double *src=getConstPointer();
double *dest=ret->getPointer();
if(nbOfComp==6)
- for(std::size_t i=0;i<nbOfTuple;i++,dest++,src+=6)
+ for(mcIdType i=0;i<nbOfTuple;i++,dest++,src+=6)
*dest=src[0]+src[1]+src[2];
else if(nbOfComp==4)
- for(std::size_t i=0;i<nbOfTuple;i++,dest++,src+=4)
+ for(mcIdType i=0;i<nbOfTuple;i++,dest++,src+=4)
*dest=src[0]+src[3];
else
- for(std::size_t i=0;i<nbOfTuple;i++,dest++,src+=9)
+ for(mcIdType i=0;i<nbOfTuple;i++,dest++,src+=9)
*dest=src[0]+src[4]+src[8];
return ret;
}
if(nbOfComp!=6)
throw INTERP_KERNEL::Exception("DataArrayDouble::deviator : must be an array with exactly 6 components !");
DataArrayDouble *ret=DataArrayDouble::New();
- std::size_t nbOfTuple=getNumberOfTuples();
+ mcIdType nbOfTuple=getNumberOfTuples();
ret->alloc(nbOfTuple,6);
const double *src=getConstPointer();
double *dest=ret->getPointer();
- for(std::size_t i=0;i<nbOfTuple;i++,dest+=6,src+=6)
+ for(mcIdType i=0;i<nbOfTuple;i++,dest+=6,src+=6)
{
double tr=(src[0]+src[1]+src[2])/3.;
dest[0]=src[0]-tr;
checkAllocated();
std::size_t nbOfComp=getNumberOfComponents();
DataArrayDouble *ret=DataArrayDouble::New();
- std::size_t nbOfTuple=getNumberOfTuples();
+ mcIdType nbOfTuple=getNumberOfTuples();
ret->alloc(nbOfTuple,1);
const double *src=getConstPointer();
double *dest=ret->getPointer();
- for(std::size_t i=0;i<nbOfTuple;i++,dest++)
+ for(mcIdType i=0;i<nbOfTuple;i++,dest++)
{
double sum=0.;
for(std::size_t j=0;j<nbOfComp;j++,src++)
DataArrayDouble *DataArrayDouble::maxPerTuple() const
{
checkAllocated();
- mcIdType nbOfComp=ToIdType(getNumberOfComponents());
+ std::size_t nbOfComp(getNumberOfComponents());
MCAuto<DataArrayDouble> ret=DataArrayDouble::New();
- mcIdType nbOfTuple=ToIdType(getNumberOfTuples());
+ mcIdType nbOfTuple(getNumberOfTuples());
ret->alloc(nbOfTuple,1);
const double *src=getConstPointer();
double *dest=ret->getPointer();
DataArrayDouble *DataArrayDouble::maxPerTupleWithCompoId(DataArrayInt* &compoIdOfMaxPerTuple) const
{
checkAllocated();
- mcIdType nbOfComp=ToIdType(getNumberOfComponents());
+ std::size_t nbOfComp(getNumberOfComponents());
MCAuto<DataArrayDouble> ret0=DataArrayDouble::New();
MCAuto<DataArrayInt> ret1=DataArrayInt::New();
- mcIdType nbOfTuple=ToIdType(getNumberOfTuples());
+ mcIdType nbOfTuple=getNumberOfTuples();
ret0->alloc(nbOfTuple,1); ret1->alloc(nbOfTuple,1);
const double *src=getConstPointer();
double *dest=ret0->getPointer(); int *dest1=ret1->getPointer();
DataArrayDouble *DataArrayDouble::buildEuclidianDistanceDenseMatrix() const
{
checkAllocated();
- mcIdType nbOfComp=ToIdType(getNumberOfComponents());
- mcIdType nbOfTuples=ToIdType(getNumberOfTuples());
+ std::size_t nbOfComp(getNumberOfComponents());
+ mcIdType nbOfTuples(getNumberOfTuples());
const double *inData=getConstPointer();
MCAuto<DataArrayDouble> ret=DataArrayDouble::New();
ret->alloc(nbOfTuples*nbOfTuples,1);
for(mcIdType j=i+1;j<nbOfTuples;j++)
{
double dist=0.;
- for(mcIdType k=0;k<nbOfComp;k++)
+ for(std::size_t k=0;k<nbOfComp;k++)
{ double delta=inData[i*nbOfComp+k]-inData[j*nbOfComp+k]; dist+=delta*delta; }
dist=sqrt(dist);
outData[i*nbOfTuples+j]=dist;
throw INTERP_KERNEL::Exception("DataArrayDouble::buildEuclidianDistanceDenseMatrixWith : input parameter is null !");
checkAllocated();
other->checkAllocated();
- mcIdType nbOfComp=ToIdType(getNumberOfComponents());
- mcIdType otherNbOfComp=ToIdType(other->getNumberOfComponents());
+ std::size_t nbOfComp(getNumberOfComponents());
+ std::size_t otherNbOfComp(other->getNumberOfComponents());
if(nbOfComp!=otherNbOfComp)
{
std::ostringstream oss; oss << "DataArrayDouble::buildEuclidianDistanceDenseMatrixWith : this nb of compo=" << nbOfComp << " and other nb of compo=" << otherNbOfComp << ". It should match !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- mcIdType nbOfTuples=ToIdType(getNumberOfTuples());
- mcIdType otherNbOfTuples=ToIdType(other->getNumberOfTuples());
+ mcIdType nbOfTuples(getNumberOfTuples());
+ mcIdType otherNbOfTuples(other->getNumberOfTuples());
const double *inData=getConstPointer();
const double *inDataOther=other->getConstPointer();
MCAuto<DataArrayDouble> ret=DataArrayDouble::New();
for(mcIdType j=0;j<nbOfTuples;j++)
{
double dist=0.;
- for(mcIdType k=0;k<nbOfComp;k++)
+ for(std::size_t k=0;k<nbOfComp;k++)
{ double delta=inDataOther[k]-inData[j*nbOfComp+k]; dist+=delta*delta; }
dist=sqrt(dist);
outData[i*nbOfTuples+j]=dist;
{
checkAllocated();
double *pt=getPointer();
- mcIdType nbOfTuple=ToIdType(getNumberOfTuples());
- mcIdType nbOfComp=ToIdType(getNumberOfComponents());
+ mcIdType nbOfTuple(getNumberOfTuples());
+ std::size_t nbOfComp(getNumberOfComponents());
if(asc)
for(mcIdType i=0;i<nbOfTuple;i++,pt+=nbOfComp)
std::sort(pt,pt+nbOfComp);
{
checkAllocated();
DataArrayDouble *newArr=DataArrayDouble::New();
- mcIdType nbOfTuples=ToIdType(getNumberOfTuples());
- mcIdType oldNbOfComp=ToIdType(getNumberOfComponents());
+ mcIdType nbOfTuples(getNumberOfTuples());
+ std::size_t oldNbOfComp(getNumberOfComponents());
newArr->alloc(nbOfTuples,nbOfComp);
const double *ptr=getConstPointer();
double *ptrToFill=newArr->getPointer();
*/
DataArrayDouble *DataArrayDouble::applyFunc(const std::string& func, bool isSafe) const
{
- mcIdType nbOfComp=ToIdType(getNumberOfComponents());
+ std::size_t nbOfComp(getNumberOfComponents());
if(nbOfComp<=0)
throw INTERP_KERNEL::Exception("DataArrayDouble::applyFunc : output number of component must be > 0 !");
checkAllocated();
- mcIdType nbOfTuples=ToIdType(getNumberOfTuples());
+ mcIdType nbOfTuples(getNumberOfTuples());
MCAuto<DataArrayDouble> newArr(DataArrayDouble::New());
newArr->alloc(nbOfTuples,nbOfComp);
INTERP_KERNEL::ExprParser expr(func);
{
for(mcIdType i=0;i<nbOfTuples;i++)
{
- for(mcIdType iComp=0;iComp<nbOfComp;iComp++,ptr++,ptrToFill++)
+ for(std::size_t iComp=0;iComp<nbOfComp;iComp++,ptr++,ptrToFill++)
{
buff=*ptr;
expr.evaluateDoubleInternal(stck);
{
for(mcIdType i=0;i<nbOfTuples;i++)
{
- for(mcIdType iComp=0;iComp<nbOfComp;iComp++,ptr++,ptrToFill++)
+ for(std::size_t iComp=0;iComp<nbOfComp;iComp++,ptr++,ptrToFill++)
{
buff=*ptr;
try
*/
void DataArrayDouble::applyFuncOnThis(const std::string& func, bool isSafe)
{
- mcIdType nbOfComp=ToIdType(getNumberOfComponents());
+ std::size_t nbOfComp(getNumberOfComponents());
if(nbOfComp<=0)
throw INTERP_KERNEL::Exception("DataArrayDouble::applyFuncOnThis : output number of component must be > 0 !");
checkAllocated();
- mcIdType nbOfTuples=ToIdType(getNumberOfTuples());
+ mcIdType nbOfTuples(getNumberOfTuples());
INTERP_KERNEL::ExprParser expr(func);
expr.parse();
std::set<std::string> vars;
{
for(mcIdType i=0;i<nbOfTuples;i++)
{
- for(mcIdType iComp=0;iComp<nbOfComp;iComp++,ptr++,ptrToFill++)
+ for(std::size_t iComp=0;iComp<nbOfComp;iComp++,ptr++,ptrToFill++)
{
buff=*ptr;
expr.evaluateDoubleInternal(stck);
{
for(mcIdType i=0;i<nbOfTuples;i++)
{
- for(mcIdType iComp=0;iComp<nbOfComp;iComp++,ptr++,ptrToFill++)
+ for(std::size_t iComp=0;iComp<nbOfComp;iComp++,ptr++,ptrToFill++)
{
buff=*ptr;
try
if(nbOfComp<=0)
throw INTERP_KERNEL::Exception("DataArrayDouble::applyFuncNamedCompo : output number of component must be > 0 !");
std::vector<std::string> varsOrder2(varsOrder);
- mcIdType oldNbOfComp=ToIdType(getNumberOfComponents());
- for(int i=(int)varsOrder.size();i<oldNbOfComp;i++)
+ std::size_t oldNbOfComp(getNumberOfComponents());
+ for(std::size_t i=varsOrder.size();i<oldNbOfComp;i++)
varsOrder2.push_back(std::string());
checkAllocated();
- mcIdType nbOfTuples=ToIdType(getNumberOfTuples());
+ mcIdType nbOfTuples(getNumberOfTuples());
INTERP_KERNEL::ExprParser expr(func);
expr.parse();
std::set<std::string> vars;
expr.getTrueSetOfVars(vars);
- if((int)vars.size()>oldNbOfComp)
+ if(vars.size()>oldNbOfComp)
{
std::ostringstream oss; oss << "The field has " << oldNbOfComp << " components and there are ";
oss << vars.size() << " variables : ";
std::vector<double> stck;
for(int iComp=0;iComp<nbOfComp;iComp++)
{
- expr.prepareExprEvaluationDouble(varsOrder2,oldNbOfComp,nbOfComp,iComp,buffPtr,buffPtr+oldNbOfComp);
+ expr.prepareExprEvaluationDouble(varsOrder2,ToIdType(oldNbOfComp),nbOfComp,iComp,buffPtr,buffPtr+oldNbOfComp);
expr.prepareFastEvaluator();
const double *ptr(getConstPointer());
ptrToFill=newArr->getPointer()+iComp;
//
double *ptr=getPointer();
std::size_t nbOfComp=getNumberOfComponents();
- std::size_t nbOfTuples=getNumberOfTuples();
+ mcIdType nbOfTuples=getNumberOfTuples();
std::size_t nbOfElems=nbOfTuples*nbOfComp;
for(std::size_t i=0;i<nbOfElems;i++,ptr++)
*ptr=funcPtr(*ptr);
//
double *ptr=getPointer();
std::size_t nbOfComp=getNumberOfComponents();
- std::size_t nbOfTuples=getNumberOfTuples();
+ mcIdType nbOfTuples=getNumberOfTuples();
std::size_t nbOfElems=nbOfTuples*nbOfComp;
for(std::size_t i=0;i<nbOfElems;i++,ptr++)
*ptr=funcPtr(*ptr);
checkAllocated();
if(getNumberOfComponents()!=3)
throw INTERP_KERNEL::Exception("DataArrayDouble::symmetry3DPlane : this is excepted to have 3 components !");
- mcIdType nbTuples=ToIdType(getNumberOfTuples());
+ mcIdType nbTuples(getNumberOfTuples());
MCAuto<DataArrayDouble> ret(DataArrayDouble::New());
ret->alloc(nbTuples,3);
Symmetry3DPlane(point,normalVector,nbTuples,begin(),ret->getPointer());
throw INTERP_KERNEL::Exception("DataArrayDouble::findIdsInRange : this must have exactly one component !");
const double *cptr(begin());
MCAuto<DataArrayInt> ret(DataArrayInt::New()); ret->alloc(0,1);
- mcIdType nbOfTuples=ToIdType(getNumberOfTuples());
+ mcIdType nbOfTuples(getNumberOfTuples());
for(mcIdType i=0;i<nbOfTuples;i++,cptr++)
if(*cptr>=vmin && *cptr<=vmax)
ret->pushBackSilent(i);
throw INTERP_KERNEL::Exception("DataArrayDouble::findIdsNotInRange : this must have exactly one component !");
const double *cptr(begin());
MCAuto<DataArrayInt> ret(DataArrayInt::New()); ret->alloc(0,1);
- mcIdType nbOfTuples=ToIdType(getNumberOfTuples());
+ mcIdType nbOfTuples(getNumberOfTuples());
for(mcIdType i=0;i<nbOfTuples;i++,cptr++)
if(*cptr<vmin || *cptr>vmax)
ret->pushBackSilent(i);
throw INTERP_KERNEL::Exception("DataArrayDouble::Aggregate : input list must contain at least one NON EMPTY DataArrayDouble !");
std::vector<const DataArrayDouble *>::const_iterator it=a.begin();
std::size_t nbOfComp((*it)->getNumberOfComponents());
- std::size_t nbt=(*it++)->getNumberOfTuples();
+ mcIdType nbt=(*it++)->getNumberOfTuples();
for(int i=1;it!=a.end();it++,i++)
{
if((*it)->getNumberOfComponents()!=nbOfComp)
std::size_t nbOfComp(a1->getNumberOfComponents());
if(nbOfComp!=a2->getNumberOfComponents())
throw INTERP_KERNEL::Exception("Nb of components mismatch for array Dot !");
- std::size_t nbOfTuple(a1->getNumberOfTuples());
+ mcIdType nbOfTuple(a1->getNumberOfTuples());
if(nbOfTuple!=a2->getNumberOfTuples())
throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array Dot !");
DataArrayDouble *ret=DataArrayDouble::New();
throw INTERP_KERNEL::Exception("Nb of components mismatch for array crossProduct !");
if(nbOfComp!=3)
throw INTERP_KERNEL::Exception("Nb of components must be equal to 3 for array crossProduct !");
- std::size_t nbOfTuple(a1->getNumberOfTuples());
+ mcIdType nbOfTuple(a1->getNumberOfTuples());
if(nbOfTuple!=a2->getNumberOfTuples())
throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array crossProduct !");
DataArrayDouble *ret=DataArrayDouble::New();
ret->alloc(nbOfTuple,3);
double *retPtr=ret->getPointer();
const double *a1Ptr(a1->begin()),*a2Ptr(a2->begin());
- for(std::size_t i=0;i<nbOfTuple;i++)
+ for(mcIdType i=0;i<nbOfTuple;i++)
{
retPtr[3*i]=a1Ptr[3*i+1]*a2Ptr[3*i+2]-a1Ptr[3*i+2]*a2Ptr[3*i+1];
retPtr[3*i+1]=a1Ptr[3*i+2]*a2Ptr[3*i]-a1Ptr[3*i]*a2Ptr[3*i+2];
std::size_t nbOfComp(a1->getNumberOfComponents());
if(nbOfComp!=a2->getNumberOfComponents())
throw INTERP_KERNEL::Exception("Nb of components mismatch for array Max !");
- std::size_t nbOfTuple(a1->getNumberOfTuples());
+ mcIdType nbOfTuple(a1->getNumberOfTuples());
if(nbOfTuple!=a2->getNumberOfTuples())
throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array Max !");
MCAuto<DataArrayDouble> ret(DataArrayDouble::New());
std::size_t nbOfComp(a1->getNumberOfComponents());
if(nbOfComp!=a2->getNumberOfComponents())
throw INTERP_KERNEL::Exception("Nb of components mismatch for array min !");
- std::size_t nbOfTuple(a1->getNumberOfTuples());
+ mcIdType nbOfTuple(a1->getNumberOfTuples());
if(nbOfTuple!=a2->getNumberOfTuples())
throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array min !");
MCAuto<DataArrayDouble> ret(DataArrayDouble::New());
{
if(!a1 || !a2)
throw INTERP_KERNEL::Exception("DataArrayDouble::Pow : at least one of input instances is null !");
- std::size_t nbOfTuple=a1->getNumberOfTuples();
- std::size_t nbOfTuple2=a2->getNumberOfTuples();
+ mcIdType nbOfTuple=a1->getNumberOfTuples();
+ mcIdType nbOfTuple2=a2->getNumberOfTuples();
std::size_t nbOfComp=a1->getNumberOfComponents();
std::size_t nbOfComp2=a2->getNumberOfComponents();
if(nbOfTuple!=nbOfTuple2)
MCAuto<DataArrayDouble> ret=DataArrayDouble::New(); ret->alloc(nbOfTuple,1);
const double *ptr1(a1->begin()),*ptr2(a2->begin());
double *ptr=ret->getPointer();
- for(std::size_t i=0;i<nbOfTuple;i++,ptr1++,ptr2++,ptr++)
+ for(mcIdType i=0;i<nbOfTuple;i++,ptr1++,ptr2++,ptr++)
{
if(*ptr1>=0)
{
{
if(!other)
throw INTERP_KERNEL::Exception("DataArrayDouble::powEqual : input instance is null !");
- std::size_t nbOfTuple=getNumberOfTuples();
- std::size_t nbOfTuple2=other->getNumberOfTuples();
+ mcIdType nbOfTuple=getNumberOfTuples();
+ mcIdType nbOfTuple2=other->getNumberOfTuples();
std::size_t nbOfComp=getNumberOfComponents();
std::size_t nbOfComp2=other->getNumberOfComponents();
if(nbOfTuple!=nbOfTuple2)
throw INTERP_KERNEL::Exception("DataArrayDouble::powEqual : number of components of both arrays must be equal to 1 !");
double *ptr=getPointer();
const double *ptrc=other->begin();
- for(std::size_t i=0;i<nbOfTuple;i++,ptrc++,ptr++)
+ for(mcIdType i=0;i<nbOfTuple;i++,ptrc++,ptr++)
{
if(*ptr>=0)
*ptr=pow(*ptr,*ptrc);
checkAllocated();
if(getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayDouble::toVectorOfBool : must be applied on single component array !");
- std::size_t nbt(getNumberOfTuples());
+ mcIdType nbt(getNumberOfTuples());
std::vector<bool> ret(nbt);
const double *pt(begin());
- for(std::size_t i=0;i<nbt;i++)
+ for(mcIdType i=0;i<nbt;i++)
{
if(fabs(pt[i])<eps)
ret[i]=false;
tinyInfo.resize(2);
if(isAllocated())
{
- tinyInfo[0]=ToIdType(getNumberOfTuples());
+ tinyInfo[0]=getNumberOfTuples();
tinyInfo[1]=ToIdType(getNumberOfComponents());
}
else
{
if(isAllocated())
{
- mcIdType nbOfCompo=ToIdType(getNumberOfComponents());
+ std::size_t nbOfCompo(getNumberOfComponents());
tinyInfo.resize(nbOfCompo+1);
tinyInfo[0]=getName();
- for(mcIdType i=0;i<nbOfCompo;i++)
+ for(std::size_t i=0;i<nbOfCompo;i++)
tinyInfo[i+1]=getInfoOnComponent(i);
}
else
setName(tinyInfoS[0]);
if(isAllocated())
{
- mcIdType nbOfCompo=ToIdType(getNumberOfComponents());
- for(mcIdType i=0;i<nbOfCompo;i++)
+ std::size_t nbOfCompo(getNumberOfComponents());
+ for(std::size_t i=0;i<nbOfCompo;i++)
setInfoOnComponent(i,tinyInfoS[i+1]);
}
}
{
}
-DataArrayDoubleTuple::DataArrayDoubleTuple(double *pt, int nbOfComp):DataArrayTuple<double>(pt,nbOfComp)
+DataArrayDoubleTuple::DataArrayDoubleTuple(double *pt, std::size_t nbOfComp):DataArrayTuple<double>(pt,nbOfComp)
{
}
* This method throws an INTERP_KERNEL::Exception is it is impossible to match sizes of \b this that is too say \b nbOfCompo=this->_nb_of_elem and \bnbOfTuples==1 or
* \b nbOfCompo=1 and \bnbOfTuples==this->_nb_of_elem.
*/
-DataArrayDouble *DataArrayDoubleTuple::buildDADouble(int nbOfTuples, int nbOfCompo) const
+DataArrayDouble *DataArrayDoubleTuple::buildDADouble(std::size_t nbOfTuples, std::size_t nbOfCompo) const
{
return this->buildDA(nbOfTuples,nbOfCompo);
}
{
}
-DataArrayInt32Tuple::DataArrayInt32Tuple(Int32 *pt, mcIdType nbOfComp):DataArrayTuple<Int32>(pt,nbOfComp)
+DataArrayInt32Tuple::DataArrayInt32Tuple(Int32 *pt, std::size_t nbOfComp):DataArrayTuple<Int32>(pt,nbOfComp)
{
}
* This method throws an INTERP_KERNEL::Exception is it is impossible to match sizes of \b this that is too say \b nbOfCompo=this->_nb_of_elem and \bnbOfTuples==1 or
* \b nbOfCompo=1 and \bnbOfTuples==this->_nb_of_elem.
*/
-DataArrayInt32 *DataArrayInt32Tuple::buildDAInt(mcIdType nbOfTuples, mcIdType nbOfCompo) const
+DataArrayInt32 *DataArrayInt32Tuple::buildDAInt(std::size_t nbOfTuples, std::size_t nbOfCompo) const
{
return this->buildDA(nbOfTuples,nbOfCompo);
}
{
}
-DataArrayInt64Tuple::DataArrayInt64Tuple(Int64 *pt, mcIdType nbOfComp):DataArrayTuple<Int64>(pt,nbOfComp)
+DataArrayInt64Tuple::DataArrayInt64Tuple(Int64 *pt, std::size_t nbOfComp):DataArrayTuple<Int64>(pt,nbOfComp)
{
}
return this->zeValue();
}
-DataArrayInt64 *DataArrayInt64Tuple::buildDAInt(mcIdType nbOfTuples, mcIdType nbOfCompo) const
+DataArrayInt64 *DataArrayInt64Tuple::buildDAInt(std::size_t nbOfTuples, std::size_t nbOfCompo) const
{
return this->buildDA(nbOfTuples,nbOfCompo);
}
MEDCOUPLING_EXPORT void reprZip(int sl, std::ostream& stream) const;
MEDCOUPLING_EXPORT void reprNotTooLong(int sl, std::ostream& stream) const;
MEDCOUPLING_EXPORT void fillWithValue(const T& val);
- MEDCOUPLING_EXPORT T *fromNoInterlace(int nbOfComp) const;
- MEDCOUPLING_EXPORT T *toNoInterlace(int nbOfComp) const;
+ MEDCOUPLING_EXPORT T *fromNoInterlace(std::size_t nbOfComp) const;
+ MEDCOUPLING_EXPORT T *toNoInterlace(std::size_t nbOfComp) const;
MEDCOUPLING_EXPORT void sort(bool asc);
- MEDCOUPLING_EXPORT void reverse(int nbOfComp);
+ MEDCOUPLING_EXPORT void reverse(std::size_t nbOfComp);
MEDCOUPLING_EXPORT void alloc(std::size_t nbOfElements);
MEDCOUPLING_EXPORT void reserve(std::size_t newNbOfElements);
MEDCOUPLING_EXPORT void reAlloc(std::size_t newNbOfElements);
MEDCOUPLING_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
MEDCOUPLING_EXPORT void setName(const std::string& name);
MEDCOUPLING_EXPORT void copyStringInfoFrom(const DataArray& other);
- MEDCOUPLING_EXPORT void copyPartOfStringInfoFrom(const DataArray& other, const std::vector<int>& compoIds);
- MEDCOUPLING_EXPORT void copyPartOfStringInfoFrom2(const std::vector<int>& compoIds, const DataArray& other);
+ MEDCOUPLING_EXPORT void copyPartOfStringInfoFrom(const DataArray& other, const std::vector<std::size_t>& compoIds);
+ MEDCOUPLING_EXPORT void copyPartOfStringInfoFrom(const DataArray& other, const std::vector<mcIdType>& compoIds);
+ MEDCOUPLING_EXPORT void copyPartOfStringInfoFrom2(const std::vector<std::size_t>& compoIds, const DataArray& other);
+ MEDCOUPLING_EXPORT void copyPartOfStringInfoFrom2(const std::vector<mcIdType>& compoIds, const DataArray& other);
MEDCOUPLING_EXPORT bool areInfoEqualsIfNotWhy(const DataArray& other, std::string& reason) const;
MEDCOUPLING_EXPORT bool areInfoEquals(const DataArray& other) const;
MEDCOUPLING_EXPORT std::string cppRepr(const std::string& varName) const;
MEDCOUPLING_EXPORT void setInfoAndChangeNbOfCompo(const std::vector<std::string>& info);
MEDCOUPLING_EXPORT std::vector<std::string> getVarsOnComponent() const;
MEDCOUPLING_EXPORT std::vector<std::string> getUnitsOnComponent() const;
- MEDCOUPLING_EXPORT std::string getInfoOnComponent(int i) const;
- MEDCOUPLING_EXPORT std::string getVarOnComponent(int i) const;
- MEDCOUPLING_EXPORT std::string getUnitOnComponent(int i) const;
- MEDCOUPLING_EXPORT void setInfoOnComponent(int i, const std::string& info);
+ MEDCOUPLING_EXPORT std::string getInfoOnComponent(std::size_t i) const;
+ MEDCOUPLING_EXPORT std::string getVarOnComponent(std::size_t i) const;
+ MEDCOUPLING_EXPORT std::string getUnitOnComponent(std::size_t i) const;
+ MEDCOUPLING_EXPORT void setInfoOnComponent(std::size_t i, const std::string& info);
MEDCOUPLING_EXPORT std::size_t getNumberOfComponents() const { return _info_on_compo.size(); }
MEDCOUPLING_EXPORT void setPartOfValuesBase3(const DataArray *aBase, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true);
MEDCOUPLING_EXPORT virtual void *getVoidStarPointer() = 0;
MEDCOUPLING_EXPORT virtual bool isAllocated() const = 0;
MEDCOUPLING_EXPORT virtual void checkAllocated() const = 0;
MEDCOUPLING_EXPORT virtual void desallocate() = 0;
- MEDCOUPLING_EXPORT virtual std::size_t getNumberOfTuples() const = 0;
+ MEDCOUPLING_EXPORT virtual mcIdType getNumberOfTuples() const = 0;
MEDCOUPLING_EXPORT virtual std::size_t getNbOfElems() const = 0;
MEDCOUPLING_EXPORT virtual std::size_t getNbOfElemAllocated() const = 0;
MEDCOUPLING_EXPORT virtual void alloc(std::size_t nbOfTuple, std::size_t nbOfCompo=1) = 0;
MEDCOUPLING_EXPORT virtual void setContigPartOfSelectedValues(int tupleIdStart, const DataArray *aBase, const DataArrayInt32 *tuplesSelec) = 0;
MEDCOUPLING_EXPORT virtual void setContigPartOfSelectedValuesSlice(int tupleIdStart, const DataArray *aBase, int bg, int end2, int step) = 0;
MEDCOUPLING_EXPORT virtual DataArray *selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const = 0;
- MEDCOUPLING_EXPORT virtual DataArray *keepSelectedComponents(const std::vector<int>& compoIds) const = 0;
+ MEDCOUPLING_EXPORT virtual DataArray *keepSelectedComponents(const std::vector<mcIdType>& compoIds) const = 0;
+ MEDCOUPLING_EXPORT virtual DataArray *keepSelectedComponents(const std::vector<std::size_t>& compoIds) const = 0;
MEDCOUPLING_EXPORT virtual DataArray *selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const = 0;
MEDCOUPLING_EXPORT virtual DataArray *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const = 0;
MEDCOUPLING_EXPORT virtual DataArray *selectByTupleIdSafeSlice(int bg, int end2, int step) const = 0;
- MEDCOUPLING_EXPORT virtual void rearrange(int newNbOfCompo) = 0;
+ MEDCOUPLING_EXPORT virtual void rearrange(std::size_t newNbOfCompo) = 0;
MEDCOUPLING_EXPORT virtual void circularPermutation(int nbOfShift=1) = 0;
MEDCOUPLING_EXPORT virtual void circularPermutationPerTuple(int nbOfShift=1) = 0;
MEDCOUPLING_EXPORT virtual void reversePerTuple() = 0;
- MEDCOUPLING_EXPORT void checkNbOfTuples(int nbOfTuples, const std::string& msg) const;
- MEDCOUPLING_EXPORT void checkNbOfComps(int nbOfCompo, const std::string& msg) const;
+ MEDCOUPLING_EXPORT void checkNbOfTuples(mcIdType nbOfTuples, const std::string& msg) const;
+ MEDCOUPLING_EXPORT void checkNbOfComps(std::size_t nbOfCompo, const std::string& msg) const;
MEDCOUPLING_EXPORT void checkNbOfTuplesAndComp(const DataArray& other, const std::string& msg) const;
- MEDCOUPLING_EXPORT void checkNbOfTuplesAndComp(int nbOfTuples, int nbOfCompo, const std::string& msg) const;
+ MEDCOUPLING_EXPORT void checkNbOfTuplesAndComp(mcIdType nbOfTuples, std::size_t nbOfCompo, const std::string& msg) const;
MEDCOUPLING_EXPORT void checkNbOfElems(std::size_t nbOfElems, const std::string& msg) const;
MEDCOUPLING_EXPORT static void GetSlice(int start, int stop, int step, int sliceId, int nbOfSlices, int& startSlice, int& stopSlice);
MEDCOUPLING_EXPORT static int GetNumberOfItemGivenBES(int begin, int end, int step, const std::string& msg);
std::size_t getHeapMemorySizeWithoutChildren() const;
MEDCOUPLING_EXPORT void updateTime() const { }
//
- MEDCOUPLING_EXPORT std::size_t getNumberOfTuples() const { return _info_on_compo.empty()?0:_mem.getNbOfElem()/getNumberOfComponents(); }
+ MEDCOUPLING_EXPORT mcIdType getNumberOfTuples() const { return ToIdType(_info_on_compo.empty()?0:_mem.getNbOfElem()/getNumberOfComponents()); }
MEDCOUPLING_EXPORT std::size_t getNbOfElems() const { return _mem.getNbOfElem(); }
MEDCOUPLING_EXPORT bool empty() const;
MEDCOUPLING_EXPORT void *getVoidStarPointer() { return getPointer(); }
MEDCOUPLING_EXPORT T *rwBegin() { return getPointer(); }
MEDCOUPLING_EXPORT T *rwEnd() { return getPointer()+getNbOfElems(); }
MEDCOUPLING_EXPORT void alloc(std::size_t nbOfTuple, std::size_t nbOfCompo=1);
- MEDCOUPLING_EXPORT void useArray(const T *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo);
- MEDCOUPLING_EXPORT void useExternalArrayWithRWAccess(const T *array, int nbOfTuple, int nbOfCompo);
- MEDCOUPLING_EXPORT T getIJSafe(int tupleId, int compoId) const;
- MEDCOUPLING_EXPORT T getIJ(int tupleId, int compoId) const { return _mem[tupleId*_info_on_compo.size()+compoId]; }
- MEDCOUPLING_EXPORT void setIJ(int tupleId, int compoId, T newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; declareAsNew(); }
- MEDCOUPLING_EXPORT void setIJSilent(int tupleId, int compoId, T newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; }
+ MEDCOUPLING_EXPORT void useArray(const T *array, bool ownership, DeallocType type, std::size_t nbOfTuple, std::size_t nbOfCompo);
+ MEDCOUPLING_EXPORT void useExternalArrayWithRWAccess(const T *array, std::size_t nbOfTuple, std::size_t nbOfCompo);
+ MEDCOUPLING_EXPORT T getIJSafe(std::size_t tupleId, std::size_t compoId) const;
+ MEDCOUPLING_EXPORT T getIJ(std::size_t tupleId, std::size_t compoId) const { return _mem[tupleId*_info_on_compo.size()+compoId]; }
+ MEDCOUPLING_EXPORT void setIJ(std::size_t tupleId, std::size_t compoId, T newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; declareAsNew(); }
+ MEDCOUPLING_EXPORT void setIJSilent(std::size_t tupleId, std::size_t compoId, T newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; }
MEDCOUPLING_EXPORT T *getPointer() { return _mem.getPointer(); declareAsNew(); }
MEDCOUPLING_EXPORT void pack() const;
MEDCOUPLING_EXPORT bool isAllocated() const override;
MEDCOUPLING_EXPORT void checkAllocated() const;
MEDCOUPLING_EXPORT void desallocate();
MEDCOUPLING_EXPORT void reserve(std::size_t nbOfElems);
- MEDCOUPLING_EXPORT void rearrange(int newNbOfCompo);
+ MEDCOUPLING_EXPORT void rearrange(std::size_t newNbOfCompo);
MEDCOUPLING_EXPORT void transpose();
MEDCOUPLING_EXPORT void pushBackSilent(T val);
MEDCOUPLING_EXPORT void pushBackValsSilent(const T *valsBg, const T *valsEnd);
MEDCOUPLING_EXPORT typename Traits<T>::ArrayType *renumber(const int *old2New) const;
MEDCOUPLING_EXPORT typename Traits<T>::ArrayType *renumberR(const int *new2Old) const;
MEDCOUPLING_EXPORT typename Traits<T>::ArrayType *renumberAndReduce(const int *old2New, int newNbOfTuple) const;
- MEDCOUPLING_EXPORT typename Traits<T>::ArrayType *changeNbOfComponents(int newNbOfComp, T dftValue) const;
+ MEDCOUPLING_EXPORT typename Traits<T>::ArrayType *changeNbOfComponents(std::size_t newNbOfComp, T dftValue) const;
MEDCOUPLING_EXPORT typename Traits<T>::ArrayType *subArray(int tupleIdBg, int tupleIdEnd=-1) const;
MEDCOUPLING_EXPORT MCAuto<typename Traits<T>::ArrayTypeCh> selectPartDef(const PartDefinition* pd) const;
MEDCOUPLING_EXPORT void circularPermutation(int nbOfShift=1);
typename Traits<T>::ArrayType *mySelectByTupleId(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const;
typename Traits<T>::ArrayType *mySelectByTupleId(const DataArrayIdType& di) const;
typename Traits<T>::ArrayType *mySelectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const;
- typename Traits<T>::ArrayType *myKeepSelectedComponents(const std::vector<int>& compoIds) const;
+ typename Traits<T>::ArrayType *myKeepSelectedComponents(const std::vector<mcIdType>& compoIds) const;
+ typename Traits<T>::ArrayType *myKeepSelectedComponents(const std::vector<std::size_t>& compoIds) const;
typename Traits<T>::ArrayType *mySelectByTupleIdSafeSlice(int bg, int end2, int step) const;
typename Traits<T>::ArrayType *mySelectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const;
protected:
MEDCOUPLING_EXPORT MCAuto<DataArrayDouble> convertToDblArr() const;
MEDCOUPLING_EXPORT MCAuto<DataArrayInt32> convertToIntArr() const;
MEDCOUPLING_EXPORT MCAuto<DataArrayFloat> convertToFloatArr() const;
- MEDCOUPLING_EXPORT void applyLin(T a, T b, int compoId);
+ MEDCOUPLING_EXPORT void applyLin(T a, T b, std::size_t compoId);
MEDCOUPLING_EXPORT void applyLin(T a, T b);
MEDCOUPLING_EXPORT typename Traits<T>::ArrayType *negate() const;
MEDCOUPLING_EXPORT void addEqual(const typename Traits<T>::ArrayType *other);
MEDCOUPLING_EXPORT DataArrayFloat *deepCopy() const;
MEDCOUPLING_EXPORT DataArrayFloat *buildNewEmptyInstance() const { return DataArrayFloat::New(); }
MEDCOUPLING_EXPORT DataArrayFloat *selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const { return DataArrayTemplateFP<float>::mySelectByTupleRanges(ranges); }
- MEDCOUPLING_EXPORT DataArrayFloat *keepSelectedComponents(const std::vector<int>& compoIds) const { return DataArrayTemplateFP<float>::myKeepSelectedComponents(compoIds); }
+ MEDCOUPLING_EXPORT DataArrayFloat *keepSelectedComponents(const std::vector<std::size_t>& compoIds) const { return DataArrayTemplateFP<float>::myKeepSelectedComponents(compoIds); }
+ MEDCOUPLING_EXPORT DataArrayFloat *keepSelectedComponents(const std::vector<mcIdType>& compoIds) const { return DataArrayTemplateFP<float>::myKeepSelectedComponents(compoIds); }
MEDCOUPLING_EXPORT DataArrayFloat *selectByTupleId(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const { return this->mySelectByTupleId(new2OldBg,new2OldEnd); }
MEDCOUPLING_EXPORT DataArrayFloat *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplateFP<float>::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); }
MEDCOUPLING_EXPORT DataArrayFloat *selectByTupleIdSafeSlice(int bg, int end2, int step) const { return DataArrayTemplateFP<float>::mySelectByTupleIdSafeSlice(bg,end2,step); }
MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleId(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const { return this->mySelectByTupleId(new2OldBg,new2OldEnd); }
MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleId(const DataArrayIdType& di) const { return this->mySelectByTupleId(di); }
MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplateFP<double>::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); }
- MEDCOUPLING_EXPORT DataArrayDouble *keepSelectedComponents(const std::vector<int>& compoIds) const { return DataArrayTemplateFP<double>::myKeepSelectedComponents(compoIds); }
+ MEDCOUPLING_EXPORT DataArrayDouble *keepSelectedComponents(const std::vector<std::size_t>& compoIds) const { return DataArrayTemplateFP<double>::myKeepSelectedComponents(compoIds); }
+ MEDCOUPLING_EXPORT DataArrayDouble *keepSelectedComponents(const std::vector<mcIdType>& compoIds) const { return DataArrayTemplateFP<double>::myKeepSelectedComponents(compoIds); }
MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleIdSafeSlice(int bg, int end2, int step) const { return DataArrayTemplateFP<double>::mySelectByTupleIdSafeSlice(bg,end2,step); }
MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const { return DataArrayTemplateFP<double>::mySelectByTupleRanges(ranges); }
MEDCOUPLING_EXPORT bool areIncludedInMe(const DataArrayDouble *other, double prec, DataArrayInt32 *&tupleIds) const;
MEDCOUPLING_EXPORT DataArrayDouble *getDifferentValues(double prec, int limitTupleId=-1) const;
MEDCOUPLING_EXPORT DataArrayInt32 *findClosestTupleId(const DataArrayDouble *other) const;
MEDCOUPLING_EXPORT DataArrayInt32 *computeNbOfInteractionsWith(const DataArrayDouble *otherBBoxFrmt, double eps) const;
- MEDCOUPLING_EXPORT void setSelectedComponents(const DataArrayDouble *a, const std::vector<int>& compoIds);
+ MEDCOUPLING_EXPORT void setSelectedComponents(const DataArrayDouble *a, const std::vector<std::size_t>& compoIds);
+ MEDCOUPLING_EXPORT void setSelectedComponents(const DataArrayDouble *a, const std::vector<mcIdType>& compoIds);
MEDCOUPLING_EXPORT DataArrayDoubleIterator *iterator();
MEDCOUPLING_EXPORT void checkNoNullValues() const;
MEDCOUPLING_EXPORT void getMinMaxPerComponent(double *bounds) const;
MEDCOUPLING_EXPORT void normMaxPerComponent(double * res) const;
MEDCOUPLING_EXPORT double normMin() const;
MEDCOUPLING_EXPORT void accumulate(double *res) const;
- MEDCOUPLING_EXPORT double accumulate(int compId) const;
+ MEDCOUPLING_EXPORT double accumulate(std::size_t compId) const;
MEDCOUPLING_EXPORT DataArrayDouble *accumulatePerChunck(const int *bgOfIndex, const int *endOfIndex) const;
MEDCOUPLING_EXPORT MCAuto<DataArrayDouble> cumSum() const;
MEDCOUPLING_EXPORT double distanceToTuple(const double *tupleBg, const double *tupleEnd, int& tupleId) const;
MEDCOUPLING_EXPORT bool isUniform(T val) const;
MEDCOUPLING_EXPORT T checkUniformAndGuess() const;
MEDCOUPLING_EXPORT bool hasUniqueValues() const;
+ MEDCOUPLING_EXPORT void setSelectedComponents(const DataArrayType *a, const std::vector<std::size_t>& compoIds);
MEDCOUPLING_EXPORT void setSelectedComponents(const DataArrayType *a, const std::vector<mcIdType>& compoIds);
MEDCOUPLING_EXPORT DataArrayIdType *findIdsNotEqual(T val) const;
MEDCOUPLING_EXPORT DataArrayIdType *findIdsEqualTuple(const T *tupleBg, const T *tupleEnd) const;
MEDCOUPLING_EXPORT bool presenceOfValue(T value) const;
MEDCOUPLING_EXPORT bool presenceOfValue(const std::vector<T>& vals) const;
MEDCOUPLING_EXPORT void accumulate(T *res) const;
- MEDCOUPLING_EXPORT T accumulate(mcIdType compId) const;
+ MEDCOUPLING_EXPORT T accumulate(std::size_t compId) const;
MEDCOUPLING_EXPORT DataArrayType *accumulatePerChunck(const mcIdType *bgOfIndex, const mcIdType *endOfIndex) const;
MEDCOUPLING_EXPORT void getMinMaxValues(T& minValue, T& maxValue) const;
MEDCOUPLING_EXPORT void applyInv(T numerator);
MEDCOUPLING_EXPORT DataArrayInt32 *selectByTupleId(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const { return this->mySelectByTupleId(new2OldBg,new2OldEnd); }
MEDCOUPLING_EXPORT DataArrayInt32 *selectByTupleId(const DataArrayIdType& di) const { return this->mySelectByTupleId(di); }
MEDCOUPLING_EXPORT DataArrayInt32 *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplate<int>::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); }
- MEDCOUPLING_EXPORT DataArrayInt32 *keepSelectedComponents(const std::vector<int>& compoIds) const { return DataArrayTemplate<int>::myKeepSelectedComponents(compoIds); }
+ MEDCOUPLING_EXPORT DataArrayInt32 *keepSelectedComponents(const std::vector<std::size_t>& compoIds) const { return DataArrayTemplate<int>::myKeepSelectedComponents(compoIds); }
+ MEDCOUPLING_EXPORT DataArrayInt32 *keepSelectedComponents(const std::vector<mcIdType>& compoIds) const { return DataArrayTemplate<int>::myKeepSelectedComponents(compoIds); }
MEDCOUPLING_EXPORT DataArrayInt32 *selectByTupleIdSafeSlice(int bg, int end2, int step) const { return DataArrayTemplate<int>::mySelectByTupleIdSafeSlice(bg,end2,step); }
MEDCOUPLING_EXPORT DataArrayInt32 *selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const { return DataArrayTemplate<int>::mySelectByTupleRanges(ranges); }
public:
MEDCOUPLING_EXPORT DataArrayInt64 *selectByTupleId(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const { return this->mySelectByTupleId(new2OldBg,new2OldEnd); }
MEDCOUPLING_EXPORT DataArrayInt64 *selectByTupleId(const DataArrayIdType& di) const { return this->mySelectByTupleId(di); }
MEDCOUPLING_EXPORT DataArrayInt64 *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplate<Int64>::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); }
- MEDCOUPLING_EXPORT DataArrayInt64 *keepSelectedComponents(const std::vector<int>& compoIds) const { return DataArrayTemplate<Int64>::myKeepSelectedComponents(compoIds); }
+ MEDCOUPLING_EXPORT DataArrayInt64 *keepSelectedComponents(const std::vector<std::size_t>& compoIds) const { return DataArrayTemplate<Int64>::myKeepSelectedComponents(compoIds); }
+ MEDCOUPLING_EXPORT DataArrayInt64 *keepSelectedComponents(const std::vector<mcIdType>& compoIds) const { return DataArrayTemplate<Int64>::myKeepSelectedComponents(compoIds); }
MEDCOUPLING_EXPORT DataArrayInt64 *selectByTupleIdSafeSlice(int bg, int end2, int step) const { return DataArrayTemplate<Int64>::mySelectByTupleIdSafeSlice(bg,end2,step); }
MEDCOUPLING_EXPORT DataArrayInt64 *selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const { return DataArrayTemplate<Int64>::mySelectByTupleRanges(ranges); }
public:
throw INTERP_KERNEL::Exception("DataArrayInt::findIdsAdv : this must have exactly one component !");
const T *cptr(this->begin());
MCAuto<DataArrayInt> ret(DataArrayInt::New()); ret->alloc(0,1);
- mcIdType nbOfTuples=ToIdType(this->getNumberOfTuples());
+ mcIdType nbOfTuples=this->getNumberOfTuples();
for(mcIdType i=0;i<nbOfTuples;i++,cptr++)
if(op(*cptr))
ret->pushBackSilent(i);
MEDCOUPLING_EXPORT DataArrayChar *selectByTupleId(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const { return this->mySelectByTupleId(new2OldBg,new2OldEnd); }
MEDCOUPLING_EXPORT DataArrayChar *selectByTupleId(const DataArrayIdType& di) const { return this->mySelectByTupleId(di); }
MEDCOUPLING_EXPORT DataArrayChar *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplate<char>::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); }
- MEDCOUPLING_EXPORT DataArrayChar *keepSelectedComponents(const std::vector<int>& compoIds) const { return DataArrayTemplate<char>::myKeepSelectedComponents(compoIds); }
+ MEDCOUPLING_EXPORT DataArrayChar *keepSelectedComponents(const std::vector<std::size_t>& compoIds) const { return DataArrayTemplate<char>::myKeepSelectedComponents(compoIds); }
+ MEDCOUPLING_EXPORT DataArrayChar *keepSelectedComponents(const std::vector<mcIdType>& compoIds) const { return DataArrayTemplate<char>::myKeepSelectedComponents(compoIds); }
MEDCOUPLING_EXPORT DataArrayChar *selectByTupleIdSafeSlice(int bg, int end2, int step) const { return DataArrayTemplate<char>::mySelectByTupleIdSafeSlice(bg,end2,step); }
MEDCOUPLING_EXPORT bool isUniform(char val) const;
MEDCOUPLING_EXPORT void meldWith(const DataArrayChar *other);
typename Traits<T>::ArrayType *_da;
T *_pt;
mcIdType _tuple_id;
- mcIdType _nb_comp;
+ std::size_t _nb_comp;
mcIdType _nb_tuple;
};
class DataArrayTuple
{
public:
- MEDCOUPLING_EXPORT DataArrayTuple(T *pt, mcIdType nbOfComp);
+ MEDCOUPLING_EXPORT DataArrayTuple(T *pt, std::size_t nbOfComp);
//MEDCOUPLING_EXPORT std::string repr() const;
- MEDCOUPLING_EXPORT mcIdType getNumberOfCompo() const { return _nb_of_compo; }
+ MEDCOUPLING_EXPORT std::size_t getNumberOfCompo() const { return _nb_of_compo; }
MEDCOUPLING_EXPORT const T *getConstPointer() const { return _pt; }
MEDCOUPLING_EXPORT T *getPointer() { return _pt; }
- MEDCOUPLING_EXPORT typename Traits<T>::ArrayType *buildDA(mcIdType nbOfTuples, mcIdType nbOfCompo) const;
+ MEDCOUPLING_EXPORT typename Traits<T>::ArrayType *buildDA(std::size_t nbOfTuples, std::size_t nbOfCompo) const;
protected:
T zeValue() const;
protected:
T *_pt;
- mcIdType _nb_of_compo;
+ std::size_t _nb_of_compo;
};
class DataArrayDoubleTuple;
class DataArrayDoubleTuple : public DataArrayTuple<double>
{
public:
- MEDCOUPLING_EXPORT DataArrayDoubleTuple(double *pt, mcIdType nbOfComp);
+ MEDCOUPLING_EXPORT DataArrayDoubleTuple(double *pt, std::size_t nbOfComp);
MEDCOUPLING_EXPORT std::string repr() const;
MEDCOUPLING_EXPORT double doubleValue() const;
- MEDCOUPLING_EXPORT DataArrayDouble *buildDADouble(mcIdType nbOfTuples, mcIdType nbOfCompo) const;
+ MEDCOUPLING_EXPORT DataArrayDouble *buildDADouble(std::size_t nbOfTuples, std::size_t nbOfCompo) const;
};
class DataArrayFloatTuple;
class DataArrayFloatTuple : public DataArrayTuple<float>
{
public:
- MEDCOUPLING_EXPORT DataArrayFloatTuple(float *pt, mcIdType nbOfComp);
+ MEDCOUPLING_EXPORT DataArrayFloatTuple(float *pt, std::size_t nbOfComp);
MEDCOUPLING_EXPORT std::string repr() const;
MEDCOUPLING_EXPORT float floatValue() const;
- MEDCOUPLING_EXPORT DataArrayFloat *buildDAFloat(mcIdType nbOfTuples, mcIdType nbOfCompo) const;
+ MEDCOUPLING_EXPORT DataArrayFloat *buildDAFloat(std::size_t nbOfTuples, std::size_t nbOfCompo) const;
};
class DataArrayInt32Iterator : public DataArrayIterator<Int32>
class DataArrayInt32Tuple : public DataArrayTuple<Int32>
{
public:
- MEDCOUPLING_EXPORT DataArrayInt32Tuple(Int32 *pt, mcIdType nbOfComp);
+ MEDCOUPLING_EXPORT DataArrayInt32Tuple(Int32 *pt, std::size_t nbOfComp);
MEDCOUPLING_EXPORT std::string repr() const;
MEDCOUPLING_EXPORT Int32 intValue() const;
- MEDCOUPLING_EXPORT DataArrayInt32 *buildDAInt(mcIdType nbOfTuples, mcIdType nbOfCompo) const;
+ MEDCOUPLING_EXPORT DataArrayInt32 *buildDAInt(std::size_t nbOfTuples, std::size_t nbOfCompo) const;
};
class DataArrayInt64Tuple : public DataArrayTuple<Int64>
{
public:
- MEDCOUPLING_EXPORT DataArrayInt64Tuple(Int64 *pt, mcIdType nbOfComp);
+ MEDCOUPLING_EXPORT DataArrayInt64Tuple(Int64 *pt, std::size_t nbOfComp);
MEDCOUPLING_EXPORT std::string repr() const;
MEDCOUPLING_EXPORT Int64 intValue() const;
- MEDCOUPLING_EXPORT DataArrayInt64 *buildDAInt(mcIdType nbOfTuples, mcIdType nbOfCompo) const;
+ MEDCOUPLING_EXPORT DataArrayInt64 *buildDAInt(std::size_t nbOfTuples, std::size_t nbOfCompo) const;
};
typedef DataArrayInt32Tuple DataArrayIntTuple;
private:
DataArrayAsciiChar *_da;
char *_pt;
- int _tuple_id;
- int _nb_comp;
- int _nb_tuple;
+ mcIdType _tuple_id;
+ std::size_t _nb_comp;
+ mcIdType _nb_tuple;
};
class DataArrayAsciiCharTuple
{
public:
- MEDCOUPLING_EXPORT DataArrayAsciiCharTuple(char *pt, int nbOfComp);
+ MEDCOUPLING_EXPORT DataArrayAsciiCharTuple(char *pt, std::size_t nbOfComp);
MEDCOUPLING_EXPORT std::string repr() const;
- MEDCOUPLING_EXPORT int getNumberOfCompo() const { return _nb_of_compo; }
+ MEDCOUPLING_EXPORT std::size_t getNumberOfCompo() const { return _nb_of_compo; }
MEDCOUPLING_EXPORT const char *getConstPointer() const { return _pt; }
MEDCOUPLING_EXPORT char *getPointer() { return _pt; }
MEDCOUPLING_EXPORT char asciiCharValue() const;
- MEDCOUPLING_EXPORT DataArrayAsciiChar *buildDAAsciiChar(int nbOfTuples, int nbOfCompo) const;
+ MEDCOUPLING_EXPORT DataArrayAsciiChar *buildDAAsciiChar(std::size_t nbOfTuples, std::size_t nbOfCompo) const;
private:
char *_pt;
- int _nb_of_compo;
+ std::size_t _nb_of_compo;
};
class DataArrayByteTuple;
private:
DataArrayByte *_da;
char *_pt;
- int _tuple_id;
- int _nb_comp;
- int _nb_tuple;
+ mcIdType _tuple_id;
+ std::size_t _nb_comp;
+ mcIdType _nb_tuple;
};
class DataArrayByteTuple
{
public:
- MEDCOUPLING_EXPORT DataArrayByteTuple(char *pt, int nbOfComp);
+ MEDCOUPLING_EXPORT DataArrayByteTuple(char *pt, std::size_t nbOfComp);
MEDCOUPLING_EXPORT std::string repr() const;
- MEDCOUPLING_EXPORT int getNumberOfCompo() const { return _nb_of_compo; }
+ MEDCOUPLING_EXPORT std::size_t getNumberOfCompo() const { return _nb_of_compo; }
MEDCOUPLING_EXPORT const char *getConstPointer() const { return _pt; }
MEDCOUPLING_EXPORT char *getPointer() { return _pt; }
MEDCOUPLING_EXPORT char byteValue() const;
- MEDCOUPLING_EXPORT DataArrayByte *buildDAByte(int nbOfTuples, int nbOfCompo) const;
+ MEDCOUPLING_EXPORT DataArrayByte *buildDAByte(std::size_t nbOfTuples, std::size_t nbOfCompo) const;
private:
char *_pt;
- int _nb_of_compo;
+ std::size_t _nb_of_compo;
};
}
}
template<class T>
- T *MemArray<T>::fromNoInterlace(int nbOfComp) const
+ T *MemArray<T>::fromNoInterlace(std::size_t nbOfComp) const
{
if(nbOfComp<1)
throw INTERP_KERNEL::Exception("MemArray<T>::fromNoInterlace : number of components must be > 0 !");
T *ret=(T*)malloc(_nb_of_elem*sizeof(T));
T *w=ret;
for(std::size_t i=0;i<nbOfTuples;i++)
- for(int j=0;j<nbOfComp;j++,w++)
+ for(std::size_t j=0;j<nbOfComp;j++,w++)
*w=pt[j*nbOfTuples+i];
return ret;
}
template<class T>
- T *MemArray<T>::toNoInterlace(int nbOfComp) const
+ T *MemArray<T>::toNoInterlace(std::size_t nbOfComp) const
{
if(nbOfComp<1)
throw INTERP_KERNEL::Exception("MemArray<T>::toNoInterlace : number of components must be > 0 !");
std::size_t nbOfTuples=_nb_of_elem/nbOfComp;
T *ret=(T*)malloc(_nb_of_elem*sizeof(T));
T *w=ret;
- for(int i=0;i<nbOfComp;i++)
+ for(std::size_t i=0;i<nbOfComp;i++)
for(std::size_t j=0;j<nbOfTuples;j++,w++)
*w=pt[j*nbOfComp+i];
return ret;
}
template<class T>
- void MemArray<T>::reverse(int nbOfComp)
+ void MemArray<T>::reverse(std::size_t nbOfComp)
{
if(nbOfComp<1)
throw INTERP_KERNEL::Exception("MemArray<T>::reverse : only supported with 'this' array with ONE or more than ONE component !");
std::size_t nbOfTuples=_nb_of_elem/nbOfComp;
for(std::size_t i=0;i<nbOfTuples/2;i++,pt+=nbOfComp,pt2-=nbOfComp)
{
- for(int j=0;j<nbOfComp;j++)
+ for(std::size_t j=0;j<nbOfComp;j++)
std::swap(pt[j],pt2[j]);
}
}
_da->incrRef();
if(_da->isAllocated())
{
- _nb_comp=ToIdType(da->getNumberOfComponents());
- _nb_tuple=ToIdType(da->getNumberOfTuples());
+ _nb_comp=da->getNumberOfComponents();
+ _nb_tuple=da->getNumberOfTuples();
_pt=da->getPointer();
}
}
//////////////////////////////////
template<class T>
- DataArrayTuple<T>::DataArrayTuple(T *pt, int nbOfComp):_pt(pt),_nb_of_compo(nbOfComp)
+ DataArrayTuple<T>::DataArrayTuple(T *pt, std::size_t nbOfComp):_pt(pt),_nb_of_compo(nbOfComp)
{
}
}
template<class T>
- typename Traits<T>::ArrayType *DataArrayTuple<T>::buildDA(int nbOfTuples, int nbOfCompo) const
+ typename Traits<T>::ArrayType *DataArrayTuple<T>::buildDA(std::size_t nbOfTuples, std::size_t nbOfCompo) const
{
if((_nb_of_compo==nbOfCompo && nbOfTuples==1) || (_nb_of_compo==nbOfTuples && nbOfCompo==1))
{
{
checkAllocated();
std::size_t sz(getNumberOfComponents());
- std::size_t nbTuples(getNumberOfTuples());
+ mcIdType nbTuples(getNumberOfTuples());
std::string name(getName());
std::vector<std::string> compNames(getInfoOnComponents());
std::vector< MCAuto< typename Traits<T>::ArrayTypeCh > > ret(sz);
part->setName(name);
part->setInfoOnComponent(0,compNames[i]);
T *otherPt(part->getPointer());
- for(std::size_t j=0;j<nbTuples;j++)
+ for(mcIdType j=0;j<nbTuples;j++)
otherPt[j]=thisPt[sz*j+i];
ret[i]=part;
}
* \param [in] nbOfCompo - new number of components in \a this.
*/
template<class T>
- void DataArrayTemplate<T>::useArray(const T *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo)
+ void DataArrayTemplate<T>::useArray(const T *array, bool ownership, DeallocType type, std::size_t nbOfTuple, std::size_t nbOfCompo)
{
_info_on_compo.resize(nbOfCompo);
- _mem.useArray(array,ownership,type,(std::size_t)nbOfTuple*nbOfCompo);
+ _mem.useArray(array,ownership,type,nbOfTuple*nbOfCompo);
declareAsNew();
}
template<class T>
- void DataArrayTemplate<T>::useExternalArrayWithRWAccess(const T *array, int nbOfTuple, int nbOfCompo)
+ void DataArrayTemplate<T>::useExternalArrayWithRWAccess(const T *array, std::size_t nbOfTuple, std::size_t nbOfCompo)
{
_info_on_compo.resize(nbOfCompo);
- _mem.useExternalArrayWithRWAccess(array,(std::size_t)nbOfTuple*nbOfCompo);
+ _mem.useExternalArrayWithRWAccess(array,nbOfTuple*nbOfCompo);
declareAsNew();
}
* \throw If condition <em>( 0 <= compoId < this->getNumberOfComponents() )</em> is violated.
*/
template<class T>
- T DataArrayTemplate<T>::getIJSafe(int tupleId, int compoId) const
+ T DataArrayTemplate<T>::getIJSafe(std::size_t tupleId, std::size_t compoId) const
{
checkAllocated();
- if(tupleId<0 || tupleId>=ToIdType(getNumberOfTuples()))
+ if(ToIdType(tupleId)>=getNumberOfTuples())
{
std::ostringstream oss; oss << Traits<T>::ArrayTypeName << "::getIJSafe : request for tupleId " << tupleId << " should be in [0," << getNumberOfTuples() << ") !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- if(compoId<0 || compoId>=(int)getNumberOfComponents())
+ if(compoId>=getNumberOfComponents())
{
std::ostringstream oss; oss << Traits<T>::ArrayTypeName << "::getIJSafe : request for compoId " << compoId << " should be in [0," << getNumberOfComponents() << ") !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
{
if(isAllocated())
{
- if(nbOfTuple!=getNumberOfTuples() || nbOfCompo!=getNumberOfComponents())
+ if(ToIdType(nbOfTuple)!=getNumberOfTuples() || nbOfCompo!=getNumberOfComponents())
alloc(nbOfTuple,nbOfCompo);
}
else
void DataArrayTemplate<T>::deepCopyFrom(const DataArrayTemplate<T>& other)
{
other.checkAllocated();
- std::size_t nbOfTuples(other.getNumberOfTuples()),nbOfComp(other.getNumberOfComponents());
+ mcIdType nbOfTuples(other.getNumberOfTuples());
+ std::size_t nbOfComp(other.getNumberOfComponents());
allocIfNecessary(nbOfTuples,nbOfComp);
std::size_t nbOfElems(nbOfTuples*nbOfComp);
T *pt(getPointer());
void DataArrayTemplate<T>::reverse()
{
checkAllocated();
- _mem.reverse(ToIdType(getNumberOfComponents()));
+ _mem.reverse(getNumberOfComponents());
declareAsNew();
}
void DataArrayTemplate<T>::renumberInPlace(const int *old2New)
{
checkAllocated();
- mcIdType nbTuples=ToIdType(getNumberOfTuples());
- mcIdType nbOfCompo=ToIdType(getNumberOfComponents());
+ mcIdType nbTuples(getNumberOfTuples());
+ std::size_t nbOfCompo(getNumberOfComponents());
T *tmp(new T[nbTuples*nbOfCompo]);
const T *iptr(begin());
for(int i=0;i<nbTuples;i++)
void DataArrayTemplate<T>::renumberInPlaceR(const int *new2Old)
{
checkAllocated();
- mcIdType nbTuples=ToIdType(getNumberOfTuples());
- mcIdType nbOfCompo=ToIdType(getNumberOfComponents());
+ mcIdType nbTuples(getNumberOfTuples());
+ std::size_t nbOfCompo(getNumberOfComponents());
T *tmp(new T[nbTuples*nbOfCompo]);
const T *iptr(begin());
for(mcIdType i=0;i<nbTuples;i++)
typename Traits<T>::ArrayType *DataArrayTemplate<T>::renumber(const int *old2New) const
{
checkAllocated();
- mcIdType nbTuples=ToIdType(getNumberOfTuples());
- mcIdType nbOfCompo=ToIdType(getNumberOfComponents());
+ mcIdType nbTuples(getNumberOfTuples());
+ std::size_t nbOfCompo(getNumberOfComponents());
MCAuto<DataArray> ret0(buildNewEmptyInstance());
MCAuto< typename Traits<T>::ArrayType > ret(DynamicCastSafe<DataArray,typename Traits<T>::ArrayType>(ret0));
ret->alloc(nbTuples,nbOfCompo);
typename Traits<T>::ArrayType *DataArrayTemplate<T>::renumberR(const int *new2Old) const
{
checkAllocated();
- mcIdType nbTuples=ToIdType(getNumberOfTuples());
- mcIdType nbOfCompo=ToIdType(getNumberOfComponents());
+ mcIdType nbTuples(getNumberOfTuples());
+ std::size_t nbOfCompo(getNumberOfComponents());
MCAuto<DataArray> ret0(buildNewEmptyInstance());
MCAuto< typename Traits<T>::ArrayType > ret(DynamicCastSafe<DataArray,typename Traits<T>::ArrayType>(ret0));
ret->alloc(nbTuples,nbOfCompo);
typename Traits<T>::ArrayType *DataArrayTemplate<T>::renumberAndReduce(const int *old2New, int newNbOfTuple) const
{
checkAllocated();
- mcIdType nbTuples=ToIdType(getNumberOfTuples());
- mcIdType nbOfCompo=ToIdType(getNumberOfComponents());
+ mcIdType nbTuples(getNumberOfTuples());
+ std::size_t nbOfCompo(getNumberOfComponents());
MCAuto<DataArray> ret0(buildNewEmptyInstance());
MCAuto< typename Traits<T>::ArrayType > ret(DynamicCastSafe<DataArray,typename Traits<T>::ArrayType>(ret0));
ret->alloc(newNbOfTuple,nbOfCompo);
{
int a,b,c;
spd->getSlice(a,b,c);
- if(a==0 && b==(int)getNumberOfTuples() && c==1)
+ if(a==0 && b==getNumberOfTuples() && c==1)
{
DataArrayTemplate<T> *directRet(const_cast<DataArrayTemplate<T> *>(this));
directRet->incrRef();
checkAllocated();
MCAuto<DataArray> ret0(buildNewEmptyInstance());
MCAuto< typename Traits<T>::ArrayType > ret(DynamicCastSafe<DataArray,typename Traits<T>::ArrayType>(ret0));
- mcIdType nbComp=ToIdType(getNumberOfComponents());
- mcIdType oldNbOfTuples=ToIdType(getNumberOfTuples());
+ std::size_t nbComp(getNumberOfComponents());
+ mcIdType oldNbOfTuples(getNumberOfTuples());
ret->alloc((int)std::distance(new2OldBg,new2OldEnd),nbComp);
ret->copyStringInfoFrom(*this);
T *pt(ret->getPointer());
* \warning This method erases all (name and unit) component info set before!
*/
template<class T>
- void DataArrayTemplate<T>::rearrange(int newNbOfCompo)
+ void DataArrayTemplate<T>::rearrange(std::size_t newNbOfCompo)
{
checkAllocated();
if(newNbOfCompo<1)
void DataArrayTemplate<T>::transpose()
{
checkAllocated();
- rearrange(ToIdType (getNumberOfTuples()));
+ rearrange(getNumberOfTuples());
}
/*!
* \throw If \a this is not allocated.
*/
template<class T>
- typename Traits<T>::ArrayType *DataArrayTemplate<T>::changeNbOfComponents(int newNbOfComp, T dftValue) const
+ typename Traits<T>::ArrayType *DataArrayTemplate<T>::changeNbOfComponents(std::size_t newNbOfComp, T dftValue) const
{
checkAllocated();
MCAuto<DataArray> ret0(buildNewEmptyInstance());
ret->alloc(getNumberOfTuples(),newNbOfComp);
const T *oldc(getConstPointer());
T *nc(ret->getPointer());
- mcIdType nbOfTuples=ToIdType(getNumberOfTuples());
- mcIdType oldNbOfComp=ToIdType(getNumberOfComponents());
- mcIdType dim(std::min(oldNbOfComp,newNbOfComp));
+ mcIdType nbOfTuples=getNumberOfTuples();
+ std::size_t oldNbOfComp=getNumberOfComponents();
+ std::size_t dim(std::min(oldNbOfComp,newNbOfComp));
for(mcIdType i=0;i<nbOfTuples;i++)
{
- mcIdType j=0;
+ std::size_t j=0;
for(;j<dim;j++)
nc[newNbOfComp*i+j]=oldc[i*oldNbOfComp+j];
for(;j<newNbOfComp;j++)
nc[newNbOfComp*i+j]=dftValue;
}
ret->setName(getName());
- for(mcIdType i=0;i<dim;i++)
+ for(std::size_t i=0;i<dim;i++)
ret->setInfoOnComponent(i,getInfoOnComponent(i));
ret->setName(getName());
return ret.retn();
* \endif
*/
template<class T>
- typename Traits<T>::ArrayType *DataArrayTemplate<T>::myKeepSelectedComponents(const std::vector<int>& compoIds) const
+ typename Traits<T>::ArrayType *DataArrayTemplate<T>::myKeepSelectedComponents(const std::vector<std::size_t>& compoIds) const
{
checkAllocated();
MCAuto<DataArray> ret0(buildNewEmptyInstance());
MCAuto< typename Traits<T>::ArrayType > ret(DynamicCastSafe<DataArray,typename Traits<T>::ArrayType>(ret0));
- std::size_t newNbOfCompo=ToIdType(compoIds.size());
- mcIdType oldNbOfCompo=ToIdType(getNumberOfComponents());
- for(std::vector<int>::const_iterator it=compoIds.begin();it!=compoIds.end();it++)
+ std::size_t newNbOfCompo=compoIds.size();
+ std::size_t oldNbOfCompo=getNumberOfComponents();
+ for(std::vector<std::size_t>::const_iterator it=compoIds.begin();it!=compoIds.end();it++)
if((*it)<0 || (*it)>=oldNbOfCompo)
{
std::ostringstream oss; oss << Traits<T>::ArrayTypeName << "::keepSelectedComponents : invalid requested component : " << *it << " whereas it should be in [0," << oldNbOfCompo << ") !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- mcIdType nbOfTuples=ToIdType(getNumberOfTuples());
+ mcIdType nbOfTuples(getNumberOfTuples());
ret->alloc(nbOfTuples,newNbOfCompo);
ret->copyPartOfStringInfoFrom(*this,compoIds);
const T *oldc(getConstPointer());
return ret.retn();
}
+ template<class T>
+ typename Traits<T>::ArrayType *DataArrayTemplate<T>::myKeepSelectedComponents(const std::vector<mcIdType>& compoIds) const
+ {
+ std::vector<std::size_t> ids (compoIds.size());
+ std::copy(compoIds.begin(), compoIds.end(), ids.begin());
+ return myKeepSelectedComponents (ids);
+ }
/*!
* Returns a shorten copy of \a this array. The new DataArrayDouble contains all
* tuples starting from the \a tupleIdBg-th tuple and including all tuples located before
typename Traits<T>::ArrayType *DataArrayTemplate<T>::subArray(int tupleIdBg, int tupleIdEnd) const
{
checkAllocated();
- mcIdType nbt=ToIdType(getNumberOfTuples());
+ mcIdType nbt=getNumberOfTuples();
if(tupleIdBg<0)
{
std::ostringstream oss; oss << Traits<T>::ArrayTypeName << "::subArray : The tupleIdBg parameter must be greater than 0 !";
}
else
trueEnd=nbt;
- mcIdType nbComp=ToIdType(getNumberOfComponents());
+ std::size_t nbComp=getNumberOfComponents();
MCAuto<DataArray> ret0(buildNewEmptyInstance());
MCAuto< typename Traits<T>::ArrayType > ret(DynamicCastSafe<DataArray,typename Traits<T>::ArrayType>(ret0));
ret->alloc(trueEnd-tupleIdBg,nbComp);
checkAllocated();
MCAuto<DataArray> ret0(buildNewEmptyInstance());
MCAuto< typename Traits<T>::ArrayType > ret(DynamicCastSafe<DataArray,typename Traits<T>::ArrayType>(ret0));
- mcIdType nbComp=ToIdType(getNumberOfComponents());
+ std::size_t nbComp(getNumberOfComponents());
std::ostringstream oss; oss << Traits<T>::ArrayTypeName << "::selectByTupleIdSafeSlice : ";
int newNbOfTuples(GetNumberOfItemGivenBESRelative(bg,end2,step,oss.str()));
ret->alloc(newNbOfTuples,nbComp);
a->checkAllocated();
int newNbOfTuples(DataArray::GetNumberOfItemGivenBES(bgTuples,endTuples,stepTuples,msg));
int newNbOfComp(DataArray::GetNumberOfItemGivenBES(bgComp,endComp,stepComp,msg));
- mcIdType nbComp=ToIdType(getNumberOfComponents());
- mcIdType nbOfTuples=ToIdType(getNumberOfTuples());
+ std::size_t nbComp(getNumberOfComponents());
+ mcIdType nbOfTuples(getNumberOfTuples());
DataArray::CheckValueInRangeEx(nbOfTuples,bgTuples,endTuples,"invalid tuple value");
- DataArray::CheckValueInRangeEx(nbComp,bgComp,endComp,"invalid component value");
+ DataArray::CheckValueInRangeEx(ToIdType(nbComp),bgComp,endComp,"invalid component value");
bool assignTech(true);
if(a->getNbOfElems()==(std::size_t)newNbOfTuples*newNbOfComp)
{
checkAllocated();
int newNbOfTuples(DataArray::GetNumberOfItemGivenBES(bgTuples,endTuples,stepTuples,msg));
int newNbOfComp(DataArray::GetNumberOfItemGivenBES(bgComp,endComp,stepComp,msg));
- mcIdType nbComp=ToIdType(getNumberOfComponents());
- mcIdType nbOfTuples=ToIdType(getNumberOfTuples());
+ std::size_t nbComp(getNumberOfComponents());
+ mcIdType nbOfTuples(getNumberOfTuples());
DataArray::CheckValueInRangeEx(nbOfTuples,bgTuples,endTuples,"invalid tuple value");
- DataArray::CheckValueInRangeEx(nbComp,bgComp,endComp,"invalid component value");
+ DataArray::CheckValueInRangeEx(ToIdType(nbComp),bgComp,endComp,"invalid component value");
T *pt=getPointer()+bgTuples*nbComp+bgComp;
for(mcIdType i=0;i<newNbOfTuples;i++,pt+=stepTuples*nbComp)
for(mcIdType j=0;j<newNbOfComp;j++)
const char msg[]="DataArrayTemplate::setPartOfValues2";
checkAllocated();
a->checkAllocated();
- mcIdType nbComp=ToIdType(getNumberOfComponents());
- mcIdType nbOfTuples=ToIdType(getNumberOfTuples());
+ std::size_t nbComp(getNumberOfComponents());
+ mcIdType nbOfTuples(getNumberOfTuples());
for(const int *z=bgComp;z!=endComp;z++)
- DataArray::CheckValueInRange(nbComp,*z,"invalid component id");
- int newNbOfTuples((int)std::distance(bgTuples,endTuples));
- int newNbOfComp((int)std::distance(bgComp,endComp));
+ DataArray::CheckValueInRange(ToIdType(nbComp),*z,"invalid component id");
+ mcIdType newNbOfTuples(ToIdType(std::distance(bgTuples,endTuples)));
+ std::size_t newNbOfComp(std::distance(bgComp,endComp));
bool assignTech(true);
- if(a->getNbOfElems()==(std::size_t)newNbOfTuples*newNbOfComp)
+ if(a->getNbOfElems()==newNbOfTuples*newNbOfComp)
{
if(strictCompoCompare)
a->checkNbOfTuplesAndComp(newNbOfTuples,newNbOfComp,msg);
void DataArrayTemplate<T>::setPartOfValuesSimple2(T a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp)
{
checkAllocated();
- mcIdType nbComp=ToIdType(getNumberOfComponents());
- mcIdType nbOfTuples=ToIdType(getNumberOfTuples());
+ std::size_t nbComp=getNumberOfComponents();
+ mcIdType nbOfTuples=getNumberOfTuples();
for(const int *z=bgComp;z!=endComp;z++)
- DataArray::CheckValueInRange(nbComp,*z,"invalid component id");
+ DataArray::CheckValueInRange(ToIdType(nbComp),*z,"invalid component id");
T *pt(getPointer());
for(const int *w=bgTuples;w!=endTuples;w++)
for(const int *z=bgComp;z!=endComp;z++)
const char msg[]="DataArrayTemplate::setPartOfValues3";
checkAllocated();
a->checkAllocated();
- int newNbOfComp=DataArray::GetNumberOfItemGivenBES(bgComp,endComp,stepComp,msg);
- mcIdType nbComp=ToIdType(getNumberOfComponents());
- mcIdType nbOfTuples=ToIdType(getNumberOfTuples());
- DataArray::CheckValueInRangeEx(nbComp,bgComp,endComp,"invalid component value");
- int newNbOfTuples=(int)std::distance(bgTuples,endTuples);
+ std::size_t newNbOfComp=DataArray::GetNumberOfItemGivenBES(bgComp,endComp,stepComp,msg);
+ std::size_t nbComp(getNumberOfComponents());
+ mcIdType nbOfTuples(getNumberOfTuples());
+ DataArray::CheckValueInRangeEx(ToIdType(nbComp),bgComp,endComp,"invalid component value");
+ mcIdType newNbOfTuples=ToIdType(std::distance(bgTuples,endTuples));
bool assignTech=true;
- if(a->getNbOfElems()==(std::size_t)newNbOfTuples*newNbOfComp)
+ if(a->getNbOfElems()==newNbOfTuples*newNbOfComp)
{
if(strictCompoCompare)
a->checkNbOfTuplesAndComp(newNbOfTuples,newNbOfComp,msg);
if(assignTech)
{
for(const int *w=bgTuples;w!=endTuples;w++)
- for(int j=0;j<newNbOfComp;j++,srcPt++)
+ for(std::size_t j=0;j<newNbOfComp;j++,srcPt++)
{
DataArray::CheckValueInRange(nbOfTuples,*w,"invalid tuple id");
pt[(std::size_t)(*w)*nbComp+j*stepComp]=*srcPt;
for(const int *w=bgTuples;w!=endTuples;w++)
{
const T *srcPt2=srcPt;
- for(int j=0;j<newNbOfComp;j++,srcPt2++)
+ for(std::size_t j=0;j<newNbOfComp;j++,srcPt2++)
{
DataArray::CheckValueInRange(nbOfTuples,*w,"invalid tuple id");
pt[(std::size_t)(*w)*nbComp+j*stepComp]=*srcPt2;
{
const char msg[]="DataArrayTemplate::setPartOfValuesSimple3";
checkAllocated();
- int newNbOfComp(DataArray::GetNumberOfItemGivenBES(bgComp,endComp,stepComp,msg));
- mcIdType nbComp=ToIdType(getNumberOfComponents());
- mcIdType nbOfTuples=ToIdType(getNumberOfTuples());
- DataArray::CheckValueInRangeEx(nbComp,bgComp,endComp,"invalid component value");
+ std::size_t newNbOfComp(DataArray::GetNumberOfItemGivenBES(bgComp,endComp,stepComp,msg));
+ std::size_t nbComp(getNumberOfComponents());
+ mcIdType nbOfTuples(getNumberOfTuples());
+ DataArray::CheckValueInRangeEx(ToIdType(nbComp),bgComp,endComp,"invalid component value");
T *pt(getPointer()+bgComp);
for(const int *w=bgTuples;w!=endTuples;w++)
- for(int j=0;j<newNbOfComp;j++)
+ for(std::size_t j=0;j<newNbOfComp;j++)
{
DataArray::CheckValueInRange(nbOfTuples,*w,"invalid tuple id");
pt[(std::size_t)(*w)*nbComp+j*stepComp]=a;
checkAllocated();
a->checkAllocated();
int newNbOfTuples(DataArray::GetNumberOfItemGivenBES(bgTuples,endTuples,stepTuples,msg));
- int newNbOfComp((int)std::distance(bgComp,endComp));
- mcIdType nbComp=ToIdType(getNumberOfComponents());
+ std::size_t newNbOfComp(std::distance(bgComp,endComp));
+ std::size_t nbComp(getNumberOfComponents());
for(const int *z=bgComp;z!=endComp;z++)
- DataArray::CheckValueInRange(nbComp,*z,"invalid component id");
- mcIdType nbOfTuples=ToIdType(getNumberOfTuples());
+ DataArray::CheckValueInRange(ToIdType(nbComp),*z,"invalid component id");
+ mcIdType nbOfTuples(getNumberOfTuples());
DataArray::CheckValueInRangeEx(nbOfTuples,bgTuples,endTuples,"invalid tuple value");
bool assignTech(true);
- if(a->getNbOfElems()==(std::size_t)newNbOfTuples*newNbOfComp)
+ if(a->getNbOfElems()==newNbOfTuples*newNbOfComp)
{
if(strictCompoCompare)
a->checkNbOfTuplesAndComp(newNbOfTuples,newNbOfComp,msg);
const char msg[]="DataArrayTemplate::setPartOfValuesSimple4";
checkAllocated();
int newNbOfTuples(DataArray::GetNumberOfItemGivenBES(bgTuples,endTuples,stepTuples,msg));
- mcIdType nbComp=ToIdType(getNumberOfComponents());
+ std::size_t nbComp(getNumberOfComponents());
for(const int *z=bgComp;z!=endComp;z++)
- DataArray::CheckValueInRange(nbComp,*z,"invalid component id");
- mcIdType nbOfTuples=ToIdType(getNumberOfTuples());
+ DataArray::CheckValueInRange(ToIdType(nbComp),*z,"invalid component id");
+ mcIdType nbOfTuples(getNumberOfTuples());
DataArray::CheckValueInRangeEx(nbOfTuples,bgTuples,endTuples,"invalid tuple value");
T *pt=getPointer()+bgTuples*nbComp;
for(int i=0;i<newNbOfTuples;i++,pt+=stepTuples*nbComp)
throw INTERP_KERNEL::Exception("DataArrayTemplate::setPartOfValuesAdv : This and a do not have the same number of components !");
if(tuplesSelec->getNumberOfComponents()!=2)
throw INTERP_KERNEL::Exception("DataArrayTemplate::setPartOfValuesAdv : Expecting to have a tuple selector DataArrayInt instance with exactly 2 components !");
- mcIdType thisNt=ToIdType(getNumberOfTuples());
- mcIdType aNt=ToIdType(a->getNumberOfTuples());
+ mcIdType thisNt(getNumberOfTuples());
+ mcIdType aNt(a->getNumberOfTuples());
T *valsToSet(getPointer());
const T *valsSrc(a->getConstPointer());
for(const int *tuple=tuplesSelec->begin();tuple!=tuplesSelec->end();tuple+=2)
throw INTERP_KERNEL::Exception("DataArrayTemplate::setContigPartOfSelectedValues : This and a do not have the same number of components !");
if(tuplesSelec->getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayTemplate::setContigPartOfSelectedValues : Expecting to have a tuple selector DataArrayInt instance with exactly 1 component !");
- mcIdType thisNt=ToIdType(getNumberOfTuples());
- mcIdType aNt=ToIdType(a->getNumberOfTuples());
- mcIdType nbOfTupleToWrite=ToIdType(tuplesSelec->getNumberOfTuples());
+ mcIdType thisNt(getNumberOfTuples());
+ mcIdType aNt(a->getNumberOfTuples());
+ mcIdType nbOfTupleToWrite(tuplesSelec->getNumberOfTuples());
T *valsToSet(getPointer()+tupleIdStart*nbOfComp);
if(tupleIdStart+nbOfTupleToWrite>thisNt)
throw INTERP_KERNEL::Exception("DataArrayTemplate::setContigPartOfSelectedValues : invalid number range of values to write !");
int nbOfTupleToWrite(DataArray::GetNumberOfItemGivenBES(bg,end2,step,msg));
if(nbOfComp!=a->getNumberOfComponents())
throw INTERP_KERNEL::Exception("DataArrayTemplate::setContigPartOfSelectedValuesSlice : This and a do not have the same number of components !");
- mcIdType thisNt=ToIdType(getNumberOfTuples());
- mcIdType aNt=ToIdType(a->getNumberOfTuples());
+ mcIdType thisNt(getNumberOfTuples());
+ mcIdType aNt(a->getNumberOfTuples());
T *valsToSet(getPointer()+tupleIdStart*nbOfComp);
if(tupleIdStart+nbOfTupleToWrite>thisNt)
throw INTERP_KERNEL::Exception("DataArrayTemplate::setContigPartOfSelectedValuesSlice : invalid number range of values to write !");
typename Traits<T>::ArrayType *DataArrayTemplate<T>::mySelectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const
{
checkAllocated();
- mcIdType nbOfComp=ToIdType(getNumberOfComponents());
- mcIdType nbOfTuplesThis=ToIdType(getNumberOfTuples());
+ std::size_t nbOfComp(getNumberOfComponents());
+ mcIdType nbOfTuplesThis(getNumberOfTuples());
if(ranges.empty())
{
MCAuto<DataArray> ret0(buildNewEmptyInstance());
checkAllocated();
if(getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayTemplate::front : number of components not equal to one !");
- mcIdType nbOfTuples=ToIdType(getNumberOfTuples());
+ mcIdType nbOfTuples=getNumberOfTuples();
if(nbOfTuples<1)
throw INTERP_KERNEL::Exception("DataArrayTemplate::front : number of tuples must be >= 1 !");
return *(getConstPointer());
checkAllocated();
if(getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayTemplate::back : number of components not equal to one !");
- mcIdType nbOfTuples=ToIdType(getNumberOfTuples());
+ mcIdType nbOfTuples=getNumberOfTuples();
if(nbOfTuples<1)
throw INTERP_KERNEL::Exception("DataArrayTemplate::back : number of tuples must be >= 1 !");
return *(getConstPointer()+nbOfTuples-1);
checkAllocated();
if(getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayDouble::getMaxValue : must be applied on DataArrayDouble with only one component, you can call 'rearrange' method before or call 'getMaxValueInArray' method !");
- mcIdType nbOfTuples=ToIdType(getNumberOfTuples());
+ mcIdType nbOfTuples=getNumberOfTuples();
if(nbOfTuples<=0)
throw INTERP_KERNEL::Exception("DataArrayDouble::getMaxValue : array exists but number of tuples must be > 0 !");
const T *vals(getConstPointer());
checkAllocated();
if(getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayDouble::getMaxAbsValue : must be applied on DataArrayDouble with only one component, you can call 'rearrange' method before or call 'getMaxValueInArray' method !");
- std::size_t nbTuples(this->getNumberOfTuples());
+ mcIdType nbTuples(this->getNumberOfTuples());
if(nbTuples==0)
throw INTERP_KERNEL::Exception("DataArrayTemplate<T>::getMaxAbsValue : empty array !");
T ret((T)-1);
tupleId=0;
const T *pt(begin());
- for(std::size_t i=0;i<nbTuples;i++,pt++)
+ for(mcIdType i=0;i<nbTuples;i++,pt++)
{
T cand((T)std::abs(*pt));
if(cand>ret)
checkAllocated();
if(getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayDouble::getMinValue : must be applied on DataArrayDouble with only one component, you can call 'rearrange' method before call 'getMinValueInArray' method !");
- mcIdType nbOfTuples=ToIdType(getNumberOfTuples());
+ mcIdType nbOfTuples=getNumberOfTuples();
if(nbOfTuples<=0)
throw INTERP_KERNEL::Exception("DataArrayDouble::getMinValue : array exists but number of tuples must be > 0 !");
const T *vals(getConstPointer());
void DataArrayTemplate<T>::circularPermutation(int nbOfShift)
{
checkAllocated();
- mcIdType nbOfCompo=ToIdType(getNumberOfComponents());
- mcIdType nbTuples=ToIdType(getNumberOfTuples());
+ std::size_t nbOfCompo(getNumberOfComponents());
+ mcIdType nbTuples(getNumberOfTuples());
int effNbSh(EffectiveCircPerm(nbOfShift,nbTuples));
if(effNbSh==0)
return ;
void DataArrayTemplate<T>::circularPermutationPerTuple(int nbOfShift)
{
checkAllocated();
- mcIdType nbOfCompo=ToIdType(getNumberOfComponents());
- mcIdType nbTuples=ToIdType(getNumberOfTuples());
- int effNbSh(EffectiveCircPerm(nbOfShift,nbOfCompo));
+ std::size_t nbOfCompo(getNumberOfComponents());
+ mcIdType nbTuples(getNumberOfTuples());
+ int effNbSh(EffectiveCircPerm(nbOfShift,ToIdType(nbOfCompo)));
if(effNbSh==0)
return ;
T *work(getPointer());
- if(effNbSh<nbOfCompo-effNbSh)
+ if(effNbSh<ToIdType(nbOfCompo)-effNbSh)
{
typename INTERP_KERNEL::AutoPtr<T> buf(new T[effNbSh]);
for(mcIdType i=0;i<nbTuples;i++,work+=nbOfCompo)
}
}
std::vector<std::string> sts(nbOfCompo);
- for(mcIdType i=0;i<nbOfCompo;i++)
+ for(std::size_t i=0;i<nbOfCompo;i++)
sts[i]=_info_on_compo[(i+effNbSh)%nbOfCompo];
setInfoOnComponents(sts);
}
void DataArrayTemplate<T>::reversePerTuple()
{
checkAllocated();
- mcIdType nbOfCompo=ToIdType(getNumberOfComponents());
- mcIdType nbTuples=ToIdType(getNumberOfTuples());
+ std::size_t nbOfCompo(getNumberOfComponents());
+ mcIdType nbTuples(getNumberOfTuples());
if(nbOfCompo<=1)
return ;
T *work(getPointer());
* \throw If \a this is not allocated, or \a compoId is not in [0,\c this->getNumberOfComponents() ).
*/
template<class T>
- void DataArrayTemplateClassic<T>::applyLin(T a, T b, int compoId)
+ void DataArrayTemplateClassic<T>::applyLin(T a, T b, std::size_t compoId)
{
this->checkAllocated();
- T *ptr(this->getPointer()+compoId);
- mcIdType nbOfComp=ToIdType(this->getNumberOfComponents());
- mcIdType nbOfTuple=ToIdType(this->getNumberOfTuples());
- if(compoId<0 || compoId>=nbOfComp)
+ std::size_t nbOfComp=this->getNumberOfComponents();
+ if(compoId>=nbOfComp)
{
std::ostringstream oss; oss << "DataArrayDouble::applyLin : The compoId requested (" << compoId << ") is not valid ! Must be in [0," << nbOfComp << ") !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
+ T *ptr(this->getPointer()+compoId);
+ mcIdType nbOfTuple=this->getNumberOfTuples();
for(mcIdType i=0;i<nbOfTuple;i++,ptr+=nbOfComp)
*ptr=a*(*ptr)+b;
this->declareAsNew();
{
this->checkAllocated();
MCAuto<typename Traits<T>::ArrayType> newArr(Traits<T>::ArrayType::New());
- mcIdType nbOfTuples=ToIdType(this->getNumberOfTuples());
- mcIdType nbOfComp=ToIdType(this->getNumberOfComponents());
+ mcIdType nbOfTuples(this->getNumberOfTuples());
+ std::size_t nbOfComp(this->getNumberOfComponents());
newArr->alloc(nbOfTuples,nbOfComp);
const T *cptr(this->begin());
std::transform(cptr,cptr+nbOfTuples*nbOfComp,newArr->getPointer(),std::negate<T>());
const char *msg="Nb of tuples mismatch for DataArrayDouble::multiplyEqual !";
this->checkAllocated();
other->checkAllocated();
- mcIdType nbOfTuple=ToIdType(this->getNumberOfTuples());
- mcIdType nbOfTuple2=ToIdType(other->getNumberOfTuples());
- mcIdType nbOfComp=ToIdType(this->getNumberOfComponents());
- mcIdType nbOfComp2=ToIdType(other->getNumberOfComponents());
+ mcIdType nbOfTuple(this->getNumberOfTuples());
+ mcIdType nbOfTuple2(other->getNumberOfTuples());
+ std::size_t nbOfComp(this->getNumberOfComponents());
+ std::size_t nbOfComp2(other->getNumberOfComponents());
if(nbOfTuple==nbOfTuple2)
{
if(nbOfComp==nbOfComp2)
{
if(!a1 || !a2)
throw INTERP_KERNEL::Exception("DivSub : input DataArrayDouble instance is NULL !");
- mcIdType nbOfTuple1=ToIdType(a1->getNumberOfTuples());
- mcIdType nbOfTuple2=ToIdType(a2->getNumberOfTuples());
- mcIdType nbOfComp1=ToIdType(a1->getNumberOfComponents());
- mcIdType nbOfComp2=ToIdType(a2->getNumberOfComponents());
+ mcIdType nbOfTuple1(a1->getNumberOfTuples());
+ mcIdType nbOfTuple2(a2->getNumberOfTuples());
+ std::size_t nbOfComp1(a1->getNumberOfComponents());
+ std::size_t nbOfComp2(a2->getNumberOfComponents());
if(nbOfTuple2==nbOfTuple1)
{
if(nbOfComp1==nbOfComp2)
{
if(!a1 || !a2)
throw INTERP_KERNEL::Exception("DataArrayDouble::MulAdd : input DataArrayDouble instance is NULL !");
- mcIdType nbOfTuple=ToIdType(a1->getNumberOfTuples());
- mcIdType nbOfTuple2=ToIdType(a2->getNumberOfTuples());
- mcIdType nbOfComp=ToIdType(a1->getNumberOfComponents());
- mcIdType nbOfComp2=ToIdType(a2->getNumberOfComponents());
+ mcIdType nbOfTuple(a1->getNumberOfTuples());
+ mcIdType nbOfTuple2(a2->getNumberOfTuples());
+ std::size_t nbOfComp(a1->getNumberOfComponents());
+ std::size_t nbOfComp2(a2->getNumberOfComponents());
MCAuto<typename Traits<T>::ArrayType> ret=0;
if(nbOfTuple==nbOfTuple2)
{
}
else
{
- mcIdType nbOfCompMin,nbOfCompMax;
+ std::size_t nbOfCompMin,nbOfCompMax;
const typename Traits<T>::ArrayType *aMin, *aMax;
if(nbOfComp>nbOfComp2)
{
for(it=a.begin();it!=a.end();it++)
(*it)->checkAllocated();
it=a.begin();
- std::size_t nbOfTuples((*it)->getNumberOfTuples());
- std::vector<int> nbc(a.size());
+ mcIdType nbOfTuples((*it)->getNumberOfTuples());
+ std::vector<std::size_t> nbc(a.size());
std::vector<const T *> pts(a.size());
- nbc[0]=ToIdType((*it)->getNumberOfComponents());
+ nbc[0]=(*it)->getNumberOfComponents();
pts[0]=(*it++)->getConstPointer();
for(int i=1;it!=a.end();it++,i++)
{
if(nbOfTuples!=(*it)->getNumberOfTuples())
throw INTERP_KERNEL::Exception("DataArrayDouble::Meld : mismatch of number of tuples !");
- nbc[i]=ToIdType((*it)->getNumberOfComponents());
+ nbc[i]=(*it)->getNumberOfComponents();
pts[i]=(*it)->getConstPointer();
}
- int totalNbOfComp=std::accumulate(nbc.begin(),nbc.end(),0);
+ std::size_t totalNbOfComp=std::accumulate(nbc.begin(),nbc.end(),(std::size_t)0);
typename Traits<T>::ArrayType *ret(Traits<T>::ArrayType::New());
ret->alloc(nbOfTuples,totalNbOfComp);
T *retPtr(ret->getPointer());
- for(std::size_t i=0;i<nbOfTuples;i++)
+ for(mcIdType i=0;i<nbOfTuples;i++)
for(std::size_t j=0;j<a.size();j++)
{
retPtr=std::copy(pts[j],pts[j]+nbc[j],retPtr);
pts[j]+=nbc[j];
}
- int k=0;
- for(int i=0;i<(int)a.size();i++)
- for(int j=0;j<nbc[i];j++,k++)
+ std::size_t k=0;
+ for(std::size_t i=0;i<a.size();i++)
+ for(std::size_t j=0;j<nbc[i];j++,k++)
ret->setInfoOnComponent(k,a[i]->getInfoOnComponent(j));
return ret;
}
{
if(this->_mem.isNull())
throw INTERP_KERNEL::Exception("DataArrayDouble::fromNoInterlace : Not defined array !");
- T *tab(this->_mem.fromNoInterlace(ToIdType(this->getNumberOfComponents())));
+ T *tab(this->_mem.fromNoInterlace(this->getNumberOfComponents()));
MCAuto<typename Traits<T>::ArrayType> ret(Traits<T>::ArrayType::New());
- ret->useArray(tab,true,DeallocType::C_DEALLOC,ToIdType(this->getNumberOfTuples()),ToIdType(this->getNumberOfComponents()));
+ ret->useArray(tab,true,DeallocType::C_DEALLOC,this->getNumberOfTuples(),this->getNumberOfComponents());
return ret.retn();
}
{
if(this->_mem.isNull())
throw INTERP_KERNEL::Exception("DataArrayDouble::toNoInterlace : Not defined array !");
- T *tab(this->_mem.toNoInterlace(ToIdType(this->getNumberOfComponents())));
+ T *tab(this->_mem.toNoInterlace(this->getNumberOfComponents()));
MCAuto<typename Traits<T>::ArrayType> ret(Traits<T>::ArrayType::New());
- ret->useArray(tab,true,DeallocType::C_DEALLOC,ToIdType(this->getNumberOfTuples()),ToIdType(this->getNumberOfComponents()));
+ ret->useArray(tab,true,DeallocType::C_DEALLOC,this->getNumberOfTuples(),this->getNumberOfComponents());
return ret.retn();
}
{
this->checkAllocated();
other->checkAllocated();
- mcIdType nbOfTuples=ToIdType((this->getNumberOfTuples()));
- if(nbOfTuples!=ToIdType(other->getNumberOfTuples()))
+ mcIdType nbOfTuples(this->getNumberOfTuples());
+ if(nbOfTuples!=other->getNumberOfTuples())
throw INTERP_KERNEL::Exception("DataArrayDouble::meldWith : mismatch of number of tuples !");
- mcIdType nbOfComp1=ToIdType(this->getNumberOfComponents());
- mcIdType nbOfComp2=ToIdType(other->getNumberOfComponents());
+ std::size_t nbOfComp1=this->getNumberOfComponents();
+ std::size_t nbOfComp2=other->getNumberOfComponents();
T *newArr=(T *)malloc((nbOfTuples*(nbOfComp1+nbOfComp2))*sizeof(T));
T *w=newArr;
const T *inp1(this->begin()),*inp2(other->begin());
w=std::copy(inp2,inp2+nbOfComp2,w);
}
this->useArray(newArr,true,DeallocType::C_DEALLOC,nbOfTuples,nbOfComp1+nbOfComp2);
- std::vector<int> compIds(nbOfComp2);
- for(int i=0;i<nbOfComp2;i++)
+ std::vector<std::size_t> compIds(nbOfComp2);
+ for(std::size_t i=0;i<nbOfComp2;i++)
compIds[i]=nbOfComp1+i;
this->copyPartOfStringInfoFrom2(compIds,*other);
}
throw INTERP_KERNEL::Exception("DataArrayDouble::duplicateEachTupleNTimes : this should have only one component !");
if(nbTimes<1)
throw INTERP_KERNEL::Exception("DataArrayDouble::duplicateEachTupleNTimes : nb times should be >= 1 !");
- mcIdType nbTuples=ToIdType(this->getNumberOfTuples());
+ mcIdType nbTuples=this->getNumberOfTuples();
const T *inPtr(this->begin());
MCAuto<typename Traits<T>::ArrayType> ret(Traits<T>::ArrayType::New()); ret->alloc(nbTimes*nbTuples,1);
T *retPtr(ret->getPointer());
{
this->checkAllocated();
MCAuto<typename Traits<T>::ArrayType> newArr(Traits<T>::ArrayType::New());
- std::size_t nbOfTuples(this->getNumberOfTuples());
+ mcIdType nbOfTuples(this->getNumberOfTuples());
std::size_t nbOfComp(this->getNumberOfComponents());
newArr->alloc(nbOfTuples,nbOfComp);
std::transform(this->begin(),this->end(),newArr->getPointer(),std::ptr_fun<T,T>(std::abs));
typename Traits<T>::ArrayType *DataArrayTemplateClassic<T>::sumPerTuple() const
{
this->checkAllocated();
- std::size_t nbOfComp(this->getNumberOfComponents()),nbOfTuple(this->getNumberOfTuples());
+ std::size_t nbOfComp(this->getNumberOfComponents());
+ mcIdType nbOfTuple(this->getNumberOfTuples());
MCAuto<typename Traits<T>::ArrayType> ret(Traits<T>::ArrayType::New());
ret->alloc(nbOfTuple,1);
const T *src(this->begin());
T *dest(ret->getPointer());
- for(std::size_t i=0;i<nbOfTuple;i++,dest++,src+=nbOfComp)
+ for(mcIdType i=0;i<nbOfTuple;i++,dest++,src+=nbOfComp)
*dest=std::accumulate(src,src+nbOfComp,(T)0);
return ret.retn();
}
if(this->getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayDouble::iota : works only for arrays with only one component, you can call 'rearrange' method before !");
T *ptr(this->getPointer());
- std::size_t ntuples(this->getNumberOfTuples());
- for(std::size_t i=0;i<ntuples;i++)
+ mcIdType ntuples(this->getNumberOfTuples());
+ for(mcIdType i=0;i<ntuples;i++)
ptr[i]=init+(T)i;
this->declareAsNew();
}
this->checkAllocated();
if(this->getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayInt::switchOnTupleEqualTo : number of components of this should be equal to one !");
- std::size_t nbOfTuples(this->getNumberOfTuples());
+ mcIdType nbOfTuples(this->getNumberOfTuples());
if(nbOfTuples!=vec.size())
throw INTERP_KERNEL::Exception("DataArrayInt::switchOnTupleEqualTo : number of tuples of this should be equal to size of input vector of bool !");
const T *pt(this->begin());
- for(std::size_t i=0;i<nbOfTuples;i++)
+ for(mcIdType i=0;i<nbOfTuples;i++)
if(algo(pt[i],val))
vec[i]=true;
}
this->checkAllocated();
if(this->getNumberOfComponents()!=1 || other.getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayInt::buildPermutationArr : 'this' and 'other' have to have exactly ONE component !");
- mcIdType nbTuple=ToIdType(this->getNumberOfTuples());
+ mcIdType nbTuple(this->getNumberOfTuples());
other.checkAllocated();
- if(nbTuple!=ToIdType(other.getNumberOfTuples()))
+ if(nbTuple!=other.getNumberOfTuples())
throw INTERP_KERNEL::Exception("DataArrayInt::buildPermutationArr : 'this' and 'other' must have the same number of tuple !");
MCAuto<DataArrayIdType> ret(DataArrayIdType::New());
ret->alloc(nbTuple,1);
if(this->getNumberOfComponents()!=1 || partOfThis.getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayInt::indicesOfSubPart : this and input array must be one component array !");
this->checkAllocated(); partOfThis.checkAllocated();
- mcIdType thisNbTuples=ToIdType(this->getNumberOfTuples()),nbTuples=ToIdType(partOfThis.getNumberOfTuples());
+ mcIdType thisNbTuples(this->getNumberOfTuples()),nbTuples(partOfThis.getNumberOfTuples());
const T *thisPt(this->begin()),*pt(partOfThis.begin());
MCAuto<DataArrayIdType> ret(DataArrayIdType::New());
ret->alloc(nbTuples,1);
template<class T>
void DataArrayDiscrete<T>::reprCppStream(const std::string& varName, std::ostream& stream) const
{
- mcIdType nbTuples=ToIdType(this->getNumberOfTuples());
- mcIdType nbComp=ToIdType(this->getNumberOfComponents());
+ mcIdType nbTuples(this->getNumberOfTuples());
+ std::size_t nbComp(this->getNumberOfComponents());
const T *data(this->getConstPointer());
stream << Traits<T>::ArrayTypeName << " *" << varName << "=" << Traits<T>::ArrayTypeName << "::New();" << std::endl;
if(nbTuples*nbComp>=1)
std::size_t nbOfCompo(this->getNumberOfComponents());
if(nbOfCompo>=1)
{
- std::size_t nbOfTuples(this->getNumberOfTuples());
+ mcIdType nbOfTuples(this->getNumberOfTuples());
stream << "Number of tuples : " << nbOfTuples << ". Number of components : " << nbOfCompo << "." << std::endl;
reprQuickOverviewData(stream,MAX_NB_OF_BYTE_IN_REPR);
}
void DataArrayDiscrete<T>::reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const
{
const T *data(this->begin());
- std::size_t nbOfTuples(this->getNumberOfTuples()),nbOfCompo(this->getNumberOfComponents());
+ mcIdType nbOfTuples(this->getNumberOfTuples());
+ std::size_t nbOfCompo(this->getNumberOfComponents());
std::ostringstream oss2; oss2 << "[";
std::string oss2Str(oss2.str());
bool isFinished=true;
if(this->getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("Call transformWithIndArr method on DataArrayInt with only one component, you can call 'rearrange' method before !");
mcIdType nbElemsIn=ToIdType(std::distance(indArrBg,indArrEnd));
- std::size_t nbOfTuples(this->getNumberOfTuples());
+ mcIdType nbOfTuples(this->getNumberOfTuples());
T *pt(this->getPointer());
- for(std::size_t i=0;i<nbOfTuples;i++,pt++)
+ for(mcIdType i=0;i<nbOfTuples;i++,pt++)
{
if(*pt>=0 && *pt<nbElemsIn)
*pt=indArrBg[*pt];
if(this->getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("Call transformWithIndArr method on DataArrayInt with only one component, you can call 'rearrange' method before !");
const typename std::map<T,T>& dat(m.data());
- std::size_t nbOfTuples(this->getNumberOfTuples());
+ mcIdType nbOfTuples(this->getNumberOfTuples());
T *pt(this->getPointer());
- for(std::size_t i=0;i<nbOfTuples;i++,pt++)
+ for(mcIdType i=0;i<nbOfTuples;i++,pt++)
{
typename std::map<T,T>::const_iterator it(dat.find(*pt));
if(it!=dat.end())
throw INTERP_KERNEL::Exception("DataArrayInt::findIdsEqual : the array must have only one component, you can call 'rearrange' method before !");
const T *cptr(this->getConstPointer());
MCAuto<DataArrayIdType> ret(DataArrayIdType::New()); ret->alloc(0,1);
- std::size_t nbOfTuples(this->getNumberOfTuples());
- for(std::size_t i=0;i<nbOfTuples;i++,cptr++)
+ mcIdType nbOfTuples(this->getNumberOfTuples());
+ for(mcIdType i=0;i<nbOfTuples;i++,cptr++)
if(*cptr==val)
ret->pushBackSilent(ToIdType(i));
return ret.retn();
if(this->getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("Call transformWithIndArrR method on DataArrayInt with only one component, you can call 'rearrange' method before !");
mcIdType nbElemsIn=ToIdType(std::distance(indArrBg,indArrEnd));
- mcIdType nbOfTuples=ToIdType(this->getNumberOfTuples());
+ mcIdType nbOfTuples(this->getNumberOfTuples());
const T *pt=this->getConstPointer();
MCAuto<DataArrayIdType> ret=DataArrayIdType::New();
ret->alloc(nbOfTuples,1);
this->checkAllocated();
if(this->getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("Call splitByValueRange method on DataArrayInt with only one component, you can call 'rearrange' method before !");
- std::size_t nbOfTuples=this->getNumberOfTuples();
+ mcIdType nbOfTuples=this->getNumberOfTuples();
std::size_t nbOfCast=std::distance(arrBg,arrEnd);
if(nbOfCast<2)
throw INTERP_KERNEL::Exception("DataArrayInt::splitByValueRange : The input array giving the cast range values should be of size >=2 !");
T *ret1Ptr=ret1->getPointer();
T *ret2Ptr=ret2->getPointer();
std::set<T> castsDetected;
- for(std::size_t i=0;i<nbOfTuples;i++)
+ for(mcIdType i=0;i<nbOfTuples;i++)
{
rintstart res=std::find_if(bg,end2,std::bind2nd(std::less_equal<T>(), work[i]));
std::size_t pos=std::distance(bg,res);
this->checkAllocated();
if(this->getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayInt::isRange : this must be single component array !");
- mcIdType nbTuples=ToIdType(this->getNumberOfTuples());
+ mcIdType nbTuples(this->getNumberOfTuples());
if(nbTuples==0)
{ strt=0; sttoopp=0; stteepp=1; return true; }
const T *pt(this->begin());
{
MCAuto<DataArrayIdType> ret(DataArrayIdType::New());
ret->alloc(newNbOfElem,1);
- mcIdType nbOfOldNodes=ToIdType(this->getNumberOfTuples());
+ mcIdType nbOfOldNodes(this->getNumberOfTuples());
const T *old2New(this->begin());
mcIdType *pt(ret->getPointer());
for(mcIdType i=0;i!=nbOfOldNodes;i++)
const T *new2Old=this->getConstPointer();
mcIdType *pt=ret->getPointer();
std::fill(pt,pt+oldNbOfElem,-1);
- mcIdType nbOfNewElems=ToIdType(this->getNumberOfTuples());
+ mcIdType nbOfNewElems(this->getNumberOfTuples());
for(mcIdType i=0;i<nbOfNewElems;i++)
{
T v(new2Old[i]);
{
MCAuto<DataArrayIdType> ret=DataArrayIdType::New();
ret->alloc(newNbOfElem,1);
- mcIdType nbOfOldNodes=ToIdType(this->getNumberOfTuples());
+ mcIdType nbOfOldNodes(this->getNumberOfTuples());
const T *old2New=this->getConstPointer();
mcIdType *pt=ret->getPointer();
for(mcIdType i=nbOfOldNodes-1;i>=0;i--)
MCAuto< MapKeyVal<T, mcIdType> > ret(MapKeyVal<T, mcIdType>::New());
std::map<T, mcIdType>& m(ret->data());
const T *new2Old(this->begin());
- mcIdType nbOfNewElems=ToIdType(this->getNumberOfTuples());
+ mcIdType nbOfNewElems(this->getNumberOfTuples());
for(mcIdType i=0;i<nbOfNewElems;i++)
{
T v(new2Old[i]);
MCAuto< MapKeyVal<mcIdType, T> > ret(MapKeyVal<mcIdType, T>::New());
std::map<mcIdType,T>& m(ret->data());
const T *new2Old(this->begin());
- mcIdType nbOfNewElems=ToIdType(this->getNumberOfTuples());
+ mcIdType nbOfNewElems(this->getNumberOfTuples());
for(mcIdType i=0;i<nbOfNewElems;i++)
{
T v(new2Old[i]);
this->checkAllocated();
if(this->getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayInt::checkAndPreparePermutation : number of components must == 1 !");
- mcIdType nbTuples=ToIdType(this->getNumberOfTuples());
+ mcIdType nbTuples(this->getNumberOfTuples());
const T *pt=this->getConstPointer();
mcIdType *pt2=this->CheckAndPreparePermutation(pt,pt+nbTuples);
DataArrayIdType *ret=DataArrayIdType::New();
this->checkAllocated();
if(this->getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayInt::changeSurjectiveFormat : number of components must == 1 !");
- mcIdType nbOfTuples=ToIdType(this->getNumberOfTuples());
+ mcIdType nbOfTuples(this->getNumberOfTuples());
const T *input=this->getConstPointer();
std::vector< std::vector<mcIdType> > tmp(targetNb);
for(mcIdType i=0;i<nbOfTuples;i++)
this->checkAllocated();
if(this->getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayInt::buildPermArrPerLevel : number of components must == 1 !");
- std::size_t nbOfTuples=this->getNumberOfTuples();
+ mcIdType nbOfTuples=this->getNumberOfTuples();
const T *pt=this->getConstPointer();
std::map<T,mcIdType> m;
MCAuto<DataArrayIdType> ret=DataArrayIdType::New();
ret->alloc(nbOfTuples,1);
mcIdType *opt=ret->getPointer();
- for(std::size_t i=0;i<nbOfTuples;i++,pt++,opt++)
+ for(mcIdType i=0;i<nbOfTuples;i++,pt++,opt++)
{
T val=*pt;
typename std::map<T,mcIdType>::iterator it=m.find(val);
}
pt=this->getConstPointer();
opt=ret->getPointer();
- for(std::size_t i=0;i<nbOfTuples;i++,pt++,opt++)
+ for(mcIdType i=0;i<nbOfTuples;i++,pt++,opt++)
*opt+=m[*pt];
//
return ret.retn();
this->checkAllocated();
if(this->getNumberOfComponents()!=1)
return false;
- mcIdType nbOfTuples=ToIdType(this->getNumberOfTuples());
+ mcIdType nbOfTuples(this->getNumberOfTuples());
if(nbOfTuples!=sizeExpected)
return false;
const T *pt=this->getConstPointer();
this->checkAllocated();
if(this->getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayInt::hasOnlyUniqueValues: must be applied on DataArrayInt with only one component, you can call 'rearrange' method before !");
- std::size_t nbOfTuples(this->getNumberOfTuples());
+ std::size_t nbOfElements(this->getNumberOfTuples());
std::set<T> s(this->begin(),this->end()); // in C++11, should use unordered_set (O(1) complexity)
- if (s.size() != nbOfTuples)
+ if (s.size() != nbOfElements)
return false;
return true;
}
* \endif
*/
template <class T>
- void DataArrayDiscrete<T>::setSelectedComponents(const DataArrayType *a, const std::vector<mcIdType>& compoIds)
+ void DataArrayDiscrete<T>::setSelectedComponents(const DataArrayType *a, const std::vector<std::size_t>& compoIds)
{
if(!a)
throw INTERP_KERNEL::Exception("DataArrayInt::setSelectedComponents : input DataArrayInt is NULL !");
a->checkAllocated();
this->copyPartOfStringInfoFrom2(compoIds,*a);
std::size_t partOfCompoSz=compoIds.size();
- mcIdType nbOfCompo=ToIdType(this->getNumberOfComponents());
- mcIdType nbOfTuples=ToIdType(std::min(this->getNumberOfTuples(),a->getNumberOfTuples()));
+ std::size_t nbOfCompo = this->getNumberOfComponents();
+ mcIdType nbOfTuples=std::min(this->getNumberOfTuples(),a->getNumberOfTuples());
const T *ac=a->getConstPointer();
T *nc=this->getPointer();
for(mcIdType i=0;i<nbOfTuples;i++)
for(std::size_t j=0;j<partOfCompoSz;j++,ac++)
nc[nbOfCompo*i+compoIds[j]]=*ac;
}
+ template <class T>
+ void DataArrayDiscrete<T>::setSelectedComponents(const DataArrayType *a, const std::vector<mcIdType>& compoIds)
+ {
+ std::vector<std::size_t> ids (compoIds.size());
+ std::copy(compoIds.begin(), compoIds.end(), ids.begin());
+ setSelectedComponents (a, ids);
+ }
/*!
* Creates a new DataArrayInt containing IDs (indices) of tuples holding value \b not
const T *cptr(this->getConstPointer());
MCAuto<DataArrayIdType> ret(DataArrayIdType::New());
ret->alloc(0,1);
- mcIdType nbOfTuples=ToIdType(this->getNumberOfTuples());
+ mcIdType nbOfTuples(this->getNumberOfTuples());
for(mcIdType i=0;i<nbOfTuples;i++,cptr++)
if(*cptr!=val)
ret->pushBackSilent(i);
template <class T>
DataArrayIdType *DataArrayDiscrete<T>::findIdsEqualTuple(const T *tupleBg, const T *tupleEnd) const
{
- mcIdType nbOfCompoExp=ToIdType(std::distance(tupleBg,tupleEnd));
+ std::size_t nbOfCompoExp=std::distance(tupleBg,tupleEnd);
this->checkAllocated();
- if(ToIdType(this->getNumberOfComponents())!=nbOfCompoExp)
+ if(this->getNumberOfComponents()!=nbOfCompoExp)
{
std::ostringstream oss; oss << "DataArrayInt::findIdsEqualTuple : mismatch of number of components. Input tuple has " << nbOfCompoExp << " whereas this array has " << this->getNumberOfComponents() << " components !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
work=std::search(work,end2,tupleBg,tupleEnd);
if(work!=end2)
{
- mcIdType pos=ToIdType(std::distance(bg,work));
+ std::ptrdiff_t pos=std::distance(bg,work);
if(pos%nbOfCompoExp==0)
- ret->pushBackSilent(pos/nbOfCompoExp);
+ ret->pushBackSilent(ToIdType(pos/nbOfCompoExp));
work++;
}
}
throw INTERP_KERNEL::Exception("DataArrayInt::findIdsEqualList : the array must have only one component, you can call 'rearrange' method before !");
std::set<T> vals2(valsBg,valsEnd);
const T *cptr(this->getConstPointer());
- mcIdType nbOfTuples=ToIdType(this->getNumberOfTuples());
+ mcIdType nbOfTuples(this->getNumberOfTuples());
MCAuto<DataArrayIdType> ret(DataArrayIdType::New()); ret->alloc(0,1);
for(mcIdType i=0;i<nbOfTuples;i++,cptr++)
if(vals2.find(*cptr)!=vals2.end())
throw INTERP_KERNEL::Exception("DataArrayInt::findIdsNotEqualList : the array must have only one component, you can call 'rearrange' method before !");
std::set<T> vals2(valsBg,valsEnd);
const T *cptr=this->getConstPointer();
- mcIdType nbOfTuples=ToIdType(this->getNumberOfTuples());
+ mcIdType nbOfTuples(this->getNumberOfTuples());
MCAuto<DataArrayIdType> ret(DataArrayIdType::New()); ret->alloc(0,1);
for(mcIdType i=0;i<nbOfTuples;i++,cptr++)
if(vals2.find(*cptr)==vals2.end())
if(this->getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayInt::presenceOfValue : the array must have only one component, you can call 'rearrange' method before !");
const T *cptr=this->getConstPointer();
- mcIdType nbOfTuples=ToIdType(this->getNumberOfTuples());
+ mcIdType nbOfTuples(this->getNumberOfTuples());
const T *ret=std::find(cptr,cptr+nbOfTuples,value);
if(ret!=cptr+nbOfTuples)
return ToIdType(std::distance(cptr,ret));
throw INTERP_KERNEL::Exception("DataArrayInt::presenceOfValue : the array must have only one component, you can call 'rearrange' method before !");
std::set<T> vals2(vals.begin(),vals.end());
const T *cptr=this->getConstPointer();
- mcIdType nbOfTuples=ToIdType(this->getNumberOfTuples());
+ mcIdType nbOfTuples(this->getNumberOfTuples());
for(const T *w=cptr;w!=cptr+nbOfTuples;w++)
if(vals2.find(*w)!=vals2.end())
return ToIdType(std::distance(cptr,w));
mcIdType DataArrayDiscrete<T>::findIdFirstEqualTuple(const std::vector<T>& tupl) const
{
this->checkAllocated();
- mcIdType nbOfCompo=ToIdType(this->getNumberOfComponents());
+ std::size_t nbOfCompo(this->getNumberOfComponents());
if(nbOfCompo==0)
throw INTERP_KERNEL::Exception("DataArrayInt::findIdFirstEqualTuple : 0 components in 'this' !");
- if(nbOfCompo!=ToIdType(tupl.size()))
+ if(nbOfCompo!=tupl.size())
{
std::ostringstream oss; oss << "DataArrayInt::findIdFirstEqualTuple : 'this' contains " << nbOfCompo << " components and searching for a tuple of length " << tupl.size() << " !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
if(this->getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayInt::count : must be applied on DataArrayInt with only one component, you can call 'rearrange' method before !");
const T *vals=this->begin();
- std::size_t nbOfTuples=this->getNumberOfTuples();
- for(std::size_t i=0;i<nbOfTuples;i++,vals++)
+ std::size_t nbOfElements=this->getNumberOfTuples();
+ for(std::size_t i=0;i<nbOfElements;i++,vals++)
if(*vals==value)
ret++;
return ret;
{
this->checkAllocated();
const T *ptr=this->getConstPointer();
- mcIdType nbTuple=ToIdType(this->getNumberOfTuples());
- mcIdType nbComps=ToIdType(this->getNumberOfComponents());
+ mcIdType nbTuple(this->getNumberOfTuples());
+ std::size_t nbComps(this->getNumberOfComponents());
std::fill(res,res+nbComps,0);
for(mcIdType i=0;i<nbTuple;i++)
std::transform(ptr+i*nbComps,ptr+(i+1)*nbComps,res,res,std::plus<T>());
}
template <class T>
- T DataArrayDiscrete<T>::accumulate(mcIdType compId) const
+ T DataArrayDiscrete<T>::accumulate(std::size_t compId) const
{
this->checkAllocated();
const T *ptr=this->getConstPointer();
- mcIdType nbTuple=ToIdType(this->getNumberOfTuples());
- mcIdType nbComps=ToIdType(this->getNumberOfComponents());
+ mcIdType nbTuple(this->getNumberOfTuples());
+ std::size_t nbComps(this->getNumberOfComponents());
if(compId<0 || compId>=nbComps)
throw INTERP_KERNEL::Exception("DataArrayInt::accumulate : Invalid compId specified : No such nb of components !");
T ret=0;
if(!bgOfIndex || !endOfIndex)
throw INTERP_KERNEL::Exception("DataArrayInt::accumulatePerChunck : input pointer NULL !");
this->checkAllocated();
- mcIdType nbCompo=ToIdType(this->getNumberOfComponents());
- mcIdType nbOfTuples=ToIdType(this->getNumberOfTuples());
+ std::size_t nbCompo(this->getNumberOfComponents());
+ mcIdType nbOfTuples(this->getNumberOfTuples());
mcIdType sz=ToIdType(std::distance(bgOfIndex,endOfIndex));
if(sz<1)
throw INTERP_KERNEL::Exception("DataArrayInt::accumulatePerChunck : invalid size of input index array !");
this->checkAllocated();
if(this->getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayInt::getMinMaxValues : must be applied on DataArrayInt with only one component !");
- std::size_t nbTuples(this->getNumberOfTuples());
+ std::size_t nbElements(this->getNumberOfTuples());
const T *pt(this->begin());
minValue=std::numeric_limits<T>::max(); maxValue=-std::numeric_limits<T>::max();
- for(std::size_t i=0;i<nbTuples;i++,pt++)
+ for(std::size_t i=0;i<nbElements;i++,pt++)
{
if(*pt<minValue)
minValue=*pt;
this->checkAllocated();
if(this->getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayInt::checkAllIdsInRange : this must have exactly one component !");
- mcIdType nbOfTuples=ToIdType(this->getNumberOfTuples());
+ mcIdType nbOfTuples(this->getNumberOfTuples());
bool ret=true;
const T *cptr=this->getConstPointer();
for(mcIdType i=0;i<nbOfTuples;i++,cptr++)
throw INTERP_KERNEL::Exception("DataArrayInt::buildComplement : only single component allowed !");
std::vector<bool> tmp(nbOfElement);
const T *pt=this->getConstPointer();
- std::size_t nbOfTuples=this->getNumberOfTuples();
- for(const T *w=pt;w!=pt+nbOfTuples;w++)
+ std::size_t nbOfElements=this->getNumberOfTuples();
+ for(const T *w=pt;w!=pt+nbOfElements;w++)
if(*w>=0 && *w<nbOfElement)
tmp[*w]=true;
else
if(other->getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayInt::buildSubstraction : only single component allowed for other type !");
const T *pt=this->getConstPointer();
- std::size_t nbOfTuples=this->getNumberOfTuples();
- std::set<T> s1(pt,pt+nbOfTuples);
+ std::size_t nbOfElements=this->getNumberOfTuples();
+ std::set<T> s1(pt,pt+nbOfElements);
pt=other->getConstPointer();
- nbOfTuples=other->getNumberOfTuples();
- std::set<T> s2(pt,pt+nbOfTuples);
+ nbOfElements=other->getNumberOfTuples();
+ std::set<T> s2(pt,pt+nbOfElements);
std::vector<T> r;
std::set_difference(s1.begin(),s1.end(),s2.begin(),s2.end(),std::back_insert_iterator< std::vector<T> >(r));
DataArrayType *ret=DataArrayType::New();
this->checkAllocated();
if(this->getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayInt::buildUnique : only single component allowed !");
- std::size_t nbOfTuples=this->getNumberOfTuples();
+ std::size_t nbOfElements=this->getNumberOfTuples();
MCAuto<DataArrayType> tmp=DataArrayType::New();
tmp->deepCopyFrom (*this);
T *data=tmp->getPointer();
- T *last=std::unique(data,data+nbOfTuples);
+ T *last=std::unique(data,data+nbOfElements);
MCAuto<DataArrayType> ret=DataArrayType::New();
ret->alloc(std::distance(data,last),1);
std::copy(data,last,ret->getPointer());
this->checkAllocated();
if(this->getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayInt::deltaShiftIndex : only single component allowed !");
- std::size_t nbOfTuples=this->getNumberOfTuples();
- if(nbOfTuples<2)
+ std::size_t nbOfElements=this->getNumberOfTuples();
+ if(nbOfElements<2)
throw INTERP_KERNEL::Exception("DataArrayInt::deltaShiftIndex : 1 tuple at least must be present in 'this' !");
const T *ptr=this->getConstPointer();
DataArrayType *ret=DataArrayType::New();
- ret->alloc(nbOfTuples-1,1);
+ ret->alloc(nbOfElements-1,1);
T *out=ret->getPointer();
- std::transform(ptr+1,ptr+nbOfTuples,ptr,out,std::minus<T>());
+ std::transform(ptr+1,ptr+nbOfElements,ptr,out,std::minus<T>());
return ret;
}
this->checkAllocated();
if(this->getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayInt::computeOffsets : only single component allowed !");
- std::size_t nbOfTuples=this->getNumberOfTuples();
- if(nbOfTuples==0)
+ std::size_t nbOfElements=this->getNumberOfTuples();
+ if(nbOfElements==0)
return ;
T *work=this->getPointer();
T tmp=work[0];
work[0]=0;
- for(std::size_t i=1;i<nbOfTuples;i++)
+ for(std::size_t i=1;i<nbOfElements;i++)
{
T tmp2=work[i];
work[i]=work[i-1]+tmp;
this->checkAllocated();
if(this->getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayInt::computeOffsetsFull : only single component allowed !");
- std::size_t nbOfTuples=this->getNumberOfTuples();
- T *ret=(T *)malloc((nbOfTuples+1)*sizeof(T));
+ std::size_t nbOfElements=this->getNumberOfTuples();
+ T *ret=(T *)malloc((nbOfElements+1)*sizeof(T));
const T *work=this->getConstPointer();
ret[0]=0;
- for(std::size_t i=0;i<nbOfTuples;i++)
+ for(std::size_t i=0;i<nbOfElements;i++)
ret[i+1]=work[i]+ret[i];
- this->useArray(ret,true,DeallocType::C_DEALLOC,ToIdType(nbOfTuples)+1,1);
+ this->useArray(ret,true,DeallocType::C_DEALLOC,nbOfElements+1,1);
this->declareAsNew();
}
offsets->checkAllocated();
if(offsets->getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayInt::buildExplicitArrByRanges : input array should have only single component !");
- mcIdType othNbTuples=ToIdType(offsets->getNumberOfTuples())-1;
- mcIdType nbOfTuples=ToIdType(this->getNumberOfTuples());
+ mcIdType othNbTuples=offsets->getNumberOfTuples()-1;
+ mcIdType nbOfTuples=this->getNumberOfTuples();
T retNbOftuples=0;
const T *work=this->getConstPointer();
const T *offPtr=offsets->getConstPointer();
throw INTERP_KERNEL::Exception("DataArrayInt::buildExplicitArrOfSliceOnScaledArr : not allocated array !");
if(this->getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayInt::buildExplicitArrOfSliceOnScaledArr : number of components is expected to be equal to one !");
- mcIdType nbOfTuples = ToIdType(this->getNumberOfTuples());
+ mcIdType nbOfTuples(this->getNumberOfTuples());
if(nbOfTuples==0)
throw INTERP_KERNEL::Exception("DataArrayInt::buildExplicitArrOfSliceOnScaledArr : number of tuples must be != 0 !");
const T *ids(this->begin());
this->checkAllocated();
if(this->getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayInt::findRangeIdForEachTuple : this should have only one component !");
- mcIdType nbTuples=ToIdType(this->getNumberOfTuples());
+ mcIdType nbTuples(this->getNumberOfTuples());
MCAuto<DataArrayIdType> ret=DataArrayIdType::New(); ret->alloc(nbTuples,1);
- mcIdType nbOfRanges=ToIdType(ranges->getNumberOfTuples());
+ mcIdType nbOfRanges(ranges->getNumberOfTuples());
const T *rangesPtr=ranges->getConstPointer();
mcIdType *retPtr=ret->getPointer();
const T *inPtr=this->getConstPointer();
this->checkAllocated();
if(this->getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayInt::findIdInRangeForEachTuple : this should have only one component !");
- std::size_t nbTuples=this->getNumberOfTuples();
+ mcIdType nbTuples=this->getNumberOfTuples();
MCAuto<DataArrayType> ret=DataArrayType::New(); ret->alloc(nbTuples,1);
- std::size_t nbOfRanges=ranges->getNumberOfTuples();
+ mcIdType nbOfRanges=ranges->getNumberOfTuples();
const T *rangesPtr=ranges->getConstPointer();
T *retPtr=ret->getPointer();
const T *inPtr=this->getConstPointer();
- for(std::size_t i=0;i<nbTuples;i++,retPtr++)
+ for(mcIdType i=0;i<nbTuples;i++,retPtr++)
{
T val=inPtr[i];
bool found=false;
- for(std::size_t j=0;j<nbOfRanges && !found;j++)
+ for(mcIdType j=0;j<nbOfRanges && !found;j++)
if(val>=rangesPtr[2*j] && val<rangesPtr[2*j+1])
{ *retPtr=val-rangesPtr[2*j]; found=true; }
if(found)
this->checkAllocated();
if(this->getNumberOfComponents()!=2)
throw INTERP_KERNEL::Exception("DataArrayInt::sortEachPairToMakeALinkedList : Only works on DataArrayInt instance with nb of components equal to 2 !");
- std::size_t nbOfTuples(this->getNumberOfTuples());
+ mcIdType nbOfTuples(this->getNumberOfTuples());
if(nbOfTuples<=1)
return ;
T *conn(this->getPointer());
- for(std::size_t i=1;i<nbOfTuples;i++,conn+=2)
+ for(mcIdType i=1;i<nbOfTuples;i++,conn+=2)
{
if(i>1)
{
{
this->checkAllocated();
this->checkNbOfComps(2,"DataArrayInt::fromLinkedListOfPairToList : this is expected to have 2 components");
- mcIdType nbTuples=ToIdType(this->getNumberOfTuples());
+ mcIdType nbTuples(this->getNumberOfTuples());
if(nbTuples<1)
throw INTERP_KERNEL::Exception("DataArrayInt::fromLinkedListOfPairToList : no tuples in this ! Not a linked list !");
MCAuto<DataArrayType> ret(DataArrayType::New()); ret->alloc(nbTuples+1,1);
throw INTERP_KERNEL::Exception("DataArrayInt::splitInBalancedSlices : this array should have number of components equal to one and must be allocated !");
if(nbOfSlices<=0)
throw INTERP_KERNEL::Exception("DataArrayInt::splitInBalancedSlices : number of slices must be >= 1 !");
- T sum(this->accumulate(0));
- mcIdType nbOfTuples=ToIdType(this->getNumberOfTuples());
+ T sum(this->accumulate((std::size_t)0));
+ mcIdType nbOfTuples(this->getNumberOfTuples());
T sumPerSlc(sum/nbOfSlices);
mcIdType pos(0);
const T *w(this->begin());
throw INTERP_KERNEL::Exception("DataArrayInt::modulusEqual : input DataArrayInt instance is NULL !");
const char *msg="Nb of tuples mismatch for DataArrayInt::modulusEqual !";
this->checkAllocated(); other->checkAllocated();
- mcIdType nbOfTuple=ToIdType(this->getNumberOfTuples());
- mcIdType nbOfTuple2=ToIdType(other->getNumberOfTuples());
- mcIdType nbOfComp=ToIdType(this->getNumberOfComponents());
- mcIdType nbOfComp2=ToIdType(other->getNumberOfComponents());
+ mcIdType nbOfTuple(this->getNumberOfTuples());
+ mcIdType nbOfTuple2(other->getNumberOfTuples());
+ std::size_t nbOfComp(this->getNumberOfComponents());
+ std::size_t nbOfComp2(other->getNumberOfComponents());
if(nbOfTuple==nbOfTuple2)
{
if(nbOfComp==nbOfComp2)
{
if(!other)
throw INTERP_KERNEL::Exception("DataArrayInt::powEqual : input instance is null !");
- std::size_t nbOfTuple=this->getNumberOfTuples();
- std::size_t nbOfTuple2=other->getNumberOfTuples();
+ mcIdType nbOfTuple=this->getNumberOfTuples();
+ mcIdType nbOfTuple2=other->getNumberOfTuples();
std::size_t nbOfComp=this->getNumberOfComponents();
std::size_t nbOfComp2=other->getNumberOfComponents();
if(nbOfTuple!=nbOfTuple2)
throw INTERP_KERNEL::Exception("DataArrayInt::powEqual : number of components of both arrays must be equal to 1 !");
T *ptr=this->getPointer();
const T *ptrc=other->begin();
- for(std::size_t i=0;i<nbOfTuple;i++,ptrc++,ptr++)
+ for(mcIdType i=0;i<nbOfTuple;i++,ptrc++,ptr++)
{
if(*ptrc>=0)
{
tinyInfo.resize(2);
if(this->isAllocated())
{
- tinyInfo[0]=ToIdType(this->getNumberOfTuples());
+ tinyInfo[0]=this->getNumberOfTuples();
tinyInfo[1]=ToIdType(this->getNumberOfComponents());
}
else
{
if(this->isAllocated())
{
- mcIdType nbOfCompo=ToIdType(this->getNumberOfComponents());
+ std::size_t nbOfCompo(this->getNumberOfComponents());
tinyInfo.resize(nbOfCompo+1);
tinyInfo[0]=this->getName();
- for(mcIdType i=0;i<nbOfCompo;i++)
+ for(std::size_t i=0;i<nbOfCompo;i++)
tinyInfo[i+1]=this->getInfoOnComponent(i);
}
else
{
if(!a1 || !a2)
throw INTERP_KERNEL::Exception("DataArrayInt::Pow : at least one of input instances is null !");
- std::size_t nbOfTuple=a1->getNumberOfTuples();
- std::size_t nbOfTuple2=a2->getNumberOfTuples();
+ mcIdType nbOfTuple=a1->getNumberOfTuples();
+ mcIdType nbOfTuple2=a2->getNumberOfTuples();
std::size_t nbOfComp=a1->getNumberOfComponents();
std::size_t nbOfComp2=a2->getNumberOfComponents();
if(nbOfTuple!=nbOfTuple2)
MCAuto<DataArrayType> ret=DataArrayType::New(); ret->alloc(nbOfTuple,1);
const T *ptr1(a1->begin()),*ptr2(a2->begin());
T *ptr=ret->getPointer();
- for(std::size_t i=0;i<nbOfTuple;i++,ptr1++,ptr2++,ptr++)
+ for(mcIdType i=0;i<nbOfTuple;i++,ptr1++,ptr2++,ptr++)
{
if(*ptr2>=0)
{
{
if(!a1 || !a2)
throw INTERP_KERNEL::Exception("DataArrayInt::Modulus : input DataArrayInt instance is NULL !");
- mcIdType nbOfTuple1=ToIdType(a1->getNumberOfTuples());
- mcIdType nbOfTuple2=ToIdType(a2->getNumberOfTuples());
- mcIdType nbOfComp1=ToIdType(a1->getNumberOfComponents());
- mcIdType nbOfComp2=ToIdType(a2->getNumberOfComponents());
+ mcIdType nbOfTuple1(a1->getNumberOfTuples());
+ mcIdType nbOfTuple2(a2->getNumberOfTuples());
+ std::size_t nbOfComp1(a1->getNumberOfComponents());
+ std::size_t nbOfComp2(a2->getNumberOfComponents());
if(nbOfTuple2==nbOfTuple1)
{
if(nbOfComp1==nbOfComp2)
throw INTERP_KERNEL::Exception("DataArrayInt::FindPermutationFromFirstToSecond : the two arrays are not lying on same ids ! Impossible to find a permutation between the 2 arrays !");
MCAuto<DataArrayIdType> p1=ids1->checkAndPreparePermutation();
MCAuto<DataArrayIdType> p2=ids2->checkAndPreparePermutation();
- p2=p2->invertArrayO2N2N2O(ToIdType(p2->getNumberOfTuples()));
+ p2=p2->invertArrayO2N2N2O(p2->getNumberOfTuples());
p2=p2->selectByTupleIdSafe(p1->begin(),p1->end());
return p2.retn();
}
std::size_t nbOfComp(a1->getNumberOfComponents());
if(nbOfComp!=a2->getNumberOfComponents())
throw INTERP_KERNEL::Exception("Nb of components mismatch for array Aggregation !");
- std::size_t nbOfTuple1(a1->getNumberOfTuples()),nbOfTuple2(a2->getNumberOfTuples());
+ mcIdType nbOfTuple1(a1->getNumberOfTuples()),nbOfTuple2(a2->getNumberOfTuples());
MCAuto<DataArrayType> ret(DataArrayType::New());
ret->alloc(nbOfTuple1+nbOfTuple2-offsetA2,nbOfComp);
T *pt=std::copy(a1->begin(),a1->end(),ret->getPointer());
if(a.empty())
throw INTERP_KERNEL::Exception("DataArrayInt::Aggregate : input list must be NON EMPTY !");
typename std::vector<const DataArrayType *>::const_iterator it=a.begin();
- std::size_t nbOfComp((*it)->getNumberOfComponents()),nbt((*it++)->getNumberOfTuples());
+ std::size_t nbOfComp((*it)->getNumberOfComponents());
+ mcIdType nbt((*it++)->getNumberOfTuples());
for(;it!=a.end();it++)
{
if((*it)->getNumberOfComponents()!=nbOfComp)
std::ostringstream oss; oss << "DataArrayInt::AggregateIndexes : presence of a DataArrayInt instance with nb of compo != 1 at pos " << std::distance(arrs.begin(),it4) << " !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- mcIdType nbTupl=ToIdType((*it4)->getNumberOfTuples());
+ mcIdType nbTupl((*it4)->getNumberOfTuples());
if(nbTupl<1)
{
std::ostringstream oss; oss << "DataArrayInt::AggregateIndexes : presence of a DataArrayInt instance with nb of tuples < 1 at pos " << std::distance(arrs.begin(),it4) << " !";
for(typename std::vector<const DataArrayType *>::const_iterator it=a.begin();it!=a.end();it++)
{
const T *pt=(*it)->getConstPointer();
- mcIdType nbOfTuples=ToIdType((*it)->getNumberOfTuples());
+ mcIdType nbOfTuples((*it)->getNumberOfTuples());
r.insert(pt,pt+nbOfTuples);
}
DataArrayType *ret=DataArrayType::New();
for(typename std::vector<const DataArrayType *>::const_iterator it=a.begin();it!=a.end();it++)
{
const T *pt=(*it)->getConstPointer();
- mcIdType nbOfTuples=ToIdType((*it)->getNumberOfTuples());
+ mcIdType nbOfTuples((*it)->getNumberOfTuples());
std::set<T> s1(pt,pt+nbOfTuples);
if(it!=a.begin())
{
std::size_t sz=std::distance(idsOfSelectBg,idsOfSelectEnd);
const T *arrInPtr=arrIn->begin();
const mcIdType *arrIndxPtr=arrIndxIn->begin();
- mcIdType nbOfGrps=ToIdType(arrIndxIn->getNumberOfTuples())-1;
+ mcIdType nbOfGrps=arrIndxIn->getNumberOfTuples()-1;
if(nbOfGrps<0)
throw INTERP_KERNEL::Exception("DataArrayInt::ExtractFromIndexedArrays : The format of \"arrIndxIn\" is invalid ! Its nb of tuples should be >=1 !");
- mcIdType maxSizeOfArr=ToIdType(arrIn->getNumberOfTuples());
+ mcIdType maxSizeOfArr(arrIn->getNumberOfTuples());
MCAuto<DataArrayType> arro=DataArrayType::New();
MCAuto<DataArrayIdType> arrIo=DataArrayIdType::New();
arrIo->alloc(sz+1,1);
mcIdType sz=DataArray::GetNumberOfItemGivenBESRelative(idsOfSelectStart,idsOfSelectStop,idsOfSelectStep,"MEDCouplingUMesh::ExtractFromIndexedArraysSlice : Input slice ");
const T *arrInPtr=arrIn->begin();
const mcIdType *arrIndxPtr=arrIndxIn->begin();
- mcIdType nbOfGrps=ToIdType(arrIndxIn->getNumberOfTuples())-1;
+ mcIdType nbOfGrps=arrIndxIn->getNumberOfTuples()-1;
if(nbOfGrps<0)
throw INTERP_KERNEL::Exception("DataArrayInt::ExtractFromIndexedArraysSlice : The format of \"arrIndxIn\" is invalid ! Its nb of tuples should be >=1 !");
- mcIdType maxSizeOfArr=ToIdType(arrIn->getNumberOfTuples());
+ mcIdType maxSizeOfArr(arrIn->getNumberOfTuples());
MCAuto<DataArrayType> arro=DataArrayType::New();
MCAuto<DataArrayIdType> arrIo=DataArrayIdType::New();
arrIo->alloc(sz+1,1);
throw INTERP_KERNEL::Exception("DataArrayInt::SetPartOfIndexedArrays : presence of null pointer in input parameter !");
MCAuto<DataArrayType> arro=DataArrayType::New();
MCAuto<DataArrayIdType> arrIo=DataArrayIdType::New();
- mcIdType nbOfTuples=ToIdType(arrIndxIn->getNumberOfTuples())-1;
+ mcIdType nbOfTuples=arrIndxIn->getNumberOfTuples()-1;
std::vector<bool> v(nbOfTuples,true);
mcIdType offset=0;
const mcIdType *arrIndxInPtr=arrIndxIn->begin();
throw INTERP_KERNEL::Exception("DataArrayInt::SetPartOfIndexedArraysSlice : presence of null pointer in input parameter !");
MCAuto<DataArrayType> arro=DataArrayType::New();
MCAuto<DataArrayIdType> arrIo=DataArrayIdType::New();
- mcIdType nbOfTuples=ToIdType(arrIndxIn->getNumberOfTuples())-1;
+ mcIdType nbOfTuples=arrIndxIn->getNumberOfTuples()-1;
mcIdType offset=0;
const mcIdType *arrIndxInPtr=arrIndxIn->begin();
const mcIdType *srcArrIndexPtr=srcArrIndex->begin();
{
if(arrInOut==0 || arrIndxIn==0 || srcArr==0 || srcArrIndex==0)
throw INTERP_KERNEL::Exception("DataArrayInt::SetPartOfIndexedArraysSameIdx : presence of null pointer in input parameter !");
- mcIdType nbOfTuples=ToIdType(arrIndxIn->getNumberOfTuples())-1;
+ mcIdType nbOfTuples=arrIndxIn->getNumberOfTuples()-1;
const mcIdType *arrIndxInPtr=arrIndxIn->begin();
const mcIdType *srcArrIndexPtr=srcArrIndex->begin();
T *arrInOutPtr=arrInOut->getPointer();
{
if(arrInOut==0 || arrIndxIn==0 || srcArr==0 || srcArrIndex==0)
throw INTERP_KERNEL::Exception("DataArrayInt::SetPartOfIndexedArraysSameIdxSlice : presence of null pointer in input parameter !");
- mcIdType nbOfTuples=ToIdType(arrIndxIn->getNumberOfTuples())-1;
+ mcIdType nbOfTuples=arrIndxIn->getNumberOfTuples()-1;
const mcIdType *arrIndxInPtr=arrIndxIn->begin();
const mcIdType *srcArrIndexPtr=srcArrIndex->begin();
T *arrInOutPtr=arrInOut->getPointer();
if(offsetForRemoval<0)
throw INTERP_KERNEL::Exception("DataArrayInt::RemoveIdsFromIndexedArrays : offsetForRemoval should be >=0 !");
std::set<T> s(idsToRemoveBg,idsToRemoveEnd);
- mcIdType nbOfGrps=ToIdType(arrIndx->getNumberOfTuples())-1;
+ mcIdType nbOfGrps=arrIndx->getNumberOfTuples()-1;
mcIdType *arrIPtr=arrIndx->getPointer();
*arrIPtr++=0;
mcIdType previousArrI=0;
throw INTERP_KERNEL::Exception("DataArrayChar::meldWith : DataArrayChar pointer in input is NULL !");
checkAllocated();
other->checkAllocated();
- mcIdType nbOfTuples=ToIdType(getNumberOfTuples());
- if(nbOfTuples!=ToIdType(other->getNumberOfTuples()))
+ mcIdType nbOfTuples=getNumberOfTuples();
+ if(nbOfTuples!=other->getNumberOfTuples())
throw INTERP_KERNEL::Exception("DataArrayChar::meldWith : mismatch of number of tuples !");
- mcIdType nbOfComp1=ToIdType(getNumberOfComponents());
- mcIdType nbOfComp2=ToIdType(other->getNumberOfComponents());
+ std::size_t nbOfComp1=getNumberOfComponents();
+ std::size_t nbOfComp2=other->getNumberOfComponents();
char *newArr=(char *)malloc(nbOfTuples*(nbOfComp1+nbOfComp2)*sizeof(char));
char *w=newArr;
const char *inp1=getConstPointer();
w=std::copy(inp2,inp2+nbOfComp2,w);
}
useArray(newArr,true,DeallocType::C_DEALLOC,nbOfTuples,nbOfComp1+nbOfComp2);
- std::vector<int> compIds(nbOfComp2);
- for(int i=0;i<nbOfComp2;i++)
+ std::vector<std::size_t> compIds(nbOfComp2);
+ for(std::size_t i=0;i<nbOfComp2;i++)
compIds[i]=nbOfComp1+i;
copyPartOfStringInfoFrom2(compIds,*other);
}
return 0;
}
-DataArrayByteTuple::DataArrayByteTuple(char *pt, int nbOfComp):_pt(pt),_nb_of_compo(nbOfComp)
+DataArrayByteTuple::DataArrayByteTuple(char *pt, std::size_t nbOfComp):_pt(pt),_nb_of_compo(nbOfComp)
{
}
* This method throws an INTERP_KERNEL::Exception is it is impossible to match sizes of \b this that is too say \b nbOfCompo=this->_nb_of_elem and \bnbOfTuples==1 or
* \b nbOfCompo=1 and \bnbOfTuples==this->_nb_of_elem.
*/
-DataArrayByte *DataArrayByteTuple::buildDAByte(int nbOfTuples, int nbOfCompo) const
+DataArrayByte *DataArrayByteTuple::buildDAByte(std::size_t nbOfTuples, std::size_t nbOfCompo) const
{
if((_nb_of_compo==nbOfCompo && nbOfTuples==1) || (_nb_of_compo==nbOfTuples && nbOfCompo==1))
{
return 0;
}
-DataArrayAsciiCharTuple::DataArrayAsciiCharTuple(char *pt, int nbOfComp):_pt(pt),_nb_of_compo(nbOfComp)
+DataArrayAsciiCharTuple::DataArrayAsciiCharTuple(char *pt, std::size_t nbOfComp):_pt(pt),_nb_of_compo(nbOfComp)
{
}
* This method throws an INTERP_KERNEL::Exception is it is impossible to match sizes of \b this that is too say \b nbOfCompo=this->_nb_of_elem and \bnbOfTuples==1 or
* \b nbOfCompo=1 and \bnbOfTuples==this->_nb_of_elem.
*/
-DataArrayAsciiChar *DataArrayAsciiCharTuple::buildDAAsciiChar(int nbOfTuples, int nbOfCompo) const
+DataArrayAsciiChar *DataArrayAsciiCharTuple::buildDAAsciiChar(std::size_t nbOfTuples, std::size_t nbOfCompo) const
{
if((_nb_of_compo==nbOfCompo && nbOfTuples==1) || (_nb_of_compo==nbOfTuples && nbOfCompo==1))
{
{
}
-DataArrayFloatTuple::DataArrayFloatTuple(float *pt, int nbOfComp):DataArrayTuple<float>(pt,nbOfComp)
+DataArrayFloatTuple::DataArrayFloatTuple(float *pt, std::size_t nbOfComp):DataArrayTuple<float>(pt,nbOfComp)
{
}
* This method throws an INTERP_KERNEL::Exception is it is impossible to match sizes of \b this that is too say \b nbOfCompo=this->_nb_of_elem and \bnbOfTuples==1 or
* \b nbOfCompo=1 and \bnbOfTuples==this->_nb_of_elem.
*/
-DataArrayFloat *DataArrayFloatTuple::buildDAFloat(int nbOfTuples, int nbOfCompo) const
+DataArrayFloat *DataArrayFloatTuple::buildDAFloat(std::size_t nbOfTuples, std::size_t nbOfCompo) const
{
return this->buildDA(nbOfTuples,nbOfCompo);
}
cI->alloc(_super_index->getNbOfElems(),1); // same number of super packs as number of cells
int * cIVecP(cI->getPointer());
MCAuto <DataArrayInt> dsi = _index->deltaShiftIndex();
- int sz = dsi->accumulate(0) + ToIdType(dsi->getNbOfElems()); // think about it: one slot for the type, -1 at the end of each face of the cell
+ int sz = dsi->accumulate((std::size_t)0) + ToIdType(dsi->getNbOfElems()); // think about it: one slot for the type, -1 at the end of each face of the cell
c->alloc(sz, 1);
int * cVecP(c->getPointer());
return ret;
}
-MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::keepSelectedComponents(const std::vector<int>& compoIds) const
+MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::keepSelectedComponents(const std::vector<std::size_t>& compoIds) const
{
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
ret->setArrays(arrays3,0);
return ret;
}
+MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::keepSelectedComponents(const std::vector<mcIdType>& compoIds) const
+{
+ std::vector<std::size_t> ids (compoIds.size());
+ std::copy(compoIds.begin(), compoIds.end(), ids.begin());
+ return keepSelectedComponents(ids);
+}
-void MEDCouplingTimeDiscretization::setSelectedComponents(const MEDCouplingTimeDiscretization *other, const std::vector<int>& compoIds)
+void MEDCouplingTimeDiscretization::setSelectedComponents(const MEDCouplingTimeDiscretization *other, const std::vector<std::size_t>& compoIds)
{
std::vector<DataArrayDouble *> arrays1,arrays2;
getArrays(arrays1);
throw INTERP_KERNEL::Exception("TimeDiscretization::setSelectedComponents : some time array in correspondence are not defined symmetrically !");
}
}
+void MEDCouplingTimeDiscretization::setSelectedComponents(const MEDCouplingTimeDiscretization *other, const std::vector<mcIdType>& compoIds)
+{
+ std::vector<std::size_t> ids (compoIds.size());
+ std::copy(compoIds.begin(), compoIds.end(), ids.begin());
+ setSelectedComponents (other, ids);
+}
-void MEDCouplingTimeDiscretization::changeNbOfComponents(int newNbOfComp, double dftValue)
+void MEDCouplingTimeDiscretization::changeNbOfComponents(std::size_t newNbOfComp, double dftValue)
{
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
MEDCOUPLING_EXPORT virtual MEDCouplingTimeDiscretization *magnitude() const;
MEDCOUPLING_EXPORT virtual MEDCouplingTimeDiscretization *negate() const;
MEDCOUPLING_EXPORT virtual MEDCouplingTimeDiscretization *maxPerTuple() const;
- MEDCOUPLING_EXPORT virtual MEDCouplingTimeDiscretization *keepSelectedComponents(const std::vector<int>& compoIds) const;
- MEDCOUPLING_EXPORT virtual void setSelectedComponents(const MEDCouplingTimeDiscretization *other, const std::vector<int>& compoIds);
- MEDCOUPLING_EXPORT virtual void changeNbOfComponents(int newNbOfComp, double dftValue);
+ MEDCOUPLING_EXPORT virtual MEDCouplingTimeDiscretization *keepSelectedComponents(const std::vector<std::size_t>& compoIds) const;
+ MEDCOUPLING_EXPORT virtual MEDCouplingTimeDiscretization *keepSelectedComponents(const std::vector<mcIdType>& compoIds) const;
+ MEDCOUPLING_EXPORT virtual void setSelectedComponents(const MEDCouplingTimeDiscretization *other, const std::vector<std::size_t>& compoIds);
+ MEDCOUPLING_EXPORT virtual void setSelectedComponents(const MEDCouplingTimeDiscretization *other, const std::vector<mcIdType>& compoIds);
+ MEDCOUPLING_EXPORT virtual void changeNbOfComponents(std::size_t newNbOfComp, double dftValue);
MEDCOUPLING_EXPORT virtual void sortPerTuple(bool asc);
MEDCOUPLING_EXPORT virtual void setUniformValue(int nbOfTuple, int nbOfCompo, double value);
MEDCOUPLING_EXPORT virtual void setOrCreateUniformValueOnAllComponents(int nbOfTuple, double value);
// Localize faces in 2D thanks to barycenters
MCAuto<DataArrayDouble> baryPart = mPartCand->computeCellCenterOfMass();
- vector<int> compo; compo.push_back(2);
+ vector<std::size_t> compo; compo.push_back(2);
MCAuto<DataArrayDouble> baryPartZ = baryPart->keepSelectedComponents(compo);
MCAuto<DataArrayInt> idsGoodPlane = baryPartZ->findIdsInRange(-eps, +eps);
if (!idsGoodPlane->getNumberOfTuples())
// Eliminate all edges for which y or z is not null
MCAuto<DataArrayDouble> baryPart = mPartCand->computeCellCenterOfMass();
- vector<int> compo; compo.push_back(1);
+ vector<std::size_t> compo; compo.push_back(1);
MCAuto<DataArrayDouble> baryPartY = baryPart->keepSelectedComponents(compo);
compo[0] = 2;
MCAuto<DataArrayDouble> baryPartZ = baryPart->keepSelectedComponents(compo);
f1->checkConsistencyLight();
//
const int arr2[6]={1,2,1,2,0,0};
- std::vector<int> arr2V(arr2,arr2+6);
+ std::vector<std::size_t> arr2V(arr2,arr2+6);
MEDCouplingFieldDouble *f2=f1->keepSelectedComponents(arr2V);
CPPUNIT_ASSERT(f2->getMesh()==f1->getMesh());
CPPUNIT_ASSERT(f2->getTimeDiscretization()==ONE_TIME);
CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f2->getIJ(0,i),1e-14);
//setSelectedComponents
const int arr3[2]={3,2};
- std::vector<int> arr3V(arr3,arr3+2);
+ std::vector<std::size_t> arr3V(arr3,arr3+2);
MEDCouplingFieldDouble *f5=f1->keepSelectedComponents(arr3V);
f5->setTime(6.7,8,9);
f5->getArray()->setInfoOnComponent(0,"eeee");
f5->getArray()->setInfoOnComponent(1,"ffff");
f5->checkConsistencyLight();
const int arr4[2]={1,2};
- std::vector<int> arr4V(arr4,arr4+2);
+ std::vector<std::size_t> arr4V(arr4,arr4+2);
f2->setSelectedComponents(f5,arr4V);
CPPUNIT_ASSERT_EQUAL(6,(int)f2->getNumberOfComponents());
CPPUNIT_ASSERT_EQUAL(5,(int)f2->getNumberOfTuples());
{
isPolyh=true;
MCAuto<DataArrayInt> tmp2(cur->computeEffectiveNbOfNodesPerCell());
- szD+=tmp2->accumulate(0)+curNbCells;
+ szD+=tmp2->accumulate((std::size_t)0)+curNbCells;
szF+=2*curNbCells+cur->getNodalConnectivity()->getNumberOfTuples();
}
}