How does the gradient of a vector(delta V) become a 3x3 matrix? And how do you compute its eigenvalue efficiently? Is there any C++ library that can do this (can the C++ library Eigen do this)?
-
https://en.wikipedia.org/wiki/Gradient#Gradient_of_a_vector. And yes eigen can compute eigenvalues of a matrix... so use it or another lib such as armadillo – coincoin Nov 06 '16 at 22:20
-
Yes, I read that article. The gradient is a single row vector, how does it become 3x3? If I give Eigen a vector, can it turn it into a 3x3 matrix? – user6682440 Nov 06 '16 at 22:27
-
because you have different derivaties on 3 dimensions. And no you have to do render your matrix by yourself. – coincoin Nov 06 '16 at 22:59
1 Answers
The gradient is a generalization of the derivative for functions with more than one variable. It consists of all the partial derivatives of the function, so it has one derivative for each variable.
For a scalar valued N-variable function
scalar y = f(x1, ..., xN)
, the gradient is a vector with N scalar elements.Generalizing it further to a vector valued function
vector y = f(x1, ..., xN)
, (where the vector has N elements, and the function has N scalar variables), the gradient can be thought as a vector with N vector elements, which is actually a matrix with NxN elements, also called the Jacobian.
In your case the function must be like vector3 y = f(x1, x2, x3)
, so the gradient is a 3x3 matrix.
You can compute the eigenvalues of it like for any other matrix, e.g. using Eigen decomposition. As the name suggests, the Eigen linear algebra library does offer such functionality.

- 8,183
- 7
- 53
- 101
-
It's probably worth noting that, in general, the matrix formed from the derivatives of an arbitrary vector field will not be symmetric. This means that the Eigen-decomposition of that matrix may involve complex numbers. If, on the other hand, the vector was itself the derivative of a scalar function, then the matrix of second derivatives would be symmetric and half real-valued eigenvalues. – rwp Feb 20 '18 at 16:43