Simbody
3.4
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
SimTKmath/include/simmath/internal/common.h
Go to the documentation of this file.
1
#ifndef SimTK_SIMMATH_COMMON_H_
2
#define SimTK_SIMMATH_COMMON_H_
3
4
/* -------------------------------------------------------------------------- *
5
* Simbody(tm): SimTKmath *
6
* -------------------------------------------------------------------------- *
7
* This is part of the SimTK biosimulation toolkit originating from *
8
* Simbios, the NIH National Center for Physics-Based Simulation of *
9
* Biological Structures at Stanford, funded under the NIH Roadmap for *
10
* Medical Research, grant U54 GM072970. See https://simtk.org/home/simbody. *
11
* *
12
* Portions copyright (c) 2006-12 Stanford University and the Authors. *
13
* Authors: Jack Middleton *
14
* Contributors: Michael Sherman *
15
* *
16
* Licensed under the Apache License, Version 2.0 (the "License"); you may *
17
* not use this file except in compliance with the License. You may obtain a *
18
* copy of the License at http://www.apache.org/licenses/LICENSE-2.0. *
19
* *
20
* Unless required by applicable law or agreed to in writing, software *
21
* distributed under the License is distributed on an "AS IS" BASIS, *
22
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
23
* See the License for the specific language governing permissions and *
24
* limitations under the License. *
25
* -------------------------------------------------------------------------- */
26
32
#include "
SimTKcommon.h
"
33
34
/* Shared libraries are messy in Visual Studio. We have to distinguish three
35
* cases:
36
* (1) this header is being used to build the simmath shared library (dllexport)
37
* (2) this header is being used by a *client* of the simmath shared
38
* library (dllimport)
39
* (3) we are building the simmath static library, or the client is
40
* being compiled with the expectation of linking with the
41
* simmath static library (nothing special needed)
42
* In the CMake script for building this library, we define one of the symbols
43
* SIMMATH_BUILDING_{SHARED|STATIC}_LIBRARY
44
* Client code normally has no special symbol defined, in which case we'll
45
* assume it wants to use the shared library. However, if the client defines
46
* the symbol SimTK_USE_STATIC_LIBRARIES we'll suppress the dllimport so
47
* that the client code can be linked with static libraries. Note that
48
* the client symbol is not library dependent, while the library symbols
49
* affect only the simmath library, meaning that other libraries can
50
* be clients of this one. However, we are assuming all-static or all-shared.
51
*/
52
53
#ifdef _WIN32
54
#if defined(SimTK_SIMMATH_BUILDING_SHARED_LIBRARY)
55
#define SimTK_SIMMATH_EXPORT __declspec(dllexport)
56
#elif defined(SimTK_SIMMATH_BUILDING_STATIC_LIBRARY) || defined(SimTK_USE_STATIC_LIBRARIES)
57
#define SimTK_SIMMATH_EXPORT
58
#else
59
/* i.e., a client of a shared library */
60
#define SimTK_SIMMATH_EXPORT __declspec(dllimport)
61
#endif
62
#else
63
/* Linux, Mac */
64
#define SimTK_SIMMATH_EXPORT
65
#endif
66
67
68
// Every SimTK Core library must provide these two routines, with the library
69
// name appearing after the "version_" and "about_".
70
extern
"C"
{
71
SimTK_SIMMATH_EXPORT
void
SimTK_version_simmath
(
int
* major,
int
* minor,
int
* build);
72
SimTK_SIMMATH_EXPORT
void
SimTK_about_simmath
(
const
char
* key,
int
maxlen,
char
* value);
73
}
74
75
76
77
const
static
double
POSITIVE_INF
= 2e19;
78
const
static
double
NEGATIVE_INF
= -2e19;
79
80
namespace
SimTK {
81
82
83
namespace
Exception {
84
85
class
OptimizerFailed
:
public
Base
{
86
public
:
87
OptimizerFailed
(
const
char
* fn,
int
ln,
String
msg) :
Base
(fn, ln)
88
{
89
setMessage
(
"Optimizer failed: "
+ msg );
90
}
91
private
:
92
};
93
94
class
UnrecognizedParameter
:
public
Base
{
95
public
:
96
UnrecognizedParameter
(
const
char
* fn,
int
ln,
String
msg) :
Base
(fn, ln)
97
{
98
setMessage
(
"Unrecognized Parameter: "
+ msg );
99
}
100
private
:
101
};
102
103
class
IllegalLapackArg
:
public
Base
{
104
public
:
105
IllegalLapackArg
(
const
char
*fn,
int
ln,
const
char
*lapackRoutine,
106
int
info ) :
Base
(fn, ln)
107
{
108
char
buf[1024];
109
110
sprintf(buf,
"SimTK internal error: %s called with an illegal value to"
111
" argument #%d.\nPlease report this at SimTK.org."
,
112
lapackRoutine, -info );
113
setMessage
(
String
(buf));
114
115
}
116
private
:
117
};
118
class
IncorrectArrayLength
:
public
Base
{
119
public
:
120
IncorrectArrayLength
(
const
char
*fn,
int
ln,
const
char
*valueName,
int
length,
121
const
char
*paramName,
int
paramValue,
const
char
*where) :
Base
(fn, ln)
122
{
123
char
buf[1024];
124
125
sprintf(buf,
"Incorrect array length in %s : %s is %d and must equal %s which is %d"
,
126
where, valueName, length, paramName, paramValue );
127
setMessage
(
String
(buf));
128
129
}
130
private
:
131
};
132
133
class
SingularMatrix
:
public
Base
{
134
public
:
135
SingularMatrix
(
const
char
*fn,
int
ln,
int
index,
136
const
char
*where) :
Base
(fn, ln)
137
{
138
char
buf[1024];
139
140
sprintf(buf,
"%s failed because index %d in matrix was singular and factorization failed"
,
141
where, index );
142
setMessage
(
String
(buf));
143
144
}
145
private
:
146
};
147
148
class
ConvergedFailed
:
public
Base
{
149
public
:
150
ConvergedFailed
(
const
char
*fn,
int
ln,
const
char
*algorithm,
151
const
char
*where) :
Base
(fn, ln)
152
{
153
char
buf[1024];
154
155
sprintf(buf,
"%s failed because %s failed to converge"
, where, algorithm );
156
setMessage
(
String
(buf));
157
158
}
159
private
:
160
};
161
162
class
NotPositiveDefinite
:
public
Base
{
163
public
:
164
NotPositiveDefinite
(
const
char
*fn,
int
ln,
int
index,
165
const
char
*where) :
Base
(fn, ln)
166
{
167
char
buf[1024];
168
169
sprintf(buf,
"%s failed because index %d in matrix was not positive definite and factorization failed "
,
170
where, index );
171
setMessage
(
String
(buf));
172
173
}
174
private
:
175
};
176
}
// namespace Exception
177
178
}
// namespace SimTK
179
180
#endif // SimTK_SIMMATH_COMMON_H_
SimTKmath
include
simmath
internal
common.h
Generated on Tue Dec 2 2014 13:13:22 for Simbody by
1.8.1.2