This is a simple forward-differences Jacobian estimator. I've modified
it a little to reduce the required context, so it hasn't been directly
You can get better estimates using central or higher-order differences.
my_functor_t& f, // the function
vnl_vector<double> x_0, // the central point
const vnl_vector<double> &scale) // the measurement scale.
vnl_vector<double> r_0 = f(x_0);
unsigned nr = r_0.size();
unsigned nx = x_0.size();
vnl_matrix<double> jacobian(nr, nx);
for (unsigned i=0; i<nx; ++i)
x(i) += scale(i);
vnl_vector<double> dr = r - r_0;
dr /= scale(i);
XIN LI wrote:
> Sorry. I should say that I would like to get the jacobian matrix of a vector value function. Just as the traditional definition of Jacobian.
> Could you please tell me how to implement this funcion using VXL library?
> Thank you very much!
> ----- Original Message -----
> From: Ian Scott <ian.m.scott@...>
> Date: Tuesday, May 1, 2007 4:15 am
> Subject: Re: [Vxl-users] question about jacobian
> To: XIN LI <xli16@...>
> Cc: VXL users <vxl-users@...>
>> This probably isn't what you want to hear but --- are you sure you
>> understand what you are asking for?
>> The Jacobian is traditionally defined on a vector function Y=F(X),
>> Y in a m element vector and X is an n element vector.
>> The Jacobian is the matrix of first derivatives of Y, w.r.t. to each
>> element in X,
>> J_ij = ____
>> (or possibly the transpose - I can't remember)
>> You can talk about an analogous Jacobian of a matrix, but usually
>> defining a flattening of the matrix into a vector, and then defining
>> variables against which you want to calculate the derivative.
>> The are plenty of other meanings of "the Jacobian of a matrix", e.g.
>> assuming the matrix is a Hessian of F, its square is a rough
>> approximation to the Jacobian.
>> The code to perform these calculations is available in VXL, but not
>> as a
>> simple class, since the implementation depends on what exactly you
>> by "Jacobian of a matrix"
>> XIN LI wrote:
>> > Hello,
>> > I am using vxl-1.8.0. I would like to get the jacobian of a matrix.
>> > Could you please tell me which class I should use to get the
>> > matrix?
>> > Thanks!
>> > Xin