Ipopt Documentation  
 
Loading...
Searching...
No Matches
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// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
6
7#ifndef __IPUTILS_HPP__
8#define __IPUTILS_HPP__
9
10// Standard Ip Include Files
11#include "IpTypes.hpp"
12#include "IpDebug.hpp"
13
14namespace Ipopt
15{
16
17inline Index Max(
18 Index a,
19 Index b
20)
21{
22 return ((a) > (b) ? (a) : (b));
23}
24
25inline Index Max(
26 Index a,
27 Index b,
28 Index c
29)
30{
31 Index max = Max(a, b);
32 max = Max(max, c);
33 return max;
34}
35
36inline Index Max(
37 Index a,
38 Index b,
39 Index c,
40 Index d
41)
42{
43 Index max = Max(a, b, c);
44 max = Max(max, d);
45 return max;
46}
47
48inline Index Min(
49 Index a,
50 Index b
51)
52{
53 return ((a) < (b) ? (a) : (b));
54}
55
56inline Index Min(
57 Index a,
58 Index b,
59 Index c
60)
61{
62 Index min = Min(a, b);
63 min = Min(min, c);
64 return min;
65}
66
67inline Index Min(
68 Index a,
69 Index b,
70 Index c,
71 Index d
72)
73{
74 Index min = Min(a, b, c);
75 min = Min(min, d);
76 return min;
77}
78
80
81inline Number Max(
82 Number a,
83 Number b
84)
85{
86 return ((a) > (b) ? (a) : (b));
87}
88
89inline Number Max(
90 Number a,
91 Number b,
92 Number c
93)
94{
95 Number max = Max(a, b);
96 max = Max(max, c);
97 return max;
98}
99
100inline Number Max(
101 Number a,
102 Number b,
103 Number c,
104 Number d
105)
106{
107 Number max = Max(a, b, c);
108 max = Max(max, d);
109 return max;
110}
111
112inline Number Min(
113 Number a,
114 Number b
115)
116{
117 return ((a) < (b) ? (a) : (b));
118}
119
120inline Number Min(
121 Number a,
122 Number b,
123 Number c
124)
125{
126 Number min = Min(a, b);
127 min = Min(min, c);
128 return min;
129}
130
131inline Number Min(
132 Number a,
133 Number b,
134 Number c,
135 Number d
136)
137{
138 Number min = Min(a, b, c);
139 min = Min(min, d);
140 return min;
141}
142
146 Number val
147);
148
151
154
157
160
163
171 Number lhs,
172 Number rhs,
173 Number BasVal
174);
175
178 char* str,
179 long size,
180 const char* format,
181 ...
182);
183
184} //namespace Ipopt
185
186#endif
#define IPOPTLIB_EXPORT
This file contains a base class for all exceptions and a set of macros to help with exceptions.
IPOPTLIB_EXPORT Number CpuTime()
method determining CPU time
Index Max(Index a, Index b)
Definition: IpUtils.hpp:17
IPOPTLIB_EXPORT Number SysTime()
method determining system time
IPOPTLIB_EXPORT bool IsFiniteNumber(Number val)
Function returning true iff the argument is a valid double number (not NaN or Inf).
IPOPTLIB_EXPORT bool Compare_le(Number lhs, Number rhs, Number BasVal)
Method for comparing two numbers within machine precision.
int Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:17
Index Min(Index a, Index b)
Definition: IpUtils.hpp:48
IPOPTLIB_EXPORT void IpResetRandom01()
Function resetting the random number generator.
IPOPTLIB_EXPORT int Snprintf(char *str, long size, const char *format,...)
Method for printing a formatted output to a string with given size.
IPOPTLIB_EXPORT Number WallclockTime()
method determining wallclock time since first call
IPOPTLIB_EXPORT Number IpRandom01()
Function returning a random number between 0 and 1.
double Number
Type of all numbers.
Definition: IpTypes.hpp:15