#include "rnop.hh" using namespace RVL; // Rosenbrock function template int rosie(int m, int n, T const * x, T * y) { if ((m!=2) || (n!=2)) return 1; y[0]=10*(x[1]-x[0]*x[0]); y[1]=ScalarFieldTraits::One()-x[0]; return 0; } // Rosenbrock jacobian template int rosiejac(int m, int n, T const * x, T * y) { if ((m!=2) || (n!=2)) return 1; // df[0]/dx[0] y[0]=-20*x[0]; // df[1]/dx[0] y[1]=-ScalarFieldTraits::One(); // df[0]/dx[1] y[2]=10*ScalarFieldTraits::One(); // df[1]/dx[1] y[3]=ScalarFieldTraits::Zero(); return 0; } int main() { cout<<"******************************************************"< dom(m); GenOp, rosiejac > op(dom,dom); // vector workspace LocalVector x(dom); LocalVector y(dom); // assign values to x - increments version, makes it "fresh" x.getData()[0]=-1.2f; x.getData()[1]=1.0f; // evaluate operator at x OperatorEvaluation opeval(op,x); // extract the image of x under op (which causes it to be computed) y.copy(opeval.getValue()); // report cout<<"\ninput vector:\n"; x.write(cout); cout<<"\noutput vector:\n"; y.write(cout); cout<<"\nJacobian:\n"; // a bit complicated to pull the Jacobian data out, but it's // accessible. First, grab the Operator copy being used with // Operator::getOp. It's a GenOp, so cast it, making the additional // GenOp attributes available. One of these is the internal GenMat // used to store the Jacobian. The Jacobian has been initialized // because the operator has been applied to a vector, so you can // access the GenMat, and then its internal float * data. GenOp const & currop = dynamic_cast const &>(opeval.getOp()); float const * j = currop.getGenMat().getData(); cout<<"j[0,0]="<