Changeset 2811 for trunk/test_more


Ignore:
Timestamp:
May 14, 2013 5:35:37 AM (7 years ago)
Author:
bradbell
Message:

rev_sparse_jac.hpp: fix indexing bug.
user_atomic.hpp: fix error message spelling.
reciprocal.cpp: fix test of Hessian sparsity (was being skipped).
rev_sparse_jac.cpp: add test that demonstrates bug.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test_more/rev_sparse_jac.cpp

    r2506 r2811  
    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
     
    392392}
    393393
     394
     395// case where s is not identity matrix
     396bool case_four()
     397{       
     398        bool ok = true;
     399        using namespace CppAD;
     400
     401        // dimension of the domain space
     402        size_t n = 2;
     403
     404        // dimension of the range space
     405        size_t m = n;
     406
     407        // independent and variable vectors
     408        CPPAD_TESTVECTOR(AD<double>) ax(n), ay(m);
     409        ax[0] = 2.;
     410        ax[1] = 3.;
     411        Independent(ax);
     412        ay[0] = ax[1];
     413        ay[1] = ax[0];
     414
     415        // create function object F : x -> y
     416        ADFun<double> F(ax, ay);
     417
     418        // evaluate the dependency matrix for F(x)
     419        size_t q = 1;
     420        CPPAD_TESTVECTOR( bool ) s(q * m), r(q * n);
     421        s[0] = true;
     422        s[1] = false;
     423        r = F.RevSparseJac(q, s);
     424
     425        ok &= r.size() == q * n;
     426        ok &= r[0] == false;
     427        ok &= r[1] == true;
     428
     429        return ok;
     430}
     431
    394432} // END empty namespace
    395433
     
    400438        ok &= case_two();
    401439        ok &= case_three();
     440        ok &= case_four();
    402441
    403442        return ok;
Note: See TracChangeset for help on using the changeset viewer.