acado/function/transition.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 
38 
39 
41 
42 
43 
44 
45 //
46 // PUBLIC MEMBER FUNCTIONS:
47 //
48 
50  :Function(){
51 
52  counter = 0;
53  component = 0;
54 }
55 
57  :Function(arg){
58 
59  int run1;
60  counter = arg.counter;
61  if( arg.component != 0 ){
62  component = (int*)calloc(counter,sizeof(int));
63  for( run1 = 0; run1 < counter; run1++ )
64  component[run1] = arg.component[run1];
65  }
66  else component = 0;
67 }
68 
70 
71  if( component != 0 ) free(component);
72 }
73 
74 
76 
77  if ( this != &arg ){
78 
79  if( component != 0 )
80  free(component);
81 
82  Function::operator=( arg );
83 
84  counter = arg.counter;
85 
86  if( arg.component == 0 ){
87  component = 0;
88  }
89  else{
90  int run1;
91  component = (int*)calloc(counter,sizeof(int));
92  for( run1 = 0; run1 < counter; run1++ ){
93  component[run1] = arg.component[run1];
94  }
95  }
96  }
97  return *this;
98 }
99 
100 
102 
103  uint run1;
104  component = (int*)realloc(component,(counter+arg.getDim())*sizeof(int));
105 
106  for( run1 = 0; run1 < arg.getDim(); run1++ ){
107  counter++;
108  component[counter-1] = arg.getComponent(run1);
109  }
110  return *this;
111 }
112 
113 
115 
117  return *this;
118 }
119 
120 
121 Transition& Transition::operator==( const double &arg ){
122 
123  Expression tmp;
124  tmp = arg;
125  return operator==(tmp);
126 }
127 
128 
130 
131  uint run1;
132 
133  for( run1 = 0; run1 < arg.getDim(); run1++ )
134  operator==( arg(run1) );
135 
136  return *this;
137 }
138 
139 
141 
142  uint run1, run2;
143 
144  for( run1 = 0; run1 < arg.getNumRows(); run1++ )
145  for( run2 = 0; run2 < arg.getNumCols(); run2++ )
146  operator==( arg(run1,run2) );
147 
148  return *this;
149 }
150 
151 
152 
153 
154 
156 
157 // end of file.
Transition & operator=(const Transition &arg)
Allows to setup and evaluate a general function based on SymbolicExpressions.
Definition: function_.hpp:59
BEGIN_NAMESPACE_ACADO typedef unsigned int uint
Definition: acado_types.hpp:42
#define CLOSE_NAMESPACE_ACADO
Transition & operator<<(const DifferentialState &arg)
Base class for all variables within the symbolic expressions family.
Definition: expression.hpp:56
int * component
Definition: transition.hpp:104
Transition & operator==(const Expression &arg)
unsigned getDim() const
Definition: vector.hpp:172
Function & operator=(const Function &rhs)
Definition: function.cpp:78
unsigned getNumRows() const
Definition: matrix.hpp:185
unsigned getNumCols() const
Definition: matrix.hpp:189
Allows to setup and evaluate transition functions based on SymbolicExpressions.
Definition: transition.hpp:53
uint getComponent(const unsigned int idx) const
#define BEGIN_NAMESPACE_ACADO
Function & operator<<(const Expression &arg)
Definition: function.cpp:102
uint getDim() const


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