Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Func.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/constraints/Func.cc
11 /// @brief Definition for functions used in definition of constraints.
12 /// @author Andrew Leaver-Fay
13 /// @author James Thompson
14 /// @author Oliver Lange
15 
18 
19 #include <core/types.hh>
20 
21 #include <utility/pointer/ReferenceCount.hh>
22 
23 // AUTO-REMOVED #include <numeric/angle.functions.hh>
24 #include <ObjexxFCL/format.hh>
25 #include <basic/Tracer.hh>
26 
27 // C++ Headers
28 //#include <cstdlib>
29 //#include <iostream>
30 //#include <map>
31 //#include <utility>
32 
33 namespace core {
34 namespace scoring {
35 namespace constraints {
36 
37 /// @details Auto-generated virtual destructor
39 
40 void
41 Func::read_data( std::istream& ) {
42  basic::Tracer tr("core.scoring.constraints.Func" );
43  tr.Warning << " Base clase Func::read_data stubbed out --- virtual function not overloaded " << std::endl;
44 }
45 
46 Real
47 Func::estimate_dfunc( Real const r ) const {
48  Real h = 1e-6;
49  return estimate_dfunc( r, h );
50 }
51 
52 Real Func::estimate_dfunc( Real const r, Real const h ) const {
53  return ( (func(r+h) - func(r-h)) / (2*h) );
54 }
55 
56 void Func::show( std::ostream& out ) const {
57  using namespace ObjexxFCL::fmt;
58 
59  Real start = 2;
60  Real end = 20;
61  Real res = 0.5;
62  int width = 10;
63  out << A( width, "r" )
64  << A( width, "func" )
65  << A( width, "dfunc")
66  << A( width, "dfunc_est" )
67  << std::endl;
68  for ( Real r = start; r <= end; r += res ) {
69  out << I( width, r )
70  << F( width, 3, func(r) )
71  << F( width, 3, dfunc(r) )
72  << F( width, 3, estimate_dfunc(r) )
73  << std::endl;
74  }
75 } // virtual void show( std::ostream& out )
76 
77 void Func::show_definition( std::ostream &out ) const {
78  out << "Func::show_def() stubbed out" << std::endl;
79 }
80 
81 Size Func::show_violations( std::ostream& out, Real r, Size verbose_level, Real threshold ) const {
82  Real f = func(r);
83  if ( verbose_level > 100 ) out << f << std::endl;
84  return f > threshold;
85 }
86 
87 std::ostream& operator<<( std::ostream& out, const Func& f ) {
88  f.show( out );
89  return out;
90 }
91 
92 } // namespace constraints
93 } // namespace scoring
94 } // namespace core
95