Changeset 4266eb


Ignore:
Timestamp:
Oct 3, 2016, 5:19:53 PM (9 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Fix_FitPotential_needs_atomicnumbers
Children:
96af51
Parents:
6d08032
Message:

Moved SubgraphEdge over to FunctionApproximation and derived argument_t from it.

Location:
src
Files:
1 added
1 deleted
2 edited
4 moved

Legend:

Unmodified
Added
Removed
  • src/FunctionApproximation/FunctionArgument.hpp

    r6d08032 r4266eb  
    1717#include <iosfwd>
    1818
     19#include "FunctionApproximation/Subgraph/SubgraphEdge.hpp"
     20
    1921/** This class encapsulates all information with respect to a single argument
    2022 *  for a high-dimensional model function.
     
    2527 *
    2628 */
    27 struct argument_t
     29struct argument_t : public SubgraphEdge
    2830{
    2931  //!> grant operator access to private parts
    3032  friend std::ostream& operator<<(std::ostream &ost, const argument_t &arg);
    31 
    32   //!> typedef for the two indices of the argument
    33   typedef std::pair<size_t, size_t> indices_t;
    34   //!> typedef for the underlying type of the particle
    35   typedef unsigned int ParticleType_t;
    36   //!> typedef for the two particle types of the argument
    37   typedef std::pair<ParticleType_t, ParticleType_t> types_t;
    3833
    3934  /** Default constructor for class argument_t.
     
    4136   */
    4237  argument_t() :
    43     indices( std::make_pair(0,1) ),
    44     types( std::make_pair(0,0) ),
    4538    distance(0.),
    4639    globalid(-1)
     
    5447   */
    5548  argument_t(const double &_distance) :
    56     indices( std::make_pair(0,1) ),
    57     types( std::make_pair(0,0) ),
     49    SubgraphEdge(
     50      indices_t( std::make_pair(0,1) ),
     51      types_t( std::make_pair(0,0) )),
    5852    distance(_distance),
    5953    globalid(-1)
     
    6660   */
    6761  argument_t(const indices_t &_indices, const double &_distance) :
    68     indices( _indices ),
    69     types( std::make_pair(0,0) ),
     62    SubgraphEdge(
     63      indices,
     64      types_t( std::make_pair(0,0) )),
    7065    distance(_distance),
    7166    globalid(-1)
     
    7974   */
    8075  argument_t(const indices_t &_indices, const types_t &_types, const double &_distance) :
    81     indices( _indices ),
    82     types( _types ),
     76    SubgraphEdge(_indices, _types),
    8377    distance(_distance),
    8478    globalid(-1)
     
    106100   * \return true - first type is less or if equal, second type is less, else
    107101   */
    108   bool static TypeComparator(const argument_t &one, const argument_t &other)
     102  bool static IndexComparator(const argument_t &one, const argument_t &other)
    109103  {
    110     if (one.types.first < other.types.first)
    111       return true;
    112     else if (one.types.first > other.types.first)
    113       return false;
    114     else
    115       return one.types.second < other.types.second;
     104    return (static_cast<const SubgraphEdge &>(one) < static_cast<const SubgraphEdge &>(other));
    116105  }
    117106
    118   /** Comparator with respect to the pair of indices.
    119    *
    120    * \note We'll have this as static function to allow usage in e.g. STL's sort.
    121    *
    122    * \param one first argument
    123    * \param other other argument to compare to \a one to
    124    * \return true - first index is less or if equal, second index is less, else
    125    */
    126   bool static IndexComparator(const argument_t &one, const argument_t &other)
    127   {
    128     if (one.indices.first < other.indices.first)
    129       return true;
    130     else if (one.indices.first > other.indices.first)
    131       return false;
    132     else
    133       return one.indices.second < other.indices.second;
    134   }
    135 
    136   /** Less comparator for FunctionArgument.
    137    *
    138    * @param other other argument to compare to
    139    * @return true - this argument is less than \a other, false - else
    140    */
    141   bool operator<(const argument_t &other) const
    142   {
    143     if (types.first < other.types.first)
    144       return true;
    145     else if (types.first > other.types.first)
    146       return false;
    147     else if (types.second < other.types.second)
    148       return true;
    149     else if (types.second > other.types.second)
    150       return false;
    151     else {
    152       if (indices.first < other.indices.first)
    153         return true;
    154       else if (indices.first > other.indices.first)
    155         return false;
    156       else
    157         return indices.second < other.indices.second;
    158     }
    159   }
    160 
    161   /** Equality operator for FunctionArgument.
    162    *
    163    * \note This compares only types and indices.
    164    *
    165    * @param other other argument to compare to
    166    * @return true - this argument is equal to \a other, false - else
    167    */
    168   bool operator==(const argument_t &other) const
    169   {
    170     if (types.first != other.types.first)
    171       return false;
    172     else if (types.second != other.types.second)
    173       return false;
    174     if (indices.first != other.indices.first)
    175       return false;
    176     else if (indices.second != other.indices.second)
    177       return false;
    178     else
    179       return true;
    180   }
    181 
    182   //!> indices between which the distance is given
    183   indices_t indices;
    184   //!> indices between which the distance is given
    185   types_t types;
    186107  //!> distance
    187108  double distance;
  • src/FunctionApproximation/Subgraph/SubgraphEdge.hpp

    r6d08032 r4266eb  
    77
    88
    9 #ifndef POTENTIALS_SUBGRAPH_SUBGRAPHEDGE_HPP_
    10 #define POTENTIALS_SUBGRAPH_SUBGRAPHEDGE_HPP_
     9#ifndef FUNCTIONAPPROXIMATION_SUBGRAPH_SUBGRAPHEDGE_HPP_
     10#define FUNCTIONAPPROXIMATION_SUBGRAPH_SUBGRAPHEDGE_HPP_
    1111
    1212// include config.h
     
    1818 *
    1919 * Each edge contains two indices and two types.
    20  *
    21  * \sa argument_t
    2220 */
    2321class SubgraphEdge
     
    116114  }
    117115
    118 private:
     116protected:
    119117
    120118  //!> indices between which the distance is given
     
    125123
    126124
    127 #endif /* POTENTIALS_SUBGRAPH_SUBGRAPHEDGE_HPP_ */
     125#endif /* FUNCTIONAPPROXIMATION_SUBGRAPH_SUBGRAPHEDGE_HPP_ */
  • src/FunctionApproximation/Subgraph/unittests/SubgraphEdgeUnitTest.cpp

    r6d08032 r4266eb  
    3939#include <cppunit/ui/text/TestRunner.h>
    4040
    41 #include "SubgraphEdgeUnitTest.hpp"
     41#include "../../../FunctionApproximation/Subgraph/unittests/SubgraphEdgeUnitTest.hpp"
    4242
    4343#include <boost/assign.hpp>
     
    4545#include "CodePatterns/Assert.hpp"
    4646
    47 #include "Potentials/Subgraph/SubgraphEdge.hpp"
     47#include "../../../FunctionApproximation/Subgraph/SubgraphEdge.hpp"
    4848
    4949using namespace boost::assign;
  • src/unittests/Makefile.am

    r6d08032 r4266eb  
    2020include ../../src/Filling/unittests/Makefile.am
    2121include ../../src/FunctionApproximation/unittests/Makefile.am
     22include ../../src/FunctionApproximation/Subgraph/unittests/Makefile.am
    2223include ../../src/Fragmentation/unittests/Makefile.am
    2324include ../../src/Fragmentation/Exporters/unittests/Makefile.am
     
    3738include ../../src/Potentials/unittests/Makefile.am
    3839include ../../src/Potentials/Specifics/unittests/Makefile.am
    39 include ../../src/Potentials/Subgraph/unittests/Makefile.am
    4040include ../../src/RandomNumbers/unittests/Makefile.am
    4141include ../../src/Shapes/unittests/Makefile.am
Note: See TracChangeset for help on using the changeset viewer.