[Insight-developers] itk vs vnl / Vector & Matrix

Luis Ibanez luis.ibanez@kitware.com
Wed, 20 Feb 2002 08:45:24 -0500


Robert,

Well there is no clear cut rule on this...



The following could serve as basic guidelines:

1) itkVector   defines its dimension at compile time
   vnl_vector  defines its dimension at run time
 
  as a consequence vnl_vector has an overload in
  memory of 8 bytes with respect to the itkVector.
   
  So, if you are planning to create millions of them,
  your are better off with itk::Vector.

  On the other hand, vnl_vector is the native type for
  vnl mathematical operations...  so, if you care more
  about math, vnl_vector is a better option. Math in
  itkVector is limited to arithmetic ops and product by
  an itkMatrix. Scalar products and normalization are
  defined for the itkVector too.


2) itk::Matrix and vnl_matrix are more closely related
   the itk::Matix has a vnl_matrix_fix internally.
  Both have dimension defined at compile time (though
  vnl_matrix_fixed is just hidding a run time assignment)

  itk::Matrix was added as a convenience wrapper of the
  vnl_matrix in order to avoid conversion between itkVectors
  and vnl_vector just for performing a vector*matrix product.

  It was a bit shameful to require ten lines of code for
  multiplying a vector by a matrix ...    :-)    



We have tryied to pass itk::Vector and itk::Matrix around
in the API of itk classes but this is just a preference.



Luis


----------------------------------------------------------------

Robert J Tamburo wrote:

>On the subject of itkPoint ......... when should someone use itkVector vs.
>vnl_vector or itkMatrix vs. vnl_matrix. I kind of just "wing" it based on
>what functionality I need (i.e. I'll use vnl_vector if I need dot products),
>but I'm sure there's some logic in choosing the more appropriate class.
>
>Rob
>