Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PeriodicFunc.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/PeriodicFunc.cc
11 /// @brief Definition for periodic functions
12 /// @author Florian Richter, floric@u.washington.edu
13 
15 #include <math.h>
16 #include <iostream>
17 
18 namespace core {
19 namespace scoring {
20 namespace constraints {
21 
22 
23 Real
24 PeriodicFunc::func( Real const x ) const
25 {
26  return ( k_ * (cos( n_periodic_ * ( x - x0_ ) ) ) ) + C_;
27 }
28 
29 Real
30 PeriodicFunc::dfunc( Real const x ) const
31 {
32  return -1. * k_ * n_periodic_ * sin( n_periodic_ * (x - x0_ ) );
33 }
34 
35 void
36 PeriodicFunc::read_data( std::istream& in )
37 {
38  in >> x0_ >> n_periodic_ >> k_ >> C_;
39 }
40 
41 void
42 PeriodicFunc::show_definition(std::ostream &out ) const {
43  out << "PERIODIC " << x0_ << " " << n_periodic_ << " " << k_ << " " << C_
44  << std::endl;
45 }
46 
47 //copied from HarmonicFunc.cc
48 Size
50  std::ostream& out, Real x, Size verbose_level, Real threshold
51 ) const {
52  if (verbose_level > 100 ) {
53  out << "PERIODIC " << func(x) << std::endl;
54  }
55  return Func::show_violations( out, x, verbose_level, threshold);
56 
57 }
58 
59 
60 } //constraints
61 } //scoring
62 } //core
63 
64