-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2014 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
* See \ref MEDCouplingArrayBasicsName "DataArrays infos" for more information.
* \param [in] name - new array name
*/
-void DataArray::setName(const char *name)
+void DataArray::setName(const std::string& name)
{
_name=name;
}
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
for(std::size_t i=0;i<newNbOfCompo;i++)
- setInfoOnComponent((int)i,other.getInfoOnComponent(compoIds[i]).c_str());
+ setInfoOnComponent((int)i,other.getInfoOnComponent(compoIds[i]));
}
void DataArray::copyPartOfStringInfoFrom2(const std::vector<int>& compoIds, const DataArray& other)
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
for(std::size_t i=0;i<partOfCompoToSet;i++)
- setInfoOnComponent(compoIds[i],other.getInfoOnComponent((int)i).c_str());
+ setInfoOnComponent(compoIds[i],other.getInfoOnComponent((int)i));
}
bool DataArray::areInfoEqualsIfNotWhy(const DataArray& other, std::string& reason) const
stream << "\n";
}
-std::string DataArray::cppRepr(const char *varName) const
+std::string DataArray::cppRepr(const std::string& varName) const
{
std::ostringstream ret;
reprCppStream(varName,ret);
return info.substr(p1+1,p2-p1-1);
}
+/*!
+ * This method put in info format the result of the merge of \a var and \a unit.
+ * The standard format for that is "var [unit]".
+ * Inversely you can retrieve the var part or the unit part of info string using resp. GetVarNameFromInfo and GetUnitFromInfo.
+ */
+std::string DataArray::BuildInfoFromVarAndUnit(const std::string& var, const std::string& unit)
+{
+ std::ostringstream oss;
+ oss << var << " [" << unit << "]";
+ return oss.str();
+}
+
/*!
* Returns a new DataArray by concatenating all given arrays, so that (1) the number
* of tuples in the result array is a sum of the number of tuples of given arrays and (2)
* \param [in] info - the string containing the information.
* \throw If \a i is not a valid component index.
*/
-void DataArray::setInfoOnComponent(int i, const char *info)
+void DataArray::setInfoOnComponent(int i, const std::string& info)
{
if(i<(int)_info_on_compo.size() && i>=0)
_info_on_compo[i]=info;
_info_on_compo=info;
}
-void DataArray::checkNbOfTuples(int nbOfTuples, const char *msg) const
+void DataArray::checkNbOfTuples(int nbOfTuples, const std::string& msg) const
{
if(getNumberOfTuples()!=nbOfTuples)
{
}
}
-void DataArray::checkNbOfComps(int nbOfCompo, const char *msg) const
+void DataArray::checkNbOfComps(int nbOfCompo, const std::string& msg) const
{
if(getNumberOfComponents()!=nbOfCompo)
{
}
}
-void DataArray::checkNbOfElems(std::size_t nbOfElems, const char *msg) const
+void DataArray::checkNbOfElems(std::size_t nbOfElems, const std::string& msg) const
{
if(getNbOfElems()!=nbOfElems)
{
}
}
-void DataArray::checkNbOfTuplesAndComp(const DataArray& other, const char *msg) const
+void DataArray::checkNbOfTuplesAndComp(const DataArray& other, const std::string& msg) const
{
- if(getNumberOfTuples()!=other.getNumberOfTuples())
+ if(getNumberOfTuples()!=other.getNumberOfTuples())
{
std::ostringstream oss; oss << msg << " : mismatch number of tuples : expected " << other.getNumberOfTuples() << " having " << getNumberOfTuples() << " !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
}
-void DataArray::checkNbOfTuplesAndComp(int nbOfTuples, int nbOfCompo, const char *msg) const
+void DataArray::checkNbOfTuplesAndComp(int nbOfTuples, int nbOfCompo, const std::string& msg) const
{
checkNbOfTuples(nbOfTuples,msg);
checkNbOfComps(nbOfCompo,msg);
/*!
* Simply this method checks that \b value is in [0,\b ref).
*/
-void DataArray::CheckValueInRange(int ref, int value, const char *msg)
+void DataArray::CheckValueInRange(int ref, int value, const std::string& msg)
{
if(value<0 || value>=ref)
{
* This method checks that [\b start, \b end) is compliant with ref length \b value.
* typicaly start in [0,\b value) and end in [0,\b value). If value==start and start==end, it is supported.
*/
-void DataArray::CheckValueInRangeEx(int value, int start, int end, const char *msg)
+void DataArray::CheckValueInRangeEx(int value, int start, int end, const std::string& msg)
{
if(start<0 || start>=value)
{
}
}
-void DataArray::CheckClosingParInRange(int ref, int value, const char *msg)
+void DataArray::CheckClosingParInRange(int ref, int value, const std::string& msg)
{
if(value<0 || value>ref)
{
stopSlice=stop;
}
-int DataArray::GetNumberOfItemGivenBES(int begin, int end, int step, const char *msg)
+int DataArray::GetNumberOfItemGivenBES(int begin, int end, int step, const std::string& msg)
{
if(end<begin)
{
return (end-1-begin)/step+1;
}
-int DataArray::GetNumberOfItemGivenBESRelative(int begin, int end, int step, const char *msg)
+int DataArray::GetNumberOfItemGivenBESRelative(int begin, int end, int step, const std::string& msg)
{
if(step==0)
throw INTERP_KERNEL::Exception("DataArray::GetNumberOfItemGivenBES : step=0 is not allowed !");
return ret.str();
}
-void DataArrayDouble::writeVTK(std::ostream& ofs, int indent, const char *nameInFile, DataArrayByte *byteArr) const
+void DataArrayDouble::writeVTK(std::ostream& ofs, int indent, const std::string& nameInFile, DataArrayByte *byteArr) const
{
static const char SPACE[4]={' ',' ',' ',' '};
checkAllocated();
_mem.reprZip(getNumberOfComponents(),stream);
}
-void DataArrayDouble::reprCppStream(const char *varName, std::ostream& stream) const
+void DataArrayDouble::reprCppStream(const std::string& varName, std::ostream& stream) const
{
int nbTuples=getNumberOfTuples(),nbComp=getNumberOfComponents();
const double *data=getConstPointer();
{
DataArrayInt *ret=DataArrayInt::New();
ret->alloc(getNumberOfTuples(),getNumberOfComponents());
- std::size_t nbOfVals=getNbOfElems();
int *dest=ret->getPointer();
- // to make Visual C++ happy : instead of std::copy(src,src+nbOfVals,dest);
+ // to make Visual C++ happy : instead of std::size_t nbOfVals=getNbOfElems(); std::copy(src,src+nbOfVals,dest);
for(const double *src=begin();src!=end();src++,dest++)
*dest=(int)*src;
ret->copyStringInfoFrom(*this);
for(;j<newNbOfComp;j++)
nc[newNbOfComp*i+j]=dftValue;
}
- ret->setName(getName().c_str());
+ ret->setName(getName());
for(int i=0;i<dim;i++)
- ret->setInfoOnComponent(i,getInfoOnComponent(i).c_str());
- ret->setName(getName().c_str());
+ ret->setInfoOnComponent(i,getInfoOnComponent(i));
+ ret->setName(getName());
return ret.retn();
}
* \throw If a component index (\a i) is not valid:
* \a i < 0 || \a i >= \a this->getNumberOfComponents().
*
+ * \if ENABLE_EXAMPLES
* \ref py_mcdataarraydouble_KeepSelectedComponents "Here is a Python example".
+ * \endif
*/
DataArray *DataArrayDouble::keepSelectedComponents(const std::vector<int>& compoIds) const
{
* \throw If \a this is not allocated.
* \throw If \a this and \a other arrays have different number of tuples.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcdataarraydouble_meldwith "Here is a C++ example".
*
* \ref py_mcdataarraydouble_meldwith "Here is a Python example".
+ * \endif
*/
void DataArrayDouble::meldWith(const DataArrayDouble *other)
{
* [ \a commIndex[1], \a commIndex[2] ). \a commIndex->getNumberOfTuples()-1
* gives the number of groups of coincident tuples.
* \throw If \a this is not allocated.
- * \throw If the number of components is not in [1,2,3].
+ * \throw If the number of components is not in [1,2,3,4].
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcdataarraydouble_findcommontuples "Here is a C++ example".
*
* \ref py_mcdataarraydouble_findcommontuples "Here is a Python example".
+ * \endif
* \sa DataArrayInt::BuildOld2NewArrayFromSurjectiveFormat2(), DataArrayDouble::areIncludedInMe
*/
void DataArrayDouble::findCommonTuples(double prec, int limitTupleId, DataArrayInt *&comm, DataArrayInt *&commIndex) const
{
checkAllocated();
int nbOfCompo=getNumberOfComponents();
- if ((nbOfCompo<1) || (nbOfCompo>3)) //test before work
- throw INTERP_KERNEL::Exception("DataArrayDouble::findCommonTuples : Unexpected spacedim of coords. Must be 1, 2 or 3.");
-
+ 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.");
+
int nbOfTuples=getNumberOfTuples();
//
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> c(DataArrayInt::New()),cI(DataArrayInt::New()); c->alloc(0,1); cI->pushBackSilent(0);
switch(nbOfCompo)
- {
+ {
+ case 4:
+ findCommonTuplesAlg<4>(begin(),nbOfTuples,limitTupleId,prec,c,cI);
+ break;
case 3:
findCommonTuplesAlg<3>(begin(),nbOfTuples,limitTupleId,prec,c,cI);
break;
findCommonTuplesAlg<1>(begin(),nbOfTuples,limitTupleId,prec,c,cI);
break;
default:
- throw INTERP_KERNEL::Exception("DataArrayDouble::findCommonTuples : nb of components managed are 1,2 and 3 ! not implemented for other number of components !");
- }
+ throw INTERP_KERNEL::Exception("DataArrayDouble::findCommonTuples : nb of components managed are 1,2,3 and 4 ! not implemented for other number of components !");
+ }
comm=c.retn();
commIndex=cI.retn();
}
double bounds[6];
getMinMaxPerComponent(bounds);
switch(nbOfCompo)
- {
+ {
case 3:
{
double xDelta(fabs(bounds[1]-bounds[0])),yDelta(fabs(bounds[3]-bounds[2])),zDelta(fabs(bounds[5]-bounds[4]));
}
default:
throw INTERP_KERNEL::Exception("Unexpected spacedim of coords for findClosestTupleId. Must be 1, 2 or 3.");
- }
+ }
return ret.retn();
}
const double *thisBBPtr(begin());
int *retPtr(ret->getPointer());
switch(nbOfComp/2)
- {
+ {
case 3:
{
BBTree<3,int> bbt(otherBBoxFrmt->begin(),0,0,otherBBoxFrmt->getNumberOfTuples(),eps);
}
default:
throw INTERP_KERNEL::Exception("DataArrayDouble::computeNbOfInteractionsWith : space dimension supported are [1,2,3] !");
- }
-
+ }
+
return ret.retn();
}
* \return DataArrayDouble * - the new instance of DataArrayDouble that the caller
* is to delete using decrRef() as it is no more needed.
* \throw If \a this is not allocated.
- * \throw If the number of components is not in [1,2,3].
+ * \throw If the number of components is not in [1,2,3,4].
*
+ * \if ENABLE_EXAMPLES
* \ref py_mcdataarraydouble_getdifferentvalues "Here is a Python example".
+ * \endif
*/
DataArrayDouble *DataArrayDouble::getDifferentValues(double prec, int limitTupleId) const
{
* \throw If \a compoIds.size() != \a a->getNumberOfComponents().
* \throw If \a compoIds[i] < 0 or \a compoIds[i] > \a this->getNumberOfComponents().
*
+ * \if ENABLE_EXAMPLES
* \ref py_mcdataarraydouble_setselectedcomponents "Here is a Python example".
+ * \endif
*/
void DataArrayDouble::setSelectedComponents(const DataArrayDouble *a, const std::vector<int>& compoIds)
{
* \throw If \a strictCompoCompare == \a true && \a a->getNumberOfComponents() !=
* \c len(\c range(\a bgComp,\a endComp,\a stepComp)).
*
+ * \if ENABLE_EXAMPLES
* \ref py_mcdataarraydouble_setpartofvalues1 "Here is a Python example".
+ * \endif
*/
void DataArrayDouble::setPartOfValues1(const DataArrayDouble *a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare)
{
* non-empty range of increasing indices or indices are out of a valid range
* for \this array.
*
+ * \if ENABLE_EXAMPLES
* \ref py_mcdataarraydouble_setpartofvaluessimple1 "Here is a Python example".
+ * \endif
*/
void DataArrayDouble::setPartOfValuesSimple1(double a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp)
{
* \throw In the second *mode of usage*, if \a a->getNumberOfTuples() != 1 or
* <em> a->getNumberOfComponents() != (endComp - bgComp)</em>.
*
+ * \if ENABLE_EXAMPLES
* \ref py_mcdataarraydouble_setpartofvalues2 "Here is a Python example".
+ * \endif
*/
void DataArrayDouble::setPartOfValues2(const DataArrayDouble *a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp, bool strictCompoCompare)
{
* \throw If any index of tuple/component given by <em>bgTuples / bgComp</em> is
* out of a valid range for \a this array.
*
+ * \if ENABLE_EXAMPLES
* \ref py_mcdataarraydouble_setpartofvaluessimple2 "Here is a Python example".
+ * \endif
*/
void DataArrayDouble::setPartOfValuesSimple2(double a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp)
{
* non-empty range of increasing indices or indices are out of a valid range
* for \this array.
*
+ * \if ENABLE_EXAMPLES
* \ref py_mcdataarraydouble_setpartofvalues3 "Here is a Python example".
+ * \endif
*/
void DataArrayDouble::setPartOfValues3(const DataArrayDouble *a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare)
{
* non-empty range of increasing indices or indices are out of a valid range
* for \this array.
*
+ * \if ENABLE_EXAMPLES
* \ref py_mcdataarraydouble_setpartofvaluessimple3 "Here is a Python example".
+ * \endif
*/
void DataArrayDouble::setPartOfValuesSimple3(double a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp)
{
int nbOfTuplesOther=other->getNumberOfTuples();
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cArr(DataArrayInt::New()),cIArr(DataArrayInt::New()); cArr->alloc(0,1); cIArr->pushBackSilent(0);
switch(nbOfCompo)
- {
+ {
case 3:
{
BBTreePts<3,int> myTree(begin(),0,0,getNumberOfTuples(),eps);
}
default:
throw INTERP_KERNEL::Exception("Unexpected spacedim of coords for computeTupleIdsNearTuples. Must be 1, 2 or 3.");
- }
+ }
c=cArr.retn(); cI=cIArr.retn();
}
/*!
* Returns the maximum norm of the vector defined by \a this array.
+ * This method works even if the number of components is diferent from one.
+ * If the number of elements in \a this is 0, -1. is returned.
* \return double - the value of the maximum norm, i.e.
- * the maximal absolute value among values of \a this array.
+ * the maximal absolute value among values of \a this array (whatever its number of components).
* \throw If \a this is not allocated.
*/
double DataArrayDouble::normMax() const
{
checkAllocated();
- double ret=-1.;
- std::size_t nbOfElems=getNbOfElems();
- const double *pt=getConstPointer();
+ double ret(-1.);
+ std::size_t nbOfElems(getNbOfElems());
+ const double *pt(getConstPointer());
for(std::size_t i=0;i<nbOfElems;i++,pt++)
{
- double val=std::abs(*pt);
+ double val(std::abs(*pt));
if(val>ret)
ret=val;
}
return ret;
}
+/*!
+ * Returns the minimum norm (absolute value) of the vector defined by \a this array.
+ * This method works even if the number of components is diferent from one.
+ * If the number of elements in \a this is 0, std::numeric_limits<double>::max() is returned.
+ * \return double - the value of the minimum norm, i.e.
+ * the minimal absolute value among values of \a this array (whatever its number of components).
+ * \throw If \a this is not allocated.
+ */
+double DataArrayDouble::normMin() const
+{
+ checkAllocated();
+ double ret(std::numeric_limits<double>::max());
+ std::size_t nbOfElems(getNbOfElems());
+ const double *pt(getConstPointer());
+ for(std::size_t i=0;i<nbOfElems;i++,pt++)
+ {
+ double val(std::abs(*pt));
+ if(val<ret)
+ ret=val;
+ }
+ return ret;
+}
+
/*!
* Accumulates values of each component of \a this array.
* \param [out] res - an array of length \a this->getNumberOfComponents(), allocated
w[1]=wIn[0]*sin(wIn[1]);
w[2]=wIn[2];
}
- ret->setInfoOnComponent(2,getInfoOnComponent(2).c_str());
+ ret->setInfoOnComponent(2,getInfoOnComponent(2));
return ret;
}
const double *src=getConstPointer();
double *dest=ret->getPointer();
switch(getNumberOfComponents())
- {
+ {
case 6:
for(int 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];
default:
ret->decrRef();
throw INTERP_KERNEL::Exception("DataArrayDouble::determinant : Invalid number of components ! must be in 4,6,9 !");
- }
+ }
}
/*!
ret->alloc(nbOfTuple,nbOfComp);
const double *src=getConstPointer();
double *dest=ret->getPointer();
-if(nbOfComp==6)
+ if(nbOfComp==6)
for(int 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];
/*!
* Converts every value of \a this array to its absolute value.
- * \throw If \a this is not allocated.
+ * \b WARNING this method is non const. If a new DataArrayDouble instance should be built containing the result of abs DataArrayDouble::computeAbs
+ * should be called instead.
+ *
+ * \throw If \a this is not allocated.
+ * \sa DataArrayDouble::computeAbs
*/
void DataArrayDouble::abs()
{
checkAllocated();
- double *ptr=getPointer();
- std::size_t nbOfElems=getNbOfElems();
+ double *ptr(getPointer());
+ std::size_t nbOfElems(getNbOfElems());
std::transform(ptr,ptr+nbOfElems,ptr,std::ptr_fun<double,double>(fabs));
declareAsNew();
}
+/*!
+ * This method builds a new instance of \a this object containing the result of std::abs applied of all elements in \a this.
+ * This method is a const method (that do not change any values in \a this) contrary to DataArrayDouble::abs method.
+ *
+ * \return DataArrayDouble * - the new instance of DataArrayDouble containing the
+ * same number of tuples and component as \a this array.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If \a this is not allocated.
+ * \sa DataArrayDouble::abs
+ */
+DataArrayDouble *DataArrayDouble::computeAbs() const
+{
+ checkAllocated();
+ DataArrayDouble *newArr(DataArrayDouble::New());
+ int nbOfTuples(getNumberOfTuples());
+ int nbOfComp(getNumberOfComponents());
+ newArr->alloc(nbOfTuples,nbOfComp);
+ std::transform(begin(),end(),newArr->getPointer(),std::ptr_fun<double,double>(fabs));
+ newArr->copyStringInfoFrom(*this);
+ return newArr;
+}
+
/*!
* Apply a liner function to a given component of \a this array, so that
* an array element <em>(x)</em> becomes \f$ a * x + b \f$.
* \throw If \a this is not allocated.
* \throw If computing \a func fails.
*/
-DataArrayDouble *DataArrayDouble::applyFunc(int nbOfComp, const char *func) const
+DataArrayDouble *DataArrayDouble::applyFunc(int nbOfComp, const std::string& func) const
{
checkAllocated();
INTERP_KERNEL::ExprParser expr(func);
for(int i=0;i<nbOfTuples;i++)
{
try
- {
+ {
expr.evaluateExpr(nbOfComp,ptr+i*oldNbOfComp,ptrToFill+i*nbOfComp);
- }
+ }
catch(INTERP_KERNEL::Exception& e)
- {
+ {
std::ostringstream oss; oss << "For tuple # " << i << " with value (";
std::copy(ptr+oldNbOfComp*i,ptr+oldNbOfComp*(i+1),std::ostream_iterator<double>(oss,", "));
oss << ") : Evaluation of function failed !" << e.what();
newArr->decrRef();
throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
+ }
}
return newArr;
}
* \throw If \a this is not allocated.
* \throw If computing \a func fails.
*/
-DataArrayDouble *DataArrayDouble::applyFunc(const char *func) const
+DataArrayDouble *DataArrayDouble::applyFunc(const std::string& func) const
{
checkAllocated();
INTERP_KERNEL::ExprParser expr(func);
for(int i=0;i<nbOfTuples;i++)
{
try
- {
+ {
expr.evaluateExpr(nbOfComp,ptr+i*nbOfComp,ptrToFill+i*nbOfComp);
- }
+ }
catch(INTERP_KERNEL::Exception& e)
- {
+ {
std::ostringstream oss; oss << "For tuple # " << i << " with value (";
std::copy(ptr+nbOfComp*i,ptr+nbOfComp*(i+1),std::ostream_iterator<double>(oss,", "));
oss << ") : Evaluation of function failed ! " << e.what();
newArr->decrRef();
throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
+ }
}
return newArr;
}
* \throw If \a func contains vars that are not in \a this->getInfoOnComponent().
* \throw If computing \a func fails.
*/
-DataArrayDouble *DataArrayDouble::applyFunc2(int nbOfComp, const char *func) const
+DataArrayDouble *DataArrayDouble::applyFunc2(int nbOfComp, const std::string& func) const
{
checkAllocated();
INTERP_KERNEL::ExprParser expr(func);
for(int i=0;i<nbOfTuples;i++)
{
try
- {
+ {
expr.evaluateExpr(nbOfComp,ptr+i*oldNbOfComp,ptrToFill+i*nbOfComp);
- }
+ }
catch(INTERP_KERNEL::Exception& e)
- {
+ {
std::ostringstream oss; oss << "For tuple # " << i << " with value (";
std::copy(ptr+oldNbOfComp*i,ptr+oldNbOfComp*(i+1),std::ostream_iterator<double>(oss,", "));
oss << ") : Evaluation of function failed !" << e.what();
newArr->decrRef();
throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
+ }
}
return newArr;
}
* \throw If \a func contains vars not in \a varsOrder.
* \throw If computing \a func fails.
*/
-DataArrayDouble *DataArrayDouble::applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const char *func) const
+DataArrayDouble *DataArrayDouble::applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func) const
{
checkAllocated();
INTERP_KERNEL::ExprParser expr(func);
for(int i=0;i<nbOfTuples;i++)
{
try
- {
+ {
expr.evaluateExpr(nbOfComp,ptr+i*oldNbOfComp,ptrToFill+i*nbOfComp);
- }
+ }
catch(INTERP_KERNEL::Exception& e)
- {
+ {
std::ostringstream oss; oss << "For tuple # " << i << " with value (";
std::copy(ptr+oldNbOfComp*i,ptr+oldNbOfComp*(i+1),std::ostream_iterator<double>(oss,", "));
oss << ") : Evaluation of function failed !" << e.what();
newArr->decrRef();
throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
+ }
}
return newArr;
}
-void DataArrayDouble::applyFuncFast32(const char *func)
+void DataArrayDouble::applyFuncFast32(const std::string& func)
{
checkAllocated();
INTERP_KERNEL::ExprParser expr(func);
declareAsNew();
}
-void DataArrayDouble::applyFuncFast64(const char *func)
+void DataArrayDouble::applyFuncFast64(const std::string& func)
{
checkAllocated();
INTERP_KERNEL::ExprParser expr(func);
*
* \sa DataArrayDouble::getIdsNotInRange
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcdataarraydouble_getidsinrange "Here is a C++ example".<br>
* \ref py_mcdataarraydouble_getidsinrange "Here is a Python example".
+ * \endif
*/
DataArrayInt *DataArrayDouble::getIdsInRange(double vmin, double vmax) const
{
* the number of component in the result array is same as that of each of given arrays.
* Info on components is copied from the first of the given arrays. Number of components
* in the given arrays must be the same.
+ * If the number of non null of elements in \a arr is equal to one the returned object is a copy of it
+ * not the object itself.
* \param [in] arr - a sequence of arrays to include in the result array.
* \return DataArrayDouble * - the new instance of DataArrayDouble.
* The caller is to delete this result array using decrRef() as it is no more
int k=0;
for(int i=0;i<(int)a.size();i++)
for(int j=0;j<nbc[i];j++,k++)
- ret->setInfoOnComponent(k,a[i]->getInfoOnComponent(j).c_str());
+ ret->setInfoOnComponent(k,a[i]->getInfoOnComponent(j));
return ret;
}
sum+=a1Ptr[i*nbOfComp+j]*a2Ptr[i*nbOfComp+j];
retPtr[i]=sum;
}
- ret->setInfoOnComponent(0,a1->getInfoOnComponent(0).c_str());
- ret->setName(a1->getName().c_str());
+ ret->setInfoOnComponent(0,a1->getInfoOnComponent(0));
+ ret->setName(a1->getName());
return ret;
}
*/
void DataArrayDouble::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<std::string>& tinyInfoS)
{
- setName(tinyInfoS[0].c_str());
+ setName(tinyInfoS[0]);
if(isAllocated())
{
int nbOfCompo=getNumberOfComponents();
for(int i=0;i<nbOfCompo;i++)
- setInfoOnComponent(i,tinyInfoS[i+1].c_str());
+ setInfoOnComponent(i,tinyInfoS[i+1]);
}
}
return ret.str();
}
-void DataArrayInt::writeVTK(std::ostream& ofs, int indent, const char *type, const char *nameInFile, DataArrayByte *byteArr) const
+void DataArrayInt::writeVTK(std::ostream& ofs, int indent, const std::string& type, const std::string& nameInFile, DataArrayByte *byteArr) const
{
static const char SPACE[4]={' ',' ',' ',' '};
checkAllocated();
_mem.reprZip(getNumberOfComponents(),stream);
}
-void DataArrayInt::reprCppStream(const char *varName, std::ostream& stream) const
+void DataArrayInt::reprCppStream(const std::string& varName, std::ostream& stream) const
{
int nbTuples=getNumberOfTuples(),nbComp=getNumberOfComponents();
const int *data=getConstPointer();
* \throw If any value of \a this is not less than \a arrEnd[-1].
*/
void DataArrayInt::splitByValueRange(const int *arrBg, const int *arrEnd,
- DataArrayInt *& castArr, DataArrayInt *& rankInsideCast, DataArrayInt *& castsPresent) const throw(INTERP_KERNEL::Exception)
-{
+ DataArrayInt *& castArr, DataArrayInt *& rankInsideCast, DataArrayInt *& castsPresent) const
+ {
checkAllocated();
if(getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("Call splitByValueRange method on DataArrayInt with only one component, you can call 'rearrange' method before !");
castArr=ret1.retn();
rankInsideCast=ret2.retn();
castsPresent=ret3.retn();
-}
+ }
/*!
* Creates a one-dimensional DataArrayInt (\a res) whose contents are computed from
* The caller is to delete this result array using decrRef() as it is no more
* needed.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcdataarrayint_invertarrayo2n2n2o "Here is a C++ example".<br>
* \ref py_mcdataarrayint_invertarrayo2n2n2o "Here is a Python example".
+ * \endif
*/
DataArrayInt *DataArrayInt::invertArrayO2N2N2O(int newNbOfElem) const
{
* The caller is to delete this result array using decrRef() as it is no more
* needed.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcdataarrayint_invertarrayn2o2o2n "Here is a C++ example".
*
* \ref py_mcdataarrayint_invertarrayn2o2o2n "Here is a Python example".
+ * \endif
*/
DataArrayInt *DataArrayInt::invertArrayN2O2O2N(int oldNbOfElem) const
{
{
int v(new2Old[i]);
if(v>=0 && v<oldNbOfElem)
- pt[v]=i;
+ pt[v]=i;
else
{
std::ostringstream oss; oss << "DataArrayInt::invertArrayN2O2O2N : in new id #" << i << " old value is " << v << " expected to be in [0," << oldNbOfElem << ") !";
checkAllocated();
if(getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayInt::isFittingWith : number of components of this should be equal to one !");
- int nbOfTuples(getNumberOfTuples());
const int *w(begin()),*end2(end());
int refVal=-std::numeric_limits<int>::max();
int i=0;
* \throw If \a this->getNumberOfTuples() != \a other->getNumberOfTuples().
* \throw If \a other includes a value which is not in \a this array.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcdataarrayint_buildpermutationarr "Here is a C++ example".
*
* \ref py_mcdataarrayint_buildpermutationarr "Here is a Python example".
+ * \endif
*/
DataArrayInt *DataArrayInt::buildPermutationArr(const DataArrayInt& other) const
{
for(;j<newNbOfComp;j++)
nc[newNbOfComp*i+j]=dftValue;
}
- ret->setName(getName().c_str());
+ ret->setName(getName());
for(int i=0;i<dim;i++)
- ret->setInfoOnComponent(i,getInfoOnComponent(i).c_str());
- ret->setName(getName().c_str());
+ ret->setInfoOnComponent(i,getInfoOnComponent(i));
+ ret->setName(getName());
return ret.retn();
}
* \throw If a component index (\a i) is not valid:
* \a i < 0 || \a i >= \a this->getNumberOfComponents().
*
+ * \if ENABLE_EXAMPLES
* \ref py_mcdataarrayint_keepselectedcomponents "Here is a Python example".
+ * \endif
*/
DataArray *DataArrayInt::keepSelectedComponents(const std::vector<int>& compoIds) const
{
* \throw If \a this is not allocated.
* \throw If \a this and \a other arrays have different number of tuples.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcdataarrayint_meldwith "Here is a C++ example".
*
* \ref py_mcdataarrayint_meldwith "Here is a Python example".
+ * \endif
*/
void DataArrayInt::meldWith(const DataArrayInt *other)
{
* \throw If \a compoIds.size() != \a a->getNumberOfComponents().
* \throw If \a compoIds[i] < 0 or \a compoIds[i] > \a this->getNumberOfComponents().
*
+ * \if ENABLE_EXAMPLES
* \ref py_mcdataarrayint_setselectedcomponents "Here is a Python example".
+ * \endif
*/
void DataArrayInt::setSelectedComponents(const DataArrayInt *a, const std::vector<int>& compoIds)
{
* \throw If \a strictCompoCompare == \a true && \a a->getNumberOfComponents() !=
* \c len(\c range(\a bgComp,\a endComp,\a stepComp)).
*
+ * \if ENABLE_EXAMPLES
* \ref py_mcdataarrayint_setpartofvalues1 "Here is a Python example".
+ * \endif
*/
void DataArrayInt::setPartOfValues1(const DataArrayInt *a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare)
{
* non-empty range of increasing indices or indices are out of a valid range
* for \this array.
*
+ * \if ENABLE_EXAMPLES
* \ref py_mcdataarrayint_setpartofvaluessimple1 "Here is a Python example".
+ * \endif
*/
void DataArrayInt::setPartOfValuesSimple1(int a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp)
{
* \throw In the second *mode of usage*, if \a a->getNumberOfTuples() != 1 or
* <em> a->getNumberOfComponents() != (endComp - bgComp)</em>.
*
+ * \if ENABLE_EXAMPLES
* \ref py_mcdataarrayint_setpartofvalues2 "Here is a Python example".
+ * \endif
*/
void DataArrayInt::setPartOfValues2(const DataArrayInt *a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp, bool strictCompoCompare)
{
* \throw If any index of tuple/component given by <em>bgTuples / bgComp</em> is
* out of a valid range for \a this array.
*
+ * \if ENABLE_EXAMPLES
* \ref py_mcdataarrayint_setpartofvaluessimple2 "Here is a Python example".
+ * \endif
*/
void DataArrayInt::setPartOfValuesSimple2(int a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp)
{
* non-empty range of increasing indices or indices are out of a valid range
* for \this array.
*
+ * \if ENABLE_EXAMPLES
* \ref py_mcdataarrayint_setpartofvalues3 "Here is a Python example".
+ * \endif
*/
void DataArrayInt::setPartOfValues3(const DataArrayInt *a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare)
{
* non-empty range of increasing indices or indices are out of a valid range
* for \this array.
*
+ * \if ENABLE_EXAMPLES
* \ref py_mcdataarrayint_setpartofvaluessimple3 "Here is a Python example".
+ * \endif
*/
void DataArrayInt::setPartOfValuesSimple3(int a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp)
{
* array using decrRef() as it is no more needed.
* \throw If \a this is not allocated.
* \throw If \a this->getNumberOfComponents() != 1.
+ * \sa DataArrayInt::getIdsEqualTuple
*/
DataArrayInt *DataArrayInt::getIdsEqual(int val) const
{
checkAllocated();
if(getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayInt::getIdsEqual : the array must have only one component, you can call 'rearrange' method before !");
- const int *cptr=getConstPointer();
+ const int *cptr(getConstPointer());
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret(DataArrayInt::New()); ret->alloc(0,1);
int nbOfTuples=getNumberOfTuples();
for(int i=0;i<nbOfTuples;i++,cptr++)
checkAllocated();
if(getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayInt::getIdsNotEqual : the array must have only one component, you can call 'rearrange' method before !");
- const int *cptr=getConstPointer();
+ const int *cptr(getConstPointer());
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret(DataArrayInt::New()); ret->alloc(0,1);
int nbOfTuples=getNumberOfTuples();
for(int i=0;i<nbOfTuples;i++,cptr++)
return ret.retn();
}
+/*!
+ * Creates a new DataArrayInt containing IDs (indices) of tuples holding tuple equal to those defined by [ \a tupleBg , \a tupleEnd )
+ * This method is an extension of DataArrayInt::getIdsEqual method.
+ *
+ * \param [in] tupleBg - the begin (included) of the input tuple to find within \a this.
+ * \param [in] tupleEnd - the end (excluded) of the input tuple to find within \a this.
+ * \return DataArrayInt * - a new instance of DataArrayInt. The caller is to delete this
+ * array using decrRef() as it is no more needed.
+ * \throw If \a this is not allocated.
+ * \throw If \a this->getNumberOfComponents() != std::distance(tupleBg,tupleEnd).
+ * \throw If \a this->getNumberOfComponents() is equal to 0.
+ * \sa DataArrayInt::getIdsEqual
+ */
+DataArrayInt *DataArrayInt::getIdsEqualTuple(const int *tupleBg, const int *tupleEnd) const
+{
+ std::size_t nbOfCompoExp(std::distance(tupleBg,tupleEnd));
+ checkAllocated();
+ if(getNumberOfComponents()!=(int)nbOfCompoExp)
+ {
+ std::ostringstream oss; oss << "DataArrayInt::getIdsEqualTuple : mismatch of number of components. Input tuple has " << nbOfCompoExp << " whereas this array has " << getNumberOfComponents() << " components !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ if(nbOfCompoExp==0)
+ throw INTERP_KERNEL::Exception("DataArrayInt::getIdsEqualTuple : number of components should be > 0 !");
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret(DataArrayInt::New()); ret->alloc(0,1);
+ const int *bg(begin()),*end2(end()),*work(begin());
+ while(work!=end2)
+ {
+ work=std::search(work,end2,tupleBg,tupleEnd);
+ if(work!=end2)
+ {
+ std::size_t pos(std::distance(bg,work));
+ if(pos%nbOfCompoExp==0)
+ ret->pushBackSilent(pos/nbOfCompoExp);
+ work++;
+ }
+ }
+ return ret.retn();
+}
/*!
* Assigns \a newValue to all elements holding \a oldValue within \a this
* the number of component in the result array is same as that of each of given arrays.
* Info on components is copied from the first of the given arrays. Number of components
* in the given arrays must be the same.
+ * If the number of non null of elements in \a arr is equal to one the returned object is a copy of it
+ * not the object itself.
* \param [in] arr - a sequence of arrays to include in the result array.
* \return DataArrayInt * - the new instance of DataArrayInt.
* The caller is to delete this result array using decrRef() as it is no more
/*!
* Converts every value of \a this array to its absolute value.
- * \throw If \a this is not allocated.
+ * \b WARNING this method is non const. If a new DataArrayInt instance should be built containing the result of abs DataArrayInt::computeAbs
+ * should be called instead.
+ *
+ * \throw If \a this is not allocated.
+ * \sa DataArrayInt::computeAbs
*/
void DataArrayInt::abs()
{
checkAllocated();
- int *ptr=getPointer();
- std::size_t nbOfElems=getNbOfElems();
+ int *ptr(getPointer());
+ std::size_t nbOfElems(getNbOfElems());
std::transform(ptr,ptr+nbOfElems,ptr,std::ptr_fun<int,int>(std::abs));
declareAsNew();
}
+/*!
+ * This method builds a new instance of \a this object containing the result of std::abs applied of all elements in \a this.
+ * This method is a const method (that do not change any values in \a this) contrary to DataArrayInt::abs method.
+ *
+ * \return DataArrayInt * - the new instance of DataArrayInt containing the
+ * same number of tuples and component as \a this array.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If \a this is not allocated.
+ * \sa DataArrayInt::abs
+ */
+DataArrayInt *DataArrayInt::computeAbs() const
+{
+ checkAllocated();
+ DataArrayInt *newArr(DataArrayInt::New());
+ int nbOfTuples(getNumberOfTuples());
+ int nbOfComp(getNumberOfComponents());
+ newArr->alloc(nbOfTuples,nbOfComp);
+ std::transform(begin(),end(),newArr->getPointer(),std::ptr_fun<int,int>(std::abs));
+ newArr->copyStringInfoFrom(*this);
+ return newArr;
+}
+
/*!
* Apply a liner function to a given component of \a this array, so that
* an array element <em>(x)</em> becomes \f$ a * x + b \f$.
int k=0;
for(int i=0;i<(int)a.size();i++)
for(int j=0;j<nbc[i];j++,k++)
- ret->setInfoOnComponent(k,a[i]->getInfoOnComponent(j).c_str());
+ ret->setInfoOnComponent(k,a[i]->getInfoOnComponent(j));
return ret;
}
else
r=s1;
}
- DataArrayInt *ret=DataArrayInt::New();
+ DataArrayInt *ret(DataArrayInt::New());
ret->alloc((int)r.size(),1);
std::copy(r.begin(),r.end(),ret->getPointer());
return ret;
}
+/// @cond INTERNAL
+namespace ParaMEDMEMImpl
+{
+ class OpSwitchedOn
+ {
+ public:
+ OpSwitchedOn(int *pt):_pt(pt),_cnt(0) { }
+ void operator()(const bool& b) { if(b) *_pt++=_cnt; _cnt++; }
+ private:
+ int *_pt;
+ int _cnt;
+ };
+
+ class OpSwitchedOff
+ {
+ public:
+ OpSwitchedOff(int *pt):_pt(pt),_cnt(0) { }
+ void operator()(const bool& b) { if(!b) *_pt++=_cnt; _cnt++; }
+ private:
+ int *_pt;
+ int _cnt;
+ };
+}
+/// @endcond
+
+/*!
+ * This method returns the list of ids in ascending mode so that v[id]==true.
+ */
+DataArrayInt *DataArrayInt::BuildListOfSwitchedOn(const std::vector<bool>& v)
+{
+ int sz((int)std::count(v.begin(),v.end(),true));
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret(DataArrayInt::New()); ret->alloc(sz,1);
+ std::for_each(v.begin(),v.end(),ParaMEDMEMImpl::OpSwitchedOn(ret->getPointer()));
+ return ret.retn();
+}
+
+/*!
+ * This method returns the list of ids in ascending mode so that v[id]==false.
+ */
+DataArrayInt *DataArrayInt::BuildListOfSwitchedOff(const std::vector<bool>& v)
+{
+ int sz((int)std::count(v.begin(),v.end(),false));
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret(DataArrayInt::New()); ret->alloc(sz,1);
+ std::for_each(v.begin(),v.end(),ParaMEDMEMImpl::OpSwitchedOff(ret->getPointer()));
+ return ret.retn();
+}
+
+/*!
+ * This method allows to put a vector of vector of integer into a more compact data stucture (skyline).
+ * This method is not available into python because no available optimized data structure available to map std::vector< std::vector<int> >.
+ *
+ * \param [in] v the input data structure to be translate into skyline format.
+ * \param [out] data the first element of the skyline format. The user is expected to deal with newly allocated array.
+ * \param [out] dataIndex the second element of the skyline format.
+ */
+void DataArrayInt::PutIntoToSkylineFrmt(const std::vector< std::vector<int> >& v, DataArrayInt *& data, DataArrayInt *& dataIndex)
+{
+ int sz((int)v.size());
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret0(DataArrayInt::New()),ret1(DataArrayInt::New());
+ ret1->alloc(sz+1,1);
+ int *pt(ret1->getPointer()); *pt=0;
+ for(int i=0;i<sz;i++,pt++)
+ pt[1]=pt[0]+(int)v[i].size();
+ ret0->alloc(ret1->back(),1);
+ pt=ret0->getPointer();
+ for(int i=0;i<sz;i++)
+ pt=std::copy(v[i].begin(),v[i].end(),pt);
+ data=ret0.retn(); dataIndex=ret1.retn();
+}
+
/*!
* Returns a new DataArrayInt which contains a complement of elements of \a this
* one-dimensional array. I.e. the result array contains all elements from the range [0,
*/
DataArrayInt *DataArrayInt::buildComplement(int nbOfElement) const
{
- checkAllocated();
- if(getNumberOfComponents()!=1)
- throw INTERP_KERNEL::Exception("DataArrayInt::buildComplement : only single component allowed !");
- std::vector<bool> tmp(nbOfElement);
- const int *pt=getConstPointer();
- int nbOfTuples=getNumberOfTuples();
- for(const int *w=pt;w!=pt+nbOfTuples;w++)
- if(*w>=0 && *w<nbOfElement)
- tmp[*w]=true;
- else
- throw INTERP_KERNEL::Exception("DataArrayInt::buildComplement : an element is not in valid range : [0,nbOfElement) !");
- int nbOfRetVal=(int)std::count(tmp.begin(),tmp.end(),false);
- DataArrayInt *ret=DataArrayInt::New();
- ret->alloc(nbOfRetVal,1);
- int j=0;
- int *retPtr=ret->getPointer();
- for(int i=0;i<nbOfElement;i++)
- if(!tmp[i])
- retPtr[j++]=i;
- return ret;
+ checkAllocated();
+ if(getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("DataArrayInt::buildComplement : only single component allowed !");
+ std::vector<bool> tmp(nbOfElement);
+ const int *pt=getConstPointer();
+ int nbOfTuples=getNumberOfTuples();
+ for(const int *w=pt;w!=pt+nbOfTuples;w++)
+ if(*w>=0 && *w<nbOfElement)
+ tmp[*w]=true;
+ else
+ throw INTERP_KERNEL::Exception("DataArrayInt::buildComplement : an element is not in valid range : [0,nbOfElement) !");
+ int nbOfRetVal=(int)std::count(tmp.begin(),tmp.end(),false);
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc(nbOfRetVal,1);
+ int j=0;
+ int *retPtr=ret->getPointer();
+ for(int i=0;i<nbOfElement;i++)
+ if(!tmp[i])
+ retPtr[j++]=i;
+ return ret;
}
/*!
checkAllocated();
other->checkAllocated();
if(getNumberOfComponents()!=1)
- throw INTERP_KERNEL::Exception("DataArrayInt::buildSubstraction : only single component allowed !");
+ throw INTERP_KERNEL::Exception("DataArrayInt::buildSubstraction : only single component allowed !");
if(other->getNumberOfComponents()!=1)
- throw INTERP_KERNEL::Exception("DataArrayInt::buildSubstraction : only single component allowed for other type !");
+ throw INTERP_KERNEL::Exception("DataArrayInt::buildSubstraction : only single component allowed for other type !");
const int *pt=getConstPointer();
int nbOfTuples=getNumberOfTuples();
std::set<int> s1(pt,pt+nbOfTuples);
{
checkAllocated();
if(getNumberOfComponents()!=1)
- throw INTERP_KERNEL::Exception("DataArrayInt::buildUnique : only single component allowed !");
+ throw INTERP_KERNEL::Exception("DataArrayInt::buildUnique : only single component allowed !");
int nbOfTuples=getNumberOfTuples();
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=deepCpy();
int *data=tmp->getPointer();
{
checkAllocated();
if(getNumberOfComponents()!=1)
- throw INTERP_KERNEL::Exception("DataArrayInt::deltaShiftIndex : only single component allowed !");
+ throw INTERP_KERNEL::Exception("DataArrayInt::deltaShiftIndex : only single component allowed !");
int nbOfTuples=getNumberOfTuples();
if(nbOfTuples<2)
throw INTERP_KERNEL::Exception("DataArrayInt::deltaShiftIndex : 1 tuple at least must be present in 'this' !");
{
checkAllocated();
if(getNumberOfComponents()!=1)
- throw INTERP_KERNEL::Exception("DataArrayInt::computeOffsets : only single component allowed !");
+ throw INTERP_KERNEL::Exception("DataArrayInt::computeOffsets : only single component allowed !");
int nbOfTuples=getNumberOfTuples();
if(nbOfTuples==0)
return ;
throw INTERP_KERNEL::Exception("DataArrayInt::buildExplicitArrByRanges : DataArrayInt pointer in input is NULL !");
checkAllocated();
if(getNumberOfComponents()!=1)
- throw INTERP_KERNEL::Exception("DataArrayInt::buildExplicitArrByRanges : only single component allowed !");
+ throw INTERP_KERNEL::Exception("DataArrayInt::buildExplicitArrByRanges : only single component allowed !");
offsets->checkAllocated();
if(offsets->getNumberOfComponents()!=1)
- throw INTERP_KERNEL::Exception("DataArrayInt::buildExplicitArrByRanges : input array should have only single component !");
+ throw INTERP_KERNEL::Exception("DataArrayInt::buildExplicitArrByRanges : input array should have only single component !");
int othNbTuples=offsets->getNumberOfTuples()-1;
int nbOfTuples=getNumberOfTuples();
int retNbOftuples=0;
* \throw If \a this->getNumberOfComponents() != 1.
* \throw If \a this->getNumberOfTuples() == 0.
* \throw If \a this is not monotonically increasing.
- * \throw If any element of ids in ( \a gb \a end \a step ) points outside the scale in \a this.
+ * \throw If any element of ids in ( \a bg \a stop \a step ) points outside the scale in \a this.
*
* \b Example: <br>
- * - \a bg , \a end and \a step : (0,5,2)
+ * - \a bg , \a stop and \a step : (0,5,2)
* - \a this: [0,3,6,10,14,20]
* - result array: [0,0,0, 2,2,2,2, 4,4,4,4,4,4] == <br>
*/
-DataArrayInt *DataArrayInt::buildExplicitArrOfSliceOnScaledArr(int bg, int end, int step) const
+DataArrayInt *DataArrayInt::buildExplicitArrOfSliceOnScaledArr(int bg, int stop, int step) const
{
if(!isAllocated())
throw INTERP_KERNEL::Exception("DataArrayInt::buildExplicitArrOfSliceOnScaledArr : not allocated array !");
if(nbOfTuples==0)
throw INTERP_KERNEL::Exception("DataArrayInt::buildExplicitArrOfSliceOnScaledArr : number of tuples must be != 0 !");
const int *ids(begin());
- int nbOfEltsInSlc(GetNumberOfItemGivenBESRelative(bg,end,step,"DataArrayInt::buildExplicitArrOfSliceOnScaledArr")),sz(0),pos(bg);
+ int nbOfEltsInSlc(GetNumberOfItemGivenBESRelative(bg,stop,step,"DataArrayInt::buildExplicitArrOfSliceOnScaledArr")),sz(0),pos(bg);
for(int i=0;i<nbOfEltsInSlc;i++,pos+=step)
{
if(pos>=0 && pos<nbOfTuples-1)
*/
DataArrayInt *DataArrayInt::Modulus(const DataArrayInt *a1, const DataArrayInt *a2)
{
- if(!a1 || !a2)
+ if(!a1 || !a2)
throw INTERP_KERNEL::Exception("DataArrayInt::Modulus : input DataArrayInt instance is NULL !");
int nbOfTuple1=a1->getNumberOfTuples();
int nbOfTuple2=a2->getNumberOfTuples();
*/
void DataArrayInt::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<std::string>& tinyInfoS)
{
- setName(tinyInfoS[0].c_str());
+ setName(tinyInfoS[0]);
if(isAllocated())
{
int nbOfCompo=tinyInfoI[1];
for(int i=0;i<nbOfCompo;i++)
- setInfoOnComponent(i,tinyInfoS[i+1].c_str());
+ setInfoOnComponent(i,tinyInfoS[i+1]);
}
}