Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
polynomial.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 // This file is part of the Rosetta software suite and is made available under license.
5 // The Rosetta software is developed by the contributing members of the Rosetta Commons consortium.
6 // (C) 199x-2009 Rosetta Commons participating institutions and developers.
7 // For more information, see http://www.rosettacommons.org/.
8 
9 /// @file core/scoring/hbonds/polynomial.cc
10 /// @brief Classes for hydrogen bond polynomial evaluation functions
11 /// @author Matthew O'Meara (mattjomeara@gmail.com
12 
13 
14 // Unit Headers
16 
17 // Package headers
20 
21 // Project headers
22 #include <core/types.hh>
23 
24 // Utility headers
25 #include <utility/vector1.hh>
26 
27 // Numeric headers
28 #include <numeric/polynomial.hh>
29 #include <numeric/conversions.hh>
30 
31 // ObjexxFCL headers
32 #include <ObjexxFCL/format.hh>
33 
34 // C++ headers
35 #include <iostream>
36 #include <string>
37 #include <cmath>
38 
39 namespace ObjexxFCL { namespace fmt { } } using namespace ObjexxFCL::fmt;
40 
41 namespace core {
42 namespace scoring {
43 namespace hbonds {
44 
45 using namespace std;
46 using namespace utility;
47 
48 /// @brief ctor
49 Polynomial_1d::Polynomial_1d(
50  string const & polynomial_name,
51  HBGeoDimType const geometric_dimension,
52  Real const xmin,
53  Real const xmax,
54  Real const min_val,
55  Real const max_val,
56  Real const root1,
57  Real const root2,
58  Size degree,
59  vector1< Real > const & coefficients):
60  numeric::Polynomial_1d(polynomial_name, xmin, xmax, min_val, max_val, root1, root2, degree, coefficients),
61  geometric_dimension_(geometric_dimension)
62 {}
63 
65  numeric::Polynomial_1d(src),
66  geometric_dimension_(src.geometric_dimension_)
67 {}
68 
71 {
72  return geometric_dimension_;
73 }
74 
75 ostream &
76 operator<< ( ostream & out, const Polynomial_1d & poly ){
77  poly.show( out );
78  return out;
79 }
80 
81 void
82 Polynomial_1d::show( ostream & out ) const{
83  out << name() << " "
84  << "geometric dimension:" << HBondTypeManager::name_from_geo_dim_type(geometric_dimension()) << " "
85  << "domain:(" << xmin() << "," << xmax() << ") "
86  << "out_of_range_vals:(" << min_val() << "," << max_val() << ") "
87  << "roots:[" << root1() << "," << root2() << "] "
88  << "degree:" << degree() << " "
89  << "y=";
90  for(Size i=1; i <= degree(); ++i){
91  if (i >1){
92  if (coefficients()[i] > 0 ){
93  out << "+";
94  } else if (coefficients()[i] < 0 ){
95  out << "-";
96  } else{
97  continue;
98  }
99  }
100  out << std::abs(coefficients()[i]);
101  if (degree()-i >1){
102  out << "x^" << degree()-i;
103  } else if (degree()-i == 1){
104  out << "x";
105  } else {}
106  }
107 }
108 
111 
112  using numeric::conversions::radians;
113 
114  Real energy, deriv;
115  stringstream out;
116  out << name();
117 
118  switch(geometric_dimension_){
119  case(hbgd_NONE):
120  out << " NONE ";
121  break;
122  case(hbgd_AHdist):
123  out << " AHdist ";
124  for ( Size i=120; i<= 300; i+=2 ){
125  Real const AHdist( 0.01 * i );
126  operator()(AHdist, energy, deriv);
127  out << F(9, 3, energy) << " ";
128  }
129  break;
130  case(hbgd_cosBAH):
131  out << " cosBAH ";
132  for ( Size i=60; i<= 180; i+=2 ) {
133  Real const xH( cos( radians( 180.0 - i ) ) );
134  operator()(xH, energy, deriv);
135  out << F(9, 3, energy) << " ";
136  }
137  break;
138  case(hbgd_cosAHD):
139  //out << " cosAHD ";
140  for ( Size i=60; i<= 180; i+=2 ) {
141  Real const xD( cos( radians( 180.0 - i ) ) );
142  operator()(xD, energy, deriv);
143  out << F(9, 3, energy) << " ";
144  }
145  break;
146  case(hbgd_AHD):
147  //out << " AHD ";
148  // I am not sure how this should be implemented; I added this case block to remove compiler warning:
149  // "enum value hbgd_AHD not handled in switch statement"
150  // ~Labonte
151  break;
152  case(hbgd_chi):
153  // just a guess, needs checking !
154  for ( Size i=0; i<=360; i+=6) {
155  Real const chi( cos( radians( 180.0 - i ) ) );
156  operator()(chi, energy, deriv);
157  out << F(9, 3, energy) << " ";
158  }
159  break;
160  }
161  return out.str();
162 }
163 
164 } // hbonds
165 } // scoring
166 } // core