Ipopt  3.12.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
IpUtils.hpp
Go to the documentation of this file.
1 // Copyright (C) 2004, 2009 International Business Machines and others.
2 // All Rights Reserved.
3 // This code is published under the Eclipse Public License.
4 //
5 // $Id: IpUtils.hpp 2167 2013-03-08 11:15:38Z stefan $
6 //
7 // Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
8 
9 #ifndef __IPUTILS_HPP__
10 #define __IPUTILS_HPP__
11 
12 // Standard Ip Include Files
13 #include "IpTypes.hpp"
14 #include "IpDebug.hpp"
15 
16 namespace Ipopt
17 {
18 
19  inline Index Max(Index a, Index b)
20  {
21  return ((a) > (b) ? (a) : (b));
22  }
23 
24  inline Index Max(Index a, Index b, Index c)
25  {
26  Index max = Max(a,b);
27  max = Max(max, c);
28  return max;
29  }
30 
31  inline Index Max(Index a, Index b, Index c, Index d)
32  {
33  Index max = Max(a, b, c);
34  max = Max(max, d);
35  return max;
36  }
37 
38  inline Index Min(Index a, Index b)
39  {
40  return ((a) < (b) ? (a) : (b));
41  }
42 
43  inline Index Min(Index a, Index b, Index c)
44  {
45  Index min = Min(a,b);
46  min = Min(min, c);
47  return min;
48  }
49 
50  inline Index Min(Index a, Index b, Index c, Index d)
51  {
52  Index min = Min(a, b, c);
53  min = Min(min, d);
54  return min;
55  }
56 
58 
59  inline Number Max(Number a, Number b)
60  {
61  return ((a) > (b) ? (a) : (b));
62  }
63 
64  inline Number Max(Number a, Number b, Number c)
65  {
66  Number max = Max(a,b);
67  max = Max(max, c);
68  return max;
69  }
70 
71  inline Number Max(Number a, Number b, Number c, Number d)
72  {
73  Number max = Max(a, b, c);
74  max = Max(max, d);
75  return max;
76  }
77 
78  inline Number Min(Number a, Number b)
79  {
80  return ((a) < (b) ? (a) : (b));
81  }
82 
83  inline Number Min(Number a, Number b, Number c)
84  {
85  Number min = Min(a,b);
86  min = Min(min, c);
87  return min;
88  }
89 
90  inline Number Min(Number a, Number b, Number c, Number d)
91  {
92  Number min = Min(a, b, c);
93  min = Min(min, d);
94  return min;
95  }
96 
100 
102  Number IpRandom01();
103 
105  void IpResetRandom01();
106 
108  Number CpuTime();
109 
111  Number SysTime();
112 
115 
120  bool Compare_le(Number lhs, Number rhs, Number BasVal);
121 
124  int Snprintf(char* str, long size, const char* format, ...);
125 
126 } //namespace Ipopt
127 
128 #endif
Index Max(Index a, Index b)
Definition: IpUtils.hpp:19
Number IpRandom01()
Function returning a random number between 0 and 1.
double Number
Type of all numbers.
Definition: IpTypes.hpp:17
void IpResetRandom01()
Function resetting the random number generator.
char char * val
Number WallclockTime()
method determining wallclock time since first call
bool IsFiniteNumber(Number val)
Function returning true iff the argument is a valid double number (not NaN or Inf).
Number CpuTime()
method determining CPU time
Index Min(Index a, Index b)
Definition: IpUtils.hpp:38
Number SysTime()
method determining system time
int Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:19
int Snprintf(char *str, long size, const char *format,...)
Method for printing a formatted output to a string with given size.
double Number
Type for all number.
bool Compare_le(Number lhs, Number rhs, Number BasVal)
Method for comparing two numbers within machine precision.