void Function::gradient(const IntervalVector& x, IntervalVector& g) const { assert(g.size()==nb_var()); assert(x.size()==nb_var()); Gradient().gradient(*this,x,g); // if (!df) ((Function*) this)->df=new Function(*this,DIFF); // g=df->eval_vector(x); }
void Function::jacobian(const IntervalVector& x, IntervalMatrix& J) const { assert(J.nb_cols()==nb_var()); assert(x.size()==nb_var()); assert(J.nb_rows()==image_dim()); // calculate the gradient of each component of f for (int i=0; i<image_dim(); i++) { (*this)[i].gradient(x,J[i]); } }
void Function::jacobian(const IntervalVector& box, IntervalMatrix& J, const VarSet& set) const { assert(J.nb_cols()==set.nb_var); assert(box.size()==nb_var()); assert(J.nb_rows()==image_dim()); IntervalVector g(nb_var()); // calculate the gradient of each component of f for (int i=0; i<image_dim(); i++) { (*this)[i].gradient(box,g); J.set_row(i,set.var_box(g)); } }
void Function::hansen_matrix(const IntervalVector& box, IntervalMatrix& H) const { int n=nb_var(); int m=expr().dim.vec_size(); assert(H.nb_cols()==n); assert(box.size()==n); assert(expr().dim.is_vector()); assert(H.nb_rows()==m); IntervalVector x=box.mid(); IntervalMatrix J(m,n); // test! // int tab[box.size()]; // box.sort_indices(false,tab); // int var; for (int var=0; var<n; var++) { //var=tab[i]; x[var]=box[var]; jacobian(x,J); H.set_col(var,J.col(var)); } }
void Function::hansen_matrix(const IntervalVector& box, IntervalMatrix& H, const VarSet& set) const { int n=set.nb_var; int m=image_dim(); assert(H.nb_cols()==n); assert(box.size()==nb_var()); assert(H.nb_rows()==m); IntervalVector var_box=set.var_box(box); IntervalVector param_box=set.param_box(box); IntervalVector x=var_box.mid(); IntervalMatrix J(m,n); for (int var=0; var<n; var++) { //var=tab[i]; x[var]=var_box[var]; jacobian(set.full_box(x,param_box),J,set); H.set_col(var,J.col(var)); } }
void Function::gradient(const IntervalVector& x, IntervalVector& g) const { assert(g.size()==nb_var()); assert(x.size()==nb_var()); Gradient().gradient(*this,x,g); }