Ignore:
Timestamp:
May 25, 2016, 7:13:59 AM (9 years ago)
Author:
Frederik Heber <heber@…>
Children:
4b96da
Parents:
7e9402
git-author:
Frederik Heber <heber@…> (06/30/14 09:35:42)
git-committer:
Frederik Heber <heber@…> (05/25/16 07:13:59)
Message:

SphericalPointDistribution is now working with bond degree weights.

  • recurseMatching() now works on IndexTupleList_t.
  • also rewrote calculatePairwiseDistances() and calculateErrorOfMatching().
  • L1THRESHOLD in recurseMatching() moved over to class body.
  • increased verbosity level of ...Matching() functions by one, added note on eventually chosen matching and why.
  • we assert that bestL2 is not too large.
  • FIX: calculateErrorOfMatching() did not use absolute value of gap for L1 error.
  • TESTFIX: Using limited accuracy on point coordinates.
  • TESTS: Regresssion test FragmentMolecule-cycles working again.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest.cpp

    r7e9402 r4d611d  
    6868CPPUNIT_TEST_SUITE_REGISTRATION( SphericalPointDistributionTest );
    6969
     70/** due to root-taking in function we only have limited numerical precision,
     71 * basically half of the double range.
     72 */
     73const double CenterAccuracy = sqrt(std::numeric_limits<double>::epsilon()*1e2);
    7074
    7175void SphericalPointDistributionTest::setUp()
     
    638642}
    639643
     644/** UnitTest for matchSphericalPointDistributions() with four points and weights
     645 * not all equal to one.
     646 */
     647void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_multiple()
     648{
     649  SphericalPointDistribution SPD(1.);
     650
     651  // test with four points: one point having weight of two
     652  {
     653    SphericalPointDistribution::WeightedPolygon_t polygon;
     654    polygon += std::make_pair( Vector(1.,0.,0.), 2);
     655    SphericalPointDistribution::Polygon_t newpolygon =
     656        SPD.get<4>();
     657    SphericalPointDistribution::Polygon_t expected;
     658    expected += Vector(-0.5773502691896,-5.551115123126e-17,0.8164965809277);
     659    expected += Vector(-0.5773502691896,-5.551115123126e-17,-0.8164965809277);
     660    SphericalPointDistribution::Polygon_t remaining =
     661        SphericalPointDistribution::matchSphericalPointDistributions(
     662            polygon,
     663            newpolygon);
     664//    std::cout << std::setprecision(13) << "Matched polygon is " << remaining << std::endl;
     665//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
     666    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     667  }
     668
     669  // test with five points: one point having weight of two
     670  {
     671    SphericalPointDistribution::WeightedPolygon_t polygon;
     672    polygon += std::make_pair( Vector(1.,0.,0.), 2);
     673    SphericalPointDistribution::Polygon_t newpolygon =
     674        SPD.get<5>();
     675    SphericalPointDistribution::Polygon_t expected;
     676    expected += Vector(-0.7071067811865,0.7071067811865,0);
     677    expected += Vector(-0.3535533905933,-0.3535533905933,0.8660254037844);
     678    expected += Vector(-0.3535533905933,-0.3535533905933,-0.8660254037844);
     679    SphericalPointDistribution::Polygon_t remaining =
     680        SphericalPointDistribution::matchSphericalPointDistributions(
     681            polygon,
     682            newpolygon);
     683//    std::cout << std::setprecision(13) << "Matched polygon is " << remaining << std::endl;
     684//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
     685    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     686  }
     687
     688
     689  // test with five points: one point having weight of two, one weight of one
     690  {
     691    SphericalPointDistribution::WeightedPolygon_t polygon;
     692    polygon += std::make_pair( Vector(M_SQRT1_2,M_SQRT1_2,0.), 2);
     693    polygon += std::make_pair( Vector(-1.,0.,0.), 1);
     694    SphericalPointDistribution::Polygon_t newpolygon =
     695        SPD.get<5>();
     696    SphericalPointDistribution::Polygon_t expected;
     697    expected += Vector(0.3535533786708,-0.3535533955317,-0.8660254066357);
     698    expected += Vector(0.3535534025157,-0.3535533856548,0.8660254009332);
     699    SphericalPointDistribution::Polygon_t remaining =
     700        SphericalPointDistribution::matchSphericalPointDistributions(
     701            polygon,
     702            newpolygon);
     703//    std::cout << std::setprecision(13) << "Matched polygon is " << remaining << std::endl;
     704//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
     705    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     706  }
     707
     708  // test with six points: two points each having weight of two
     709  {
     710    SphericalPointDistribution::WeightedPolygon_t polygon;
     711    polygon += std::make_pair( Vector(M_SQRT1_2,-M_SQRT1_2,0.), 2);
     712    polygon += std::make_pair( Vector(-M_SQRT1_2,M_SQRT1_2,0.), 2);
     713    SphericalPointDistribution::Polygon_t newpolygon =
     714        SPD.get<6>();
     715    SphericalPointDistribution::Polygon_t expected;
     716    expected += Vector(0.,0.,-1.);
     717    expected += Vector(0.,0.,1.);
     718    SphericalPointDistribution::Polygon_t remaining =
     719        SphericalPointDistribution::matchSphericalPointDistributions(
     720            polygon,
     721            newpolygon);
     722//    std::cout << std::setprecision(13) << "Matched polygon is " << remaining << std::endl;
     723//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
     724    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     725  }
     726}
     727
    640728/** UnitTest for matchSphericalPointDistributions() with five points
    641729 */
Note: See TracChangeset for help on using the changeset viewer.