return _mem.isEqual(other._mem,prec,tmp);
}
-/*!
- * Returns a new DataArrayDouble holding the same values as \a this array but differently
- * arranged in memory. If \a this array holds 2 components of 3 values:
- * \f$ x_0,x_1,x_2,y_0,y_1,y_2 \f$, then the result array holds these values arranged
- * as follows: \f$ x_0,y_0,x_1,y_1,x_2,y_2 \f$.
- * \warning Do not confuse this method with transpose()!
- * \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.
- */
-DataArrayDouble *DataArrayDouble::fromNoInterlace() const
-{
- if(_mem.isNull())
- throw INTERP_KERNEL::Exception("DataArrayDouble::fromNoInterlace : Not defined array !");
- double *tab=_mem.fromNoInterlace(getNumberOfComponents());
- DataArrayDouble *ret=DataArrayDouble::New();
- ret->useArray(tab,true,C_DEALLOC,getNumberOfTuples(),getNumberOfComponents());
- return ret;
-}
-
-/*!
- * Returns a new DataArrayDouble holding the same values as \a this array but differently
- * arranged in memory. If \a this array holds 2 components of 3 values:
- * \f$ x_0,y_0,x_1,y_1,x_2,y_2 \f$, then the result array holds these values arranged
- * as follows: \f$ x_0,x_1,x_2,y_0,y_1,y_2 \f$.
- * \warning Do not confuse this method with transpose()!
- * \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.
- */
-DataArrayDouble *DataArrayDouble::toNoInterlace() const
-{
- if(_mem.isNull())
- throw INTERP_KERNEL::Exception("DataArrayDouble::toNoInterlace : Not defined array !");
- double *tab=_mem.toNoInterlace(getNumberOfComponents());
- DataArrayDouble *ret=DataArrayDouble::New();
- ret->useArray(tab,true,C_DEALLOC,getNumberOfTuples(),getNumberOfComponents());
- return ret;
-}
-
-/*!
- * Appends components of another array to components of \a this one, tuple by tuple.
- * So that the number of tuples of \a this array remains the same and the number of
- * components increases.
- * \param [in] other - the DataArrayDouble to append to \a this one.
- * \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)
-{
- checkAllocated();
- other->checkAllocated();
- int nbOfTuples=getNumberOfTuples();
- if(nbOfTuples!=other->getNumberOfTuples())
- throw INTERP_KERNEL::Exception("DataArrayDouble::meldWith : mismatch of number of tuples !");
- int nbOfComp1=getNumberOfComponents();
- int nbOfComp2=other->getNumberOfComponents();
- double *newArr=(double *)malloc((nbOfTuples*(nbOfComp1+nbOfComp2))*sizeof(double));
- double *w=newArr;
- const double *inp1=getConstPointer();
- const double *inp2=other->getConstPointer();
- for(int i=0;i<nbOfTuples;i++,inp1+=nbOfComp1,inp2+=nbOfComp2)
- {
- w=std::copy(inp1,inp1+nbOfComp1,w);
- w=std::copy(inp2,inp2+nbOfComp2,w);
- }
- useArray(newArr,true,C_DEALLOC,nbOfTuples,nbOfComp1+nbOfComp2);
- std::vector<int> compIds(nbOfComp2);
- for(int i=0;i<nbOfComp2;i++)
- compIds[i]=nbOfComp1+i;
- copyPartOfStringInfoFrom2(compIds,*other);
-}
-
/*!
* This method checks that all tuples in \a other are in \a this.
* If true, the output param \a tupleIds contains the tuples ids of \a this that correspond to tupes in \a this.
commIndex=cI.retn();
}
-/*!
- *
- * \param [in] nbTimes specifies the nb of times each tuples in \a this will be duplicated contiguouly in returned DataArrayDouble instance.
- * \a nbTimes should be at least equal to 1.
- * \return a newly allocated DataArrayDouble having one component and number of tuples equal to \a nbTimes * \c this->getNumberOfTuples.
- * \throw if \a this is not allocated or if \a this has not number of components set to one or if \a nbTimes is lower than 1.
- */
-DataArrayDouble *DataArrayDouble::duplicateEachTupleNTimes(int nbTimes) const
-{
- checkAllocated();
- if(getNumberOfComponents()!=1)
- 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 !");
- int nbTuples=getNumberOfTuples();
- const double *inPtr=getConstPointer();
- MCAuto<DataArrayDouble> ret=DataArrayDouble::New(); ret->alloc(nbTimes*nbTuples,1);
- double *retPtr=ret->getPointer();
- for(int i=0;i<nbTuples;i++,inPtr++)
- {
- double val=*inPtr;
- for(int j=0;j<nbTimes;j++,retPtr++)
- *retPtr=val;
- }
- ret->copyStringInfoFrom(*this);
- return ret.retn();
-}
-
/*!
* This methods returns the minimal distance between the two set of points \a this and \a other.
* So \a this and \a other have to have the same number of components. If not an INTERP_KERNEL::Exception will be thrown.
nc[nbOfCompo*i+compoIds[j]]=*ac;
}
-void DataArrayDouble::SetArrayIn(DataArrayDouble *newArray, DataArrayDouble* &arrayToSet)
-{
- if(newArray!=arrayToSet)
- {
- if(arrayToSet)
- arrayToSet->decrRef();
- arrayToSet=newArray;
- if(arrayToSet)
- arrayToSet->incrRef();
- }
-}
-
-void DataArrayDouble::aggregate(const DataArrayDouble *other)
-{
- if(!other)
- throw INTERP_KERNEL::Exception("DataArrayDouble::aggregate : null pointer !");
- if(getNumberOfComponents()!=other->getNumberOfComponents())
- throw INTERP_KERNEL::Exception("DataArrayDouble::aggregate : mismatch number of components !");
- _mem.insertAtTheEnd(other->begin(),other->end());
-}
-
/*!
* Checks if 0.0 value is present in \a this array. If it is the case, an exception
* is thrown.
return ret.retn();
}
-void DataArrayInt::aggregate(const DataArrayInt *other)
-{
- if(!other)
- throw INTERP_KERNEL::Exception("DataArrayInt::aggregate : null pointer !");
- if(getNumberOfComponents()!=other->getNumberOfComponents())
- throw INTERP_KERNEL::Exception("DataArrayInt::aggregate : mismatch number of components !");
- _mem.insertAtTheEnd(other->begin(),other->end());
-}
-
-/*!
- * Returns a new DataArrayInt holding the same values as \a this array but differently
- * arranged in memory. If \a this array holds 2 components of 3 values:
- * \f$ x_0,x_1,x_2,y_0,y_1,y_2 \f$, then the result array holds these values arranged
- * as follows: \f$ x_0,y_0,x_1,y_1,x_2,y_2 \f$.
- * \warning Do not confuse this method with transpose()!
- * \return DataArrayInt * - the new instance of DataArrayInt that the caller
- * is to delete using decrRef() as it is no more needed.
- * \throw If \a this is not allocated.
- */
-DataArrayInt *DataArrayInt::fromNoInterlace() const
-{
- checkAllocated();
- if(_mem.isNull())
- throw INTERP_KERNEL::Exception("DataArrayInt::fromNoInterlace : Not defined array !");
- int *tab=_mem.fromNoInterlace(getNumberOfComponents());
- DataArrayInt *ret=DataArrayInt::New();
- ret->useArray(tab,true,C_DEALLOC,getNumberOfTuples(),getNumberOfComponents());
- return ret;
-}
-
-/*!
- * Returns a new DataArrayInt holding the same values as \a this array but differently
- * arranged in memory. If \a this array holds 2 components of 3 values:
- * \f$ x_0,y_0,x_1,y_1,x_2,y_2 \f$, then the result array holds these values arranged
- * as follows: \f$ x_0,x_1,x_2,y_0,y_1,y_2 \f$.
- * \warning Do not confuse this method with transpose()!
- * \return DataArrayInt * - the new instance of DataArrayInt that the caller
- * is to delete using decrRef() as it is no more needed.
- * \throw If \a this is not allocated.
- */
-DataArrayInt *DataArrayInt::toNoInterlace() const
-{
- checkAllocated();
- if(_mem.isNull())
- throw INTERP_KERNEL::Exception("DataArrayInt::toNoInterlace : Not defined array !");
- int *tab=_mem.toNoInterlace(getNumberOfComponents());
- DataArrayInt *ret=DataArrayInt::New();
- ret->useArray(tab,true,C_DEALLOC,getNumberOfTuples(),getNumberOfComponents());
- return ret;
-}
-
/*!
* Returns a new DataArrayInt containing a renumbering map in "Old to New" mode.
* This map, if applied to \a this array, would make it sorted. For example, if
return true;
}
-/*!
- * Appends components of another array to components of \a this one, tuple by tuple.
- * So that the number of tuples of \a this array remains the same and the number of
- * components increases.
- * \param [in] other - the DataArrayInt to append to \a this one.
- * \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)
-{
- if(!other)
- throw INTERP_KERNEL::Exception("DataArrayInt::meldWith : DataArrayInt pointer in input is NULL !");
- checkAllocated();
- other->checkAllocated();
- int nbOfTuples=getNumberOfTuples();
- if(nbOfTuples!=other->getNumberOfTuples())
- throw INTERP_KERNEL::Exception("DataArrayInt::meldWith : mismatch of number of tuples !");
- int nbOfComp1=getNumberOfComponents();
- int nbOfComp2=other->getNumberOfComponents();
- int *newArr=(int *)malloc(nbOfTuples*(nbOfComp1+nbOfComp2)*sizeof(int));
- int *w=newArr;
- const int *inp1=getConstPointer();
- const int *inp2=other->getConstPointer();
- for(int i=0;i<nbOfTuples;i++,inp1+=nbOfComp1,inp2+=nbOfComp2)
- {
- w=std::copy(inp1,inp1+nbOfComp1,w);
- w=std::copy(inp2,inp2+nbOfComp2,w);
- }
- useArray(newArr,true,C_DEALLOC,nbOfTuples,nbOfComp1+nbOfComp2);
- std::vector<int> compIds(nbOfComp2);
- for(int i=0;i<nbOfComp2;i++)
- compIds[i]=nbOfComp1+i;
- copyPartOfStringInfoFrom2(compIds,*other);
-}
-
/*!
* Copy all components in a specified order from another DataArrayInt.
* The specified components become the first ones in \a this array.
nc[nbOfCompo*i+compoIds[j]]=*ac;
}
-/*!
- * Assign pointer to one array to a pointer to another appay. Reference counter of
- * \a arrayToSet is incremented / decremented.
- * \param [in] newArray - the pointer to array to assign to \a arrayToSet.
- * \param [in,out] arrayToSet - the pointer to array to assign to.
- */
-void DataArrayInt::SetArrayIn(DataArrayInt *newArray, DataArrayInt* &arrayToSet)
-{
- if(newArray!=arrayToSet)
- {
- if(arrayToSet)
- arrayToSet->decrRef();
- arrayToSet=newArray;
- if(arrayToSet)
- arrayToSet->incrRef();
- }
-}
-
DataArrayIntIterator *DataArrayInt::iterator()
{
return new DataArrayIntIterator(this);
return ret;
}
-/*!
- *
- * \param [in] nbTimes specifies the nb of times each tuples in \a this will be duplicated contiguouly in returned DataArrayInt instance.
- * \a nbTimes should be at least equal to 1.
- * \return a newly allocated DataArrayInt having one component and number of tuples equal to \a nbTimes * \c this->getNumberOfTuples.
- * \throw if \a this is not allocated or if \a this has not number of components set to one or if \a nbTimes is lower than 1.
- */
-DataArrayInt *DataArrayInt::duplicateEachTupleNTimes(int nbTimes) const
-{
- checkAllocated();
- if(getNumberOfComponents()!=1)
- throw INTERP_KERNEL::Exception("DataArrayInt::duplicateEachTupleNTimes : this should have only one component !");
- if(nbTimes<1)
- throw INTERP_KERNEL::Exception("DataArrayInt::duplicateEachTupleNTimes : nb times should be >= 1 !");
- int nbTuples=getNumberOfTuples();
- const int *inPtr=getConstPointer();
- MCAuto<DataArrayInt> ret=DataArrayInt::New(); ret->alloc(nbTimes*nbTuples,1);
- int *retPtr=ret->getPointer();
- for(int i=0;i<nbTuples;i++,inPtr++)
- {
- int val=*inPtr;
- for(int j=0;j<nbTimes;j++,retPtr++)
- *retPtr=val;
- }
- ret->copyStringInfoFrom(*this);
- return ret.retn();
-}
-
/*!
* This method returns all different values found in \a this. This method throws if \a this has not been allocated.
* But the number of components can be different from one.
T getMaxValueInArray() const;
T getMinValue(int& tupleId) const;
T getMinValueInArray() const;
+ MEDCOUPLING_EXPORT void getTuple(int tupleId, T *res) const { std::copy(_mem.getConstPointerLoc(tupleId*_info_on_compo.size()),_mem.getConstPointerLoc((tupleId+1)*_info_on_compo.size()),res); }
+ template<class InputIterator>
+ void insertAtTheEnd(InputIterator first, InputIterator last);
+ MEDCOUPLING_EXPORT static void SetArrayIn(typename Traits<T>::ArrayType *newArray, typename Traits<T>::ArrayType* &arrayToSet);
+ MEDCOUPLING_EXPORT void writeOnPlace(std::size_t id, T element0, const T *others, int sizeOfOthers) { _mem.writeOnPlace(id,element0,others,sizeOfOthers); }
public:
MEDCOUPLING_EXPORT MemArray<T>& accessToMemArray() { return _mem; }
MEDCOUPLING_EXPORT const MemArray<T>& accessToMemArray() const { return _mem; }
MEDCOUPLING_EXPORT MCAuto<DataArrayInt> findIdsLowerOrEqualTo(T val) const;
MEDCOUPLING_EXPORT MCAuto<DataArrayInt> findIdsLowerThan(T val) const;
MEDCOUPLING_EXPORT DataArrayInt *findIdsStrictlyNegative() const;
+ MEDCOUPLING_EXPORT typename Traits<T>::ArrayType *fromNoInterlace() const;
+ MEDCOUPLING_EXPORT typename Traits<T>::ArrayType *toNoInterlace() const;
+ MEDCOUPLING_EXPORT void meldWith(const typename Traits<T>::ArrayType *other);
+ MEDCOUPLING_EXPORT typename Traits<T>::ArrayType *duplicateEachTupleNTimes(int nbTimes) const;
+ MEDCOUPLING_EXPORT void aggregate(const typename Traits<T>::ArrayType *other);
protected:
static typename Traits<T>::ArrayType *PerformCopyOrIncrRef(bool dCpy, const typename Traits<T>::ArrayType& self);
template<class OP>
MEDCOUPLING_EXPORT bool isEqual(const DataArrayDouble& other, double prec) const;
MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const DataArrayDouble& other, double prec, std::string& reason) const;
MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const DataArrayDouble& other, double prec) const;
- MEDCOUPLING_EXPORT DataArrayDouble *fromNoInterlace() const;
- MEDCOUPLING_EXPORT DataArrayDouble *toNoInterlace() const;
MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplateFP<double>::mySelectByTupleId(new2OldBg,new2OldEnd); }
MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleId(const DataArrayInt& di) const { return DataArrayTemplateFP<double>::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 *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 void meldWith(const DataArrayDouble *other);
MEDCOUPLING_EXPORT bool areIncludedInMe(const DataArrayDouble *other, double prec, DataArrayInt *&tupleIds) const;
MEDCOUPLING_EXPORT void findCommonTuples(double prec, int limitTupleId, DataArrayInt *&comm, DataArrayInt *&commIndex) const;
MEDCOUPLING_EXPORT double minimalDistanceTo(const DataArrayDouble *other, int& thisTupleId, int& otherTupleId) const;
- MEDCOUPLING_EXPORT DataArrayDouble *duplicateEachTupleNTimes(int nbTimes) const;
MEDCOUPLING_EXPORT DataArrayDouble *getDifferentValues(double prec, int limitTupleId=-1) const;
MEDCOUPLING_EXPORT DataArrayInt *findClosestTupleId(const DataArrayDouble *other) const;
MEDCOUPLING_EXPORT DataArrayInt *computeNbOfInteractionsWith(const DataArrayDouble *otherBBoxFrmt, double eps) const;
MEDCOUPLING_EXPORT void setSelectedComponents(const DataArrayDouble *a, const std::vector<int>& compoIds);
- MEDCOUPLING_EXPORT void getTuple(int tupleId, double *res) const { std::copy(_mem.getConstPointerLoc(tupleId*_info_on_compo.size()),_mem.getConstPointerLoc((tupleId+1)*_info_on_compo.size()),res); }
- MEDCOUPLING_EXPORT static void SetArrayIn(DataArrayDouble *newArray, DataArrayDouble* &arrayToSet);
MEDCOUPLING_EXPORT DataArrayDoubleIterator *iterator();
- template<class InputIterator>
- void insertAtTheEnd(InputIterator first, InputIterator last);
- MEDCOUPLING_EXPORT void aggregate(const DataArrayDouble *other);
- MEDCOUPLING_EXPORT void writeOnPlace(std::size_t id, double element0, const double *others, int sizeOfOthers) { _mem.writeOnPlace(id,element0,others,sizeOfOthers); }
MEDCOUPLING_EXPORT void checkNoNullValues() const;
MEDCOUPLING_EXPORT void getMinMaxPerComponent(double *bounds) const;
MEDCOUPLING_EXPORT DataArrayDouble *computeBBoxPerTuple(double epsilon=0.0) const;
MEDCOUPLING_EXPORT DataArrayInt *invertArrayO2N2N2O(int newNbOfElem) const;
MEDCOUPLING_EXPORT DataArrayInt *invertArrayN2O2O2N(int oldNbOfElem) const;
MEDCOUPLING_EXPORT DataArrayInt *invertArrayO2N2N2OBis(int newNbOfElem) const;
- MEDCOUPLING_EXPORT DataArrayInt *fromNoInterlace() const;
- MEDCOUPLING_EXPORT DataArrayInt *toNoInterlace() const;
MEDCOUPLING_EXPORT DataArrayInt *selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplate<int>::mySelectByTupleId(new2OldBg,new2OldEnd); }
MEDCOUPLING_EXPORT DataArrayInt *selectByTupleId(const DataArrayInt& di) const { return DataArrayTemplate<int>::mySelectByTupleId(di); }
MEDCOUPLING_EXPORT DataArrayInt *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplate<int>::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); }
MEDCOUPLING_EXPORT bool isIota(int sizeExpected) const;
MEDCOUPLING_EXPORT bool isUniform(int val) const;
MEDCOUPLING_EXPORT bool hasUniqueValues() const;
- MEDCOUPLING_EXPORT void meldWith(const DataArrayInt *other);
MEDCOUPLING_EXPORT void setSelectedComponents(const DataArrayInt *a, const std::vector<int>& compoIds);
- MEDCOUPLING_EXPORT void getTuple(int tupleId, int *res) const { std::copy(_mem.getConstPointerLoc(tupleId*_info_on_compo.size()),_mem.getConstPointerLoc((tupleId+1)*_info_on_compo.size()),res); }
- MEDCOUPLING_EXPORT static void SetArrayIn(DataArrayInt *newArray, DataArrayInt* &arrayToSet);
MEDCOUPLING_EXPORT DataArrayIntIterator *iterator();
MEDCOUPLING_EXPORT DataArrayInt *findIdsEqual(int val) const;
MEDCOUPLING_EXPORT DataArrayInt *findIdsNotEqual(int val) const;
MEDCOUPLING_EXPORT DataArrayInt *findIdInRangeForEachTuple(const DataArrayInt *ranges) const;
MEDCOUPLING_EXPORT void sortEachPairToMakeALinkedList();
MEDCOUPLING_EXPORT MCAuto<DataArrayInt> fromLinkedListOfPairToList() const;
- MEDCOUPLING_EXPORT DataArrayInt *duplicateEachTupleNTimes(int nbTimes) const;
MEDCOUPLING_EXPORT DataArrayInt *getDifferentValues() const;
MEDCOUPLING_EXPORT std::vector<DataArrayInt *> partitionByDifferentValues(std::vector<int>& differentIds) const;
MEDCOUPLING_EXPORT std::vector< std::pair<int,int> > splitInBalancedSlices(int nbOfSlices) const;
- template<class InputIterator>
- void insertAtTheEnd(InputIterator first, InputIterator last);
- MEDCOUPLING_EXPORT void aggregate(const DataArrayInt *other);
- MEDCOUPLING_EXPORT void writeOnPlace(std::size_t id, int element0, const int *others, int sizeOfOthers) { _mem.writeOnPlace(id,element0,others,sizeOfOthers); }
MEDCOUPLING_EXPORT static DataArrayInt *Modulus(const DataArrayInt *a1, const DataArrayInt *a2);
MEDCOUPLING_EXPORT void modulusEqual(const DataArrayInt *other);
MEDCOUPLING_EXPORT static DataArrayInt *Pow(const DataArrayInt *a1, const DataArrayInt *a2);
MEDCOUPLING_EXPORT bool isUniform(char val) const;
MEDCOUPLING_EXPORT void meldWith(const DataArrayChar *other);
MEDCOUPLING_EXPORT DataArray *selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const { return DataArrayTemplate<char>::mySelectByTupleRanges(ranges); }
- MEDCOUPLING_EXPORT void getTuple(int tupleId, char *res) const { std::copy(_mem.getConstPointerLoc(tupleId*_info_on_compo.size()),_mem.getConstPointerLoc((tupleId+1)*_info_on_compo.size()),res); }
MEDCOUPLING_EXPORT DataArrayInt *findIdsEqual(char val) const;
MEDCOUPLING_EXPORT DataArrayInt *findIdsNotEqual(char val) const;
MEDCOUPLING_EXPORT int findIdSequence(const std::vector<char>& vals) const;
MEDCOUPLING_EXPORT static DataArrayChar *Aggregate(const std::vector<const DataArrayChar *>& arr);
MEDCOUPLING_EXPORT static DataArrayChar *Meld(const DataArrayChar *a1, const DataArrayChar *a2);
MEDCOUPLING_EXPORT static DataArrayChar *Meld(const std::vector<const DataArrayChar *>& arr);
- template<class InputIterator>
- void insertAtTheEnd(InputIterator first, InputIterator last);
MEDCOUPLING_EXPORT MemArray<char>& accessToMemArray() { return _mem; }
MEDCOUPLING_EXPORT const MemArray<char>& accessToMemArray() const { return _mem; }
public:
pointer[_nb_of_elem++]=*first++;
}
}
-
- template<class InputIterator>
- void DataArrayDouble::insertAtTheEnd(InputIterator first, InputIterator last)
- {
- int nbCompo(getNumberOfComponents());
- if(nbCompo==1)
- _mem.insertAtTheEnd(first,last);
- else if(nbCompo==0)
- {
- _info_on_compo.resize(1);
- _mem.insertAtTheEnd(first,last);
- }
- else
- throw INTERP_KERNEL::Exception("DataArrayDouble::insertAtTheEnd : not available for DataArrayDouble with number of components different than 1 !");
- }
-
- template<class InputIterator>
- void DataArrayInt::insertAtTheEnd(InputIterator first, InputIterator last)
- {
- int nbCompo(getNumberOfComponents());
- if(nbCompo==1)
- _mem.insertAtTheEnd(first,last);
- else if(nbCompo==0)
- {
- _info_on_compo.resize(1);
- _mem.insertAtTheEnd(first,last);
- }
- else
- throw INTERP_KERNEL::Exception("DataArrayInt::insertAtTheEnd : not available for DataArrayInt with number of components different than 1 !");
- }
+ template<class T>
template<class InputIterator>
- void DataArrayChar::insertAtTheEnd(InputIterator first, InputIterator last)
+ void DataArrayTemplate<T>::insertAtTheEnd(InputIterator first, InputIterator last)
{
- int nbCompo(getNumberOfComponents());
+ int nbCompo(this->getNumberOfComponents());
if(nbCompo==1)
- _mem.insertAtTheEnd(first,last);
+ this->_mem.insertAtTheEnd(first,last);
else if(nbCompo==0)
{
- _info_on_compo.resize(1);
- _mem.insertAtTheEnd(first,last);
+ this->_info_on_compo.resize(1);
+ this->_mem.insertAtTheEnd(first,last);
}
else
- throw INTERP_KERNEL::Exception("DataArrayChar::insertAtTheEnd : not available for DataArrayChar with number of components different than 1 !");
+ throw INTERP_KERNEL::Exception("DataArrayDouble::insertAtTheEnd : not available for DataArrayDouble with number of components different than 1 !");
}
}
std::reverse(_info_on_compo.begin(),_info_on_compo.end());
}
+ /*!
+ * Assign pointer to one array to a pointer to another appay. Reference counter of
+ * \a arrayToSet is incremented / decremented.
+ * \param [in] newArray - the pointer to array to assign to \a arrayToSet.
+ * \param [in,out] arrayToSet - the pointer to array to assign to.
+ */
+ template<class T>
+ void DataArrayTemplate<T>::SetArrayIn(typename Traits<T>::ArrayType *newArray, typename Traits<T>::ArrayType* &arrayToSet)
+ {
+ if(newArray!=arrayToSet)
+ {
+ if(arrayToSet)
+ arrayToSet->decrRef();
+ arrayToSet=newArray;
+ if(arrayToSet)
+ arrayToSet->incrRef();
+ }
+ }
+
template<class T>
template<class U>
MCAuto< typename Traits<U>::ArrayType > DataArrayTemplateClassic<T>::convertToOtherTypeOfArr() const
ret->setInfoOnComponent(k,a[i]->getInfoOnComponent(j));
return ret;
}
+
+ /*!
+ * Returns a new DataArrayDouble holding the same values as \a this array but differently
+ * arranged in memory. If \a this array holds 2 components of 3 values:
+ * \f$ x_0,x_1,x_2,y_0,y_1,y_2 \f$, then the result array holds these values arranged
+ * as follows: \f$ x_0,y_0,x_1,y_1,x_2,y_2 \f$.
+ * \warning Do not confuse this method with transpose()!
+ * \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.
+ */
+ template<class T>
+ typename Traits<T>::ArrayType *DataArrayTemplateClassic<T>::fromNoInterlace() const
+ {
+ if(this->_mem.isNull())
+ throw INTERP_KERNEL::Exception("DataArrayDouble::fromNoInterlace : Not defined array !");
+ T *tab(this->_mem.fromNoInterlace(this->getNumberOfComponents()));
+ MCAuto<typename Traits<T>::ArrayType> ret(Traits<T>::ArrayType::New());
+ ret->useArray(tab,true,C_DEALLOC,this->getNumberOfTuples(),this->getNumberOfComponents());
+ return ret.retn();
+ }
+
+ /*!
+ * Returns a new DataArrayDouble holding the same values as \a this array but differently
+ * arranged in memory. If \a this array holds 2 components of 3 values:
+ * \f$ x_0,y_0,x_1,y_1,x_2,y_2 \f$, then the result array holds these values arranged
+ * as follows: \f$ x_0,x_1,x_2,y_0,y_1,y_2 \f$.
+ * \warning Do not confuse this method with transpose()!
+ * \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.
+ */
+ template<class T>
+ typename Traits<T>::ArrayType *DataArrayTemplateClassic<T>::toNoInterlace() const
+ {
+ if(this->_mem.isNull())
+ throw INTERP_KERNEL::Exception("DataArrayDouble::toNoInterlace : Not defined array !");
+ T *tab(this->_mem.toNoInterlace(this->getNumberOfComponents()));
+ MCAuto<typename Traits<T>::ArrayType> ret(Traits<T>::ArrayType::New());
+ ret->useArray(tab,true,C_DEALLOC,this->getNumberOfTuples(),this->getNumberOfComponents());
+ return ret.retn();
+ }
+
+ /*!
+ * Appends components of another array to components of \a this one, tuple by tuple.
+ * So that the number of tuples of \a this array remains the same and the number of
+ * components increases.
+ * \param [in] other - the DataArrayDouble to append to \a this one.
+ * \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
+ */
+ template<class T>
+ void DataArrayTemplateClassic<T>::meldWith(const typename Traits<T>::ArrayType *other)
+ {
+ this->checkAllocated();
+ other->checkAllocated();
+ int nbOfTuples(this->getNumberOfTuples());
+ if(nbOfTuples!=other->getNumberOfTuples())
+ throw INTERP_KERNEL::Exception("DataArrayDouble::meldWith : mismatch of number of tuples !");
+ int nbOfComp1(this->getNumberOfComponents()),nbOfComp2(other->getNumberOfComponents());
+ T *newArr=(T *)malloc((nbOfTuples*(nbOfComp1+nbOfComp2))*sizeof(T));
+ T *w=newArr;
+ const T *inp1(this->begin()),*inp2(other->begin());
+ for(int i=0;i<nbOfTuples;i++,inp1+=nbOfComp1,inp2+=nbOfComp2)
+ {
+ w=std::copy(inp1,inp1+nbOfComp1,w);
+ w=std::copy(inp2,inp2+nbOfComp2,w);
+ }
+ this->useArray(newArr,true,C_DEALLOC,nbOfTuples,nbOfComp1+nbOfComp2);
+ std::vector<int> compIds(nbOfComp2);
+ for(int i=0;i<nbOfComp2;i++)
+ compIds[i]=nbOfComp1+i;
+ this->copyPartOfStringInfoFrom2(compIds,*other);
+ }
+
+ /*!
+ *
+ * \param [in] nbTimes specifies the nb of times each tuples in \a this will be duplicated contiguouly in returned DataArrayDouble instance.
+ * \a nbTimes should be at least equal to 1.
+ * \return a newly allocated DataArrayDouble having one component and number of tuples equal to \a nbTimes * \c this->getNumberOfTuples.
+ * \throw if \a this is not allocated or if \a this has not number of components set to one or if \a nbTimes is lower than 1.
+ */
+ template<class T>
+ typename Traits<T>::ArrayType *DataArrayTemplateClassic<T>::duplicateEachTupleNTimes(int nbTimes) const
+ {
+ this->checkAllocated();
+ if(this->getNumberOfComponents()!=1)
+ 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 !");
+ int 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());
+ for(int i=0;i<nbTuples;i++,inPtr++)
+ {
+ T val(*inPtr);
+ for(int j=0;j<nbTimes;j++,retPtr++)
+ *retPtr=val;
+ }
+ ret->copyStringInfoFrom(*this);
+ return ret.retn();
+ }
+
+ template<class T>
+ void DataArrayTemplateClassic<T>::aggregate(const typename Traits<T>::ArrayType *other)
+ {
+ if(!other)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::aggregate : null pointer !");
+ if(this->getNumberOfComponents()!=other->getNumberOfComponents())
+ throw INTERP_KERNEL::Exception("DataArrayDouble::aggregate : mismatch number of components !");
+ this->_mem.insertAtTheEnd(other->begin(),other->end());
+ }
/*!
* Checks if all values in \a this array are equal to \a val at precision \a eps.
self.assertTrue(not ff0.getUndergroundDataArray().isAllocated())
self.assertEqual(ff0.getUndergroundDataArray().getInfoOnComponents(),['X [km]','YY [mm]'])
heap_memory_ref=ff0.getHeapMemorySize()
- self.assertIn(heap_memory_ref,xrange(182,465+2*strMulFac))
+ self.assertIn(heap_memory_ref,xrange(182,481+2*strMulFac))
ff0.loadArrays() ##
arr=DataArrayDouble(140) ; arr.iota() ; arr.rearrange(2)
self.assertTrue(ff0.getUndergroundDataArray().isEqualWithoutConsideringStr(arr,1e-14))
ff0=MEDFileField1TS(fname,"FieldCellPfl",False)
self.assertEqual(ff0.getUndergroundDataArray().getInfoOnComponents(),["XX [pm]","YYY [hm]"])
heap_memory_ref=ff0.getHeapMemorySize()
- self.assertIn(heap_memory_ref,xrange(350,520+6*strMulFac))
+ self.assertIn(heap_memory_ref,xrange(350,536+6*strMulFac))
ff0.loadArrays() ##
arr=DataArrayDouble(100) ; arr.iota() ; arr.rearrange(2)
self.assertTrue(ff0.getUndergroundDataArray().isEqualWithoutConsideringStr(arr,1e-14))
self.assertEqual(ff0.getUndergroundDataArray().getIJ(30,1),5.5)
self.assertTrue(not ff0.getUndergroundDataArray().isEqualWithoutConsideringStr(arr,1e-14))
heap_memory_ref=ff0.getHeapMemorySize()
- self.assertIn(heap_memory_ref,xrange(1100,1384+2*strMulFac))
+ self.assertIn(heap_memory_ref,xrange(1100,1400+2*strMulFac))
ff0.unloadArrays()
hmd=ff0.getHeapMemorySize()-heap_memory_ref
self.assertEqual(hmd,-800) # -50*8*2
#
ff0=MEDFileField1TS(fname,"FieldCellPfl",-1,-1,False)
heap_memory_ref=ff0.getHeapMemorySize()
- self.assertIn(heap_memory_ref,xrange(299,520+6*strMulFac))
+ self.assertIn(heap_memory_ref,xrange(299,536+6*strMulFac))
ff0.loadArrays() ##
self.assertTrue(ff0.getUndergroundDataArray().isEqualWithoutConsideringStr(arr,1e-14))
self.assertEqual(ff0.getHeapMemorySize()-heap_memory_ref,50*8*2)
#
ff0=MEDFileAnyTypeFieldMultiTS.New(fname,fieldName,False)
heap_memory_ref=ff0.getHeapMemorySize()
- self.assertIn(heap_memory_ref,xrange(5536,8212+(80+26+1)*strMulFac))
+ self.assertIn(heap_memory_ref,xrange(5536,10242+(80+26+1)*strMulFac))
ff0.loadArrays()
self.assertEqual(ff0.getHeapMemorySize()-heap_memory_ref,20*70*8*2)
del ff0
#
ffs=MEDFileFields(fname,False)
heap_memory_ref=ffs.getHeapMemorySize()
- self.assertIn(heap_memory_ref,xrange(5335,9031+(80+50+len(ffs))*strMulFac))
+ self.assertIn(heap_memory_ref,xrange(5335,11507+(80+50+len(ffs))*strMulFac))
ffs.loadArrays()
self.assertEqual(ffs.getHeapMemorySize()-heap_memory_ref,20*70*8*2+70*8*2+50*8*2)
pass