From: David Doria <daviddoria@gm...>  20110308 20:44:03

On Tue, Mar 8, 2011 at 11:08 AM, Peter Vanroose <peter_vanroose@...>wrote: > > Is there an adjoint function for vnl_sparse_matrix ? > > > No, not (yet); could indeed be useful and nice to have, and not too > difficult too implement. > > But beware that the adjoint of a sparse matrix will typically be > nonsparse. (And will take ages to compute if matrix dimensions are large.) > So the "adjoint" function, even with argument "sparse matrix", should > probably best return a "normal" vnl_matrix<T>. > Which, in case of large matrix dimensions, could be "too large", of course. > > The easiest way to implement this, would be to just write out a conversion > function from vnl_sparse_matrix<T> to vnl_matrix<T> (possibly as an operator > in the vnl_sparse_matrix class) and then just call the already existing > vnl_adjugate function. > Only in the "too large" cases, also this conversion would be too slow and > require a too large output object. If not, the conversion part of this story > would be just a minor fraction of the total work. (At least, in the current > implementation of vnl_adjugate). > >  Peter. > Eigen has an .adjoint() function on its SparseMatrix class (in SparseMatrixBase)  http://eigen.tuxfamily.org/dox/classEigen_1_1SparseMatrixmembers.html It may be worth looking at what they do. David 