Changeset 3712 for trunk/test_more


Ignore:
Timestamp:
Aug 26, 2015 12:04:34 PM (4 years ago)
Author:
bradbell
Message:

merge to branch: trunk
from repository: https://github.com/coin-or/CppAD
start hash code: 9068654d6c9e0157639951dd93dad71eb8149e77
end hash code: fc86286a32cd87ded0475c12f6a8ea5388bc0ccd

commit fc86286a32cd87ded0475c12f6a8ea5388bc0ccd
Author: Brad Bell <bradbell@…>
Date: Wed Aug 26 08:52:02 2015 -0700

Fix a bug in checkpoint revese mode Jacobian sparsity patterns for a subset of rows.
checkpoint.hpp: fix bug.
checkpoint.cpp: test for bug.

commit b7d27ce9be62bf303150df355fc369e1e668ff3f
Author: Brad Bell <bradbell@…>
Date: Tue Aug 25 17:55:36 2015 -0700

Use CPPAD_INTERNAL_SPARES_SET type for checkpoint sparsity information.

commit 9fa2f6bd5ac4a6541ca6d06b53ded266a46fcebb
Author: Brad Bell <bradbell@…>
Date: Sat Aug 22 18:09:13 2015 -0700

checkpoint.hpp: put calculation of sparsity in private function.
rev_sparse_jac.hpp: comments to separate routines.

commit 9d7fdd3ca29a7ccf2f02b25c07788af133284c04
Author: Brad Bell <bradbell@…>
Date: Sat Aug 22 17:05:02 2015 -0700

Change checkpoint sparse hessian to use internal pattern (less memory).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test_more/checkpoint.cpp

    r3708 r3712  
    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
     
    135135                return ok;
    136136        }
     137
     138        bool h_algo(const ADVector& ax, ADVector& ay)
     139        {       ay[0] = ax[0];
     140                ay[1] = ax[1] + ax[2];
     141                return true;
     142        }
     143        bool test_two(void)
     144        {       bool ok = true;
     145                using CppAD::checkpoint;
     146                using CppAD::ADFun;
     147                using CppAD::NearEqual;
     148
     149                // checkpoint version of H(x)
     150                size_t m = 2;
     151                size_t n = 3;
     152                ADVector ax(n), ay(m);
     153                for(size_t j = 0; j < n; j++)
     154                        ax[j] = double(j);
     155                checkpoint<double> h_check("h_check", h_algo, ax, ay);
     156
     157                // record function using h_check
     158                Independent(ax);
     159                h_check(ax, ay);
     160                ADFun<double> h(ax, ay);
     161
     162                // compute sparsity pattern h_1(x) = x[1] + x[2]
     163                CppAD::vector< std::set<size_t> > r(1), s(1);
     164                r[0].insert(1);
     165                s = h.RevSparseJac(1, r);
     166
     167                // check result
     168                ok &= s[0] == std::set<size_t>{1, 2};
     169
     170                return ok;
     171        }
    137172}
    138173
     
    140175{       bool ok = true;
    141176        ok  &= test_one();
    142 
     177        ok  &= test_two();
    143178        return ok;
    144179}
Note: See TracChangeset for help on using the changeset viewer.