Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SumFunc.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/SumFunc.cc
11 /// @brief Weighted constraint function that reweights other constraints
12 /// by a constant scalar value.
13 /// @author James Thompson, Greg Taylor
14 
15 
18 
19 #include <core/types.hh>
20 
21 #include <utility/pointer/ReferenceCount.hh>
22 
23 // AUTO-REMOVED #include <numeric/angle.functions.hh>
24 // AUTO-REMOVED #include <basic/Tracer.hh>
25 
26 // C++ Headers
27 // AUTO-REMOVED #include <string>
28 
29 #include <sstream>
30 
31 
32 namespace core {
33 namespace scoring {
34 namespace constraints {
35 
36  Real
37  SumFunc::func( Real const x ) const {
38  Real f( 0.0 );
40  it != end; ++it
41  ) {
42  f += (*it)->func( x );
43  }
44 
45  return f;
46  }
47 
48  Real
49  SumFunc::dfunc( Real const x ) const {
50  Real df( 0.0 );
52  it != end; ++it
53  ) {
54  df += (*it)->dfunc( x );
55  }
56 
57  return df;
58  }
59 
60  void
61  SumFunc::read_data( std::istream& in ) {
62  FuncFactory func_factory;
63  std::string func_type;
64 
65  Size n_funcs( 0 );
66  in >> n_funcs;
67  if ( in.fail() ) return;
68 
69  assert( n_funcs >= 1 );
70 
71  for ( Size i = 1; i <= n_funcs; ++i ) {
72  in >> func_type;
73  FuncOP current_func;
74 
75  current_func = func_factory.func_types_[ func_type ]->clone();
76  current_func->read_data( in );
77  add_func( current_func );
78  }
79  } // read_data
80 
81 } // namespace constraints
82 } // namespace scoring
83 } // namespace core