X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling%2FMEDCouplingMatrix.cxx;h=6cb94341f496a5ed09ef3faadeb9fdab74311643;hb=af8a6b836ed960509fcb2d719d7396c187dfbf2b;hp=6376bddd83e182be2055a17615795d7559deb80b;hpb=fb6ad3f990cf8c26e23ff4f6ed571d85dc738aac;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling/MEDCouplingMatrix.cxx b/src/MEDCoupling/MEDCouplingMatrix.cxx old mode 100644 new mode 100755 index 6376bddd8..6cb94341f --- a/src/MEDCoupling/MEDCouplingMatrix.cxx +++ b/src/MEDCoupling/MEDCouplingMatrix.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D +// Copyright (C) 2007-2020 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 @@ -22,28 +22,30 @@ #include "InterpKernelMatrixTools.hxx" +#include + using namespace MEDCoupling; -DenseMatrix *DenseMatrix::New(int nbRows, int nbCols) +DenseMatrix *DenseMatrix::New(mcIdType nbRows, mcIdType nbCols) { return new DenseMatrix(nbRows,nbCols); } -DenseMatrix *DenseMatrix::New(DataArrayDouble *array, int nbRows, int nbCols) +DenseMatrix *DenseMatrix::New(DataArrayDouble *array, mcIdType nbRows, mcIdType nbCols) { return new DenseMatrix(array,nbRows,nbCols); } -DenseMatrix *DenseMatrix::deepCpy() const +DenseMatrix *DenseMatrix::deepCopy() const { - MEDCouplingAutoRefCountObjectPtr arr(getData()->deepCpy()); - MEDCouplingAutoRefCountObjectPtr ret(DenseMatrix::New(arr,getNumberOfRows(),getNumberOfCols())); + MCAuto arr(getData()->deepCopy()); + MCAuto ret(DenseMatrix::New(arr,getNumberOfRows(),getNumberOfCols())); return ret.retn(); } DenseMatrix *DenseMatrix::shallowCpy() const { - MEDCouplingAutoRefCountObjectPtr ret(DenseMatrix::New(const_cast(getData()),getNumberOfRows(),getNumberOfCols())); + MCAuto ret(DenseMatrix::New(const_cast(getData()),getNumberOfRows(),getNumberOfCols())); return ret.retn(); } @@ -75,9 +77,9 @@ void DenseMatrix::updateTime() const * * \sa reShape */ -void DenseMatrix::reBuild(DataArrayDouble *array, int nbRows, int nbCols) +void DenseMatrix::reBuild(DataArrayDouble *array, mcIdType nbRows, mcIdType nbCols) { - int nbr(getNumberOfRowsExt(nbRows)),nbc(getNumberOfColsExt(nbCols)); + mcIdType nbr(getNumberOfRowsExt(nbRows)),nbc(getNumberOfColsExt(nbCols)); CheckArraySizes(array,nbr,nbc); DataArrayDouble *data(_data); if(data!=array) @@ -106,7 +108,7 @@ void DenseMatrix::reBuild(DataArrayDouble *array, int nbRows, int nbCols) * \throw if the \c nbRows*nbCols is not equal to \c this->getNbOfElems() * \sa reBuild */ -void DenseMatrix::reShape(int nbRows, int nbCols) +void DenseMatrix::reShape(mcIdType nbRows, mcIdType nbCols) { if(nbRows<0 || nbCols<0) throw INTERP_KERNEL::Exception("DenseMatrix::reShape : number of rows and number of cols must be > 0 both !"); @@ -177,7 +179,7 @@ DataArrayDouble *DenseMatrix::MatVecMult(const DenseMatrix *mat, const DataArray throw INTERP_KERNEL::Exception("DenseMatrix::MatVecMult : input vector must have only one component !"); if(vec->getNumberOfTuples()!=mat->getNumberOfCols()) throw INTERP_KERNEL::Exception("DenseMatrix::MatVecMult : Number of columns of this must be equal to number of tuples of vec !"); - MEDCouplingAutoRefCountObjectPtr ret(DataArrayDouble::New()); ret->alloc(mat->getNumberOfRows(),1); + MCAuto ret(DataArrayDouble::New()); ret->alloc(mat->getNumberOfRows(),1); INTERP_KERNEL::matrixProduct(mat->getData()->begin(),mat->getNumberOfRows(),mat->getNumberOfCols(),vec->begin(),vec->getNumberOfTuples(),1,ret->getPointer()); return ret.retn(); } @@ -187,8 +189,8 @@ DenseMatrix *DenseMatrix::Add(const DenseMatrix *a1, const DenseMatrix *a2) if(!a1 || !a2) throw INTERP_KERNEL::Exception("DenseMatrix::Add : input matrices must be not NULL !"); CheckSameSize(a1,a2); - MEDCouplingAutoRefCountObjectPtr data(DataArrayDouble::Add(a1->getData(),a2->getData())); - MEDCouplingAutoRefCountObjectPtr ret(DenseMatrix::New(data,a1->getNumberOfRows(),a1->getNumberOfCols())); + MCAuto data(DataArrayDouble::Add(a1->getData(),a2->getData())); + MCAuto ret(DenseMatrix::New(data,a1->getNumberOfRows(),a1->getNumberOfCols())); return ret.retn(); } @@ -205,8 +207,8 @@ DenseMatrix *DenseMatrix::Substract(const DenseMatrix *a1, const DenseMatrix *a2 if(!a1 || !a2) throw INTERP_KERNEL::Exception("DenseMatrix::Substract : input matrices must be not NULL !"); CheckSameSize(a1,a2); - MEDCouplingAutoRefCountObjectPtr data(DataArrayDouble::Substract(a1->getData(),a2->getData())); - MEDCouplingAutoRefCountObjectPtr ret(DenseMatrix::New(data,a1->getNumberOfRows(),a1->getNumberOfCols())); + MCAuto data(DataArrayDouble::Substract(a1->getData(),a2->getData())); + MCAuto ret(DenseMatrix::New(data,a1->getNumberOfRows(),a1->getNumberOfCols())); return ret.retn(); } @@ -223,9 +225,9 @@ DenseMatrix *DenseMatrix::Multiply(const DenseMatrix *a1, const DenseMatrix *a2) if(!a1 || !a2) throw INTERP_KERNEL::Exception("DenseMatrix::Multiply : input matrices must be not NULL !"); CheckCompatibleSizeForMul(a1,a2); - int nbr(a1->getNumberOfRows()),nbc(a2->getNumberOfCols()); - MEDCouplingAutoRefCountObjectPtr data(DataArrayDouble::New()); data->alloc(nbr*nbc,1); - MEDCouplingAutoRefCountObjectPtr ret(DenseMatrix::New(data,a1->getNumberOfRows(),a2->getNumberOfCols())); + mcIdType nbr(a1->getNumberOfRows()),nbc(a2->getNumberOfCols()); + MCAuto data(DataArrayDouble::New()); data->alloc(nbr*nbc,1); + MCAuto ret(DenseMatrix::New(data,a1->getNumberOfRows(),a2->getNumberOfCols())); INTERP_KERNEL::matrixProduct(a1->getData()->begin(),a1->getNumberOfRows(),a1->getNumberOfCols(),a2->getData()->begin(),a2->getNumberOfRows(),a2->getNumberOfCols(),data->getPointer()); return ret.retn(); } @@ -236,7 +238,7 @@ DenseMatrix *DenseMatrix::Multiply(const DenseMatrix *a1, const DataArrayDouble throw INTERP_KERNEL::Exception("DenseMatrix::Multiply #2 : input matrices must be not NULL and a2 allocated !"); if(a2->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DenseMatrix::Multiply #2 : The 2nd member must have exactly one component !"); - MEDCouplingAutoRefCountObjectPtr a2Bis(DenseMatrix::New(const_cast(a2),a2->getNumberOfTuples(),1)); + MCAuto a2Bis(DenseMatrix::New(const_cast(a2),a2->getNumberOfTuples(),1)); return DenseMatrix::Multiply(a1,a2Bis); } @@ -244,21 +246,21 @@ DenseMatrix::~DenseMatrix() { } -DenseMatrix::DenseMatrix(int nbRows, int nbCols):_nb_rows(nbRows),_nb_cols(nbCols),_data(DataArrayDouble::New()) +DenseMatrix::DenseMatrix(mcIdType nbRows, mcIdType nbCols):_nb_rows(nbRows),_nb_cols(nbCols),_data(DataArrayDouble::New()) { if(_nb_rows<0 || _nb_cols<0) throw INTERP_KERNEL::Exception("constructor of DenseMatrix : number of rows and number of cols must be > 0 both !"); - int nbOfTuples(_nb_rows*_nb_cols); + mcIdType nbOfTuples(_nb_rows*_nb_cols); _data->alloc(nbOfTuples,1); } -DenseMatrix::DenseMatrix(DataArrayDouble *array, int nbRows, int nbCols):_nb_rows(nbRows),_nb_cols(nbCols) +DenseMatrix::DenseMatrix(DataArrayDouble *array, mcIdType nbRows, mcIdType nbCols):_nb_rows(nbRows),_nb_cols(nbCols) { CheckArraySizes(array,_nb_rows,_nb_cols); _data=array; _data->incrRef(); } -int DenseMatrix::getNumberOfRowsExt(int nbRows) const +mcIdType DenseMatrix::getNumberOfRowsExt(mcIdType nbRows) const { if(nbRows<-1) throw INTERP_KERNEL::Exception("DenseMatrix::getNumberOfRowsExt : invalid input must be >= -1 !"); @@ -268,7 +270,7 @@ int DenseMatrix::getNumberOfRowsExt(int nbRows) const return nbRows; } -int DenseMatrix::getNumberOfColsExt(int nbCols) const +mcIdType DenseMatrix::getNumberOfColsExt(mcIdType nbCols) const { if(nbCols<-1) throw INTERP_KERNEL::Exception("DenseMatrix::getNumberOfColsExt : invalid input must be >= -1 !"); @@ -288,7 +290,7 @@ void DenseMatrix::checkValidData() const throw INTERP_KERNEL::Exception("DenseMatrix::checkValidData : data has not 1 component !"); } -void DenseMatrix::CheckArraySizes(DataArrayDouble *array, int nbRows, int nbCols) +void DenseMatrix::CheckArraySizes(DataArrayDouble *array, mcIdType nbRows, mcIdType nbCols) { if(nbRows<0 || nbCols<0) throw INTERP_KERNEL::Exception("constructor #2 of DenseMatrix : number of rows and number of cols must be > 0 both !"); @@ -296,8 +298,7 @@ void DenseMatrix::CheckArraySizes(DataArrayDouble *array, int nbRows, int nbCols throw INTERP_KERNEL::Exception("constructor #2 of DenseMatrix : input array is empty or not allocated !"); if(array->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("constructor #2 of DenseMatrix : input array must have exactly one component !"); - std::size_t nbr((std::size_t)nbRows),nbc((std::size_t)nbCols); - if(nbr*nbc!=array->getNbOfElems()) + if(nbRows*nbCols!=array->getNbOfElems()) throw INTERP_KERNEL::Exception("constructor #2 of DenseMatrix : the number of elems in input array is not equal to the product of nbRows and nbCols !"); }