qpOASES
3.1.1
|
00001 /* 00002 * This file is part of qpOASES. 00003 * 00004 * qpOASES -- An Implementation of the Online Active Set Strategy. 00005 * Copyright (C) 2007-2015 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 BEGIN_NAMESPACE_QPOASES 00043 00044 00047 returnValue print( const real_t* const v, 00048 int n, 00049 const char* name = 0 00050 ); 00051 00054 returnValue print( const real_t* const v, 00055 int n, 00056 const int* const V_idx, 00057 const char* name = 0 00058 ); 00059 00062 returnValue print( const real_t* const M, 00063 int nrow, 00064 int ncol, 00065 const char* name = 0 00066 ); 00067 00070 returnValue print( const real_t* const M, 00071 int nrow, 00072 int ncol , 00073 const int* const ROW_idx, 00074 const int* const COL_idx, 00075 const char* name = 0 00076 ); 00077 00080 returnValue print( const int* const index, 00081 int n, 00082 const char* name = 0 00083 ); 00084 00085 00088 returnValue myPrintf( const char* s 00089 ); 00090 00091 00094 returnValue printCopyrightNotice( ); 00095 00096 00101 returnValue readFromFile( real_t* data, 00102 int nrow, 00103 int ncol, 00104 const char* datafilename 00105 ); 00106 00111 returnValue readFromFile( real_t* data, 00112 int n, 00113 const char* datafilename 00114 ); 00115 00120 returnValue readFromFile( int* data, 00121 int n, 00122 const char* datafilename 00123 ); 00124 00125 00129 returnValue writeIntoFile( const real_t* const data, 00130 int nrow, 00131 int ncol, 00132 const char* datafilename, 00133 BooleanType append = BT_FALSE 00134 ); 00135 00139 returnValue writeIntoFile( const real_t* const data, 00140 int n, 00141 const char* datafilename, 00142 BooleanType append = BT_FALSE 00143 ); 00144 00148 returnValue writeIntoFile( const int* const integer, 00149 int n, 00150 const char* datafilename, 00151 BooleanType append = BT_FALSE 00152 ); 00153 00158 returnValue writeIntoMatFile( FILE* const matFile, 00159 const real_t* const data, 00160 int nRows, 00161 int nCols, 00162 const char* name 00163 ); 00164 00169 returnValue writeIntoMatFile( FILE* const matFile, 00170 const int* const data, 00171 int nRows, 00172 int nCols, 00173 const char* name 00174 ); 00175 00176 00179 real_t getCPUtime( ); 00180 00181 00184 real_t getNorm( const real_t* const v, 00185 int n, 00186 int type = 2 00187 ); 00188 00189 00193 inline BooleanType isEqual( real_t x, 00194 real_t y, 00195 real_t TOL = ZERO 00196 ); 00197 00198 00202 inline BooleanType isZero( real_t x, 00203 real_t TOL = ZERO 00204 ); 00205 00206 00210 inline real_t getSign( real_t arg 00211 ); 00212 00213 00216 inline int getMax( int x, 00217 int y 00218 ); 00219 00222 inline int getMin( int x, 00223 int y 00224 ); 00225 00226 00229 inline real_t getMax( real_t x, 00230 real_t y 00231 ); 00232 00235 inline real_t getMin( real_t x, 00236 real_t y 00237 ); 00238 00241 inline real_t getAbs( real_t x 00242 ); 00243 00246 inline real_t getSqrt( real_t x 00247 ); 00248 00249 00252 returnValue getKktViolation( int nV, 00253 int nC, 00254 const real_t* const H, 00255 const real_t* const g, 00256 const real_t* const A, 00257 const real_t* const lb, 00258 const real_t* const ub, 00259 const real_t* const lbA, 00260 const real_t* const ubA, 00261 const real_t* const x, 00262 const real_t* const y, 00263 real_t& stat, 00264 real_t& feas, 00265 real_t& cmpl, 00266 const real_t* const workingSetB = 0, 00267 const real_t* const workingSetC = 0, 00268 BooleanType hasIdentityHessian = BT_FALSE 00269 ); 00270 00273 returnValue getKktViolation( int nV, 00274 const real_t* const H, 00275 const real_t* const g, 00276 const real_t* const lb, 00277 const real_t* const ub, 00278 const real_t* const x, 00279 const real_t* const y, 00280 real_t& stat, 00281 real_t& feas, 00282 real_t& cmpl, 00283 const real_t* const workingSetB = 0, 00284 BooleanType hasIdentityHessian = BT_FALSE 00285 ); 00286 00287 00290 returnValue convertBooleanTypeToString( BooleanType value, 00291 char* const string 00293 ); 00294 00297 returnValue convertSubjectToStatusToString( SubjectToStatus value, 00298 char* const string 00300 ); 00301 00304 returnValue convertPrintLevelToString( PrintLevel value, 00305 char* const string 00307 ); 00308 00309 00319 int getSimpleStatus( returnValue returnvalue, 00320 BooleanType doPrintStatus = BT_FALSE 00321 ); 00322 00323 00327 returnValue normaliseConstraints( int nV, 00328 int nC, 00329 real_t* A, 00331 real_t* lbA, 00333 real_t* ubA, 00335 int type = 1 00336 ); 00337 00338 00339 #ifdef __DEBUG__ 00340 00341 extern "C" void gdb_printmat( const char *fname, 00342 real_t *M, 00343 int n, 00344 int m, 00345 int ldim 00346 ); 00347 #endif /* __DEBUG__ */ 00348 00349 00350 #if defined(__DSPACE__) || defined(__XPCTARGET__) || defined(__C_WRAPPER__) 00351 extern "C" void __cxa_pure_virtual( void ); 00352 #endif /* __DSPACE__ || __XPCTARGET__*/ 00353 00354 00355 00356 END_NAMESPACE_QPOASES 00357 00358 00359 #include <qpOASES/Utils.ipp> 00360 00361 #endif /* QPOASES_UTILS_HPP */ 00362 00363 00364 /* 00365 * end of file 00366 */