Re: Computing sets of equivalences

• To: mathgroup at smc.vnet.net
• Subject: [mg46695] Re: Computing sets of equivalences
• From: drbob at bigfoot.com (Bobby R. Treat)
• Date: Tue, 2 Mar 2004 00:14:18 -0500 (EST)
• References: <c1iqsd\$68r\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```This may not be faster, but it eliminates Union, Map, Sow, and Reap,
replacing them with DownValues,Transpose, Sort, and Split.

brt[lst_List] := Block[{f, g},
Scan[(f[#[[1]]] = f[#[[2]]] = Unique[x]) &, lst];
Scan[(Evaluate[f[#[[1]]]] = f[#[[2]]]) &, lst];
g = DownValues[f];
Split[Sort@
Transpose@{g[[All, 2]], g[[All, 1, 1, 1]]}, #1[[1]] == #2[[
1]] &][[All, All, -1]]
]

Bobby

"Simons, F.H." <F.H.Simons at tue.nl> wrote in message news:<c1iqsd\$68r\$1 at smc.vnet.net>...
> Here is another  solution of the problem. It is based on constructing a function that is constant on each equivalence class and has different values on different classes.
>
> equivalences[lst_List] := Block[{f},
>     Scan[(f[#[[1]]]=f[#[[2]]]=Unique[x])&,lst];
>     Scan[(Evaluate[f[#[[1]]]]=f[#[[2]]])& , lst];
>     Reap[Sow[#, f[#]]& /@ Union@@lst][[2]]]
>
> Only for large intial sets of initial equivalences Carl Woll's solution seems to be slightly faster.
>
> Regards,
>
> Fred Simons
> Eindhoven University of Technology

```

• Prev by Date: Re: need help with writing algorithm for polynomial gcd!
• Next by Date: Re: Factoring two-dimensional series expansions? (Ince polynomials again)
• Previous by thread: Re: need help with writing algorithm for polynomial gcd!
• Next by thread: Re: Computing sets of equivalences