Changeset 3060


Ignore:
Timestamp:
Dec 27, 2013 3:38:57 PM (6 years ago)
Author:
bradbell
Message:
  1. Fix warning generated by bug/eigen_mul.sh.
  2. Item 1 required changing arbitrary conversion to AD<Base> to be explicit.
  3. Item 2 required some explicit type conversions.

base_require.hpp: remove trailing slash in documentaiton.
ad.hpp: comment about explicit and implicit constructors.

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/bug/eigen_scalar.sh

    r3058 r3060  
    5151
    5252# if DEFINE_TEMPLATED_CONSTRUCTOR
    53         template <class T> myscalar(const T& value)
     53        template <class T> explicit myscalar(const T& value)
    5454        {       value_ = double(value); }       
    5555# endif
  • trunk/cppad/base_require.hpp

    r2506 r3060  
    44
    55/* --------------------------------------------------------------------------
    6 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell
     6CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell
    77
    88CppAD is distributed under multiple licenses. This distribution is under
     
    7979$head Include Order$$
    8080If you are linking a non-standard base type to CppAD,
    81 you must first include the file $code cppad/base_require.hpp/$$,
     81you must first include the file $code cppad/base_require.hpp$$,
    8282then provide the specifications below,
    8383and then include the file $code cppad/cppad.hpp$$.
  • trunk/cppad/local/ad.hpp

    r2910 r3060  
    147147        typedef Base value_type;
    148148
    149         // default constructor
     149        // implicit default constructor
    150150        inline AD(void);
    151151
    152         // use default copy constructor and assignment operator
     152        // use default implicit copy constructor and assignment operator
    153153        // inline AD(const AD &x);
    154154        // inline AD& operator=(const AD &x);
    155155
    156         // construction and assingment from base type
     156        // implicit construction and assingment from base type
    157157        inline AD(const Base &b);
    158158        inline AD& operator=(const Base &b);
    159159
    160         // contructor and assignment from VecAD<Base>::reference
     160        // implicit contructor and assignment from VecAD<Base>::reference
    161161        inline AD(const VecAD_reference<Base> &x);
    162162        inline AD& operator=(const VecAD_reference<Base> &x);
    163163
    164         // construction and assignment from some other type
    165         template <class T> inline AD(const T &t);
     164        // explicit construction from some other type
     165        template <class T> inline explicit AD(const T &t);
     166
     167        // assignment from some other type
    166168        template <class T> inline AD& operator=(const T &right);
    167169
  • trunk/cppad/local/ad_ctor.hpp

    r2910 r3060  
    44
    55/* --------------------------------------------------------------------------
    6 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell
     6CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell
    77
    88CppAD is distributed under multiple licenses. This distribution is under
     
    4444
    4545$head x$$
    46 The argument $icode x$$ has prototype
     46
     47$subhead implicit$$
     48There is an implicit constructor where $icode x$$ has one of the following
     49prototypes:
    4750$codei%
    48         const %Type% &%x%
     51        const %Base%&        %x%
     52        const VecAD<%Base%>& %x%
    4953%$$
    50 where $icode Type$$ is
    51 $codei%VecAD<%Base%>::reference%$$,
    52 $codei%AD<%Base%>%$$,
    53 $icode Base$$,
    54 or any type that has a constructor of the form
     54
     55$subhead explicit$$
     56There is an explicit constructor where $icode x$$ has the prototype
     57prototypes:
     58$codei%
     59        const %Type%&        %x%
     60%$$
     61or any type that has an explicit constructor of the form
    5562$icode%Base%(%x%)%$$.
    5663
  • trunk/cppad/speed/det_of_minor.hpp

    r2506 r3060  
    44
    55/* --------------------------------------------------------------------------
    6 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell
     6CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell
    77
    88CppAD is distributed under multiple licenses. This distribution is under
     
    236236
    237237        // initialize determinant of the minor M
    238         Scalar detM = 0;
     238        Scalar detM = Scalar(0);
    239239
    240240        // initialize sign of factor for next sub-minor
  • trunk/omh/whats_new/whats_new_13.omh

    r3036 r3060  
    6262assist you in learning about changes between various versions of CppAD.
    6363
     64$head 12-27$$
     65The constructor from an arbitrary type to $codei%AD<%Base%>%$$ was
     66implicit, but there was no specification to this effect.
     67The caused problems when using CppAD with
     68$cref/eigen/eigen_prefix/$$.
     69This constructor has been changed to be
     70$cref/explicit/ad_ctor/x/explicit/$$.
     71In addition the
     72$cref/implicit/ad_ctor/x/implicit/$$ constructors
     73are now listed in the documentation.
     74$pre
     75
     76$$
     77If you get a compiler error on an assignment to an
     78$icode%AD%<%Base%>%$$ variable (that used to work)
     79try an explicit conversion to
     80$icode Base$$ or $codei%AD<%Base%>%$$ before the assignment.
     81
    6482$head 12-26$$
    6583Document fact that
  • trunk/test_more/cppad_eigen.cpp

    r3022 r3060  
    2222        using CppAD::AD;
    2323        using Eigen::Dynamic;
     24        using Eigen::Matrix;
    2425
    2526        typedef Eigen::NumTraits<AD<double> >         traits;
     
    4849        ok  &= abs2(x)  == 4.0;
    4950
    50         // Outputing a matrix used to fail before paritali specialization of
     51        // Outputing a matrix used to fail before partial specialization of
    5152        // struct significant_decimals_default_impl in cppad_eigen.hpp.
    52         Eigen::Matrix< AD<double>, 1, 1> X;
     53        Matrix< AD<double>, 1, 1> X;
    5354        X(0, 0) = AD<double>(1);
    5455        std::stringstream stream_out;
    5556        stream_out << X;
    5657        ok &= "1" == stream_out.str();
     58
     59        // multiplying three matrices together used to cause warning
     60        // before making ctor from arbitrary type to AD<Base> explicit.
     61        typedef CppAD::AD<double> AScalar;
     62        Matrix<AScalar, Dynamic, Dynamic> A(1,1), B(1,1), C(1,1), D(1,1);
     63        A(0,0) = 1.0;
     64        B(0,0) = 2.0;
     65        C(0,0) = 3.0;
     66        D      = A * B * C;
     67        ok    &= D(0,0) == 6.0 ;
    5768       
    5869        return ok;
  • trunk/test_more/erf.cpp

    r2506 r3060  
    11/* $Id$ */
    22/* --------------------------------------------------------------------------
    3 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell
     3CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell
    44
    55CppAD is distributed under multiple licenses. This distribution is under
     
    5858
    5959                // test using erf with AD< AD<double> >
    60                 AD< AD<double> > X0 = x[0];
     60                AD< AD<double> > X0 = AD<double>( x[0] );
    6161                AD< AD<double> > Y0 = erf(X0);
    6262
  • trunk/test_more/romberg_one.cpp

    r2506 r3060  
    11/* $Id$ */
    22/* --------------------------------------------------------------------------
    3 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell
     3CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell
    44
    55CppAD is distributed under multiple licenses. This distribution is under
     
    4646                Float operator () (const Float &x)
    4747                {       size_t i;
    48                         Float   f = 1;
     48                        Float   f(1);
    4949                        for(i = 0; i < degree; i++)
    5050                                f *= x;
     
    6262
    6363                // arguments to RombergOne
    64                 Float a = 0.;
    65                 Float b = 1.;
     64                Float a(0);
     65                Float b(1);
    6666                Float r;
    6767                size_t n = 4;
     
    7171                // int_a^b F(x) dx =
    7272                //      [ b^(degree+1) - a^(degree+1) ] / (degree+1)
    73                 Float bpow = 1.;
    74                 Float apow = 1.;
     73                Float bpow(1);
     74                Float apow(1);
    7575                for(i = 0; i <= degree; i++)
    7676                {       bpow *= b;
     
    8484                step *= Float(2.);
    8585                // step size raised to a power
    86                 Float spow = Float(1.);
     86                Float spow = Float(1);
    8787
    8888                for(p = 0; p < n; p++)
  • trunk/test_more/std_math.cpp

    r2506 r3060  
    11/* $Id$ */
    22/* --------------------------------------------------------------------------
    3 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-07 Bradley M. Bell
     3CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell
    44
    55CppAD is distributed under multiple licenses. This distribution is under
     
    2323{       using CppAD::NearEqual;
    2424        bool ok = true;
    25         ADDdouble half   = .5;
    26         ADDdouble one    = 1.;
    27         ADDdouble two    = 2.;
    28         ADDdouble ten    = 10.;
    29         ADDdouble small  = 1e-6;
    30         ADDdouble pi_4   = 3.141592653 / 4.;
    31         ADDdouble root_2 =  sqrt(two);
     25        ADDdouble half(.5);
     26        ADDdouble one(1.);
     27        ADDdouble two(2.);
     28        ADDdouble ten(10.);
     29        ADDdouble small(1e-6);
     30        ADDdouble pi_4(3.141592653 / 4.);
     31        ADDdouble root_2( sqrt(two) );
    3232
    33         ADDdouble y = acos(one / root_2);
     33        ADDdouble y( acos(one / root_2) );
    3434        ok &= NearEqual( pi_4, y, small, small );
    3535
Note: See TracChangeset for help on using the changeset viewer.