[eigen] std::swap doesn't work on Map

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Hi eigen users/developers,

   I create two std::vector<double> objects (v1 and v2), and instantiate 
Eigen::Map<VectorXd> objects for each (v1_map and v2_map). I'd like to point 
out two behaviors and ask if these are bugs or features.

Before swap:
        v1_stl   = [1 2 3 4 5 ]'
        v2_stl   = [10 11 12 13 14 ]'
        v1_eigen = [1 2 3 4 5]'
        v2_eigen = [10 11 12 13 14]'


CASE 1: Using v1.swap(v2)
After swap:
        v1_stl   = [10 11 12 13 14 ]'
        v2_stl   = [1 2 3 4 5 ]'
        v1_eigen = [1 2 3 4 5]'
        v2_eigen = [10 11 12 13 14]'


CASE 2: using std::swap(v1_map, v2_map)
After swap:
        v1_stl   = [10 11 12 13 14 ]'
        v2_stl   = [10 11 12 13 14 ]'
        v1_eigen = [10 11 12 13 14]'
        v2_eigen = [10 11 12 13 14]'

  The behavior in Case #1 can be explained: my STL implementation is swapping 
pointer data members to allocated memory in the STL vector classes. Since my 
Eigen::Map<> objects are instantiated using these pointers, the STL vector 
swap shouldn't affect my Eigen::Map<> objects.

   The behavior in Case #2 however seems to be buggy to me. Should I file a 
bug report of some sort on the issue tracker?

Thanks,
Manoj



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/