qpOASES  3.0.1
include/qpOASES/Utils.hpp
Go to the documentation of this file.
00001 /*
00002  *  This file is part of qpOASES.
00003  *
00004  *  qpOASES -- An Implementation of the Online Active Set Strategy.
00005  *  Copyright (C) 2007-2014 by Hans Joachim Ferreau, Andreas Potschka,
00006  *  Christian Kirches et al. All rights reserved.
00007  *
00008  *  qpOASES is free software; you can redistribute it and/or
00009  *  modify it under the terms of the GNU Lesser General Public
00010  *  License as published by the Free Software Foundation; either
00011  *  version 2.1 of the License, or (at your option) any later version.
00012  *
00013  *  qpOASES is distributed in the hope that it will be useful,
00014  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00016  *  See the GNU Lesser General Public License for more details.
00017  *
00018  *  You should have received a copy of the GNU Lesser General Public
00019  *  License along with qpOASES; if not, write to the Free Software
00020  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00021  *
00022  */
00023 
00024 
00035 #ifndef QPOASES_UTILS_HPP
00036 #define QPOASES_UTILS_HPP
00037 
00038 
00039 #include <qpOASES/MessageHandling.hpp>
00040 
00041 
00042 #ifdef __NO_SNPRINTF__
00043   #if (!defined(_MSC_VER)) || defined(__DSPACE__)
00044     /* If snprintf is not available, provide an empty implementation... */
00045     int snprintf( char* s, size_t n, const char* format, ... );
00046   #else
00047     /* ... or substitute snprintf by _snprintf for Microsoft compilers. */
00048     #define snprintf _snprintf    
00049   #endif
00050 #endif /* __NO_SNPRINTF__ */
00051 
00052 
00053 BEGIN_NAMESPACE_QPOASES
00054 
00055 
00058 returnValue print(  const real_t* const v,  
00059                     int n,                  
00060                     const char* name = 0    
00061                     );
00062 
00065 returnValue print(  const real_t* const v,      
00066                     int n,                      
00067                     const int* const V_idx,     
00068                     const char* name = 0        
00069                     );
00070 
00073 returnValue print(  const real_t* const M,  
00074                     int nrow,               
00075                     int ncol,               
00076                     const char* name = 0    
00077                     );
00078 
00081 returnValue print(  const real_t* const M,      
00082                     int nrow,                   
00083                     int ncol    ,               
00084                     const int* const ROW_idx,   
00085                     const int* const COL_idx,   
00086                     const char* name = 0        
00087                     );
00088 
00091 returnValue print(  const int* const index, 
00092                     int n,                  
00093                     const char* name = 0    
00094                     );
00095 
00096 
00099 returnValue myPrintf(   const char* s   
00100                         );
00101 
00102 
00105 returnValue printCopyrightNotice( );
00106 
00107 
00112 returnValue readFromFile(   real_t* data,               
00113                             int nrow,                   
00114                             int ncol,                   
00115                             const char* datafilename    
00116                             );
00117 
00122 returnValue readFromFile(   real_t* data,               
00123                             int n,                      
00124                             const char* datafilename    
00125                             );
00126 
00131 returnValue readFromFile(   int* data,                  
00132                             int n,                      
00133                             const char* datafilename    
00134                             );
00135 
00136 
00140 returnValue writeIntoFile(  const real_t* const data,       
00141                             int nrow,                       
00142                             int ncol,                       
00143                             const char* datafilename,       
00144                             BooleanType append = BT_FALSE   
00145                             );
00146 
00150 returnValue writeIntoFile(  const real_t* const data,       
00151                             int n,                          
00152                             const char* datafilename,       
00153                             BooleanType append = BT_FALSE   
00154                             );
00155 
00159 returnValue writeIntoFile(  const int* const integer,       
00160                             int n,                          
00161                             const char* datafilename,       
00162                             BooleanType append = BT_FALSE   
00163                             );
00164 
00169 returnValue writeIntoMatFile(   FILE* const matFile,        
00170                                 const real_t* const data,   
00171                                 int nRows,                  
00172                                 int nCols,                  
00173                                 const char* name            
00174                                 );
00175 
00180 returnValue writeIntoMatFile(   FILE* const matFile,        
00181                                 const int* const data,      
00182                                 int nRows,                  
00183                                 int nCols,                  
00184                                 const char* name            
00185                                 );
00186 
00187 
00190 real_t getCPUtime( );
00191 
00192 
00195 real_t getNorm( const real_t* const v,  
00196                 int n,                  
00197                 int type = 2            
00198                 );
00199 
00200 
00204 inline BooleanType isEqual( real_t x,           
00205                             real_t y,           
00206                             real_t TOL = ZERO   
00207                             );
00208 
00209 
00213 inline BooleanType isZero(  real_t x,           
00214                             real_t TOL = ZERO   
00215                             );
00216 
00217 
00221 inline real_t getSign(  real_t arg  
00222                         );
00223 
00224 
00227 inline int getMax(  int x,  
00228                     int y   
00229                     );
00230                     
00233 inline int getMin(  int x,  
00234                     int y   
00235                     );
00236 
00237     
00240 inline real_t getMax(   real_t x,   
00241                         real_t y    
00242                         );
00243 
00246 inline real_t getMin(   real_t x,   
00247                         real_t y    
00248                         );
00249 
00252 inline real_t getAbs(   real_t x    
00253                         );
00254 
00257 inline real_t getSqrt(  real_t x    
00258                         );
00259 
00260 
00262 void getKKTResidual(    int nV,                     
00263                         int nC,                     
00264                         const real_t* const H,      
00265                         const real_t* const g,      
00266                         const real_t* const A,      
00267                         const real_t* const lb,     
00268                         const real_t* const ub,     
00269                         const real_t* const lbA,    
00270                         const real_t* const ubA,    
00271                         const real_t* const x,      
00272                         const real_t* const y,      
00273                         real_t& stat,               
00274                         real_t& feas,               
00275                         real_t& cmpl                
00276                         );
00277 
00279 void getKKTResidual(    int nV,                     
00280                         const real_t* const H,      
00281                         const real_t* const g,      
00282                         const real_t* const lb,     
00283                         const real_t* const ub,     
00284                         const real_t* const x,      
00285                         const real_t* const y,      
00286                         real_t& stat,               
00287                         real_t& feas,               
00288                         real_t& cmpl                
00289                         );
00290 
00291 
00294 returnValue convertBooleanTypeToString( BooleanType value,      
00295                                         char* const string      
00297                                         );
00298 
00301 returnValue convertSubjectToStatusToString( SubjectToStatus value,  
00302                                             char* const string      
00304                                             );
00305 
00308 returnValue convertPrintLevelToString(  PrintLevel value,       
00309                                         char* const string      
00311                                         );
00312 
00313 
00323 int getSimpleStatus(    returnValue returnvalue,                
00324                         BooleanType doPrintStatus = BT_FALSE    
00325                         );
00326 
00327 
00331 returnValue normaliseConstraints(   int nV,         
00332                                     int nC,         
00333                                     real_t* A,      
00335                                     real_t* lbA,    
00337                                     real_t* ubA,    
00339                                     int type = 1    
00340                                     );
00341 
00342 
00343 #ifdef __DEBUG__
00344 
00345 extern "C" void gdb_printmat(   const char *fname,          
00346                                 real_t *M,                  
00347                                 int n,                      
00348                                 int m,                      
00349                                 int ldim                    
00350                                 );
00351 #endif /* __DEBUG__ */
00352 
00353 
00354 #if defined(__DSPACE__) || defined(__XPCTARGET__) 
00355 extern "C" void __cxa_pure_virtual( void );
00356 #endif /* __DSPACE__ || __XPCTARGET__*/ 
00357 
00358 
00359 
00360 END_NAMESPACE_QPOASES
00361 
00362 
00363 #include <qpOASES/Utils.ipp>
00364 
00365 #endif  /* QPOASES_UTILS_HPP */
00366 
00367 
00368 /*
00369  *  end of file
00370  */