lion03 / thrust

Automatically exported from code.google.com/p/thrust
Apache License 2.0
0 stars 0 forks source link

set_symmetric_difference bug #483

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Given a A: 3, 6, 7, 7 and B: 3, 7
Sym-difference should be 6 but get 6, 7 instead

thrust::host_vector<int> a(4), b(2);

a[0] = 3; a[1] = 6; a[2] = 7; a[3] = 7;
b[0] = 3; b[1] = 7;

thrust::host_vector<int> result(4);

typedef typename thrust::host_vector<int>::iterator Iterator;
Iterator end = thrust::set_symmetric_difference(a.begin(), a.end(),
                                                b.begin(), b.end(),
                                                result.begin());

for(Iterator it = result.begin(); it != end; it++)
{
  printf("%i\n", *it);
}

//result is: 6, 7
//expected: 6

Original issue reported on code.google.com by nazcaspi...@gmail.com on 23 Mar 2012 at 4:16

GoogleCodeExporter commented 8 years ago
Actually, [6, 7] is the expected result.  See the description of how 
set_symmetric_difference handles duplicate elements here [1].  If you first 
eliminate the repeated values using the unique() algorithm you'll get a result 
of [6].

[1] http://www.sgi.com/tech/stl/set_symmetric_difference.html

Original comment by wnbell on 23 Mar 2012 at 4:23

GoogleCodeExporter commented 8 years ago
I see, thanks for your prompt response

Original comment by nazcaspi...@gmail.com on 23 Mar 2012 at 4:36