Changeset 429


Ignore:
Timestamp:
May 27, 2013 5:28:48 AM (7 years ago)
Author:
kulshres
Message:

merge branch 'new_traceless' into svn 'trunk'

Also update the tapeless_scalar and tapeless_vector examples updated

The following commits have been merged:

commit b8092a92979317d8c4926a2f01799e3f86493b87
Merge: b883461 d1739a3
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Tue Apr 30 14:31:20 2013 +0200

Merge branch 'master' into new_traceless

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit b883461efcdf7ac54268e37884b7d48f94362dad
Author: Benjamin Letschert <letschi@…>
Date: Fri Aug 31 13:35:30 2012 +0200

correct all assignment operators to return this

commit abadb57fb63c5ebe58603313a477d5c62bd75a23
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Fri Jun 8 11:32:52 2012 +0200

use inlining again as much as possible

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 72159664f51564d898a4e8cf24c00169991d43ab
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Mon Jun 4 18:20:33 2012 +0200

bugfixes and efficiency fixes for new traceless mode

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit b3139b5123a9e177bb02c93588cd6b48ed365873
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Tue May 29 16:23:38 2012 +0200

get rid of compilation errors

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 9ffa38f804f69f9e2162020aa29adb791fa2966e
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Tue May 29 15:57:48 2012 +0200

add files to build system

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 288b0b568c6b7b10d0eddc649e8c79c65600f62e
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Tue May 29 15:50:31 2012 +0200

reimplement tapeless mode

due to larger functions required with sparsity pattern detection, the
preprocessor based implementation of the tapeless mode was bad. now it
is a runtime based implementation.

the user does
#include <adolc/adtl.h>

using namespace adtl;

there is no more need for ADOLC_TAPELESS_UNIQUE_INTERNALS.

the user needs to call setNumDir(n) for n>1
and setMode(ADTL_INDO) for sparsity detection
then later setMode(ADTL_FOV) for getting derivatives

one could also do setMode(ADTL_FOV_INDO) for both simultaneously.

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit c5bb5abcb3aceeb9ca7e4ac99b3f50e0ae6ac8db
Author: Benjamin Letschert <letschi@…>
Date: Fri Mar 30 13:15:03 2012 +0200

Adding control variable for ADOLC_Init_sparse_pattern

commit b5ae7415cb4bb90d80a1f0cfbcc53197cff7939e
Author: Benjamin Letschert <letschi@…>
Date: Thu Mar 29 18:24:42 2012 +0200

Adding ADOLC_TRACELESS_SPARSE_PATTERN in traceless mode

Location:
trunk
Files:
4 added
53 edited

Legend:

Unmodified
Added
Removed
  • trunk/ADOL-C/Makefile.in

    r377 r429  
    5656DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
    5757ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    58 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
     58am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
     59        $(top_srcdir)/autoconf/acx_builtin.m4 \
     60        $(top_srcdir)/configure.ac
    5961am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    6062        $(ACLOCAL_M4)
  • trunk/ADOL-C/examples/Makefile.in

    r377 r429  
    6161        $(top_srcdir)/autoconf/depcomp
    6262ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    63 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
     63am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
     64        $(top_srcdir)/autoconf/acx_builtin.m4 \
     65        $(top_srcdir)/configure.ac
    6466am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    6567        $(ACLOCAL_M4)
  • trunk/ADOL-C/examples/additional_examples/Makefile.in

    r407 r429  
    5656DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
    5757ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    58 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
     58am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
     59        $(top_srcdir)/autoconf/acx_builtin.m4 \
     60        $(top_srcdir)/configure.ac
    5961am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    6062        $(ACLOCAL_M4)
  • trunk/ADOL-C/examples/additional_examples/checkpointing/Makefile.in

    r377 r429  
    5959        $(top_srcdir)/autoconf/depcomp
    6060ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    61 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
     61am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
     62        $(top_srcdir)/autoconf/acx_builtin.m4 \
     63        $(top_srcdir)/configure.ac
    6264am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    6365        $(ACLOCAL_M4)
  • trunk/ADOL-C/examples/additional_examples/clock/Makefile.in

    r377 r429  
    5656DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
    5757ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    58 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
     58am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
     59        $(top_srcdir)/autoconf/acx_builtin.m4 \
     60        $(top_srcdir)/configure.ac
    5961am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    6062        $(ACLOCAL_M4)
  • trunk/ADOL-C/examples/additional_examples/cuda/Makefile.in

    r407 r429  
    5656DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
    5757ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    58 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
     58am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
     59        $(top_srcdir)/autoconf/acx_builtin.m4 \
     60        $(top_srcdir)/configure.ac
    5961am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    6062        $(ACLOCAL_M4)
  • trunk/ADOL-C/examples/additional_examples/detexam/Makefile.in

    r377 r429  
    5959        $(top_srcdir)/autoconf/depcomp
    6060ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    61 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
     61am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
     62        $(top_srcdir)/autoconf/acx_builtin.m4 \
     63        $(top_srcdir)/configure.ac
    6264am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    6365        $(ACLOCAL_M4)
  • trunk/ADOL-C/examples/additional_examples/ext_diff_func/Makefile.in

    r377 r429  
    5959        $(top_srcdir)/autoconf/depcomp
    6060ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    61 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
     61am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
     62        $(top_srcdir)/autoconf/acx_builtin.m4 \
     63        $(top_srcdir)/configure.ac
    6264am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    6365        $(ACLOCAL_M4)
  • trunk/ADOL-C/examples/additional_examples/fixpoint_exam/Makefile.in

    r377 r429  
    5959        $(top_srcdir)/autoconf/depcomp
    6060ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    61 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
     61am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
     62        $(top_srcdir)/autoconf/acx_builtin.m4 \
     63        $(top_srcdir)/configure.ac
    6264am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    6365        $(ACLOCAL_M4)
  • trunk/ADOL-C/examples/additional_examples/helm/Makefile.in

    r377 r429  
    5959        $(top_srcdir)/autoconf/depcomp
    6060ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    61 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
     61am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
     62        $(top_srcdir)/autoconf/acx_builtin.m4 \
     63        $(top_srcdir)/configure.ac
    6264am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    6365        $(ACLOCAL_M4)
  • trunk/ADOL-C/examples/additional_examples/hessmat/Makefile.in

    r377 r429  
    5959        $(top_srcdir)/autoconf/depcomp
    6060ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    61 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
     61am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
     62        $(top_srcdir)/autoconf/acx_builtin.m4 \
     63        $(top_srcdir)/configure.ac
    6264am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    6365        $(ACLOCAL_M4)
  • trunk/ADOL-C/examples/additional_examples/lighthouse/Makefile.in

    r377 r429  
    6060        $(top_srcdir)/autoconf/depcomp
    6161ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    62 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
     62am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
     63        $(top_srcdir)/autoconf/acx_builtin.m4 \
     64        $(top_srcdir)/configure.ac
    6365am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    6466        $(ACLOCAL_M4)
  • trunk/ADOL-C/examples/additional_examples/lufact/Makefile.in

    r377 r429  
    5959        $(top_srcdir)/autoconf/depcomp
    6060ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    61 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
     61am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
     62        $(top_srcdir)/autoconf/acx_builtin.m4 \
     63        $(top_srcdir)/configure.ac
    6264am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    6365        $(ACLOCAL_M4)
  • trunk/ADOL-C/examples/additional_examples/ode/Makefile.in

    r377 r429  
    6060        $(top_srcdir)/autoconf/depcomp
    6161ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    62 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
     62am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
     63        $(top_srcdir)/autoconf/acx_builtin.m4 \
     64        $(top_srcdir)/configure.ac
    6365am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    6466        $(ACLOCAL_M4)
  • trunk/ADOL-C/examples/additional_examples/openmp_exam/Makefile.in

    r377 r429  
    5959        $(top_srcdir)/autoconf/depcomp
    6060ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    61 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
     61am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
     62        $(top_srcdir)/autoconf/acx_builtin.m4 \
     63        $(top_srcdir)/configure.ac
    6264am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    6365        $(ACLOCAL_M4)
  • trunk/ADOL-C/examples/additional_examples/pow/Makefile.in

    r377 r429  
    5959        $(top_srcdir)/autoconf/depcomp
    6060ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    61 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
     61am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
     62        $(top_srcdir)/autoconf/acx_builtin.m4 \
     63        $(top_srcdir)/configure.ac
    6264am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    6365        $(ACLOCAL_M4)
  • trunk/ADOL-C/examples/additional_examples/scal/Makefile.in

    r377 r429  
    5959        $(top_srcdir)/autoconf/depcomp
    6060ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    61 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
     61am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
     62        $(top_srcdir)/autoconf/acx_builtin.m4 \
     63        $(top_srcdir)/configure.ac
    6264am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    6365        $(ACLOCAL_M4)
  • trunk/ADOL-C/examples/additional_examples/sparse/Makefile.in

    r377 r429  
    6161        $(top_srcdir)/autoconf/depcomp
    6262ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    63 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
     63am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
     64        $(top_srcdir)/autoconf/acx_builtin.m4 \
     65        $(top_srcdir)/configure.ac
    6466am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    6567        $(ACLOCAL_M4)
  • trunk/ADOL-C/examples/additional_examples/speelpenning/Makefile.in

    r377 r429  
    5959        $(top_srcdir)/autoconf/depcomp
    6060ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    61 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
     61am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
     62        $(top_srcdir)/autoconf/acx_builtin.m4 \
     63        $(top_srcdir)/configure.ac
    6264am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    6365        $(ACLOCAL_M4)
  • trunk/ADOL-C/examples/additional_examples/tapesave/Makefile.in

    r377 r429  
    5959        $(top_srcdir)/autoconf/depcomp
    6060ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    61 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
     61am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
     62        $(top_srcdir)/autoconf/acx_builtin.m4 \
     63        $(top_srcdir)/configure.ac
    6264am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    6365        $(ACLOCAL_M4)
  • trunk/ADOL-C/examples/additional_examples/taylor/Makefile.in

    r377 r429  
    6161        $(top_srcdir)/autoconf/depcomp
    6262ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    63 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
     63am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
     64        $(top_srcdir)/autoconf/acx_builtin.m4 \
     65        $(top_srcdir)/configure.ac
    6466am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    6567        $(ACLOCAL_M4)
  • trunk/ADOL-C/examples/additional_examples/timing/Makefile.in

    r377 r429  
    6666        $(top_srcdir)/autoconf/depcomp
    6767ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    68 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
     68am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
     69        $(top_srcdir)/autoconf/acx_builtin.m4 \
     70        $(top_srcdir)/configure.ac
    6971am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    7072        $(ACLOCAL_M4)
  • trunk/ADOL-C/examples/tapeless_scalar.cpp

    r171 r429  
    2222using namespace std;
    2323
    24 #define ADOLC_TAPELESS
    25 #include <adolc/adouble.h>
     24#include <adolc/adtl.h>
    2625typedef adtl::adouble adouble;
    2726
     
    3635
    3736    // derivative of y with respect to x0
    38     x[0].setADValue(1);
     37    double one=1.0;
     38    x[0].setADValue(&one);
    3939
    4040    y[0] = sqrt(x[0]*x[0]+x[1]*x[1]+x[2]*x[2]);
     
    5151    // "use" the derivative
    5252    cout << "derivative:" << endl;
    53     cout << "dy[0]/dx[0] = " << y[0].getADValue() << "  dy[1]/dx[0] = " << y[1].getADValue()
    54     << "  dy[2]/dx[0] = " << y[2].getADValue() << endl;
     53    cout << "dy[0]/dx[0] = " << *y[0].getADValue() << "  dy[1]/dx[0] = " << *y[1].getADValue()
     54    << "  dy[2]/dx[0] = " << *y[2].getADValue() << endl;
    5555
    5656    return 0;
  • trunk/ADOL-C/examples/tapeless_vector.cpp

    r171 r429  
    2121using namespace std;
    2222
    23 #define ADOLC_TAPELESS
    24 #define NUMBER_DIRECTIONS 3
    25 #include <adolc/adouble.h>
     23#include <adolc/adtl.h>
    2624typedef adtl::adouble adouble;
    2725
    28 ADOLC_TAPELESS_UNIQUE_INTERNALS
    29 
    3026int main(int argc, char *argv[]) {
     27    adtl::setNumDir(3);
    3128    adouble x[3], y[3];
    3229
  • trunk/ADOL-C/include/Makefile.in

    r377 r429  
    5656DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
    5757ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    58 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
     58am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
     59        $(top_srcdir)/autoconf/acx_builtin.m4 \
     60        $(top_srcdir)/configure.ac
    5961am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    6062        $(ACLOCAL_M4)
  • trunk/ADOL-C/include/adolc/Makefile.am

    r408 r429  
    1717                       adolc_sparse.h adolc_openmp.h \
    1818                       revolve.h advector.h adolc_settings.h \
    19                        adoublecuda.h
     19                       adtl.h adoublecuda.h
    2020
    2121SUBDIRS = drivers tapedoc
  • trunk/ADOL-C/include/adolc/Makefile.in

    r407 r429  
    5959        $(srcdir)/Makefile.in $(srcdir)/adolc_settings.h.in
    6060ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    61 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
     61am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
     62        $(top_srcdir)/autoconf/acx_builtin.m4 \
     63        $(top_srcdir)/configure.ac
    6264am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    6365        $(ACLOCAL_M4)
     
    290292                       adolc_sparse.h adolc_openmp.h \
    291293                       revolve.h advector.h adolc_settings.h \
    292                        adoublecuda.h
     294                       adtl.h adoublecuda.h
    293295
    294296SUBDIRS = drivers tapedoc $(am__append_1)
  • trunk/ADOL-C/include/adolc/adouble.h

    r428 r429  
    99           class (badouble).  See below for further explanation.
    1010
    11  Copyright (c) Andrea Walther, Andreas Griewank, Andreas Kowarz, 
     11 Copyright (c) Andrea Walther, Andreas Griewank, Andreas Kowarz,
    1212               Hristo Mitev, Sebastian Schlenkrich, Jean Utke, Olaf Vogel,
    13                Kshitij Kulshreshtha
    14  
     13               Benjamin Letschert Kshitij Kulshreshtha
     14
    1515 This file is part of ADOL-C. This software is provided as open source.
    1616 Any use, reproduction, or distribution of the software constitutes
     
    3939
    4040/* NOTICE: There are automatic includes at the end of this file! */
    41 
    42 #undef TAPELESS
    43 #undef SAFE
    44 #if defined(ADOLC_TAPELESS)
    45 #  define TAPELESS
    46 #  undef SAFE
    47 #endif
    48 
    49 #if defined(SAFE_ADOLC_TAPELESS)
    50 #  define TAPELESS
    51 #  define SAFE
    52 #endif
    53 
    54 #if !defined(TAPELESS)
    5541
    5642/****************************************************************************/
     
    497483}
    498484
    499 /****************************************************************************/
    500 /* tapeless implementation                                                  */
    501 /****************************************************************************/
    502 #else
    503 
    504 #include <limits>
    505 
    506 namespace adtl {
    507 
    508 #if defined(NUMBER_DIRECTIONS)
    509 extern int ADOLC_numDir;
    510 #define ADOLC_TAPELESS_UNIQUE_INTERNALS int adtl::ADOLC_numDir = NUMBER_DIRECTIONS;
    511 #if !defined(DYNAMIC_DIRECTIONS)
    512 #  define ADVAL                adval[NUMBER_DIRECTIONS]
    513 #else
    514 #  define ADVAL                *adval;
    515 #endif
    516 #  define ADVAL_TYPE           const double *
    517 #  define FOR_I_EQ_0_LT_NUMDIR for (int _i=0; _i < ADOLC_numDir; ++_i)
    518 #  define ADVAL_I              adval[_i]
    519 #  define ADV_I                adv[_i]
    520 #  define V_I                  v[_i]
    521 #else
    522 #  define ADVAL                adval
    523 #  define ADVAL_TYPE           double
    524 #  define FOR_I_EQ_0_LT_NUMDIR
    525 #  define ADVAL_I              adval
    526 #  define ADV_I                adv
    527 #  define V_I                  v
    528 #endif
    529 
    530 inline double makeNaN() {
    531     return ADOLC_MATH_NSP::numeric_limits<double>::quiet_NaN();
    532 }
    533 
    534 inline double makeInf() {
    535     return ADOLC_MATH_NSP::numeric_limits<double>::infinity();
    536 }
    537 
    538 class adouble {
    539 public:
    540     // ctors
    541     inline adouble();
    542     inline adouble(const double v);
    543     inline adouble(const double v, ADVAL_TYPE adv);
    544     inline adouble(const adouble& a);
    545 #if defined(DYNAMIC_DIRECTIONS)
    546     inline ~adouble();
    547 #endif
    548 
    549     /*******************  temporary results  ******************************/
    550     // sign
    551     inline adouble operator - () const;
    552     inline adouble operator + () const;
    553 
    554     // addition
    555     inline adouble operator + (const double v) const;
    556     inline adouble operator + (const adouble& a) const;
    557     inline friend
    558     adouble operator + (const double v, const adouble& a);
    559 
    560     // substraction
    561     inline adouble operator - (const double v) const;
    562     inline adouble operator - (const adouble& a) const;
    563     inline friend
    564     adouble operator - (const double v, const adouble& a);
    565 
    566     // multiplication
    567     inline adouble operator * (const double v) const;
    568     inline adouble operator * (const adouble& a) const;
    569     inline friend
    570     adouble operator * (const double v, const adouble& a);
    571 
    572     // division
    573     inline adouble operator / (const double v) const;
    574     inline adouble operator / (const adouble& a) const;
    575     inline friend
    576     adouble operator / (const double v, const adouble& a);
    577 
    578     // inc/dec
    579     inline adouble operator ++ ();
    580     inline adouble operator ++ (int);
    581     inline adouble operator -- ();
    582     inline adouble operator -- (int);
    583 
    584     // functions
    585     inline friend adouble tan(const adouble &a);
    586     inline friend adouble exp(const adouble &a);
    587     inline friend adouble log(const adouble &a);
    588     inline friend adouble sqrt(const adouble &a);
    589     inline friend adouble sin(const adouble &a);
    590     inline friend adouble cos(const adouble &a);
    591     inline friend adouble asin(const adouble &a);
    592     inline friend adouble acos(const adouble &a);
    593     inline friend adouble atan(const adouble &a);
    594 
    595     inline friend adouble atan2(const adouble &a, const adouble &b);
    596     inline friend adouble pow(const adouble &a, double v);
    597     inline friend adouble pow(const adouble &a, const adouble &b);
    598     inline friend adouble pow(double v, const adouble &a);
    599     inline friend adouble log10(const adouble &a);
    600 
    601     inline friend adouble sinh (const adouble &a);
    602     inline friend adouble cosh (const adouble &a);
    603     inline friend adouble tanh (const adouble &a);
    604 #if defined(ATRIG_ERF)
    605     inline friend adouble asinh (const adouble &a);
    606     inline friend adouble acosh (const adouble &a);
    607     inline friend adouble atanh (const adouble &a);
    608 #endif
    609     inline friend adouble fabs (const adouble &a);
    610     inline friend adouble ceil (const adouble &a);
    611     inline friend adouble floor (const adouble &a);
    612     inline friend adouble fmax (const adouble &a, const adouble &b);
    613     inline friend adouble fmax (double v, const adouble &a);
    614     inline friend adouble fmax (const adouble &a, double v);
    615     inline friend adouble fmin (const adouble &a, const adouble &b);
    616     inline friend adouble fmin (double v, const adouble &a);
    617     inline friend adouble fmin (const adouble &a, double v);
    618     inline friend adouble ldexp (const adouble &a, const adouble &b);
    619     inline friend adouble ldexp (const adouble &a, const double v);
    620     inline friend adouble ldexp (const double v, const adouble &a);
    621     inline friend double frexp (const adouble &a, int* v);
    622 #if defined(ATRIG_ERF)
    623     inline friend adouble erf (const adouble &a);
    624 #endif
    625 
    626 
    627     /*******************  nontemporary results  ***************************/
    628     // assignment
    629     inline void operator = (const double v);
    630     inline void operator = (const adouble& a);
    631 
    632     // addition
    633     inline void operator += (const double v);
    634     inline void operator += (const adouble& a);
    635 
    636     // substraction
    637     inline void operator -= (const double v);
    638     inline void operator -= (const adouble& a);
    639 
    640     // multiplication
    641     inline void operator *= (const double v);
    642     inline void operator *= (const adouble& a);
    643 
    644     // division
    645     inline void operator /= (const double v);
    646     inline void operator /= (const adouble& a);
    647 
    648     // not
    649     inline int operator ! () const;
    650 
    651     // comparision
    652     inline int operator != (const adouble&) const;
    653     inline int operator != (const double) const;
    654     inline friend int operator != (const double, const adouble&);
    655 
    656     inline int operator == (const adouble&) const;
    657     inline int operator == (const double) const;
    658     inline friend int operator == (const double, const adouble&);
    659 
    660     inline int operator <= (const adouble&) const;
    661     inline int operator <= (const double) const;
    662     inline friend int operator <= (const double, const adouble&);
    663 
    664     inline int operator >= (const adouble&) const;
    665     inline int operator >= (const double) const;
    666     inline friend int operator >= (const double, const adouble&);
    667 
    668     inline int operator >  (const adouble&) const;
    669     inline int operator >  (const double) const;
    670     inline friend int operator >  (const double, const adouble&);
    671 
    672     inline int operator <  (const adouble&) const;
    673     inline int operator <  (const double) const;
    674     inline friend int operator <  (const double, const adouble&);
    675 
    676     /*******************  getter / setter  ********************************/
    677     inline double getValue() const;
    678     inline void setValue(const double v);
    679     inline ADVAL_TYPE getADValue() const;
    680     inline void setADValue(ADVAL_TYPE v);
    681 #if defined(NUMBER_DIRECTIONS)
    682     inline double getADValue(const unsigned int p) const;
    683     inline void setADValue(const unsigned int p, const double v);
    684 #endif
    685 
    686     /*******************  i/o operations  *********************************/
    687     inline friend ostream& operator << ( ostream&, const adouble& );
    688     inline friend istream& operator >> ( istream&, adouble& );
    689 
    690 
    691 private:
    692     // internal variables
    693     double val;
    694     double ADVAL;
    695 };
    696 
    697 /*******************************  ctors  ************************************/
    698 adouble::adouble() {
    699 #if defined(DYNAMIC_DIRECTIONS)
    700     adval = new double[ADOLC_numDir];
    701 #endif
    702 }
    703 
    704 adouble::adouble(const double v) : val(v) {
    705 #if defined(DYNAMIC_DIRECTIONS)
    706     adval = new double[ADOLC_numDir];
    707 #endif
    708     FOR_I_EQ_0_LT_NUMDIR
    709     ADVAL_I = 0.0;
    710 }
    711 
    712 adouble::adouble(const double v, ADVAL_TYPE adv) : val(v) {
    713 #if defined(DYNAMIC_DIRECTIONS)
    714     adval = new double[ADOLC_numDir];
    715 #endif
    716     FOR_I_EQ_0_LT_NUMDIR
    717     ADVAL_I=ADV_I;
    718 }
    719 
    720 adouble::adouble(const adouble& a) : val(a.val) {
    721 #if defined(DYNAMIC_DIRECTIONS)
    722     adval = new double[ADOLC_numDir];
    723 #endif
    724     FOR_I_EQ_0_LT_NUMDIR
    725     ADVAL_I=a.ADVAL_I;
    726 }
    727 
    728 /*******************************  dtors  ************************************/
    729 #if defined(DYNAMIC_DIRECTIONS)
    730 adouble::~adouble() {
    731     delete[] adval;
    732 }
    733 #endif
    734 
    735 /*************************  temporary results  ******************************/
    736 // sign
    737 adouble adouble::operator - () const {
    738     adouble tmp;
    739     tmp.val=-val;
    740     FOR_I_EQ_0_LT_NUMDIR
    741     tmp.ADVAL_I=-ADVAL_I;
    742     return tmp;
    743 }
    744 
    745 adouble adouble::operator + () const {
    746     return *this;
    747 }
    748 
    749 // addition
    750 adouble adouble::operator + (const double v) const {
    751     return adouble(val+v, adval);
    752 }
    753 
    754 adouble adouble::operator + (const adouble& a) const {
    755     adouble tmp;
    756     tmp.val=val+a.val;
    757     FOR_I_EQ_0_LT_NUMDIR
    758     tmp.ADVAL_I=ADVAL_I+a.ADVAL_I;
    759     return tmp;
    760 }
    761 
    762 adouble operator + (const double v, const adouble& a) {
    763     return adouble(v+a.val, a.adval);
    764 }
    765 
    766 // subtraction
    767 adouble adouble::operator - (const double v) const {
    768     return adouble(val-v, adval);
    769 }
    770 
    771 adouble adouble::operator - (const adouble& a) const {
    772     adouble tmp;
    773     tmp.val=val-a.val;
    774     FOR_I_EQ_0_LT_NUMDIR
    775     tmp.ADVAL_I=ADVAL_I-a.ADVAL_I;
    776     return tmp;
    777 }
    778 
    779 adouble operator - (const double v, const adouble& a) {
    780     adouble tmp;
    781     tmp.val=v-a.val;
    782     FOR_I_EQ_0_LT_NUMDIR
    783     tmp.ADVAL_I=-a.ADVAL_I;
    784     return tmp;
    785 }
    786 
    787 // multiplication
    788 adouble adouble::operator * (const double v) const {
    789     adouble tmp;
    790     tmp.val=val*v;
    791     FOR_I_EQ_0_LT_NUMDIR
    792     tmp.ADVAL_I=ADVAL_I*v;
    793     return tmp;
    794 }
    795 
    796 adouble adouble::operator * (const adouble& a) const {
    797     adouble tmp;
    798     tmp.val=val*a.val;
    799     FOR_I_EQ_0_LT_NUMDIR
    800     tmp.ADVAL_I=ADVAL_I*a.val+val*a.ADVAL_I;
    801     return tmp;
    802 }
    803 
    804 adouble operator * (const double v, const adouble& a) {
    805     adouble tmp;
    806     tmp.val=v*a.val;
    807     FOR_I_EQ_0_LT_NUMDIR
    808     tmp.ADVAL_I=v*a.ADVAL_I;
    809     return tmp;
    810 }
    811 
    812 // division
    813 adouble adouble::operator / (const double v) const {
    814     adouble tmp;
    815     tmp.val=val/v;
    816     FOR_I_EQ_0_LT_NUMDIR
    817     tmp.ADVAL_I=ADVAL_I/v;
    818     return tmp;
    819 }
    820 
    821 adouble adouble::operator / (const adouble& a) const {
    822     adouble tmp;
    823     tmp.val=val/a.val;
    824     FOR_I_EQ_0_LT_NUMDIR
    825     tmp.ADVAL_I=(ADVAL_I*a.val-val*a.ADVAL_I)/(a.val*a.val);
    826     return tmp;
    827 }
    828 
    829 adouble operator / (const double v, const adouble& a) {
    830     adouble tmp;
    831     tmp.val=v/a.val;
    832     FOR_I_EQ_0_LT_NUMDIR
    833     tmp.ADVAL_I=(-v*a.ADVAL_I)/(a.val*a.val);
    834     return tmp;
    835 }
    836 
    837 // inc/dec
    838 adouble adouble::operator ++ () {
    839     ++val;
    840     return *this;
    841 }
    842 
    843 adouble adouble::operator ++ (int) {
    844     adouble tmp;
    845     tmp.val=val++;
    846     FOR_I_EQ_0_LT_NUMDIR
    847     tmp.ADVAL_I=ADVAL_I;
    848     return tmp;
    849 }
    850 
    851 adouble adouble::operator -- () {
    852     --val;
    853     return *this;
    854 }
    855 
    856 adouble adouble::operator -- (int) {
    857     adouble tmp;
    858     tmp.val=val--;
    859     FOR_I_EQ_0_LT_NUMDIR
    860     tmp.ADVAL_I=ADVAL_I;
    861     return tmp;
    862 }
    863 
    864 // functions
    865 adouble tan(const adouble& a) {
    866     adouble tmp;
    867     double tmp2;
    868     tmp.val=ADOLC_MATH_NSP::tan(a.val);
    869     tmp2=ADOLC_MATH_NSP::cos(a.val);
    870     tmp2*=tmp2;
    871     FOR_I_EQ_0_LT_NUMDIR
    872     tmp.ADVAL_I=a.ADVAL_I/tmp2;
    873     return tmp;
    874 }
    875 
    876 adouble exp(const adouble &a) {
    877     adouble tmp;
    878     tmp.val=ADOLC_MATH_NSP::exp(a.val);
    879     FOR_I_EQ_0_LT_NUMDIR
    880     tmp.ADVAL_I=tmp.val*a.ADVAL_I;
    881     return tmp;
    882 }
    883 
    884 adouble log(const adouble &a) {
    885     adouble tmp;
    886     tmp.val=ADOLC_MATH_NSP::log(a.val);
    887     FOR_I_EQ_0_LT_NUMDIR
    888         if (a.val>0) tmp.ADVAL_I=a.ADVAL_I/a.val;
    889         else if (a.val==0 && a.ADVAL_I != 0.0) {
    890             int sign = (a.ADVAL_I < 0)  ? -1 : 1;
    891             tmp.ADVAL_I=sign*makeInf();
    892         } else tmp.ADVAL_I=makeNaN();
    893     return tmp;
    894 }
    895 
    896 adouble sqrt(const adouble &a) {
    897     adouble tmp;
    898     tmp.val=ADOLC_MATH_NSP::sqrt(a.val);
    899     FOR_I_EQ_0_LT_NUMDIR
    900         if (a.val>0) tmp.ADVAL_I=a.ADVAL_I/(tmp.val*2);
    901         else if (a.val==0.0 && a.ADVAL_I != 0.0) {
    902             int sign = (a.ADVAL_I < 0) ? -1 : 1;
    903             tmp.ADVAL_I=sign * makeInf();
    904         } else tmp.ADVAL_I=makeNaN();
    905     return tmp;
    906 }
    907 
    908 adouble sin(const adouble &a) {
    909     adouble tmp;
    910     double tmp2;
    911     tmp.val=ADOLC_MATH_NSP::sin(a.val);
    912     tmp2=ADOLC_MATH_NSP::cos(a.val);
    913     FOR_I_EQ_0_LT_NUMDIR
    914     tmp.ADVAL_I=tmp2*a.ADVAL_I;
    915     return tmp;
    916 }
    917 
    918 adouble cos(const adouble &a) {
    919     adouble tmp;
    920     double tmp2;
    921     tmp.val=ADOLC_MATH_NSP::cos(a.val);
    922     tmp2=-ADOLC_MATH_NSP::sin(a.val);
    923     FOR_I_EQ_0_LT_NUMDIR
    924     tmp.ADVAL_I=tmp2*a.ADVAL_I;
    925     return tmp;
    926 }
    927 
    928 adouble asin(const adouble &a) {
    929     adouble tmp;
    930     tmp.val=ADOLC_MATH_NSP::asin(a.val);
    931     double tmp2=ADOLC_MATH_NSP::sqrt(1-a.val*a.val);
    932     FOR_I_EQ_0_LT_NUMDIR
    933     tmp.ADVAL_I=a.ADVAL_I/tmp2;
    934     return tmp;
    935 }
    936 
    937 adouble acos(const adouble &a) {
    938     adouble tmp;
    939     tmp.val=ADOLC_MATH_NSP::acos(a.val);
    940     double tmp2=-ADOLC_MATH_NSP::sqrt(1-a.val*a.val);
    941     FOR_I_EQ_0_LT_NUMDIR
    942     tmp.ADVAL_I=a.ADVAL_I/tmp2;
    943     return tmp;
    944 }
    945 
    946 adouble atan(const adouble &a) {
    947     adouble tmp;
    948     tmp.val=ADOLC_MATH_NSP::atan(a.val);
    949     double tmp2=1+a.val*a.val;
    950     tmp2=1/tmp2;
    951     if (tmp2!=0)
    952         FOR_I_EQ_0_LT_NUMDIR
    953         tmp.ADVAL_I=a.ADVAL_I*tmp2;
    954     else
    955         FOR_I_EQ_0_LT_NUMDIR
    956         tmp.ADVAL_I=0.0;
    957     return tmp;
    958 }
    959 
    960 adouble atan2(const adouble &a, const adouble &b) {
    961     adouble tmp;
    962     tmp.val=ADOLC_MATH_NSP::atan2(a.val, b.val);
    963     double tmp2=a.val*a.val;
    964     double tmp3=b.val*b.val;
    965     double tmp4=tmp3/(tmp2+tmp3);
    966     if (tmp4!=0)
    967         FOR_I_EQ_0_LT_NUMDIR
    968         tmp.ADVAL_I=(a.ADVAL_I*b.val-a.val*b.ADVAL_I)/tmp3*tmp4;
    969     else
    970         FOR_I_EQ_0_LT_NUMDIR
    971         tmp.ADVAL_I=0.0;
    972     return tmp;
    973 }
    974 
    975 adouble pow(const adouble &a, double v) {
    976     adouble tmp;
    977     tmp.val=ADOLC_MATH_NSP::pow(a.val, v);
    978     double tmp2=v*ADOLC_MATH_NSP::pow(a.val, v-1);
    979     FOR_I_EQ_0_LT_NUMDIR
    980     tmp.ADVAL_I=tmp2*a.ADVAL_I;
    981     return tmp;
    982 }
    983 
    984 adouble pow(const adouble &a, const adouble &b) {
    985     adouble tmp;
    986     tmp.val=ADOLC_MATH_NSP::pow(a.val, b.val);
    987     double tmp2=b.val*ADOLC_MATH_NSP::pow(a.val, b.val-1);
    988     double tmp3=ADOLC_MATH_NSP::log(a.val)*tmp.val;
    989     FOR_I_EQ_0_LT_NUMDIR
    990     tmp.ADVAL_I=tmp2*a.ADVAL_I+tmp3*b.ADVAL_I;
    991     return tmp;
    992 }
    993 
    994 adouble pow(double v, const adouble &a) {
    995     adouble tmp;
    996     tmp.val=ADOLC_MATH_NSP::pow(v, a.val);
    997     double tmp2=tmp.val*ADOLC_MATH_NSP::log(v);
    998     FOR_I_EQ_0_LT_NUMDIR
    999     tmp.ADVAL_I=tmp2*a.ADVAL_I;
    1000     return tmp;
    1001 }
    1002 
    1003 adouble log10(const adouble &a) {
    1004     adouble tmp;
    1005     tmp.val=ADOLC_MATH_NSP::log10(a.val);
    1006     double tmp2=ADOLC_MATH_NSP::log((double)10)*a.val;
    1007     FOR_I_EQ_0_LT_NUMDIR
    1008     tmp.ADVAL_I=a.ADVAL_I/tmp2;
    1009     return tmp;
    1010 }
    1011 
    1012 adouble sinh (const adouble &a) {
    1013     adouble tmp;
    1014     tmp.val=ADOLC_MATH_NSP::sinh(a.val);
    1015     double tmp2=ADOLC_MATH_NSP::cosh(a.val);
    1016     FOR_I_EQ_0_LT_NUMDIR
    1017     tmp.ADVAL_I=a.ADVAL_I*tmp2;
    1018     return tmp;
    1019 }
    1020 
    1021 adouble cosh (const adouble &a) {
    1022     adouble tmp;
    1023     tmp.val=ADOLC_MATH_NSP::cosh(a.val);
    1024     double tmp2=ADOLC_MATH_NSP::sinh(a.val);
    1025     FOR_I_EQ_0_LT_NUMDIR
    1026     tmp.ADVAL_I=a.ADVAL_I*tmp2;
    1027     return tmp;
    1028 }
    1029 
    1030 adouble tanh (const adouble &a) {
    1031     adouble tmp;
    1032     tmp.val=ADOLC_MATH_NSP::tanh(a.val);
    1033     double tmp2=ADOLC_MATH_NSP::cosh(a.val);
    1034     tmp2*=tmp2;
    1035     FOR_I_EQ_0_LT_NUMDIR
    1036     tmp.ADVAL_I=a.ADVAL_I/tmp2;
    1037     return tmp;
    1038 }
    1039 
    1040 #if defined(ATRIG_ERF)
    1041 adouble asinh (const adouble &a) {
    1042     adouble tmp;
    1043     tmp.val=ADOLC_MATH_NSP_ERF::asinh(a.val);
    1044     double tmp2=ADOLC_MATH_NSP::sqrt(a.val*a.val+1);
    1045     FOR_I_EQ_0_LT_NUMDIR
    1046     tmp.ADVAL_I=a.ADVAL_I/tmp2;
    1047     return tmp;
    1048 }
    1049 
    1050 adouble acosh (const adouble &a) {
    1051     adouble tmp;
    1052     tmp.val=ADOLC_MATH_NSP_ERF::acosh(a.val);
    1053     double tmp2=ADOLC_MATH_NSP::sqrt(a.val*a.val-1);
    1054     FOR_I_EQ_0_LT_NUMDIR
    1055     tmp.ADVAL_I=a.ADVAL_I/tmp2;
    1056     return tmp;
    1057 }
    1058 
    1059 adouble atanh (const adouble &a) {
    1060     adouble tmp;
    1061     tmp.val=ADOLC_MATH_NSP_ERF::atanh(a.val);
    1062     double tmp2=1-a.val*a.val;
    1063     FOR_I_EQ_0_LT_NUMDIR
    1064     tmp.ADVAL_I=a.ADVAL_I/tmp2;
    1065     return tmp;
    1066 }
    1067 #endif
    1068 
    1069 adouble fabs (const adouble &a) {
    1070     adouble tmp;
    1071     tmp.val=ADOLC_MATH_NSP::fabs(a.val);
    1072     int as=0;
    1073     if (a.val>0) as=1;
    1074     if (a.val<0) as=-1;
    1075     if (as!=0)
    1076         FOR_I_EQ_0_LT_NUMDIR
    1077         tmp.ADVAL_I=a.ADVAL_I*as;
    1078     else
    1079         FOR_I_EQ_0_LT_NUMDIR {
    1080             as=0;
    1081             if (a.ADVAL_I>0) as=1;
    1082             if (a.ADVAL_I<0) as=-1;
    1083                 tmp.ADVAL_I=a.ADVAL_I*as;
    1084             }
    1085             return tmp;
    1086 }
    1087 
    1088 adouble ceil (const adouble &a) {
    1089     adouble tmp;
    1090     tmp.val=ADOLC_MATH_NSP::ceil(a.val);
    1091     FOR_I_EQ_0_LT_NUMDIR
    1092     tmp.ADVAL_I=0.0;
    1093     return tmp;
    1094 }
    1095 
    1096 adouble floor (const adouble &a) {
    1097     adouble tmp;
    1098     tmp.val=ADOLC_MATH_NSP::floor(a.val);
    1099     FOR_I_EQ_0_LT_NUMDIR
    1100     tmp.ADVAL_I=0.0;
    1101     return tmp;
    1102 }
    1103 
    1104 adouble fmax (const adouble &a, const adouble &b) {
    1105     adouble tmp;
    1106     double tmp2=a.val-b.val;
    1107     if (tmp2<0) {
    1108         tmp.val=b.val;
    1109         FOR_I_EQ_0_LT_NUMDIR
    1110         tmp.ADVAL_I=b.ADVAL_I;
    1111     } else {
    1112         tmp.val=a.val;
    1113         if (tmp2>0) {
    1114             FOR_I_EQ_0_LT_NUMDIR
    1115             tmp.ADVAL_I=a.ADVAL_I;
    1116         } else {
    1117             FOR_I_EQ_0_LT_NUMDIR
    1118             {
    1119                 if (a.ADVAL_I<b.ADVAL_I) tmp.ADVAL_I=b.ADVAL_I;
    1120                 else tmp.ADVAL_I=a.ADVAL_I;
    1121                 }
    1122             }
    1123 }
    1124 return tmp;
    1125 }
    1126 
    1127 adouble fmax (double v, const adouble &a) {
    1128     adouble tmp;
    1129     double tmp2=v-a.val;
    1130     if (tmp2<0) {
    1131         tmp.val=a.val;
    1132         FOR_I_EQ_0_LT_NUMDIR
    1133         tmp.ADVAL_I=a.ADVAL_I;
    1134     } else {
    1135         tmp.val=v;
    1136         if (tmp2>0) {
    1137             FOR_I_EQ_0_LT_NUMDIR
    1138             tmp.ADVAL_I=0.0;
    1139         } else {
    1140             FOR_I_EQ_0_LT_NUMDIR
    1141             {
    1142                 if (a.ADVAL_I>0) tmp.ADVAL_I=a.ADVAL_I;
    1143                 else tmp.ADVAL_I=0.0;
    1144                 }
    1145             }
    1146 }
    1147 return tmp;
    1148 }
    1149 
    1150 adouble fmax (const adouble &a, double v) {
    1151     adouble tmp;
    1152     double tmp2=a.val-v;
    1153     if (tmp2<0) {
    1154         tmp.val=v;
    1155         FOR_I_EQ_0_LT_NUMDIR
    1156         tmp.ADVAL_I=0.0;
    1157     } else {
    1158         tmp.val=a.val;
    1159         if (tmp2>0) {
    1160             FOR_I_EQ_0_LT_NUMDIR
    1161             tmp.ADVAL_I=a.ADVAL_I;
    1162         } else {
    1163             FOR_I_EQ_0_LT_NUMDIR
    1164             {
    1165                 if (a.ADVAL_I>0) tmp.ADVAL_I=a.ADVAL_I;
    1166                 else tmp.ADVAL_I=0.0;
    1167                 }
    1168             }
    1169 }
    1170 return tmp;
    1171 }
    1172 
    1173 adouble fmin (const adouble &a, const adouble &b) {
    1174     adouble tmp;
    1175     double tmp2=a.val-b.val;
    1176     if (tmp2<0) {
    1177         tmp.val=a.val;
    1178         FOR_I_EQ_0_LT_NUMDIR
    1179         tmp.ADVAL_I=a.ADVAL_I;
    1180     } else {
    1181         tmp.val=b.val;
    1182         if (tmp2>0) {
    1183             FOR_I_EQ_0_LT_NUMDIR
    1184             tmp.ADVAL_I=b.ADVAL_I;
    1185         } else {
    1186             FOR_I_EQ_0_LT_NUMDIR
    1187             {
    1188                 if (a.ADVAL_I<b.ADVAL_I) tmp.ADVAL_I=a.ADVAL_I;
    1189                 else tmp.ADVAL_I=b.ADVAL_I;
    1190                 }
    1191             }
    1192 }
    1193 return tmp;
    1194 }
    1195 
    1196 adouble fmin (double v, const adouble &a) {
    1197     adouble tmp;
    1198     double tmp2=v-a.val;
    1199     if (tmp2<0) {
    1200         tmp.val=v;
    1201         FOR_I_EQ_0_LT_NUMDIR
    1202         tmp.ADVAL_I=0.0;
    1203     } else {
    1204         tmp.val=a.val;
    1205         if (tmp2>0) {
    1206             FOR_I_EQ_0_LT_NUMDIR
    1207             tmp.ADVAL_I=a.ADVAL_I;
    1208         } else {
    1209             FOR_I_EQ_0_LT_NUMDIR
    1210             {
    1211                 if (a.ADVAL_I<0) tmp.ADVAL_I=a.ADVAL_I;
    1212                 else tmp.ADVAL_I=0.0;
    1213                 }
    1214             }
    1215 }
    1216 return tmp;
    1217 }
    1218 
    1219 adouble fmin (const adouble &a, double v) {
    1220     adouble tmp;
    1221     double tmp2=a.val-v;
    1222     if (tmp2<0) {
    1223         tmp.val=a.val;
    1224         FOR_I_EQ_0_LT_NUMDIR
    1225         tmp.ADVAL_I=a.ADVAL_I;
    1226     } else {
    1227         tmp.val=v;
    1228         if (tmp2>0) {
    1229             FOR_I_EQ_0_LT_NUMDIR
    1230             tmp.ADVAL_I=0.0;
    1231         } else {
    1232             FOR_I_EQ_0_LT_NUMDIR
    1233             {
    1234                 if (a.ADVAL_I<0) tmp.ADVAL_I=a.ADVAL_I;
    1235                 else tmp.ADVAL_I=0.0;
    1236                 }
    1237             }
    1238 }
    1239 return tmp;
    1240 }
    1241 
    1242 adouble ldexp (const adouble &a, const adouble &b) {
    1243     return a*pow(2.,b);
    1244 }
    1245 
    1246 adouble ldexp (const adouble &a, const double v) {
    1247     return a*ADOLC_MATH_NSP::pow(2.,v);
    1248 }
    1249 
    1250 adouble ldexp (const double v, const adouble &a) {
    1251     return v*pow(2.,a);
    1252 }
    1253 
    1254 double frexp (const adouble &a, int* v) {
    1255     return ADOLC_MATH_NSP::frexp(a.val, v);
    1256 }
    1257 
    1258 #if defined(ATRIG_ERF)
    1259 adouble erf (const adouble &a) {
    1260     adouble tmp;
    1261     tmp.val=ADOLC_MATH_NSP_ERF::erf(a.val);
    1262     double tmp2 = 2.0 /
    1263         ADOLC_MATH_NSP_ERF::sqrt(ADOLC_MATH_NSP::acos(-1.0)) *
    1264         ADOLC_MATH_NSP_ERF::exp(-a.val*a.val);
    1265     FOR_I_EQ_0_LT_NUMDIR
    1266     tmp.ADVAL_I=tmp2*a.ADVAL_I;
    1267     return tmp;
    1268 }
    1269 #endif
    1270 
    1271 
    1272 /*******************  nontemporary results  *********************************/
    1273 void adouble::operator = (const double v) {
    1274     val=v;
    1275     FOR_I_EQ_0_LT_NUMDIR
    1276     ADVAL_I=0.0;
    1277 }
    1278 
    1279 void adouble::operator = (const adouble& a) {
    1280     val=a.val;
    1281     FOR_I_EQ_0_LT_NUMDIR
    1282     ADVAL_I=a.ADVAL_I;
    1283 }
    1284 
    1285 void adouble::operator += (const double v) {
    1286     val+=v;
    1287 }
    1288 
    1289 void adouble::operator += (const adouble& a) {
    1290     val=val+a.val;
    1291     FOR_I_EQ_0_LT_NUMDIR
    1292     ADVAL_I+=a.ADVAL_I;
    1293 }
    1294 
    1295 void adouble::operator -= (const double v) {
    1296     val-=v;
    1297 }
    1298 
    1299 void adouble::operator -= (const adouble& a) {
    1300     val=val-a.val;
    1301     FOR_I_EQ_0_LT_NUMDIR
    1302     ADVAL_I-=a.ADVAL_I;
    1303 }
    1304 
    1305 void adouble::operator *= (const double v) {
    1306     val=val*v;
    1307     FOR_I_EQ_0_LT_NUMDIR
    1308     ADVAL_I*=v;
    1309 }
    1310 
    1311 void adouble::operator *= (const adouble& a) {
    1312     FOR_I_EQ_0_LT_NUMDIR
    1313     ADVAL_I=ADVAL_I*a.val+val*a.ADVAL_I;
    1314     val*=a.val;
    1315 }
    1316 
    1317 void adouble::operator /= (const double v) {
    1318     val/=v;
    1319     FOR_I_EQ_0_LT_NUMDIR
    1320     ADVAL_I/=v;
    1321 }
    1322 
    1323 void adouble::operator /= (const adouble& a) {
    1324     FOR_I_EQ_0_LT_NUMDIR
    1325     ADVAL_I=(ADVAL_I*a.val-val*a.ADVAL_I)/(a.val*a.val);
    1326     val=val/a.val;
    1327 }
    1328 
    1329 // not
    1330 int adouble::operator ! () const {
    1331     return val==0.0;
    1332 }
    1333 
    1334 // comparision
    1335 int adouble::operator != (const adouble &a) const {
    1336     return val!=a.val;
    1337 }
    1338 
    1339 int adouble::operator != (const double v) const {
    1340     return val!=v;
    1341 }
    1342 
    1343 int operator != (const double v, const adouble &a) {
    1344     return v!=a.val;
    1345 }
    1346 
    1347 int adouble::operator == (const adouble &a) const {
    1348     return val==a.val;
    1349 }
    1350 
    1351 int adouble::operator == (const double v) const {
    1352     return val==v;
    1353 }
    1354 
    1355 int operator == (const double v, const adouble &a) {
    1356     return v==a.val;
    1357 }
    1358 
    1359 int adouble::operator <= (const adouble &a) const {
    1360     return val<=a.val;
    1361 }
    1362 
    1363 int adouble::operator <= (const double v) const {
    1364     return val<=v;
    1365 }
    1366 
    1367 int operator <= (const double v, const adouble &a) {
    1368     return v<=a.val;
    1369 }
    1370 
    1371 int adouble::operator >= (const adouble &a) const {
    1372     return val>=a.val;
    1373 }
    1374 
    1375 int adouble::operator >= (const double v) const {
    1376     return val>=v;
    1377 }
    1378 
    1379 int operator >= (const double v, const adouble &a) {
    1380     return v>=a.val;
    1381 }
    1382 
    1383 int adouble::operator >  (const adouble &a) const {
    1384     return val>a.val;
    1385 }
    1386 
    1387 int adouble::operator >  (const double v) const {
    1388     return val>v;
    1389 }
    1390 
    1391 int operator >  (const double v, const adouble &a) {
    1392     return v>a.val;
    1393 }
    1394 
    1395 int adouble::operator <  (const adouble &a) const {
    1396     return val<a.val;
    1397 }
    1398 
    1399 int adouble::operator <  (const double v) const {
    1400     return val<v;
    1401 }
    1402 
    1403 int operator <  (const double v, const adouble &a) {
    1404     return v<a.val;
    1405 }
    1406 
    1407 /*******************  getter / setter  **************************************/
    1408 double adouble::getValue() const {
    1409     return val;
    1410 }
    1411 
    1412 void adouble::setValue(const double v) {
    1413     val=v;
    1414 }
    1415 
    1416 ADVAL_TYPE adouble::getADValue() const {
    1417     return adval;
    1418 }
    1419 
    1420 void adouble::setADValue(ADVAL_TYPE v) {
    1421     FOR_I_EQ_0_LT_NUMDIR
    1422     ADVAL_I=V_I;
    1423 }
    1424 
    1425 #  if defined(NUMBER_DIRECTIONS)
    1426 double adouble::getADValue(const unsigned int p) const {
    1427     if (p>=NUMBER_DIRECTIONS) {
    1428         fprintf(DIAG_OUT, "Derivative array accessed out of bounds"\
    1429                 " while \"getADValue(...)\"!!!\n");
    1430         exit(-1);
    1431     }
    1432     return adval[p];
    1433 }
    1434 
    1435 void adouble::setADValue(const unsigned int p, const double v) {
    1436     if (p>=NUMBER_DIRECTIONS) {
    1437         fprintf(DIAG_OUT, "Derivative array accessed out of bounds"\
    1438                 " while \"setADValue(...)\"!!!\n");
    1439         exit(-1);
    1440     }
    1441     adval[p]=v;
    1442 }
    1443 #  endif
    1444 
    1445 #if defined(NUMBER_DIRECTIONS)
    1446 static void setNumDir(const unsigned int p) {
    1447 #if !defined(DYNAMIC_DIRECTIONS)
    1448     if (p>NUMBER_DIRECTIONS) ADOLC_numDir=NUMBER_DIRECTIONS;
    1449     else ADOLC_numDir=p;
    1450 #else
    1451     ADOLC_numDir = p;
    1452 #endif
    1453 }
    1454 #endif
    1455 
    1456 /*******************  i/o operations  ***************************************/
    1457 ostream& operator << ( ostream& out, const adouble& a) {
    1458     out << "Value: " << a.val;
    1459 #if !defined(NUMBER_DIRECTIONS)
    1460     out << " ADValue: ";
    1461 #else
    1462     out << " ADValues (" << ADOLC_numDir << "): ";
    1463 #endif
    1464     FOR_I_EQ_0_LT_NUMDIR
    1465     out << a.ADVAL_I << " ";
    1466     out << "(a)";
    1467     return out;
    1468 }
    1469 
    1470 istream& operator >> ( istream& in, adouble& a) {
    1471     char c;
    1472     do {
    1473         in >> c;
    1474     } while (c!=':' && !in.eof());
    1475     in >> a.val;
    1476 #if !defined(NUMBER_DIRECTIONS)
    1477     do in >> c;
    1478     while (c!=':' && !in.eof());
    1479 #else
    1480 unsigned int num;
    1481 do in >> c;
    1482 while (c!='(' && !in.eof());
    1483 in >> num;
    1484 if (num>NUMBER_DIRECTIONS) {
    1485     cout << "ADOL-C error: to many directions in input\n";
    1486     exit(-1);
    1487 }
    1488 do in >> c;
    1489 while (c!=')' && !in.eof());
    1490 #endif
    1491     FOR_I_EQ_0_LT_NUMDIR
    1492     in >> a.ADVAL_I;
    1493     do in >> c;
    1494     while (c!=')' && !in.eof());
    1495     return in;
    1496 }
    1497 }
    1498 
    1499 /****************************************************************************/
    1500 #endif /* ADOLC_TAPELESS */
    1501485
    1502486/****************************************************************************/
  • trunk/ADOL-C/include/adolc/drivers/Makefile.in

    r377 r429  
    5858        $(srcdir)/Makefile.in
    5959ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    60 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
     60am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
     61        $(top_srcdir)/autoconf/acx_builtin.m4 \
     62        $(top_srcdir)/configure.ac
    6163am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    6264        $(ACLOCAL_M4)
  • trunk/ADOL-C/include/adolc/sparse/Makefile.in

    r377 r429  
    5858        $(srcdir)/Makefile.in
    5959ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    60 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
     60am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
     61        $(top_srcdir)/autoconf/acx_builtin.m4 \
     62        $(top_srcdir)/configure.ac
    6163am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    6264        $(ACLOCAL_M4)
  • trunk/ADOL-C/include/adolc/tapedoc/Makefile.in

    r377 r429  
    5858        $(srcdir)/Makefile.in
    5959ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    60 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
     60am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
     61        $(top_srcdir)/autoconf/acx_builtin.m4 \
     62        $(top_srcdir)/configure.ac
    6163am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    6264        $(ACLOCAL_M4)
  • trunk/ADOL-C/src/Makefile.am

    r410 r429  
    4949                       nonl_ind_forward_s.c nonl_ind_forward_t.c \
    5050                       nonl_ind_old_forward_s.c nonl_ind_old_forward_t.c \
    51                        int_reverse_s.c int_reverse_t.c advector.cpp
     51                       int_reverse_s.c int_reverse_t.c advector.cpp \
     52                       adouble_tl.cpp
    5253
    5354libadolc_la_LIBADD   = drivers/libdrivers.la sparse/libsparse.la \
     
    6566                       forward_partx.c \
    6667                       externfcts.cpp checkpointing.cpp \
    67                        fixpoint.cpp fov_offset_forward.c revolve.c advector.cpp
     68                       fixpoint.cpp fov_offset_forward.c revolve.c \
     69                       advector.cpp adouble_tl.cpp
    6870
    6971libadolc_la_LIBADD   = drivers/libdrivers.la tapedoc/libtapedoc.la
  • trunk/ADOL-C/src/Makefile.in

    r411 r429  
    5959        $(srcdir)/config.h.in $(top_srcdir)/autoconf/depcomp
    6060ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    61 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
     61am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
     62        $(top_srcdir)/autoconf/acx_builtin.m4 \
     63        $(top_srcdir)/configure.ac
    6264am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    6365        $(ACLOCAL_M4)
     
    105107        fov_reverse.c hos_reverse.c hos_ov_reverse.c hov_reverse.c \
    106108        forward_partx.c externfcts.cpp checkpointing.cpp fixpoint.cpp \
    107         fov_offset_forward.c revolve.c advector.cpp taping_p.h \
    108         int_forward_s.c int_forward_t.c indopro_forward_s.c \
     109        fov_offset_forward.c revolve.c advector.cpp adouble_tl.cpp \
     110        taping_p.h int_forward_s.c int_forward_t.c indopro_forward_s.c \
    109111        indopro_forward_t.c nonl_ind_forward_s.c nonl_ind_forward_t.c \
    110112        nonl_ind_old_forward_s.c nonl_ind_old_forward_t.c \
     
    119121@SPARSE_FALSE@  forward_partx.lo externfcts.lo checkpointing.lo \
    120122@SPARSE_FALSE@  fixpoint.lo fov_offset_forward.lo revolve.lo \
    121 @SPARSE_FALSE@  advector.lo
     123@SPARSE_FALSE@  advector.lo adouble_tl.lo
    122124@SPARSE_TRUE@am_libadolc_la_OBJECTS = adalloc.lo malloc.lo adouble.lo \
    123125@SPARSE_TRUE@   convolut.lo fortutils.lo interfaces.lo \
     
    133135@SPARSE_TRUE@   nonl_ind_forward_t.lo nonl_ind_old_forward_s.lo \
    134136@SPARSE_TRUE@   nonl_ind_old_forward_t.lo int_reverse_s.lo \
    135 @SPARSE_TRUE@   int_reverse_t.lo advector.lo
     137@SPARSE_TRUE@   int_reverse_t.lo advector.lo adouble_tl.lo
    136138libadolc_la_OBJECTS = $(am_libadolc_la_OBJECTS)
    137139AM_V_lt = $(am__v_lt_@AM_V@)
     
    389391@SPARSE_FALSE@                       forward_partx.c \
    390392@SPARSE_FALSE@                       externfcts.cpp checkpointing.cpp \
    391 @SPARSE_FALSE@                       fixpoint.cpp fov_offset_forward.c revolve.c advector.cpp
     393@SPARSE_FALSE@                       fixpoint.cpp fov_offset_forward.c revolve.c \
     394@SPARSE_FALSE@                       advector.cpp adouble_tl.cpp
    392395
    393396@SPARSE_TRUE@libadolc_la_SOURCES = adalloc.c malloc.c adouble.cpp \
     
    406409@SPARSE_TRUE@                       nonl_ind_forward_s.c nonl_ind_forward_t.c \
    407410@SPARSE_TRUE@                       nonl_ind_old_forward_s.c nonl_ind_old_forward_t.c \
    408 @SPARSE_TRUE@                       int_reverse_s.c int_reverse_t.c advector.cpp
     411@SPARSE_TRUE@                       int_reverse_s.c int_reverse_t.c advector.cpp \
     412@SPARSE_TRUE@                       adouble_tl.cpp
    409413
    410414@SPARSE_FALSE@libadolc_la_LIBADD = drivers/libdrivers.la tapedoc/libtapedoc.la
     
    507511@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/adalloc.Plo@am__quote@
    508512@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/adouble.Plo@am__quote@
     513@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/adouble_tl.Plo@am__quote@
    509514@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/advector.Plo@am__quote@
    510515@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/checkpointing.Plo@am__quote@
  • trunk/ADOL-C/src/config.h.in

    r411 r429  
    11/* ADOL-C/src/config.h.in.  Generated from configure.ac by autoheader.  */
     2
     3/* ADOL-C adouble late initialization mode */
     4#undef ADOLC_ADOUBLE_LATEINIT
    25
    36/* ADOL-C adouble zeroing mode */
     
    2427/* ADOL-C Version */
    2528#undef ADOLC_VERSION
     29
     30/* Define if the compiler provides __builtin_expect */
     31#undef HAVE_BUILTIN_EXPECT
    2632
    2733/* Define to 1 if you have the <dlfcn.h> header file. */
  • trunk/ADOL-C/src/drivers/Makefile.in

    r377 r429  
    5858        $(top_srcdir)/autoconf/depcomp
    5959ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    60 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
     60am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
     61        $(top_srcdir)/autoconf/acx_builtin.m4 \
     62        $(top_srcdir)/configure.ac
    6163am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    6264        $(ACLOCAL_M4)
  • trunk/ADOL-C/src/sparse/Makefile.in

    r377 r429  
    5858        $(top_srcdir)/autoconf/depcomp
    5959ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    60 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
     60am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
     61        $(top_srcdir)/autoconf/acx_builtin.m4 \
     62        $(top_srcdir)/configure.ac
    6163am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    6264        $(ACLOCAL_M4)
  • trunk/ADOL-C/src/sparse/sparsedrivers.cpp

    r427 r429  
    55 Contents: "Easy To Use" C++ interfaces of SPARSE package
    66 
    7  Copyright (c) Andrea Walther
    8  
     7
     8 Copyright (c) Andrea Walther, Benjamin Letschert, Kshitij Kulshreshtha
     9
    910 This file is part of ADOL-C. This software is provided as open source.
    1011 Any use, reproduction, or distribution of the software constitutes
     
    11131114END_C_DECLS
    11141115
     1116
     1117#include <adolc/adtl.h>
     1118
     1119namespace adtl {
     1120
     1121SparseJacInfos sJinfos = { NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0 };
     1122
     1123int ADOLC_get_sparse_jacobian( func_ad *const fun,
     1124                               int n, int m, int repeat, double* basepoints,
     1125                               int *nnz, unsigned int **rind,
     1126                               unsigned int **cind, double **values)
     1127#if HAVE_LIBCOLPACK
     1128{
     1129    int i;
     1130    unsigned int j;
     1131    int dummy;
     1132    int ret_val = -1;
     1133    if (!repeat) {
     1134    freeSparseJacInfos(sJinfos.y, sJinfos.B, sJinfos.JP, sJinfos.g, sJinfos.jr1d, sJinfos.seed_rows, sJinfos.seed_clms, sJinfos.depen);
     1135    //setNumDir(n);
     1136    setMode(ADTL_INDO);
     1137    {
     1138    adouble x[n],y[m];
     1139    for (i=0; i < n ; i++){
     1140      x[i] = basepoints[i];
     1141      //x[i].setADValue(i,1);
     1142    }
     1143    ret_val = ADOLC_Init_sparse_pattern(x,n,0);
     1144
     1145    ret_val = (*fun)(n,x,m,y);
     1146
     1147    if (ret_val < 0) {
     1148       printf(" ADOL-C error in tapeless sparse_jac() \n");
     1149       return ret_val;
     1150    }
     1151
     1152    ret_val = ADOLC_get_sparse_pattern(y, m, sJinfos.JP );
     1153    }
     1154    sJinfos.depen = m;
     1155    sJinfos.nnz_in = 0;
     1156    for (i=0;i<m;i++) {
     1157       for (j=1;j<=sJinfos.JP[i][0];j++)
     1158          sJinfos.nnz_in++;
     1159    }
     1160      *nnz = sJinfos.nnz_in;
     1161      /* sJinfos.Seed is memory managed by ColPack and will be deleted
     1162       * along with g. We only keep it in sJinfos for the repeat != 0 case */
     1163      BipartiteGraphPartialColoringInterface *g;
     1164      JacobianRecovery1D *jr1d;
     1165
     1166      g = new BipartiteGraphPartialColoringInterface(SRC_MEM_ADOLC, sJinfos.JP, m, n);
     1167      jr1d = new JacobianRecovery1D;
     1168
     1169      g->GenerateSeedJacobian(&(sJinfos.Seed), &(sJinfos.seed_rows),
     1170                                &(sJinfos.seed_clms), "SMALLEST_LAST","COLUMN_PARTIAL_DISTANCE_TWO");
     1171      sJinfos.seed_rows = m;
     1172
     1173      sJinfos.B = myalloc2(sJinfos.seed_rows,sJinfos.seed_clms);
     1174      sJinfos.y = myalloc1(m);
     1175
     1176      sJinfos.g = (void *) g;
     1177      sJinfos.jr1d = (void *) jr1d;
     1178
     1179    if (sJinfos.nnz_in != *nnz) {
     1180        printf(" ADOL-C error in sparse_jac():"
     1181               " Number of nonzeros not consistent,"
     1182               " repeat call with repeat = 0 \n");
     1183        return -3;
     1184    }
     1185
     1186    }
     1187//  ret_val = fov_forward(tag, depen, indep, sJinfos.seed_clms, basepoint, sJinfos.Seed, sJinfos.y, sJinfos.B);
     1188    setNumDir(sJinfos.seed_clms);
     1189    setMode(ADTL_FOV);
     1190    {
     1191    adouble x[n],y[m];
     1192    for (i=0; i < n ; i++){
     1193      x[i] = basepoints[i];
     1194      for (j=0; j < sJinfos.seed_clms; j++)
     1195          x[i].setADValue(j,sJinfos.Seed[i][j]);
     1196    }
     1197
     1198    ret_val = (*fun)(n,x,m,y);
     1199
     1200    for (i=0;i<m;i++)
     1201       for (j=0; j< sJinfos.seed_clms;j++)
     1202          sJinfos.B[i][j] = y[i].getADValue(j);
     1203    }
     1204    /* recover compressed Jacobian => ColPack library */
     1205
     1206      if (*values != NULL)
     1207       free(*values);
     1208      if (*rind != NULL)
     1209       free(*rind);
     1210      if (*cind != NULL)
     1211       free(*cind);
     1212     BipartiteGraphPartialColoringInterface *g;
     1213     JacobianRecovery1D *jr1d;
     1214     g = (BipartiteGraphPartialColoringInterface*)sJinfos.g;
     1215     jr1d = (JacobianRecovery1D*)sJinfos.jr1d;
     1216     jr1d->RecoverD2Cln_CoordinateFormat_unmanaged(g, sJinfos.B, sJinfos.JP, rind, cind, values);
     1217
     1218    //delete g;
     1219    //delete jr1d;
     1220
     1221    return ret_val;
     1222
     1223}
     1224#else
     1225{
     1226    fprintf(DIAG_OUT, "ADOL-C error: function %s can only be used if linked with ColPack\n", __FUNCTION__);
     1227    exit(-1);
     1228}
     1229#endif
     1230
     1231#if 0
     1232int ADOLC_get_sparse_jacobian(int n, int m, adouble *x, int *nnz, unsigned int *rind, unsigned int *cind, double *values)
     1233#if HAVE_LIBCOLPACK
     1234{
     1235    int i;
     1236    unsigned int j;
     1237    SparseJacInfos sJinfos;
     1238    int dummy;
     1239    int ret_val = -1;
     1240    BipartiteGraphPartialColoringInterface *g;
     1241    JacobianRecovery1D *jr1d;
     1242
     1243    ret_val = ADOLC_get_sparse_pattern(x, m, sJinfos.JP );
     1244
     1245    sJinfos.depen = m;
     1246    sJinfos.nnz_in = 0;
     1247    for (i=0;i<m;i++) {
     1248       for (j=1;j<=sJinfos.JP[i][0];j++)
     1249          sJinfos.nnz_in++;
     1250    }
     1251      *nnz = sJinfos.nnz_in;
     1252      /* sJinfos.Seed is memory managed by ColPack and will be deleted
     1253       * along with g. We only keep it in sJinfos for the repeat != 0 case */
     1254
     1255      g = new BipartiteGraphPartialColoringInterface(SRC_MEM_ADOLC, sJinfos.JP, m, n);
     1256      jr1d = new JacobianRecovery1D;
     1257
     1258      g->GenerateSeedJacobian(&(sJinfos.Seed), &(sJinfos.seed_rows),
     1259                                &(sJinfos.seed_clms), "SMALLEST_LAST","COLUMN_PARTIAL_DISTANCE_TWO");
     1260      sJinfos.seed_rows = m;
     1261
     1262      sJinfos.B = myalloc2(sJinfos.seed_rows,sJinfos.seed_clms);
     1263      sJinfos.y = myalloc1(m);
     1264
     1265      sJinfos.g = (void *) g;
     1266      sJinfos.jr1d = (void *) jr1d;
     1267
     1268    if (sJinfos.nnz_in != *nnz) {
     1269        printf(" ADOL-C error in sparse_jac():"
     1270               " Number of nonzeros not consistent,"
     1271               " repeat call with repeat = 0 \n");
     1272        return -3;
     1273    }
     1274
     1275//  ret_val = fov_forward(tag, depen, indep, sJinfos.seed_clms, basepoint, sJinfos.Seed, sJinfos.y, sJinfos.B);
     1276    for (i=0;i<m;i++)
     1277       for (j=0; j< sJinfos.seed_clms;j++)
     1278          sJinfos.B[i][j] = x[i].getADValue(j);
     1279
     1280    /* recover compressed Jacobian => ColPack library */
     1281
     1282      if (values != NULL)
     1283       free(values);
     1284      if (rind != NULL)
     1285       free(rind);
     1286      if (cind != NULL)
     1287       free(cind);
     1288     jr1d->RecoverD2Cln_CoordinateFormat_unmanaged(g, sJinfos.B, sJinfos.JP, &rind, &cind, &values);
     1289
     1290    delete g;
     1291    delete jr1d;
     1292
     1293    return ret_val;
     1294
     1295}
     1296#else
     1297{
     1298    fprintf(DIAG_OUT, "ADOL-C error: function %s can only be used if linked with ColPack\n", __FUNCTION__);
     1299    exit(-1);
     1300}
     1301#endif
     1302#endif
     1303
     1304}
     1305
    11151306/****************************************************************************/
    11161307/*                                                               THAT'S ALL */
  • trunk/ADOL-C/src/tapedoc/Makefile.in

    r377 r429  
    5858        $(top_srcdir)/autoconf/depcomp
    5959ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    60 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
     60am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
     61        $(top_srcdir)/autoconf/acx_builtin.m4 \
     62        $(top_srcdir)/configure.ac
    6163am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    6264        $(ACLOCAL_M4)
  • trunk/ADOL-C/test/Makefile.in

    r377 r429  
    6060        $(top_srcdir)/autoconf/depcomp
    6161ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    62 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
     62am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
     63        $(top_srcdir)/autoconf/acx_builtin.m4 \
     64        $(top_srcdir)/configure.ac
    6365am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    6466        $(ACLOCAL_M4)
  • trunk/MSVisualStudio/v10/nosparse/config.h

    r411 r429  
    2525/* ADOL-C Version */
    2626#define ADOLC_VERSION 2
     27
     28/* Define if the compiler provides __builtin_expect */
     29#define HAVE_BUILTIN_EXPECT 0
    2730
    2831/* Define to 1 if you have the <dlfcn.h> header file. */
  • trunk/MSVisualStudio/v10/nosparse/config.h.in

    r410 r429  
    2525/* ADOL-C Version */
    2626#define ADOLC_VERSION @ADOLC_VERSION@
     27
     28/* Define if the compiler provides __builtin_expect */
     29#define HAVE_BUILTIN_EXPECT 0
    2730
    2831/* Define to 1 if you have the <dlfcn.h> header file. */
  • trunk/MSVisualStudio/v10/sparse/config.h

    r411 r429  
    2525/* ADOL-C Version */
    2626#define ADOLC_VERSION 2
     27
     28/* Define if the compiler provides __builtin_expect */
     29#define HAVE_BUILTIN_EXPECT 0
    2730
    2831/* Define to 1 if you have the <dlfcn.h> header file. */
  • trunk/MSVisualStudio/v10/sparse/config.h.in

    r410 r429  
    2525/* ADOL-C Version */
    2626#define ADOLC_VERSION @ADOLC_VERSION@
     27
     28/* Define if the compiler provides __builtin_expect */
     29#define HAVE_BUILTIN_EXPECT 0
    2730
    2831/* Define to 1 if you have the <dlfcn.h> header file. */
  • trunk/MSVisualStudio/v10/x64/nosparse/config.h

    r411 r429  
    2525/* ADOL-C Version */
    2626#define ADOLC_VERSION 2
     27
     28/* Define if the compiler provides __builtin_expect */
     29#define HAVE_BUILTIN_EXPECT 0
    2730
    2831/* Define to 1 if you have the <dlfcn.h> header file. */
  • trunk/MSVisualStudio/v10/x64/nosparse/config.h.in

    r410 r429  
    2525/* ADOL-C Version */
    2626#define ADOLC_VERSION @ADOLC_VERSION@
     27
     28/* Define if the compiler provides __builtin_expect */
     29#define HAVE_BUILTIN_EXPECT 0
    2730
    2831/* Define to 1 if you have the <dlfcn.h> header file. */
  • trunk/MSVisualStudio/v10/x64/sparse/config.h

    r411 r429  
    2525/* ADOL-C Version */
    2626#define ADOLC_VERSION 2
     27
     28/* Define if the compiler provides __builtin_expect */
     29#define HAVE_BUILTIN_EXPECT 0
    2730
    2831/* Define to 1 if you have the <dlfcn.h> header file. */
  • trunk/MSVisualStudio/v10/x64/sparse/config.h.in

    r410 r429  
    2525/* ADOL-C Version */
    2626#define ADOLC_VERSION @ADOLC_VERSION@
     27
     28/* Define if the compiler provides __builtin_expect */
     29#define HAVE_BUILTIN_EXPECT 0
    2730
    2831/* Define to 1 if you have the <dlfcn.h> header file. */
  • trunk/Makefile.in

    r377 r429  
    7070        autoconf/ltmain.sh autoconf/missing
    7171ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    72 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
     72am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
     73        $(top_srcdir)/autoconf/acx_builtin.m4 \
     74        $(top_srcdir)/configure.ac
    7375am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    7476        $(ACLOCAL_M4)
     
    650652          unzip $(distdir).zip ;;\
    651653        esac
    652         chmod -R a-w $(distdir); chmod u+w $(distdir)
     654        chmod -R a-w $(distdir); chmod a+w $(distdir)
    653655        mkdir $(distdir)/_build
    654656        mkdir $(distdir)/_inst
  • trunk/aclocal.m4

    r357 r429  
    96179617]) # _AM_PROG_TAR
    96189618
     9619m4_include([acinclude.m4])
  • trunk/configure

    r411 r429  
    804804enable_harddebug
    805805enable_stdczero
     806enable_lateinit
    806807enable_tserrno
    807808with_openmp_flag
     
    14801481                          incorrect results for implicit array
    14811482                          initializations, see manual) [default=enabled]
     1483
     1484  --enable-lateinit       adouble constructors need to be called. With malloc
     1485                          or realloc that is not the case. With this option
     1486                          the adouble can do an late initialization.)
     1487                          [default=disabled]
    14821488
    14831489  --enable-tserrno        use errno as thread number cache [default=no]
     
    1584915855fi
    1585015856
     15857# check for builtin
     15858
     15859    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_expect" >&5
     15860$as_echo_n "checking for __builtin_expect... " >&6; }
     15861    ac_ext=c
     15862ac_cpp='$CPP $CPPFLAGS'
     15863ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
     15864ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
     15865ac_compiler_gnu=$ac_cv_c_compiler_gnu
     15866
     15867    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
     15868/* end confdefs.h.  */
     15869
     15870          int f(){return 1;};
     15871
     15872int
     15873main ()
     15874{
     15875
     15876          if (__builtin_expect(f(), 0));
     15877
     15878  ;
     15879  return 0;
     15880}
     15881_ACEOF
     15882if ac_fn_c_try_link "$LINENO"; then :
     15883
     15884        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
     15885$as_echo "yes" >&6; }
     15886
     15887$as_echo "#define HAVE_BUILTIN_EXPECT 1" >>confdefs.h
     15888
     15889
     15890else
     15891
     15892        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
     15893$as_echo "no" >&6; }
     15894
     15895fi
     15896rm -f core conftest.err conftest.$ac_objext \
     15897    conftest$ac_exeext conftest.$ac_ext
     15898
     15899
    1585115900# checks for header files
    1585215901{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
     
    1667816727
    1667916728$as_echo "#define ADOLC_ADOUBLE_STDCZERO 1" >>confdefs.h
     16729
     16730fi
     16731
     16732{ $as_echo "$as_me:${as_lineno-$LINENO}: checking wether the adouble varaibles have a late initialize option for functions like malloc/realloc" >&5
     16733$as_echo_n "checking wether the adouble varaibles have a late initialize option for functions like malloc/realloc... " >&6; }
     16734# Check whether --enable-lateinit was given.
     16735if test "${enable_lateinit+set}" = set; then :
     16736  enableval=$enable_lateinit;
     16737  adolc_late_init=yes
     16738  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
     16739$as_echo "yes" >&6; }
     16740
     16741else
     16742
     16743  adolc_late_init=no
     16744  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
     16745$as_echo "no" >&6; }
     16746
     16747fi
     16748
     16749
     16750if test x$adolc_late_init == xyes; then
     16751
     16752$as_echo "#define ADOLC_ADOUBLE_LATEINIT 1" >>confdefs.h
    1668016753
    1668116754fi
     
    1975319826echo \
    1975419827"  Use ADOL-C safe extern mode:        ${adolc_safe_extern}
     19828  Use ADOL-C late init mode:          ${adolc_late_init}
    1975519829
    1975619830  Build sparse drivers:               ${sparse}
  • trunk/configure.ac

    r427 r429  
    6666   AC_SUBST(libdir)
    6767fi
     68
     69# check for builtin
     70ACX_C_BUILTIN_EXPECT
    6871
    6972# checks for header files
Note: See TracChangeset for help on using the changeset viewer.