Apply clang-format

This commit is contained in:
Tobias Wood
2023-11-29 11:12:48 +00:00
parent 9ea520fc45
commit f38e16c193
534 changed files with 103368 additions and 116934 deletions

View File

@@ -23,21 +23,21 @@
#define ADOLC_TAPELESS
#ifndef NUMBER_DIRECTIONS
# define NUMBER_DIRECTIONS 2
#define NUMBER_DIRECTIONS 2
#endif
#include <adolc/adtl.h>
// adolc defines some very stupid macros:
#if defined(malloc)
# undef malloc
#undef malloc
#endif
#if defined(calloc)
# undef calloc
#undef calloc
#endif
#if defined(realloc)
# undef realloc
#undef realloc
#endif
#include "../../Eigen/Core"
@@ -45,45 +45,44 @@
namespace Eigen {
/**
* \defgroup AdolcForward_Module Adolc forward module
* This module provides support for adolc's adouble type in forward mode.
* ADOL-C is a C++ automatic differentiation library,
* see https://projects.coin-or.org/ADOL-C for more information.
* It mainly consists in:
* - a struct Eigen::NumTraits<adtl::adouble> specialization
* - overloads of internal::* math function for adtl::adouble type.
*
* Note that the maximal number of directions is controlled by
* the preprocessor token NUMBER_DIRECTIONS. The default is 2.
*
* \code
* #include <unsupported/Eigen/AdolcSupport>
* \endcode
*/
//@{
* \defgroup AdolcForward_Module Adolc forward module
* This module provides support for adolc's adouble type in forward mode.
* ADOL-C is a C++ automatic differentiation library,
* see https://projects.coin-or.org/ADOL-C for more information.
* It mainly consists in:
* - a struct Eigen::NumTraits<adtl::adouble> specialization
* - overloads of internal::* math function for adtl::adouble type.
*
* Note that the maximal number of directions is controlled by
* the preprocessor token NUMBER_DIRECTIONS. The default is 2.
*
* \code
* #include <unsupported/Eigen/AdolcSupport>
* \endcode
*/
//@{
} // namespace Eigen
} // namespace Eigen
// Eigen's require a few additional functions which must be defined in the same namespace
// than the custom scalar type own namespace
namespace adtl {
inline const adouble& conj(const adouble& x) { return x; }
inline const adouble& real(const adouble& x) { return x; }
inline adouble imag(const adouble&) { return 0.; }
inline adouble abs(const adouble& x) { return fabs(x); }
inline adouble abs2(const adouble& x) { return x*x; }
inline const adouble& conj(const adouble& x) { return x; }
inline const adouble& real(const adouble& x) { return x; }
inline adouble imag(const adouble&) { return 0.; }
inline adouble abs(const adouble& x) { return fabs(x); }
inline adouble abs2(const adouble& x) { return x * x; }
inline bool (isinf)(const adouble& x) { return (Eigen::numext::isinf)(x.getValue()); }
inline bool (isnan)(const adouble& x) { return (Eigen::numext::isnan)(x.getValue()); }
inline bool(isinf)(const adouble& x) { return (Eigen::numext::isinf)(x.getValue()); }
inline bool(isnan)(const adouble& x) { return (Eigen::numext::isnan)(x.getValue()); }
}
} // namespace adtl
namespace Eigen {
template<> struct NumTraits<adtl::adouble>
: NumTraits<double>
{
template <>
struct NumTraits<adtl::adouble> : NumTraits<double> {
typedef adtl::adouble Real;
typedef adtl::adouble NonInteger;
typedef adtl::adouble Nested;
@@ -98,20 +97,20 @@ template<> struct NumTraits<adtl::adouble>
};
};
template<typename Functor> class AdolcForwardJacobian : public Functor
{
template <typename Functor>
class AdolcForwardJacobian : public Functor {
typedef adtl::adouble ActiveScalar;
public:
public:
AdolcForwardJacobian() : Functor() {}
AdolcForwardJacobian(const Functor& f) : Functor(f) {}
// forward constructors
template<typename T0>
template <typename T0>
AdolcForwardJacobian(const T0& a0) : Functor(a0) {}
template<typename T0, typename T1>
template <typename T0, typename T1>
AdolcForwardJacobian(const T0& a0, const T1& a1) : Functor(a0, a1) {}
template<typename T0, typename T1, typename T2>
template <typename T0, typename T1, typename T2>
AdolcForwardJacobian(const T0& a0, const T1& a1, const T1& a2) : Functor(a0, a1, a2) {}
typedef typename Functor::InputType InputType;
@@ -121,11 +120,9 @@ public:
typedef Matrix<ActiveScalar, InputType::SizeAtCompileTime, 1> ActiveInput;
typedef Matrix<ActiveScalar, ValueType::SizeAtCompileTime, 1> ActiveValue;
void operator() (const InputType& x, ValueType* v, JacobianType* _jac) const
{
eigen_assert(v!=0);
if (!_jac)
{
void operator()(const InputType& x, ValueType* v, JacobianType* _jac) const {
eigen_assert(v != 0);
if (!_jac) {
Functor::operator()(x, v);
return;
}
@@ -135,25 +132,22 @@ public:
ActiveInput ax = x.template cast<ActiveScalar>();
ActiveValue av(jac.rows());
for (int j=0; j<jac.cols(); j++)
for (int i=0; i<jac.cols(); i++)
ax[i].setADValue(j, i==j ? 1 : 0);
for (int j = 0; j < jac.cols(); j++)
for (int i = 0; i < jac.cols(); i++) ax[i].setADValue(j, i == j ? 1 : 0);
Functor::operator()(ax, &av);
for (int i=0; i<jac.rows(); i++)
{
for (int i = 0; i < jac.rows(); i++) {
(*v)[i] = av[i].getValue();
for (int j=0; j<jac.cols(); j++)
jac.coeffRef(i,j) = av[i].getADValue(j);
for (int j = 0; j < jac.cols(); j++) jac.coeffRef(i, j) = av[i].getADValue(j);
}
}
protected:
protected:
};
//@}
}
} // namespace Eigen
#endif // EIGEN_ADLOC_FORWARD_MODULE_H
#endif // EIGEN_ADLOC_FORWARD_MODULE_H