declareAsNew();
}
+void DataArrayDouble::abs() throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ double *ptr=getPointer();
+ int nbOfElems=getNbOfElems();
+ std::transform(ptr,ptr+nbOfElems,ptr,std::ptr_fun<double,double>(fabs));
+}
+
void DataArrayDouble::applyLin(double a, double b, int compoId) throw(INTERP_KERNEL::Exception)
{
checkAllocated();
return *loc;
}
+void DataArrayInt::abs() throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ int *ptr=getPointer();
+ int nbOfElems=getNbOfElems();
+ std::transform(ptr,ptr+nbOfElems,ptr,std::ptr_fun<int,int>(std::abs));
+}
+
void DataArrayInt::applyLin(int a, int b, int compoId) throw(INTERP_KERNEL::Exception)
{
checkAllocated();
MEDCOUPLING_EXPORT DataArrayDouble *magnitude() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayDouble *maxPerTuple() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void sortPerTuple(bool asc) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void abs() throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void applyLin(double a, double b, int compoId) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void applyLin(double a, double b) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void applyInv(double numerator) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT int getMaxValueInArray() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT int getMinValue(int& tupleId) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT int getMinValueInArray() const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void abs() throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void applyLin(int a, int b, int compoId) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void applyLin(int a, int b) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void applyInv(int numerator) throw(INTERP_KERNEL::Exception);
//
m1->decrRef();
}
+
+void MEDCouplingBasicsTest5::testDataArrayAbs1()
+{
+ DataArrayDouble *d1=DataArrayDouble::New();
+ const double val1[12]={2.,-3.,-5.,6.,-7.,-8.,9.,10.,-11.,-12.};
+ const double expected1[12]={2.,3.,5.,6.,7.,8.,9.,10.,11.,12.};
+ d1->alloc(6,2);
+ std::copy(val1,val1+12,d1->getPointer());
+ DataArrayInt *d2=d1->convertToIntArr();
+ //
+ d1->abs();
+ for(int i=0;i<12;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],d1->getIJ(0,i),1e-14);
+ //
+ const int expected2[12]={2,3,5,6,7,8,9,10,11,12};
+ d2->abs();
+ for(int i=0;i<12;i++)
+ CPPUNIT_ASSERT_EQUAL(expected2[i],d2->getIJ(0,i));
+ //
+ d2->decrRef();
+ d1->decrRef();
+}
CPPUNIT_TEST( testDataArrayIntAdvSetting1 );
CPPUNIT_TEST( testBuildDescendingConnec2Of3DMesh1 );
CPPUNIT_TEST( testAre2DCellsNotCorrectlyOriented1 );
+ CPPUNIT_TEST( testDataArrayAbs1 );
CPPUNIT_TEST_SUITE_END();
public:
void testUMeshTessellate2D1();
void testDataArrayIntAdvSetting1();
void testBuildDescendingConnec2Of3DMesh1();
void testAre2DCellsNotCorrectlyOriented1();
+ void testDataArrayAbs1();
};
}