# Fuzzy Union in C++

Discussion in 'C++' started by Evyn, Jan 18, 2007.

1. ### EvynGuest

Hi,

What is the best way to implement a union for fuzzy sets in C++? I have
used the following code for crisp sets, but the trick to converting it
for fuzzy sets eludes me.

std::set_union(vec1.begin(), vec1.end(), vec2.begin(), vec2.end(),
std::back_inserter<std::vector<double> >(vec3));
sort (vec3.begin (), vec3.end (), less <double> ());

TIA
Evyn

Evyn, Jan 18, 2007

2. ### Ondra HolubGuest

Evyn napsal:
> Hi,
>
> What is the best way to implement a union for fuzzy sets in C++? I have
> used the following code for crisp sets, but the trick to converting it
> for fuzzy sets eludes me.
>
> std::set_union(vec1.begin(), vec1.end(), vec2.begin(), vec2.end(),
> std::back_inserter<std::vector<double> >(vec3));
> sort (vec3.begin (), vec3.end (), less <double> ());
>
> TIA
> Evyn

Although I do not know what does mean crisp set, you can simplify your
code a little bit:

std::set_union(
vec1.begin(), vec1.end(),
vec2.begin(), vec2.end(),
back_inserter(vec3)
);
std::sort (vec3.begin (), vec3.end (), std::less<double>());

Ondra Holub, Jan 18, 2007

3. ### EvynGuest

Ondra Holub wrote:
> Evyn napsal:
> > Hi,
> >
> > What is the best way to implement a union for fuzzy sets in C++? I have
> > used the following code for crisp sets, but the trick to converting it
> > for fuzzy sets eludes me.
> >
> > std::set_union(vec1.begin(), vec1.end(), vec2.begin(), vec2.end(),
> > std::back_inserter<std::vector<double> >(vec3));
> > sort (vec3.begin (), vec3.end (), less <double> ());
> >
> > TIA
> > Evyn

>
> Although I do not know what does mean crisp set, you can simplify your
> code a little bit:
>
> std::set_union(
> vec1.begin(), vec1.end(),
> vec2.begin(), vec2.end(),
> back_inserter(vec3)
> );
> std::sort (vec3.begin (), vec3.end (), std::less<double>());

Evyn, Jan 18, 2007