From: ageay Date: Fri, 17 Feb 2012 08:49:48 +0000 (+0000) Subject: Bug correction : normL1 and normL2 X-Git-Tag: V6_main_FINAL~847 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=75c18bf5ee298d13e25e16f4feb5dc46d66b4a58;p=tools%2Fmedcoupling.git Bug correction : normL1 and normL2 --- diff --git a/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx b/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx index a3bc2d072..91219d31c 100644 --- a/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx +++ b/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx @@ -117,11 +117,15 @@ void MEDCouplingFieldDiscretization::normL1(const MEDCouplingMesh *mesh, const D std::fill(res,res+nbOfCompo,0.); const double *arrPtr=arr->getConstPointer(); const double *volPtr=vol->getArray()->getConstPointer(); + double deno=0.; for(int i=0;i(),1./deno)); vol->decrRef(); } @@ -138,11 +142,15 @@ void MEDCouplingFieldDiscretization::normL2(const MEDCouplingMesh *mesh, const D std::fill(res,res+nbOfCompo,0.); const double *arrPtr=arr->getConstPointer(); const double *volPtr=vol->getArray()->getConstPointer(); + double deno=0.; for(int i=0;i(),1./deno)); std::transform(res,res+nbOfCompo,res,std::ptr_fun(std::sqrt)); vol->decrRef(); } diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx index 2c04b3959..87ed986e5 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx @@ -375,7 +375,7 @@ void MEDCouplingBasicsTest2::testNormL12Integ1D() CPPUNIT_ASSERT_DOUBLES_EQUAL(expected4[i],res[i],1e-12); //normL1 f1->normL1(res); - double expected5[3]={11.3068,27.3621,43.7881}; + double expected5[3]={6.979506172839505, 16.89018518518518, 27.02969135802469}; for(int i=0;i<3;i++) CPPUNIT_ASSERT_DOUBLES_EQUAL(expected5[i],res[i],1e-12); CPPUNIT_ASSERT_DOUBLES_EQUAL(expected5[0],f1->normL1(0),1e-12); @@ -383,7 +383,7 @@ void MEDCouplingBasicsTest2::testNormL12Integ1D() CPPUNIT_ASSERT_DOUBLES_EQUAL(expected5[2],f1->normL1(2),1e-12); //normL2 f1->normL2(res); - double expected7[3]={9.0252562290496776, 21.545259176904789, 34.433193070059595}; + double expected7[3]={7.090910979452395, 16.9275542960123, 27.053271464160858}; for(int i=0;i<3;i++) CPPUNIT_ASSERT_DOUBLES_EQUAL(expected7[i],res[i],1e-9); CPPUNIT_ASSERT_DOUBLES_EQUAL(expected7[0],f1->normL2(0),1e-9); @@ -440,10 +440,10 @@ void MEDCouplingBasicsTest2::testNormL12Integ1D() CPPUNIT_ASSERT_DOUBLES_EQUAL(sqrt(2.)*expected4[i],res[i],1e-12); f1->normL1(res); for(int i=0;i<3;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(sqrt(2.)*expected5[i],res[i],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected5[i],res[i],1e-12); f1->normL2(res); for(int i=0;i<3;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(sqrt(sqrt(2.))*expected7[i],res[i],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected7[i],res[i],1e-12); // f1->decrRef(); m1->decrRef(); diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index 19c0e02c2..2eb7afc2a 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -2265,7 +2265,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): #normL1 res=f1.normL1(); self.assertTrue(3,len(res)) - expected5=[11.3068,27.3621,43.7881] + expected5=[6.979506172839505, 16.89018518518518, 27.02969135802469] for i in xrange(3): self.assertTrue(abs(expected5[i]-res[i])<1e-12); pass @@ -2275,7 +2275,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): #normL2 res=f1.normL2(); self.assertTrue(3,len(res)) - expected7=[9.0252562290496776, 21.545259176904789, 34.433193070059595] + expected7=[7.090910979452395, 16.9275542960123, 27.053271464160858] for i in xrange(3): self.assertTrue(abs(expected7[i]-res[i])<1e-9); pass @@ -2328,11 +2328,11 @@ class MEDCouplingBasicsTest(unittest.TestCase): pass res=f1.normL1(); for i in xrange(3): - self.assertTrue(abs(sqrt(2.)*expected5[i]-res[i])<1e-12); + self.assertTrue(abs(expected5[i]-res[i])<1e-12); pass res=f1.normL2(); for i in xrange(3): - self.assertTrue(abs(sqrt(sqrt(2.))*expected7[i]-res[i])<1e-12); + self.assertTrue(abs(expected7[i]-res[i])<1e-12); pass pass