Rosetta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
IdentityFunc.cc
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file src/core/scoring/func/IdentityFunc.hh
11 /// @brief Definition for functions used in definition of constraints.
12 /// @author James Thompson
13 
14 
16 #include <core/types.hh>
17 #include <utility/pointer/ReferenceCount.hh>
18 #include <sstream>
19 
20 
21 #ifdef SERIALIZATION
22 // Utility serialization headers
23 #include <utility/serialization/serialization.hh>
24 
25 // Cereal headers
26 #include <cereal/types/base_class.hpp>
27 #include <cereal/types/polymorphic.hpp>
28 #endif // SERIALIZATION
29 
30 
31 namespace core {
32 namespace scoring {
33 namespace func {
34 
35 bool IdentityFunc::operator == ( Func const & other ) const
36 {
37  if ( ! same_type_as_me( other ) ) return false;
38  if ( ! other.same_type_as_me( *this ) ) return false;
39 
40  return true;
41 }
42 
43 bool IdentityFunc::same_type_as_me( Func const & other ) const
44 {
45  return dynamic_cast< IdentityFunc const * > ( &other );
46 }
47 
48 Real
49 IdentityFunc::func( Real const x ) const {
50  return x;
51 }
52 
53 Real
54 IdentityFunc::dfunc( Real const /*x*/ ) const {
55  return 1;
56 }
57 
58 void
59 IdentityFunc::read_data( std::istream & /*in*/ ) {}
60 
61 void
62 IdentityFunc::show_definition( std::ostream & out ) const {
63  out << "IDENTITY";
64 }
65 
66 Size
68  std::ostream & out,
69  Real x,
70  Size verbose_level,
71  Real threshold
72 ) const {
73  return Func::show_violations( out, x, verbose_level, threshold );
74 }
75 
76 } // namespace constraints
77 } // namespace scoring
78 } // namespace core
79 
80 #ifdef SERIALIZATION
81 
82 /// @brief Automatically generated serialization method
83 template< class Archive >
84 void
85 core::scoring::func::IdentityFunc::save( Archive & arc ) const {
86  arc( cereal::base_class< Func >( this ) );
87 }
88 
89 /// @brief Automatically generated deserialization method
90 template< class Archive >
91 void
92 core::scoring::func::IdentityFunc::load( Archive & arc ) {
93  arc( cereal::base_class< Func >( this ) );
94 }
95 
96 SAVE_AND_LOAD_SERIALIZABLE( core::scoring::func::IdentityFunc );
97 CEREAL_REGISTER_TYPE( core::scoring::func::IdentityFunc )
98 
99 CEREAL_REGISTER_DYNAMIC_INIT( core_scoring_func_IdentityFunc )
100 #endif // SERIALIZATION
virtual bool same_type_as_me(Func const &other) const =0
Does the input Func, "other", have the same type as me? Necessary for the equality operator to functi...
virtual bool operator==(Func const &other) const
Equality operator. Looks for strict equality. Floating-point comparison is the rule rather than the e...
Definition: IdentityFunc.cc:35
Real dfunc(Real const x) const
Returns a value representing the derivative of this function evaluated at a given point...
Definition: IdentityFunc.cc:54
virtual bool same_type_as_me(Func const &other) const
Does the input Func, "other", have the same type as me? Necessary for the equality operator to functi...
Definition: IdentityFunc.cc:43
Definition for functions used in definition of constraints.
void show_definition(std::ostream &out) const
shows the definition of this function, usually the string type of function and the parameters passed ...
Definition: IdentityFunc.cc:62
platform::Size Size
Definition: types.hh:30
Func is an abstract base class representing a function used to define constraints, in which func(r) gives the constraint score for the given value r.
Definition: Func.hh:36
Size show_violations(std::ostream &out, Real x, Size verbose_level, core::Real threshold=1) const
show some sort of stringified representation of the violations for this constraint.
Definition: IdentityFunc.cc:67
Real func(Real const x) const
Returns a value representing this function evaluated at a given point.
Definition: IdentityFunc.cc:49
rosetta project type declarations
virtual Size show_violations(std::ostream &out, Real r, Size verbose_level, Real threshold=1) const
show some sort of stringified representation of the violations for this constraint.
Definition: Func.cc:93
platform::Real Real
Definition: types.hh:35
void read_data(std::istream &in)
initialize this Func from the given std::istream.
Definition: IdentityFunc.cc:59