Hi looks interesting. Since it is very small and portable, care to make a patch?
Sean On Thu, Feb 4, 2010 at 9:18 PM, Charles Mark Maynard <[email protected]> wrote: > Hello all, I have been using UnitTest++ and am currently working on a > project and researching 3 numerical libraries(TET,GSL,BOOST MATH). While > testing I've ran into a problem using CHECK_ARRAY_CLOSE. It is not a bug, > but rather that in some cases the numbers are so large that is would be > better to check relative error then absolute. I would like to propose a new > comparison test CHECK_ARRAY_RELATIVE, which would use relative error instead > for values larger than the tolerance value. > > Currently I have resorted to using the following conditional to check > absolute or relatvie based on the size of the values I'm comparing: > > bool pass=true; > //choose between checking relative or absolute error > if(fabs(pnm.TET_pnm_r()[j])<accuracy || fabs(pnm.GSL_pnm_r()[j])<accuracy) > { > //absolute error > if(fabs(pnm.TET_pnm_r()[j]-pnm.GSL_pnm_r()[j])<accuracy) > std::cout<<"Absolute N: "<<n<<" M: "<<m<<" TET: "<<pnm.TET_pnm_r()[j]<<" > GSL: " << pnm.GSL_pnm_r()[j]<<" RIGHT\n"; > else > { > std::cout<<"***** Absolute N: "<<n<<" M: "<<m<<" TET: > "<<pnm.TET_pnm_r()[j]<<" GSL: " << pnm.GSL_pnm_r()[j]<<" WRONG\n"; > pass=false; > } > } > else > { > //relative error > > if((fabs(pnm.TET_pnm_r()[j]-pnm.GSL_pnm_r()[j])/pnm.TET_pnm_r()[j])<accuracy) > std::cout<<"Relative N: "<<n<<" M: "<<m<<" TET: "<<pnm.TET_pnm_r()[j]<<" > GSL: " << pnm.GSL_pnm_r()[j]<<" RIGHT\n"; > else > { > std::cout<<"***** Relative N: "<<n<<" M: "<<m<<" TET: > "<<pnm.TET_pnm_r()[j]<<" GSL: " << pnm.GSL_pnm_r()[j]<<" WRONG\n"; > pass=false; > } > } > > Let me know if this is of interest, I would be willing to help with > development. I've looked at through the repository, and this shouldn't take > too much effort to add, mostly a new AreRelativelyClose method and a less > than comparison of the expected term with the tolerance to decide which one > to call. > > Cheers, > Mark > > ------------------------------------------------------------------------------ > The Planet: dedicated and managed hosting, cloud storage, colocation > Stay online with enterprise data centers and the best network in the > business > Choose flexible plans and management services without long-term contracts > Personal 24x7 support from experience hosting pros just a phone call away. > http://p.sf.net/sfu/theplanet-com > _______________________________________________ > unittest-cpp-devel mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/unittest-cpp-devel > > ------------------------------------------------------------------------------ The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com _______________________________________________ unittest-cpp-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/unittest-cpp-devel
