Changeset 1551 for trunk/test_more


Ignore:
Timestamp:
Oct 16, 2009 11:23:06 AM (11 years ago)
Author:
bradbell
Message:

trunk: Extend SparseJacobian? to use vector of sets for sparsity.

check_doxygen.sh: add SparseJacobian? to check for warnings.
*/sparse_jacobian.cpp: examples and tests of sparse jacobian calculations.
makefile.am: add makefile entry for old example, now in test_more.
makefile.in: change generated automatically by change in makefile.am.
jacobian.cpp: more testing of sparse jacobians.
test_more.cpp: add new entry for sparse_jacobian.cpp.
whats_new_09.omh: user's view of the changes.
ad_fun.hpp: new private helper functions to split cases.
for_sparse_jac.hpp: minor clean up.
rev_sparse_jac.hpp: minor clean up.
rev_sparse_hes.hpp: minor clean up.
sparse_jacobian.hpp: extend to handle and use vector of sets sparsity patterns.

Location:
trunk/test_more
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/test_more/jacobian.cpp

    r1381 r1551  
    5050{       bool ok = true;
    5151        using CppAD::vector;
    52         size_t j, k;
     52        size_t i, j, k;
    5353
    5454        size_t n = 4;
     
    6969        check = eval_jac_g(x);
    7070
     71        // regular jacobian
    7172        vector<double> jac_g = fun_g.Jacobian(x);
    72 
    7373        for(k = 0; k < m *n; k++)
    7474                ok &= CppAD::NearEqual(jac_g[k], check[k], 1e-10, 1e-10);
    7575
     76        // one argument sparse jacobian
    7677        jac_g = fun_g.SparseJacobian(x);
     78        for(k = 0; k < m *n; k++)
     79                ok &= CppAD::NearEqual(jac_g[k], check[k], 1e-10, 1e-10);
    7780
     81        // sparse jacobian using bool vectors
     82        CPPAD_TEST_VECTOR<bool> p_b(m * n) , r_b(n * n);
     83        for(i = 0; i < n; i++)
     84                for(j = 0; j < n; j++)
     85                        r_b[i * n + j] = (i == j);
     86        p_b = fun_g.ForSparseJac(n, r_b);
     87        jac_g = fun_g.SparseJacobian(x, p_b);
     88        for(k = 0; k < m *n; k++)
     89                ok &= CppAD::NearEqual(jac_g[k], check[k], 1e-10, 1e-10);
     90
     91        // sparse jacobian using vectors of sets
     92        std::vector< std::set<size_t> > p_s(m) , r_s(n);
     93        for(i = 0; i < n; i++)
     94                for(j = 0; j < n; j++)
     95                        r_s[i].insert(j);
     96        p_s = fun_g.ForSparseJac(n, r_s);
     97        jac_g = fun_g.SparseJacobian(x, p_s);
    7898        for(k = 0; k < m *n; k++)
    7999                ok &= CppAD::NearEqual(jac_g[k], check[k], 1e-10, 1e-10);
  • trunk/test_more/makefile.am

    r1497 r1551  
    119119        sin_cos.cpp \
    120120        sinh.cpp \
     121        sparse_jacobian.cpp \
    121122        sparse_vec_ad.cpp \
    122123        sqrt.cpp \
  • trunk/test_more/test_more.cpp

    r1497 r1551  
    7171extern bool SinCos(void);
    7272extern bool Sinh(void);
     73extern bool sparse_jacobian(void);
    7374extern bool sparse_vec_ad(void);
    7475extern bool Sqrt(void);
     
    165166        ok &= Run( SinCos,          "SinCos"         );
    166167        ok &= Run( Sinh,            "Sinh"           );
     168        ok &= Run( sparse_jacobian, "sparse_jacobian");
    167169        ok &= Run( sparse_vec_ad,   "sparse_vec_ad"  );
    168170        ok &= Run( Sqrt,            "Sqrt"           );
Note: See TracChangeset for help on using the changeset viewer.