Changeset 3744 for trunk/test_more


Ignore:
Timestamp:
Nov 6, 2015 10:33:15 AM (4 years ago)
Author:
bradbell
Message:

merge to branch: trunk
from repository: https://github.com/coin-or/CppAD
start hash code: 5c92f4e222d7edf44cc2633c5671418dd05473d0
end hash code: 079578bc3de0b44d7c647216b46090f45bbeca9d

commit 079578bc3de0b44d7c647216b46090f45bbeca9d
Author: Brad Bell <bradbell@…>
Date: Fri Nov 6 07:02:07 2015 -0800

Store and recover independent variables when nan occurs during Forward(0, x).


forward.hpp: remove invisible white space.
forward.cpp: remove invisible white space.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test_more/forward.cpp

    r2570 r3744  
    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
     
    2525        using namespace CppAD;
    2626
    27         // independent variable vector 
     27        // independent variable vector
    2828        CPPAD_TESTVECTOR(AD<double>) X(2);
    29         X[0] = 0.; 
     29        X[0] = 0.;
    3030        X[1] = 1.;
    3131        Independent(X);
     
    3838        ADFun<double> F(X, Y);
    3939
    40         // use zero order to evaluate F[ (3, 4) ] 
     40        // use zero order to evaluate F[ (3, 4) ]
    4141        VectorDouble x0( F.Domain() );
    4242        VectorDouble y0( F.Range() );
     
    9494        using namespace CppAD;
    9595
    96         // independent variable vector 
     96        // independent variable vector
    9797        CPPAD_TESTVECTOR(AD<double>) U(3);
    9898        U[0] = 0.; U[1] = 1.; U[2] = 2.;
     
    108108        }
    109109
    110         // dependent variable vector 
     110        // dependent variable vector
    111111        CPPAD_TESTVECTOR(AD<double>) V(2);
    112112        V[0] = sum;
     
    146146
    147147        // compare values
    148         ok &= NearEqual(v1[0] , 
     148        ok &= NearEqual(v1[0] ,
    149149                g0[0]*u1[0] + g0[1]*u1[1] + g0[2]*u1[2] , 1e-10, 1e-10);
    150         ok &= NearEqual(v1[1] , 
     150        ok &= NearEqual(v1[1] ,
    151151                g1[0]*u1[0] + g1[1]*u1[1] + g1[2]*u1[2] , 1e-10, 1e-10);
    152152
     
    156156        CPPAD_TESTVECTOR(double) v2( f.Range() );
    157157        p     = 2;
    158         u2[0] = .5; u2[1] = .4; u2[2] = .3; 
     158        u2[0] = .5; u2[1] = .4; u2[2] = .3;
    159159        v2    = f.Forward(p, u2);
    160160
     
    167167
    168168        // compare values
    169         ok &= NearEqual(v2[0] , 
     169        ok &= NearEqual(v2[0] ,
    170170                g0[0]*u2[0] + g0[1]*u2[1] + g0[2]*u2[2] , 1e-10, 1e-10);
    171171
     
    173173        double v2_1 = 0.;
    174174        for(i = 0; i < 3; i++)
    175         {       v2_1 += g1[i] * u2[i];   
     175        {       v2_1 += g1[i] * u2[i];
    176176                for(j = 0; j < 3; j++)
    177177                        v2_1 += .5 * u1[i] * H1[i * 3 + j] * u1[j];
     
    190190        const char *msg      )
    191191{       // error hander must not return, so throw an exception
    192         throw std::string(msg);
     192        std::string message = msg;
     193        throw message;
    193194}
    194195
    195196bool forward_nan(void)
    196 {       
     197{
    197198
    198199        using CppAD::vector;
     
    219220        }
    220221        catch( std::string msg )
    221         {       // check that the message contains "nan"
    222                 ok = msg.find("nan") != std::string::npos;
    223         }
    224 
    225         return ok;
    226 }
    227 } // END empty namespace
     222        {       // check that the message contains
     223                // "vector_size = " and "file_name = "
     224                ok = msg.find("vector_size = ") != std::string::npos;
     225                ok = msg.find("file_name = ") != std::string::npos;
     226        }
     227
     228        return ok;
     229}
     230} // END empty namespace
    228231
    229232# include <vector>
Note: See TracChangeset for help on using the changeset viewer.