aboutsummaryrefslogtreecommitdiffhomepage
path: root/unsupported/Eigen/AdolcForward
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2009-02-04 09:44:44 +0000
committerGravatar Gael Guennebaud <g.gael@free.fr>2009-02-04 09:44:44 +0000
commit44a527dfa50ce9c473cbf1f446b8b6f406d4bc91 (patch)
treea0f045d2a4c22a38e08e1b1d1ce0e17e630898c7 /unsupported/Eigen/AdolcForward
parentb0dd22cc7271523ba83d2bc8a85504b8445587b5 (diff)
* classify and sort the doxygen "related pages"
by tweaking the filename and adding 2 categories: Troubleshooting and Advanced * use the EXCLUDE_SYMBOLS to clean the class list (insteaded of a homemade bash script) * remove the broken "exemple list" * re-structure the unsupported directory as mentionned in the ML and integrate the doc as follow: - snippets of the unsupported directory are directly imported from the main snippets/CMakefile.txt (no need to duplicate code) - add a top level "Unsupported modules" group - unsupported modules have to defined their own sub group and nest it using \ingroup Unsupported_modules - then a pair of //@{ //@} will put everything in the submodule - this is just a proposal !
Diffstat (limited to 'unsupported/Eigen/AdolcForward')
-rw-r--r--unsupported/Eigen/AdolcForward120
1 files changed, 120 insertions, 0 deletions
diff --git a/unsupported/Eigen/AdolcForward b/unsupported/Eigen/AdolcForward
new file mode 100644
index 000000000..1845cb917
--- /dev/null
+++ b/unsupported/Eigen/AdolcForward
@@ -0,0 +1,120 @@
+// This file is part of Eigen, a lightweight C++ template library
+// for linear algebra. Eigen itself is part of the KDE project.
+//
+// Copyright (C) 2008-2009 Gael Guennebaud <g.gael@free.fr>
+//
+// Eigen is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 3 of the License, or (at your option) any later version.
+//
+// Alternatively, you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of
+// the License, or (at your option) any later version.
+//
+// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License and a copy of the GNU General Public License along with
+// Eigen. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef EIGEN_ADLOC_FORWARD
+#define EIGEN_ADLOC_FORWARD
+
+//--------------------------------------------------------------------------------
+//
+// This file provides support for adolc's adouble type in forward mode.
+// ADOL-C is a C++ automatic differentiation library,
+// see http://www.math.tu-dresden.de/~adol-c/ for more information.
+//
+// Note that the maximal number of directions is controlled by
+// the preprocessor token NUMBER_DIRECTIONS. The default is 2.
+//
+//--------------------------------------------------------------------------------
+
+#define ADOLC_TAPELESS
+#ifndef NUMBER_DIRECTIONS
+# define NUMBER_DIRECTIONS 2
+#endif
+#include <adolc/adouble.h>
+
+// adolc defines some very stupid macros:
+#if defined(malloc)
+# undef malloc
+#endif
+
+#if defined(calloc)
+# undef calloc
+#endif
+
+#if defined(realloc)
+# undef realloc
+#endif
+
+#include <Eigen/Core>
+
+namespace Eigen {
+
+namespace unsupported {
+
+/** \ingroup Unsupported_modules
+ * \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 http://www.math.tu-dresden.de/~adol-c/ for more information.
+ * It mainly consists in:
+ * - a struct Eigen::NumTraits<adtl::adouble> specialization
+ * - overloads of ei_* 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 unsupported
+
+} // namespace Eigen
+
+// the Adolc's type adouble is defined in the adtl namespace
+// therefore, the following ei_* functions *must* be defined
+// in the same namespace
+namespace adtl {
+
+ inline const adouble& ei_conj(const adouble& x) { return x; }
+ inline const adouble& ei_real(const adouble& x) { return x; }
+ inline adouble ei_imag(const adouble&) { return 0.; }
+ inline adouble ei_abs(const adouble& x) { return fabs(x); }
+ inline adouble ei_abs2(const adouble& x) { return x*x; }
+ inline adouble ei_sqrt(const adouble& x) { return sqrt(x); }
+ inline adouble ei_exp(const adouble& x) { return exp(x); }
+ inline adouble ei_log(const adouble& x) { return log(x); }
+ inline adouble ei_sin(const adouble& x) { return sin(x); }
+ inline adouble ei_cos(const adouble& x) { return cos(x); }
+ inline adouble ei_pow(const adouble& x, adouble y) { return pow(x, y); }
+
+}
+
+namespace Eigen { namespace unsupported { /*@}*/ } }
+
+template<> struct EigenNumTraits<adtl::adouble>
+{
+ typedef adtl::adouble Real;
+ typedef adtl::adouble FloatingPoint;
+ enum {
+ IsComplex = 0,
+ HasFloatingPoint = 1,
+ ReadCost = 1,
+ AddCost = 1,
+ MulCost = 1
+ };
+};
+
+#endif // EIGEN_ADLOC_FORWARD