tan.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ACADO Toolkit.
3  *
4  * ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
5  * Copyright (C) 2008-2014 by Boris Houska, Hans Joachim Ferreau,
6  * Milan Vukov, Rien Quirynen, KU Leuven.
7  * Developed within the Optimization in Engineering Center (OPTEC)
8  * under supervision of Moritz Diehl. All rights reserved.
9  *
10  * ACADO Toolkit is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 3 of the License, or (at your option) any later version.
14  *
15  * ACADO Toolkit is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with ACADO Toolkit; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23  *
24  */
25 
26 
27 
37 
38 
39 double dTan(double x){
40  double v1 = tan(x);
41  return 1+v1*v1;
42 }
43 
44 double ddTan(double x){
45  double v1 = tan(x);
46  return 2*v1*(1+v1*v1);
47 }
48 
50 
51 
52 
53 
55  cName = "tan";
56 
57  fcn = &tan;
58  dfcn = &dTan;
59  ddfcn = &ddTan;
60 
62 
63 }
64 
65 Tan::Tan( Operator *_argument ):UnaryOperator(_argument){
66  cName = "tan";
67 
68  fcn = &tan;
69  dfcn = &dTan;
70  ddfcn = &ddTan;
71 
73 }
74 
75 
76 Tan::Tan( const Tan &arg ):UnaryOperator(arg){
77  cName = "tan";
78 
79  fcn = &tan;
80  dfcn = &dTan;
81  ddfcn = &ddTan;
82 
84 }
85 
86 
88 
89 }
90 
91 
92 Tan& Tan::operator=( const Tan &arg ){
93 
95 
96  return *this;
97 }
98 
99 
101 
102  x->Tan(*argument);
103  return SUCCESSFUL_RETURN;
104 }
105 
106 Operator* Tan::substitute( int index, const Operator *sub ){
107 
108  return new Tan( argument->substitute( index , sub ) );
109 
110 }
111 
113 
114  return new Tan(*this);
115 }
116 
118 
119  if( initialized ) return SUCCESSFUL_RETURN;
121 
122  derivative = convert2TreeProjection(new Quotient( new DoubleConstant( 1.0 , NE_ONE ), new Power_Int( new Cos( argument->clone() ), 2 ) ));
125  new Tan(argument->clone())
126  ),
127  new Power_Int( new Cos( argument->clone() ), 2 )
128  ));
129 
130  return argument->initDerivative();
131 }
132 
133 
135 
136 // end of file.
Operator * derivative2
Abstract base class for all scalar-valued symbolic operators.
Definition: operator.hpp:60
double(* ddfcn)(double)
Operator * derivative
double dTan(double x)
Definition: tan.cpp:39
Abstract base class for all scalar-valued unary operators within the symbolic operators family...
Allows to pass back messages to the calling function.
virtual Operator * clone() const =0
virtual void Tan(Operator &arg)=0
virtual Operator * substitute(int index, const Operator *sub)=0
IntermediateState tan(const Expression &arg)
virtual Operator * substitute(int index, const Operator *sub)
Definition: tan.cpp:106
#define CLOSE_NAMESPACE_ACADO
Operator * argument
BooleanType initialized
Definition: operator.hpp:642
double(* dfcn)(double)
UnaryOperator & operator=(const UnaryOperator &arg)
Implements the scalar cosine operator within the symbolic operators family.
Definition: cos.hpp:55
Implements the scalar tangens operator within the symbolic operators family.
Definition: tan.hpp:55
virtual returnValue initDerivative()
Definition: tan.cpp:117
Implements the scalar power operator with integer exponent within the symbolic operators family...
Definition: powerint.hpp:55
virtual returnValue initDerivative()
Definition: operator.cpp:519
double ddTan(double x)
Definition: tan.cpp:44
Tan & operator=(const Tan &arg)
Definition: tan.cpp:92
#define BT_TRUE
Definition: acado_types.hpp:47
Implements the scalar quotient operator within the symbolic operators family.
Definition: quotient.hpp:55
std::string cName
virtual Operator * clone() const
Definition: tan.cpp:112
OperatorName operatorName
Tan()
Definition: tan.cpp:54
virtual TreeProjection * convert2TreeProjection(Operator *a) const
Definition: operator.cpp:312
#define BEGIN_NAMESPACE_ACADO
Abstract base class for templated evaluation of operators.
virtual returnValue evaluate(EvaluationBase *x)
Definition: tan.cpp:100
double(* fcn)(double)
~Tan()
Definition: tan.cpp:87
Implements a scalar constant within the symbolic operators family.
Implements the scalar product operator within the symbolic operators family.
Definition: product.hpp:55


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Mon Jun 10 2019 12:35:12