![]() |
Prev | Next | a_fun_abort_xam.m | Headings |
function ok = a_fun_abort_xam() % % load the Cppad Swig library m_cppad % % initialize return variable ok = true; % ----------------------------------------------------------------------- n_ind = 2; % % create ax x = m_cppad.vec_double(n_ind); for i = [ 0 :(n_ind -1) ] x(i) = i + 1.0; end ax = m_cppad.independent(x); % % preform some a_double operations ax0 = ax(0); ax1 = ax(1); ay = ax0 + ax1; % % check that ay is a variable; its value depends on the value of ax ok = ok && ay.variable(); % % abort this recording m_cppad.abort_recording(); % % check that ay is now a parameter, no longer a variable. ok = ok && ay.parameter(); % % since it is a parameter, we can retrieve its value y = ay.value(); % % its value should be x0 + x1 ok = ok && y == x(0) + x(1); % % an abort when not recording has no effect m_cppad.abort_recording(); % return; end