Changeset 3366
 Timestamp:
 Sep 27, 2014 5:43:15 AM (6 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/bug/opt_atomic.sh
r3365 r3366 62 62 return ok; 63 63 } 64 virtual bool rev_sparse_jac(65 size_t p ,66 const vector<bool>& rt ,67 vector<bool>& st )68 { // This function needed if using RevSparseJac or optimize69 // with afun.option( CppAD::atomic_base<double>::bool_sparsity_enum )70 size_t n = st.size() / p;71 size_t m = rt.size() / p;72 assert( n == 1 );73 assert( m == 1 );74 75 // sparsity for S(x)^T = f'(x)^T * R^T is same as sparsity for R^T76 for(size_t i = 0; i < p; i++)77 st[i] = rt[i];78 79 return true;80 }81 64 // reverse Jacobian set sparsity routine called by CppAD 82 65 virtual bool rev_sparse_jac( … … 100 83 101 84 int main(){ 102 vector<AD<double> > x(2); 103 vector<AD<double> > y(1); 104 x[0]=1; x[1]=1; 105 AD<double> zero=0.0; 106 // Create the atomic reciprocal object 107 atomic_reciprocal afun("atomic_reciprocal"); 108 vector< AD<double> > ax(1); 109 vector< AD<double> > ay(1); 110 Independent(x); 111 ax[0] = x[0] + x[1]; 112 afun(ax,ay); 113 y[0] = CondExpGt(ay[0],zero,zero,ay[0]); 114 ADFun<double> F(x,y); 85 // Create the atomic function 86 atomic_reciprocal afun("atomic_reciprocal"); 87 88 vector< AD<double> > ax(1), ay(1); 89 ax[0]=1; 90 Independent(ax); 91 afun(ax, ay); 92 AD<double> az = 0.0; 93 ay[0] = CondExpGt(ay[0], az, az, ay[0]); 94 ADFun<double> F(ax, ay); 115 95 116 F.optimize(); // < Line that cause problem 96 F.optimize(); 117 97 } 118 98 EOF
Note: See TracChangeset
for help on using the changeset viewer.