|
Returns true if 'f' can be proven to be an affine function of given args. All other symbols in f are assumed to be invariant with respect to all args.
We prove that ${i=1,N}{f(x_i+y_i)} = f(x) + f(y) + f(0)$, where x, y, and 0 are vectors [1:N]. This implies that 'f' is affine.
cerr<<"\nEnter is_affine with "<<f<<" and "; for(set<Symbol*>::iterator sit=args.begin(); sit!=args.end(); ++sit){ cerr<<(*sit)->name_ref()<<", "; }
... this way they wil be removed at the end.
The original is considered f(x). Now get f(y), f(x+y), and f(0).
cerr<<"\n\tf(x) = "<<*fx; cerr<<"\n\tf(y) = "<<*fy; cerr<<"\n\tf(x+y) = "<<*fx_plus_y; cerr<<"\n\tf(0) = "<<*f0;
Build the identity.
cerr<<"\noffending: sub("<<*left<<","<<*right<<")";
cerr<<"\n\tmust_be_zero = "<<*must_be_zero;
Verify the identity.
... Save the parameters.
Return result.
Definition at line 22 of file affine.cc.
References add(), Expression::clone(), constant(), List< T >::ins_last(), is_integer_zero(), mul(), Symbol::name(), Symbol::name_ref(), OMEGA_OP, Expression::op(), simplify(), sub(), and substitute_var().
Referenced by check_scalars_affine(). |