Ignore:
Timestamp:
Sep 20, 2014 5:45:43 AM (6 years ago)
Author:
bradbell
Message:

Implement and test first order forward mode.

cache.sh: Erase taylor coefficient when create cache.
forward1sweep.hpp: copy more information from forward0sweep.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/cache/cppad/local/forward1sweep.hpp

    r3342 r3344  
    273273        if( num_text > 0 )
    274274                text = play->GetTxt(0);
     275
     276        // data structure for cache information
     277        size_t num_cache = play->num_cache_rec();
     278        CppAD::vector<addr_t> cache2var( num_cache );
     279
     280        // initialize cache indices with invalid variable value
     281        for(size_t i = 0; i < num_cache; i++)
     282                cache2var[i] = addr_t(0);
    275283        /*
    276284        <!-- end forward0sweep_code_define -->
     
    292300# if CPPAD_FORWARD1SWEEP_TRACE
    293301        std::cout << std::endl;
    294 # endif
    295 # ifndef NDEBUG
    296         // 2DO: implement tracing cache
    297         CppAD::vector<addr_t> cache2var;
    298302# endif
    299303        bool more_operators = true;
     
    806810                        default:
    807811                        CPPAD_ASSERT_UNKNOWN(0);
     812                }
     813                if( num_cache != 0 )
     814                {       size_t i_cache = size_t( play->GetVar2Cache(i_var) );
     815                        CPPAD_ASSERT_UNKNOWN( i_cache >= num_var );
     816                        for(k = 0; k <= q; k++)
     817                                taylor[ i_cache * J + k ] = taylor[ i_var * J + k ];
     818                        // use zero orgin cache indiex for cache2var vector
     819                        cache2var[ i_cache - num_var ] = i_var;
    808820                }
    809821# if CPPAD_FORWARD1SWEEP_TRACE
Note: See TracChangeset for help on using the changeset viewer.