Changeset 3733


Ignore:
Timestamp:
Sep 24, 2015 11:07:15 PM (4 years ago)
Author:
bradbell
Message:

merge to branch: trunk
from repository: https://github.com/coin-or/CppAD
start hash code: 37afaa0d224e420a8cd052c18ceadf1c684ffd34
end hash code: 168c5fb40a332151168cbc8e928e28910d43665f

commit 168c5fb40a332151168cbc8e928e28910d43665f
Author: Brad Bell <bradbell@…>
Date: Thu Sep 24 20:02:25 2015 -0700

Transfer changes automatically generated by auto-tools.

commit b002c4cab3e02a2492c1eb41a47f8462f3b9442c
Author: Brad Bell <bradbell@…>
Date: Thu Sep 24 16:20:13 2015 -0700

Remove invisible white space.

commit d25c00bc6485d72e9ac50857e758e7c72196d317
Author: Brad Bell <bradbell@…>
Date: Thu Sep 24 16:19:55 2015 -0700

  1. Move omp_alloc.cpp from example to test_more (because it is deprecated).
  2. Fix warnings about cap_bytes possibly used before set.


near_equal.hpp: fix warning about divide by zero.
det_grad_33.hpp: use numeric limits epsilon.
thread_alloc.cpp: declare temporary indices in for statement.
limits.cpp: remove begin, no longer included in documentation.
romberg_one.cpp: remove begin, no longer included in documentation.
optimize.hpp: fix divide by zero warning (need to deprecate nan.hpp)
link_sparse_hessian.cpp: fix warning about unreachable code.

Location:
trunk
Files:
1 added
1 deleted
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/cppad/local/optimize.hpp

    r3724 r3733  
    14171417        recorder<Base>*              rec       )
    14181418{
     1419        // nan with type Base
     1420        Base base_nan = Base( std::numeric_limits<double>::quiet_NaN() );
     1421
    14191422        // temporary indices
    14201423        size_t i, j, k;
     
    27842787                                {       // This argument does not affect the result and
    27852788                                        // has been optimized out so use nan in its place.
    2786                                         new_arg[0] = rec->PutPar( nan(Base(0)) );
     2789                                        new_arg[0] = rec->PutPar( base_nan );
    27872790                                        rec->PutArg(new_arg[0]);
    27882791                                        rec->PutOp(UsrapOp);
  • trunk/cppad/near_equal.hpp

    r3688 r3733  
    150150*/
    151151
     152# include <limits>
    152153# include <complex>
    153154# include <cppad/local/cppad_assert.hpp>
     
    156157namespace CppAD { // Begin CppAD namespace
    157158
    158 // determine if both x and y are finite values (z1 and z2 are zero).
    159 template <class Type>
    160 bool near_equal_isfinite(
    161         const Type &z1, const Type &z2, const Type &x , const Type &y)
    162 {       Type infinity = Type(1) / z1;
     159// determine if both x and y are finite values
     160template <class Type>
     161bool near_equal_isfinite(const Type &x , const Type &y)
     162{       Type infinity = Type( std::numeric_limits<double>::infinity() );
    163163
    164164        // handle bug where some compilers return true for nan == nan
     
    189189
    190190        // check for special cases
    191         if( ! CppAD::near_equal_isfinite(zero, zero, x, y) )
     191        if( ! CppAD::near_equal_isfinite(x, y) )
    192192                return false;
    193193
     
    233233
    234234        // check for special cases
    235         if( ! CppAD::near_equal_isfinite(zero, zero, x.real(), x.imag()) )
     235        if( ! CppAD::near_equal_isfinite(x.real(), x.imag()) )
    236236                return false;
    237         if( ! CppAD::near_equal_isfinite(zero, zero, y.real(), y.imag()) )
     237        if( ! CppAD::near_equal_isfinite(y.real(), y.imag()) )
    238238                return false;
    239239
  • trunk/cppad/speed/det_grad_33.hpp

    r2506 r3733  
    44
    55/* --------------------------------------------------------------------------
    6 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell
     6CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell
    77
    88CppAD is distributed under multiple licenses. This distribution is under
    9 the terms of the 
     9the terms of the
    1010                    Eclipse Public License Version 1.0.
    1111
     
    2525$$
    2626
    27 $section Check Gradient of Determinant of 3 by 3 matrix$$ 
     27$section Check Gradient of Determinant of 3 by 3 matrix$$
    2828
    2929$index det_grad_33$$
     
    3838
    3939$head Purpose$$
    40 This routine can be used to check a method for computing the 
     40This routine can be used to check a method for computing the
    4141gradient of the determinant of a matrix.
    4242
    4343$head Inclusion$$
    4444The template function $code det_grad_33$$ is defined in the $code CppAD$$
    45 namespace by including 
    46 the file $code cppad/speed/det_grad_33.hpp$$ 
     45namespace by including
     46the file $code cppad/speed/det_grad_33.hpp$$
    4747(relative to the CppAD distribution directory).
    48 It is only intended for example and testing purposes, 
     48It is only intended for example and testing purposes,
    4949so it is not automatically included by
    5050$cref/cppad.hpp/cppad/$$.
     
    7272
    7373$head Vector$$
    74 If $icode y$$ is a $icode Vector$$ object, 
     74If $icode y$$ is a $icode Vector$$ object,
    7575it must support the syntax
    7676$codei%
     
    8787        bool %ok%
    8888%$$
    89 It is true, if the gradient $icode g$$ 
     89It is true, if the gradient $icode g$$
    9090passes the test and false otherwise.
    9191
     
    9595
    9696$head Source Code$$
    97 The file 
     97The file
    9898$cref det_grad_33.hpp$$
    9999contains the source code for this template function.
     
    103103*/
    104104// BEGIN C++
     105# include <limits>
    105106# include <cppad/near_equal.hpp>
    106107namespace CppAD {
     
    108109        bool det_grad_33(const Vector &x, const Vector &g)
    109110        {       bool ok = true;
    110        
     111                typedef typename Vector::value_type Float;
     112                Float eps = 10. * Float( std::numeric_limits<double>::epsilon() );
     113
    111114                // use expansion by minors to compute the derivative by hand
    112115                double check[9];
     
    121124                check[6] = + ( x[1] * x[5] - x[2] * x[4] );
    122125                check[7] = - ( x[0] * x[5] - x[2] * x[3] );
    123                 check[8] = + ( x[0] * x[4] - x[1] * x[3] ); 
     126                check[8] = + ( x[0] * x[4] - x[1] * x[3] );
    124127                //
    125                 size_t i;
    126                 for(i = 0; i < 3 * 3; i++)
    127                         ok &= CppAD::NearEqual(check[i], g[i], 1e-10, 1e-10);
    128                
     128                for(size_t i = 0; i < 3 * 3; i++)
     129                        ok &= CppAD::NearEqual(check[i], g[i], eps, eps);
     130
    129131                return ok;
    130132        }
  • trunk/example/CMakeLists.txt

    r3732 r3733  
    164164        ode_stiff.cpp
    165165        ode_taylor.cpp
    166         omp_alloc.cpp
    167166        opt_val_hes.cpp
    168167        optimize.cpp
  • trunk/example/example.cpp

    r3718 r3733  
    138138extern bool OdeStiff(void);
    139139extern bool ode_taylor(void);
    140 extern bool omp_alloc(void);
    141140extern bool opt_val_hes(void);
    142141extern bool optimize(void);
     
    303302        ok &= Run( OdeStiff,          "OdeStiff"         );
    304303        ok &= Run( ode_taylor,        "ode_taylor"       );
    305         ok &= Run( omp_alloc,         "omp_alloc"        );
    306304        ok &= Run( opt_val_hes,       "opt_val_hes"      );
    307305        ok &= Run( optimize,          "optimize"         );
  • trunk/example/makefile.am

    r3718 r3733  
    170170        ode_stiff.cpp \
    171171        ode_taylor.cpp \
    172         omp_alloc.cpp \
    173172        opt_val_hes.cpp \
    174173        optimize.cpp \
  • trunk/example/makefile.in

    r3718 r3733  
    135135        numeric_type.cpp ode_err_control.cpp ode_err_maxabs.cpp \
    136136        ode_gear.cpp ode_gear_control.cpp ode_stiff.cpp ode_taylor.cpp \
    137         omp_alloc.cpp opt_val_hes.cpp optimize.cpp par_var.cpp \
    138         poly.cpp pow.cpp pow_int.cpp print_for.cpp reverse_any.cpp \
    139         reverse_one.cpp reverse_three.cpp reverse_two.cpp rev_one.cpp \
     137        opt_val_hes.cpp optimize.cpp par_var.cpp poly.cpp pow.cpp \
     138        pow_int.cpp print_for.cpp reverse_any.cpp reverse_one.cpp \
     139        reverse_three.cpp reverse_two.cpp rev_one.cpp \
    140140        rev_sparse_hes.cpp rev_sparse_jac.cpp rev_two.cpp \
    141141        romberg_mul.cpp romberg_one.cpp rosen_34.cpp runge45_1.cpp \
     
    182182        ode_err_control.$(OBJEXT) ode_err_maxabs.$(OBJEXT) \
    183183        ode_gear.$(OBJEXT) ode_gear_control.$(OBJEXT) \
    184         ode_stiff.$(OBJEXT) ode_taylor.$(OBJEXT) omp_alloc.$(OBJEXT) \
    185         opt_val_hes.$(OBJEXT) optimize.$(OBJEXT) par_var.$(OBJEXT) \
    186         poly.$(OBJEXT) pow.$(OBJEXT) pow_int.$(OBJEXT) \
    187         print_for.$(OBJEXT) reverse_any.$(OBJEXT) \
    188         reverse_one.$(OBJEXT) reverse_three.$(OBJEXT) \
    189         reverse_two.$(OBJEXT) rev_one.$(OBJEXT) \
    190         rev_sparse_hes.$(OBJEXT) rev_sparse_jac.$(OBJEXT) \
    191         rev_two.$(OBJEXT) romberg_mul.$(OBJEXT) romberg_one.$(OBJEXT) \
    192         rosen_34.$(OBJEXT) runge45_1.$(OBJEXT) runge45_2.$(OBJEXT) \
    193         seq_property.$(OBJEXT) simple_vector.$(OBJEXT) sign.$(OBJEXT) \
    194         sin.$(OBJEXT) sinh.$(OBJEXT) sparse_hessian.$(OBJEXT) \
     184        ode_stiff.$(OBJEXT) ode_taylor.$(OBJEXT) opt_val_hes.$(OBJEXT) \
     185        optimize.$(OBJEXT) par_var.$(OBJEXT) poly.$(OBJEXT) \
     186        pow.$(OBJEXT) pow_int.$(OBJEXT) print_for.$(OBJEXT) \
     187        reverse_any.$(OBJEXT) reverse_one.$(OBJEXT) \
     188        reverse_three.$(OBJEXT) reverse_two.$(OBJEXT) \
     189        rev_one.$(OBJEXT) rev_sparse_hes.$(OBJEXT) \
     190        rev_sparse_jac.$(OBJEXT) rev_two.$(OBJEXT) \
     191        romberg_mul.$(OBJEXT) romberg_one.$(OBJEXT) rosen_34.$(OBJEXT) \
     192        runge45_1.$(OBJEXT) runge45_2.$(OBJEXT) seq_property.$(OBJEXT) \
     193        simple_vector.$(OBJEXT) sign.$(OBJEXT) sin.$(OBJEXT) \
     194        sinh.$(OBJEXT) sparse_hessian.$(OBJEXT) \
    195195        sparse_jacobian.$(OBJEXT) sparse_sub_hes.$(OBJEXT) \
    196196        sparsity_sub.$(OBJEXT) sqrt.$(OBJEXT) stack_machine.$(OBJEXT) \
     
    599599        ode_stiff.cpp \
    600600        ode_taylor.cpp \
    601         omp_alloc.cpp \
    602601        opt_val_hes.cpp \
    603602        optimize.cpp \
     
    796795@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ode_stiff.Po@am__quote@
    797796@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ode_taylor.Po@am__quote@
    798 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/omp_alloc.Po@am__quote@
    799797@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opt_val_hes.Po@am__quote@
    800798@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/optimize.Po@am__quote@
  • trunk/example/thread_alloc.cpp

    r3408 r3733  
    11/* $Id$ */
    22/* --------------------------------------------------------------------------
    3 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell
     3CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell
    44
    55CppAD is distributed under multiple licenses. This distribution is under
    6 the terms of the 
     6the terms of the
    77                    Eclipse Public License Version 1.0.
    88
     
    4242namespace { // Begin empty namespace
    4343
    44        
     44
    4545
    4646bool raw_allocate(void)
     
    4949        size_t thread;
    5050
    51         // check that no memory is initilaly inuse 
     51        // check that no memory is initilaly inuse
    5252        ok &= thread_alloc::free_all();
    5353
     
    6060        size_t n_outter   = 10;
    6161        size_t n_inner    = 5;
    62         size_t cap_bytes, i, j, k;
    63         for(i = 0; i < n_outter; i++)
     62        for(size_t i = 0; i < n_outter; i++)
    6463        {       // Do not use CppAD::vector here because its use of thread_alloc
    65                 // complicates the inuse and avaialble results. 
     64                // complicates the inuse and avaialble results.
    6665                std::vector<void*> v_ptr(n_inner);
    67                 for( j = 0; j < n_inner; j++)
     66                // cap_bytes will be set by get_memory
     67                size_t cap_bytes = 0; // set here to avoid MSC warning
     68                for(size_t j = 0; j < n_inner; j++)
    6869                {       // allocate enough memory for min_size_t size_t objects
    6970                        v_ptr[j]    = thread_alloc::get_memory(min_bytes, cap_bytes);
     
    7374                        ok                &= min_size_t <= cap_size_t;
    7475                        // use placement new to call the size_t copy constructor
    75                         for(k = 0; k < cap_size_t; k++)
     76                        for(size_t k = 0; k < cap_size_t; k++)
    7677                                new(ptr + k) size_t(i + j + k);
    7778                        // check that the constructor worked
    78                         for(k = 0; k < cap_size_t; k++)
     79                        for(size_t k = 0; k < cap_size_t; k++)
    7980                                ok &= ptr[k] == (i + j + k);
    8081                }
     
    8485                ok &= thread_alloc::available(thread) == 0;
    8586                // return the memrory to thread_alloc
    86                 for(j = 0; j < n_inner; j++)
     87                for(size_t j = 0; j < n_inner; j++)
    8788                        thread_alloc::return_memory(v_ptr[j]);
    8889                // check that now n_inner * cap_bytes are now available
     
    9293        }
    9394        thread_alloc::free_available(thread);
    94        
     95
    9596        // check that the tests have not held onto memory
    9697        ok &= ! CppAD::memory_leak();
     
    111112{       bool ok = true;
    112113        using CppAD::thread_alloc;
    113         size_t i; 
     114        size_t i;
    114115
    115116        // check initial memory values
     
    122123        size_t  size_min  = 3;
    123124        size_t  size_one;
    124         my_char *array_one  = 
     125        my_char *array_one  =
    125126                thread_alloc::create_array<my_char>(size_min, size_one);
    126127
     
    133134        // now create a longer array
    134135        size_t size_two;
    135         my_char *array_two = 
     136        my_char *array_two =
    136137                thread_alloc::create_array<my_char>(2 * size_min, size_two);
    137138
     
    150151        ok   &= thread_alloc::available(thread) == 0;
    151152
    152         // delete the arrays 
     153        // delete the arrays
    153154        thread_alloc::delete_array(array_one);
    154155        thread_alloc::delete_array(array_two);
     
    159160        // free the memory for use by this thread
    160161        thread_alloc::free_available(thread);
    161        
     162
    162163        // check that the tests have not held onto memory
    163164        ok &= ! CppAD::memory_leak();
     
    192193        ok &= (v_size_t % n_byte) == 0;
    193194
    194         // return memory to available pool 
     195        // return memory to available pool
    195196        thread_alloc::return_memory(v_ptr);
    196197
     
    198199        size_t size_min = 1;
    199200        size_t size_out;
    200         my_char *array_ptr = 
     201        my_char *array_ptr =
    201202                thread_alloc::create_array<my_char>(size_min, size_out);
    202203
     
    225226        ok  &= thread_alloc::in_parallel() == false;
    226227
    227         // Instruct thread_alloc to hold onto memory.  This makes memory 
     228        // Instruct thread_alloc to hold onto memory.  This makes memory
    228229        // allocation faster (especially when there are multiple threads).
    229230        thread_alloc::hold_memory(true);
  • trunk/multi_thread/multi_newton_work.cpp

    r2506 r3733  
    11/* $Id$ */
    22/* --------------------------------------------------------------------------
    3 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell
     3CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell
    44
    55CppAD is distributed under multiple licenses. This distribution is under
    6 the terms of the 
     6the terms of the
    77                    Eclipse Public License Version 1.0.
    88
     
    1717$index multi_newton_work$$
    1818
    19 $section Multi-threading Newton Method Utility Routines$$ 
     19$section Multi-threading Newton Method Utility Routines$$
    2020$spell
    2121        Cpp
     
    5858%$$
    5959This argument must evaluate the function $latex f(x)$$,
    60 and its derivative $latex f^{(1)} (x)$$, 
     60and its derivative $latex f^{(1)} (x)$$,
    6161using the syntax
    6262$codei%
     
    6565where the arguments have the prototypes
    6666$codei%
    67         double    %x% 
     67        double    %x%
    6868        double&   %f%
    6969        double&   %df%
     
    7777        size_t %num_sub%
    7878%$$
    79 It specifies the number of sub-intervals; i.e., $latex n$$ 
     79It specifies the number of sub-intervals; i.e., $latex n$$
    8080in to split the calculation into.
    8181
     
    121121Calling this function does the computation for one thread.
    122122Following a call to $code multi_newton_setup$$,
    123 this function should be called by each of the $icode num_threads$$ threads. 
     123this function should be called by each of the $icode num_threads$$ threads.
    124124
    125125$head multi_newton_combine$$
    126126After the $icode num_threads$$ threads have completed their
    127127calls to $code multi_newton_worker$$,
    128 this function call will combine the results and return the final 
     128this function call will combine the results and return the final
    129129set of approximate zeros for $latex f(x)$$.
    130130
     
    139139$codei%
    140140        | %f%( %xout%[%i%] ) | <= %epsilon%
    141 %$$ 
    142 for each valid index $icode i$$. 
     141%$$
     142for each valid index $icode i$$.
    143143In addition, the elements of $icode xout$$ are in ascending order and
    144144$codei%
     
    186186                double xlow;
    187187                // end of interval (worker input)
    188                 double xup; 
     188                double xup;
    189189                // vector of zero candidates (worker output)
    190190                // after call to multi_newton_setup:   x.size() == 0
    191191                // after call to multi_newton_work:    x.size() is number of zeros
    192192                // after call to multi_newton_combine: x.size() == 0
    193                 vector<double> x; 
     193                vector<double> x;
    194194                // false if an error occurs, true otherwise (worker output)
    195195                bool   ok;
     
    246246                bool more_itr = true;
    247247                size_t itr    = 0;
    248                 double fcur, dfcur;
     248                // initialize these values to avoid MSC C++ warning
     249                double fcur=0.0, dfcur=0.0;
    249250                while( more_itr )
    250251                {       fun_(xcur, fcur, dfcur);
     
    254255                                more_itr = false;
    255256                        if( (xcur == xlow_i ) & (fcur * dfcur > 0.) )
    256                                 more_itr = false; 
     257                                more_itr = false;
    257258                        if( (xcur == xup_i)   & (fcur * dfcur < 0.) )
    258                                 more_itr = false; 
     259                                more_itr = false;
    259260
    260261                        // next Newton iterate
     
    269270                }
    270271                if( fabs( fcur ) <= epsilon_ )
    271                 {       // check for case where xcur is lower bound for this 
     272                {       // check for case where xcur is lower bound for this
    272273                        // sub-interval and upper bound for previous sub-interval
    273274                        if( fabs(xcur - xlast) >= sub_length_ )
     
    275276                                xlast = xcur;
    276277                                flast = fcur;
    277                         } 
     278                        }
    278279                        else if( fabs(fcur) < fabs(flast) )
    279280                        {       x[ x.size() - 1] = xcur;
     
    289290bool multi_newton_setup(
    290291        void (fun)(double x, double& f, double& df) ,
    291         size_t num_sub                              , 
     292        size_t num_sub                              ,
    292293        double xlow                                 ,
    293294        double xup                                  ,
     
    313314
    314315        // determine values that are specific to each thread
    315         size_t num_min   = num_sub / num_threads; // minimum num_sub 
     316        size_t num_min   = num_sub / num_threads; // minimum num_sub
    316317        size_t num_more  = num_sub % num_threads; // number that have one more
    317318        size_t sum_num   = 0;  // sum with respect to thread of num_sub
     
    341342                double xlow_thread = xlow + sum_num * sub_length_;
    342343
    343                 // when thread_num == num_threads - 1, xup_thread = xup 
     344                // when thread_num == num_threads - 1, xup_thread = xup
    344345                double xup_thread = xlow + (sum_num + num_sub_thread) * sub_length_;
    345346                if( thread_num == num_threads - 1 )
     
    362363}
    363364// -----------------------------------------------------------------------
    364 // get the result of the work 
     365// get the result of the work
    365366bool multi_newton_combine(CppAD::vector<double>& xout)
    366367{       // number of threads in the calculation
     
    372373        size_t thread_num;
    373374
    374         // initialize as more that sub_lenght_ / 2 from any possible solution 
    375         double xlast = - sub_length_; 
     375        // initialize as more that sub_lenght_ / 2 from any possible solution
     376        double xlast = - sub_length_;
    376377        for(thread_num = 0; thread_num < num_threads; thread_num++)
    377378        {       vector<double>& x = work_all_[thread_num]->x;
     
    381382                {       // check for case where this point is lower limit for this
    382383                        // thread and upper limit for previous thread
    383                         if( fabs(x[i] - xlast) >= sub_length_ ) 
     384                        if( fabs(x[i] - xlast) >= sub_length_ )
    384385                        {       xout.push_back( x[i] );
    385386                                xlast = x[i];
     
    405406                // call the destructor for CppAD::vector destructor
    406407                work_all_[thread_num]->x.~vector<double>();
    407                 // delete the raw memory allocation 
     408                // delete the raw memory allocation
    408409                void* v_ptr = static_cast<void*>( work_all_[thread_num] );
    409410                thread_alloc::return_memory( v_ptr );
     
    412413# endif
    413414                // Note that xout corresponds to memroy that is inuse by master
    414                 // (so we can only chech have freed all their memory). 
     415                // (so we can only chech have freed all their memory).
    415416                if( thread_num > 0 )
    416417                {       // check that there is no longer any memory inuse by this thread
  • trunk/omh/deprecated/omp_alloc.omh

    r3607 r3733  
    44
    55CppAD is distributed under multiple licenses. This distribution is under
    6 the terms of the 
     6the terms of the
    77                    Eclipse Public License Version 1.0.
    88
     
    2222$index openmp, memory allocation$$
    2323$index memory, multi-threading allocation$$
    24 $index allocation, multi-threading$$ 
     24$index allocation, multi-threading$$
    2525
    2626$head Syntax$$
     
    3333allocator keeps that memory $cref omp_available$$ for the thread so that
    3434it can be re-used without waiting for a lock.
    35 All the CppAD memory allocations use this utility. 
     35All the CppAD memory allocations use this utility.
    3636The $cref omp_free_available$$ function should be used to return memory
    3737to the system (once it is no longer required by a thread).
     
    4848$childtable%
    4949        cppad/omp_alloc.hpp%
    50         example/omp_alloc.cpp
     50        test_more/omp_alloc.cpp
    5151%$$
    5252
  • trunk/omh/example_list.omh

    r3718 r3733  
    207207$rref ode_taylor.cpp$$
    208208$rref old_reciprocal.cpp$$
    209 $rref omp_alloc.cpp$$
    210209$rref optimize.cpp$$
    211210$rref opt_val_hes.cpp$$
  • trunk/speed/src/link_sparse_hessian.cpp

    r3627 r3733  
    44
    55CppAD is distributed under multiple licenses. This distribution is under
    6 the terms of the 
     6the terms of the
    77                    Eclipse Public License Version 1.0.
    88
     
    3434        CppAD::vector<double>&        %x%         ,
    3535        const CppAD::vector<size_t>&  %row%       ,
    36         const CppAD::vector<size_t>&  %col%       , 
     36        const CppAD::vector<size_t>&  %col%       ,
    3737        CppAD::vector<double>&        %hessian%   ,
    3838        size_t                        %n_sweep%
     
    4343Given a row index vector $latex row$$
    4444and a second column vector $latex col$$,
    45 the corresponding function 
    46 $latex f : \B{R}^n \rightarrow \B{R} $$ 
     45the corresponding function
     46$latex f : \B{R}^n \rightarrow \B{R} $$
    4747is defined by $cref sparse_hes_fun$$.
    48 The non-zero entries in the Hessian of this function have 
     48The non-zero entries in the Hessian of this function have
    4949one of the following forms:
    5050$latex \[
     
    9797%$$
    9898Its size must be the same as $icode row$$; i.e., $latex K$$.
    99 It contains the column indices for the corresponding function 
     99It contains the column indices for the corresponding function
    100100$latex f(x)$$.
    101101All the elements of $icode col$$ are between zero and $latex n-1$$.
    102102There are no duplicated entries requested, to be specific,
    103 if $icode%k1% != %k2%$$ then 
    104 $codei%
    105         ( %row%[%k1%] , %col%[%k1%] ) != ( %row%[%k2%] , %col%[%k2%] ) 
     103if $icode%k1% != %k2%$$ then
     104$codei%
     105        ( %row%[%k1%] , %col%[%k1%] ) != ( %row%[%k2%] , %col%[%k2%] )
    106106%$$
    107107
     
    112112%$$
    113113and its size is $icode K$$.
    114 The input value of its elements does not matter. 
     114The input value of its elements does not matter.
    115115The output value of its elements is the Hessian of the function $latex f(x)$$.
    116116To be more specific, for
     
    124124it is the value $cref/n_sweep/sparse_hessian/n_sweep/$$ corresponding
    125125to the evaluation of $icode hessian$$.
    126 This is also the number of colors corresponding to the 
     126This is also the number of colors corresponding to the
    127127$cref/coloring method/sparse_hessian/work/color_method/$$,
    128128which can be set to $cref/colpack/speed_main/Sparsity Options/colpack/$$,
     
    132132$subhead double$$
    133133In the case where $icode package$$ is $code double$$,
    134 only the first element of $icode hessian$$ is used and it is actually 
     134only the first element of $icode hessian$$ is used and it is actually
    135135the value of $latex f(x)$$ (derivatives are not computed).
    136136
    137 $end 
     137$end
    138138-----------------------------------------------------------------------------
    139139*/
     
    153153
    154154        /*!
    155         Class used by choose_row_col to determin order of row and column indices
     155        Class used by choose_row_col to determin order of row and column indices
    156156        */
    157157        class Key {
     
    165165                { }
    166166                /*!
    167                 Construct from a value for row and col
     167                Construct from a value for row and col
    168168
    169169                \param row
     
    172172                \param col
    173173                column value for this key
    174                 */
     174                */
    175175                Key(size_t row, size_t col)
    176176                : row_(row), col_(col)
    177177                { }
    178178                /*!
    179                 Compare this key with another key using < operator
     179                Compare this key with another key using < operator
    180180
    181181                \param other
     
    205205        void choose_row_col(
    206206                size_t          n   ,
    207                 vector<size_t>& row , 
     207                vector<size_t>& row ,
    208208                vector<size_t>& col )
    209209        {       size_t i, j, k, ell;
     
    218218                        CppAD::uniform_01(max_per_row, random);
    219219
    220                         // set the indices for this row 
     220                        // set the indices for this row
    221221                        size_t k_start = col.size();
    222222                        for(ell = 0; ell < max_per_row; ell++)
     
    256256\param hessian [out]
    257257is a vector, with hessian.size() == row.size(),
    258 containing the value of the Hessian of f(x) 
     258containing the value of the Hessian of f(x)
    259259corresponding to the last repetition.
    260260
     
    272272        size_t                           repeat    ,
    273273        const CppAD::vector<size_t>&     row       ,
    274         const CppAD::vector<size_t>&     col       , 
     274        const CppAD::vector<size_t>&     col       ,
    275275        CppAD::vector<double>&           x         ,
    276276        CppAD::vector<double>&           hessian   ,
     
    285285*/
    286286bool available_sparse_hessian(void)
    287 {       
     287{
    288288        size_t n      = 2;
    289289        size_t repeat = 1;
    290290        vector<double> x(n);
    291         vector<size_t> row, col; 
     291        vector<size_t> row, col;
    292292        choose_row_col(n, row, col);
    293293        size_t K = row.size();
     
    296296        size_t n_sweep;
    297297        return link_sparse_hessian(n, repeat, row, col, x, hessian, n_sweep);
    298         exit(0);
    299298}
    300299/*!
     
    308307*/
    309308bool correct_sparse_hessian(bool is_package_double)
    310 {       
     309{
    311310        size_t n      = 10;
    312311        size_t repeat = 1;
     
    355354        static vector<size_t> row, col;
    356355
    357         size_t n = size;       
     356        size_t n = size;
    358357        vector<double> x(n);
    359358        if( size != previous_size )
     
    382381*/
    383382void info_sparse_hessian(size_t size, size_t& n_sweep)
    384 {       size_t n      = size;   
     383{       size_t n      = size;
    385384        size_t repeat = 1;
    386385        vector<size_t> row, col;
  • trunk/test_more/CMakeLists.txt

    r3689 r3733  
    1717SET(CMAKE_BUILD_TYPE DEBUG)
    1818
    19 # This directory does not contain any multi-threading tests, so
    20 # test using CPPAD_MAX_NUM_THREADS equal to one (its smallest value)
    21 ADD_DEFINITIONS("-DCPPAD_MAX_NUM_THREADS=1")
     19# This directory now contains omp_alloc.cpp which uses multi-threading, so
     20# so no longer can set CPPAD_MAX_NUM_THREADS equal to one (its smallest value)
     21# ADD_DEFINITIONS("-DCPPAD_MAX_NUM_THREADS=1")
    2222
    2323# adolc_prefix
     
    118118        neg.cpp
    119119        ode_err_control.cpp
     120        omp_alloc.cpp
    120121        optimize.cpp
    121122        parameter.cpp
  • trunk/test_more/limits.cpp

    r2884 r3733  
    11/* $Id$ */
    22/* --------------------------------------------------------------------------
    3 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell
     3CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell
    44
    55CppAD is distributed under multiple licenses. This distribution is under
    6 the terms of the 
     6the terms of the
    77                    Eclipse Public License Version 1.0.
    88
     
    1212
    1313/*
    14 $begin limits.cpp$$
     14old limits.cpp example / test
    1515$spell
    1616$$
     
    2424This code assumes that the decimal point is infront of the mantissa.
    2525Hence dividing the minimum normalized value looses precision,
    26 while multiplying the maximum normalized value results in infinity. 
     26while multiplying the maximum normalized value results in infinity.
    2727
    2828$head Externals$$
     
    6969                value tmp( Type(0) );
    7070                //
    71                 tmp.set( add_one( eps.get() / two.get() ) ); 
     71                tmp.set( add_one( eps.get() / two.get() ) );
    7272                ok        &= one.get() == tmp.get();
    7373                //
    74                 tmp.set( add_one( eps.get() ) ); 
     74                tmp.set( add_one( eps.get() ) );
    7575                ok        &= one.get() != tmp.get();
    7676                return ok;
     
    137137        ok &= check_epsilon< std::complex<double> >();
    138138
    139         // epsilon for some AD types. 
     139        // epsilon for some AD types.
    140140        ok &= check_epsilon< AD<float> >();
    141141        ok &= check_epsilon< AD<double> >();
     
    150150        ok &= check_min< std::complex<double> >();
    151151
    152         // min for some AD types. 
     152        // min for some AD types.
    153153        ok &= check_min< AD<float> >();
    154154        ok &= check_min< AD<double> >();
     
    163163        ok &= check_max< std::complex<double> >();
    164164
    165         // max for some AD types. 
     165        // max for some AD types.
    166166        ok &= check_max< AD<float> >();
    167167        ok &= check_max< AD<double> >();
  • trunk/test_more/makefile.am

    r3689 r3733  
    144144        neg.cpp \
    145145        ode_err_control.cpp \
     146        omp_alloc.cpp \
    146147        optimize.cpp \
    147148        parameter.cpp \
  • trunk/test_more/makefile.in

    r3705 r3733  
    124124        limits.cpp log.cpp log1p.cpp log10.cpp mul.cpp mul_cskip.cpp \
    125125        mul_eq.cpp mul_level.cpp mul_zdouble.cpp mul_zero_one.cpp \
    126         near_equal_ext.cpp neg.cpp ode_err_control.cpp optimize.cpp \
    127         parameter.cpp poly.cpp pow.cpp pow_int.cpp print_for.cpp \
    128         romberg_one.cpp rosen_34.cpp runge_45.cpp reverse.cpp \
    129         rev_sparse_hes.cpp rev_sparse_jac.cpp rev_two.cpp \
     126        near_equal_ext.cpp neg.cpp ode_err_control.cpp omp_alloc.cpp \
     127        optimize.cpp parameter.cpp poly.cpp pow.cpp pow_int.cpp \
     128        print_for.cpp romberg_one.cpp rosen_34.cpp runge_45.cpp \
     129        reverse.cpp rev_sparse_hes.cpp rev_sparse_jac.cpp rev_two.cpp \
    130130        simple_vector.cpp sin.cpp sin_cos.cpp sinh.cpp \
    131131        sparse_hessian.cpp sparse_jacobian.cpp sparse_vec_ad.cpp \
     
    156156        mul_level.$(OBJEXT) mul_zdouble.$(OBJEXT) \
    157157        mul_zero_one.$(OBJEXT) near_equal_ext.$(OBJEXT) neg.$(OBJEXT) \
    158         ode_err_control.$(OBJEXT) optimize.$(OBJEXT) \
    159         parameter.$(OBJEXT) poly.$(OBJEXT) pow.$(OBJEXT) \
    160         pow_int.$(OBJEXT) print_for.$(OBJEXT) romberg_one.$(OBJEXT) \
    161         rosen_34.$(OBJEXT) runge_45.$(OBJEXT) reverse.$(OBJEXT) \
    162         rev_sparse_hes.$(OBJEXT) rev_sparse_jac.$(OBJEXT) \
    163         rev_two.$(OBJEXT) simple_vector.$(OBJEXT) sin.$(OBJEXT) \
    164         sin_cos.$(OBJEXT) sinh.$(OBJEXT) sparse_hessian.$(OBJEXT) \
     158        ode_err_control.$(OBJEXT) omp_alloc.$(OBJEXT) \
     159        optimize.$(OBJEXT) parameter.$(OBJEXT) poly.$(OBJEXT) \
     160        pow.$(OBJEXT) pow_int.$(OBJEXT) print_for.$(OBJEXT) \
     161        romberg_one.$(OBJEXT) rosen_34.$(OBJEXT) runge_45.$(OBJEXT) \
     162        reverse.$(OBJEXT) rev_sparse_hes.$(OBJEXT) \
     163        rev_sparse_jac.$(OBJEXT) rev_two.$(OBJEXT) \
     164        simple_vector.$(OBJEXT) sin.$(OBJEXT) sin_cos.$(OBJEXT) \
     165        sinh.$(OBJEXT) sparse_hessian.$(OBJEXT) \
    165166        sparse_jacobian.$(OBJEXT) sparse_vec_ad.$(OBJEXT) \
    166167        sqrt.$(OBJEXT) std_math.$(OBJEXT) sub.$(OBJEXT) \
     
    545546        neg.cpp \
    546547        ode_err_control.cpp \
     548        omp_alloc.cpp \
    547549        optimize.cpp \
    548550        parameter.cpp \
     
    692694@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/neg.Po@am__quote@
    693695@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ode_err_control.Po@am__quote@
     696@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/omp_alloc.Po@am__quote@
    694697@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/optimize.Po@am__quote@
    695698@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parameter.Po@am__quote@
  • trunk/test_more/romberg_one.cpp

    r3060 r3733  
    11/* $Id$ */
    22/* --------------------------------------------------------------------------
    3 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell
     3CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell
    44
    55CppAD is distributed under multiple licenses. This distribution is under
    6 the terms of the 
     6the terms of the
    77                    Eclipse Public License Version 1.0.
    88
     
    1212
    1313/*
    14 $begin romberg_one.cpp$$
     14old romberg_one.cpp example / test
    1515$spell
    1616        Romberg
     
    3939        public:
    4040                // constructor
    41                 Fun(size_t degree_) : degree(degree_) 
     41                Fun(size_t degree_) : degree(degree_)
    4242                { }
    4343
     
    6969                size_t p;
    7070
    71                 // int_a^b F(x) dx = 
    72                 //      [ b^(degree+1) - a^(degree+1) ] / (degree+1) 
     71                // int_a^b F(x) dx =
     72                //      [ b^(degree+1) - a^(degree+1) ] / (degree+1)
    7373                Float bpow(1);
    7474                Float apow(1);
     
    7676                {       bpow *= b;
    7777                        apow *= a;
    78                 } 
     78                }
    7979                Float check = (bpow - apow) / Float(degree+1);
    8080
     
    9292
    9393                        ok  &= e < (degree+1) * spow;
    94                         ok  &= CppAD::NearEqual(check, r, Float(0.), e);       
     94                        ok  &= CppAD::NearEqual(check, r, Float(0.), e);
    9595                }
    9696
  • trunk/test_more/test_more.cpp

    r3724 r3733  
    7575extern bool Neg(void);
    7676extern bool ode_err_control(void);
     77extern bool omp_alloc(void);
    7778extern bool optimize(void);
    7879extern bool parameter(void);
     
    192193        ok &= Run( Neg,             "Neg"            );
    193194        ok &= Run( ode_err_control, "ode_err_control");
     195        ok &= Run( omp_alloc,       "omp_alloc"      );
    194196        ok &= Run( optimize,        "optimize"       );
    195197        ok &= Run( parameter,       "parameter"      );
  • trunk/test_more/test_one.sh.in

    r3683 r3733  
    5050        $cxxflags
    5151        -g
     52        -fopenmp
    5253        -DCPPAD_ADOLC_TEST
    5354        -DCPPAD_OPENMP_TEST
    54         -DCPPAD_MAX_NUM_THREADS=1
    55         @OPENMP_FLAGS@
    5655        -I..
    5756"
Note: See TracChangeset for help on using the changeset viewer.