From 82450791a2c59926c6c820ef26c1c02093f3bce3 Mon Sep 17 00:00:00 2001 From: ageay Date: Mon, 22 Aug 2011 08:11:10 +0000 Subject: [PATCH] *** empty log message *** --- src/MEDCoupling/MEDCouplingMemArray.cxx | 36 ++++++++++++------------- src/MEDCoupling/MEDCouplingMemArray.hxx | 4 +++ 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx index d720be782..7384f74fd 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ b/src/MEDCoupling/MEDCouplingMemArray.cxx @@ -1802,7 +1802,7 @@ DataArrayDouble *DataArrayDouble::Add(const DataArrayDouble *a1, const DataArray a1->checkNbOfTuplesAndComp(nbOfTuple,nbOfComp,"Nb of components mismatch for array Add !"); DataArrayDouble *ret=DataArrayDouble::New(); ret->alloc(nbOfTuple,nbOfComp); - std::transform(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple*nbOfComp,a2->getConstPointer(),ret->getPointer(),std::plus()); + std::transform(a1->begin(),a1->end(),a2->begin(),ret->getPointer(),std::plus()); ret->copyStringInfoFrom(*a1); return ret; } @@ -1812,7 +1812,7 @@ void DataArrayDouble::addEqual(const DataArrayDouble *other) throw(INTERP_KERNEL int nbOfTuple=other->getNumberOfTuples(); int nbOfComp=other->getNumberOfComponents(); checkNbOfTuplesAndComp(nbOfTuple,nbOfComp,"Nb of components mismatch for array add equal !"); - std::transform(getConstPointer(),getConstPointer()+nbOfTuple*nbOfComp,other->getConstPointer(),getPointer(),std::plus()); + std::transform(begin(),end(),other->begin(),getPointer(),std::plus()); declareAsNew(); } @@ -1823,7 +1823,7 @@ DataArrayDouble *DataArrayDouble::Substract(const DataArrayDouble *a1, const Dat a1->checkNbOfTuplesAndComp(nbOfTuple,nbOfComp,"Nb of components mismatch for array Substract !"); DataArrayDouble *ret=DataArrayDouble::New(); ret->alloc(nbOfTuple,nbOfComp); - std::transform(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple*nbOfComp,a2->getConstPointer(),ret->getPointer(),std::minus()); + std::transform(a1->begin(),a1->end(),a2->begin(),ret->getPointer(),std::minus()); ret->copyStringInfoFrom(*a1); return ret; } @@ -1833,7 +1833,7 @@ void DataArrayDouble::substractEqual(const DataArrayDouble *other) throw(INTERP_ int nbOfTuple=other->getNumberOfTuples(); int nbOfComp=other->getNumberOfComponents(); checkNbOfTuplesAndComp(nbOfTuple,nbOfComp,"Nb of components mismatch for array substract equal !"); - std::transform(getConstPointer(),getConstPointer()+nbOfTuple*nbOfComp,other->getConstPointer(),getPointer(),std::minus()); + std::transform(begin(),end(),other->begin(),getPointer(),std::minus()); declareAsNew(); } @@ -1850,7 +1850,7 @@ DataArrayDouble *DataArrayDouble::Multiply(const DataArrayDouble *a1, const Data { ret=DataArrayDouble::New(); ret->alloc(nbOfTuple,nbOfComp); - std::transform(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple*nbOfComp,a2->getConstPointer(),ret->getPointer(),std::multiplies()); + std::transform(a1->begin(),a1->end(),a2->begin(),ret->getPointer(),std::multiplies()); ret->copyStringInfoFrom(*a1); } else @@ -1894,7 +1894,7 @@ void DataArrayDouble::multiplyEqual(const DataArrayDouble *other) throw(INTERP_K throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array multiplyEqual !"); if(nbOfComp==nbOfComp2) { - std::transform(getConstPointer(),getConstPointer()+nbOfTuple*nbOfComp,other->getConstPointer(),getPointer(),std::multiplies()); + std::transform(begin(),end(),other->begin(),getPointer(),std::multiplies()); } else { @@ -1924,7 +1924,7 @@ DataArrayDouble *DataArrayDouble::Divide(const DataArrayDouble *a1, const DataAr { ret=DataArrayDouble::New(); ret->alloc(nbOfTuple,nbOfComp); - std::transform(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple*nbOfComp,a2->getConstPointer(),ret->getPointer(),std::divides()); + std::transform(a1->begin(),a1->end(),a2->begin(),ret->getPointer(),std::divides()); ret->copyStringInfoFrom(*a1); } else @@ -1956,7 +1956,7 @@ void DataArrayDouble::divideEqual(const DataArrayDouble *other) throw(INTERP_KER throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array divideEqual !"); if(nbOfComp==nbOfComp2) { - std::transform(getConstPointer(),getConstPointer()+nbOfTuple*nbOfComp,other->getConstPointer(),getPointer(),std::divides()); + std::transform(begin(),end(),other->begin(),getPointer(),std::divides()); } else { @@ -3634,7 +3634,7 @@ DataArrayInt *DataArrayInt::Add(const DataArrayInt *a1, const DataArrayInt *a2) a1->checkNbOfTuplesAndComp(nbOfTuple,nbOfComp,"Nb of components mismatch for array Add !"); DataArrayInt *ret=DataArrayInt::New(); ret->alloc(nbOfTuple,nbOfComp); - std::transform(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple*nbOfComp,a2->getConstPointer(),ret->getPointer(),std::plus()); + std::transform(a1->begin(),a1->end(),a2->begin(),ret->getPointer(),std::plus()); ret->copyStringInfoFrom(*a1); return ret; } @@ -3644,7 +3644,7 @@ void DataArrayInt::addEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exce int nbOfTuple=other->getNumberOfTuples(); int nbOfComp=other->getNumberOfComponents(); checkNbOfTuplesAndComp(nbOfTuple,nbOfComp,"Nb of components mismatch for array add equal !"); - std::transform(getConstPointer(),getConstPointer()+nbOfTuple*nbOfComp,other->getConstPointer(),getPointer(),std::plus()); + std::transform(begin(),end(),other->begin(),getPointer(),std::plus()); declareAsNew(); } @@ -3655,7 +3655,7 @@ DataArrayInt *DataArrayInt::Substract(const DataArrayInt *a1, const DataArrayInt a1->checkNbOfTuplesAndComp(nbOfTuple,nbOfComp,"Nb of components mismatch for array Substract !"); DataArrayInt *ret=DataArrayInt::New(); ret->alloc(nbOfTuple,nbOfComp); - std::transform(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple*nbOfComp,a2->getConstPointer(),ret->getPointer(),std::minus()); + std::transform(a1->begin(),a1->end(),a2->begin(),ret->getPointer(),std::minus()); ret->copyStringInfoFrom(*a1); return ret; } @@ -3665,7 +3665,7 @@ void DataArrayInt::substractEqual(const DataArrayInt *other) throw(INTERP_KERNEL int nbOfTuple=other->getNumberOfTuples(); int nbOfComp=other->getNumberOfComponents(); checkNbOfTuplesAndComp(nbOfTuple,nbOfComp,"Nb of components mismatch for array substract equal !"); - std::transform(getConstPointer(),getConstPointer()+nbOfTuple*nbOfComp,other->getConstPointer(),getPointer(),std::minus()); + std::transform(begin(),end(),other->begin(),getPointer(),std::minus()); declareAsNew(); } @@ -3682,7 +3682,7 @@ DataArrayInt *DataArrayInt::Multiply(const DataArrayInt *a1, const DataArrayInt { ret=DataArrayInt::New(); ret->alloc(nbOfTuple,nbOfComp); - std::transform(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple*nbOfComp,a2->getConstPointer(),ret->getPointer(),std::multiplies()); + std::transform(a1->begin(),a1->end(),a2->begin(),ret->getPointer(),std::multiplies()); ret->copyStringInfoFrom(*a1); } else @@ -3726,7 +3726,7 @@ void DataArrayInt::multiplyEqual(const DataArrayInt *other) throw(INTERP_KERNEL: throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array multiplyEqual !"); if(nbOfComp==nbOfComp2) { - std::transform(getConstPointer(),getConstPointer()+nbOfTuple*nbOfComp,other->getConstPointer(),getPointer(),std::multiplies()); + std::transform(begin(),end(),other->begin(),getPointer(),std::multiplies()); } else { @@ -3756,7 +3756,7 @@ DataArrayInt *DataArrayInt::Divide(const DataArrayInt *a1, const DataArrayInt *a { ret=DataArrayInt::New(); ret->alloc(nbOfTuple,nbOfComp); - std::transform(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple*nbOfComp,a2->getConstPointer(),ret->getPointer(),std::divides()); + std::transform(a1->begin(),a1->end(),a2->begin(),ret->getPointer(),std::divides()); ret->copyStringInfoFrom(*a1); } else @@ -3788,7 +3788,7 @@ void DataArrayInt::divideEqual(const DataArrayInt *other) throw(INTERP_KERNEL::E throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array divideEqual !"); if(nbOfComp==nbOfComp2) { - std::transform(getConstPointer(),getConstPointer()+nbOfTuple*nbOfComp,other->getConstPointer(),getPointer(),std::divides()); + std::transform(begin(),end(),other->begin(),getPointer(),std::divides()); } else { @@ -3812,7 +3812,7 @@ DataArrayInt *DataArrayInt::Modulus(const DataArrayInt *a1, const DataArrayInt * a1->checkNbOfTuplesAndComp(nbOfTuple,nbOfComp,"Nb of components mismatch for array Modulus"); DataArrayInt *ret=DataArrayInt::New(); ret->alloc(nbOfTuple,nbOfComp); - std::transform(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple*nbOfComp,a2->getConstPointer(),ret->getPointer(),std::modulus()); + std::transform(a1->begin(),a1->end(),a2->begin(),ret->getPointer(),std::modulus()); ret->copyStringInfoFrom(*a1); return ret; } @@ -3822,7 +3822,7 @@ void DataArrayInt::modulusEqual(const DataArrayInt *other) throw(INTERP_KERNEL:: int nbOfTuple=other->getNumberOfTuples(); int nbOfComp=other->getNumberOfComponents(); checkNbOfTuplesAndComp(nbOfTuple,nbOfComp,"Nb of components mismatch for array modulus equal"); - std::transform(getConstPointer(),getConstPointer()+nbOfTuple*nbOfComp,other->getConstPointer(),getPointer(),std::modulus()); + std::transform(begin(),end(),other->begin(),getPointer(),std::modulus()); declareAsNew(); } diff --git a/src/MEDCoupling/MEDCouplingMemArray.hxx b/src/MEDCoupling/MEDCouplingMemArray.hxx index 6206bcce2..2da9f12f7 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.hxx +++ b/src/MEDCoupling/MEDCouplingMemArray.hxx @@ -183,6 +183,8 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT double *getPointer() { return _mem.getPointer(); } MEDCOUPLING_EXPORT static void SetArrayIn(DataArrayDouble *newArray, DataArrayDouble* &arrayToSet); MEDCOUPLING_EXPORT const double *getConstPointer() const { return _mem.getConstPointer(); } + MEDCOUPLING_EXPORT const double *begin() const { return getConstPointer(); } + MEDCOUPLING_EXPORT const double *end() const { return getConstPointer()+getNbOfElems(); } MEDCOUPLING_EXPORT void useArray(const double *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo); MEDCOUPLING_EXPORT void writeOnPlace(int id, double element0, const double *others, int sizeOfOthers) { _mem.writeOnPlace(id,element0,others,sizeOfOthers); } MEDCOUPLING_EXPORT void checkNoNullValues() const throw(INTERP_KERNEL::Exception); @@ -316,6 +318,8 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT int *getPointer() { return _mem.getPointer(); } MEDCOUPLING_EXPORT static void SetArrayIn(DataArrayInt *newArray, DataArrayInt* &arrayToSet); MEDCOUPLING_EXPORT const int *getConstPointer() const { return _mem.getConstPointer(); } + MEDCOUPLING_EXPORT const int *begin() const { return getConstPointer(); } + MEDCOUPLING_EXPORT const int *end() const { return getConstPointer()+getNbOfElems(); } MEDCOUPLING_EXPORT DataArrayInt *getIdsEqual(int val) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayInt *getIdsNotEqual(int val) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayInt *getIdsEqualList(const std::vector& vals) const throw(INTERP_KERNEL::Exception); -- 2.39.2