Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Computing sets of equivalences

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

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];
    Transpose@{g[[All, 2]], g[[All, 1, 1, 1]]}, #1[[1]] == #2[[
            1]] &][[All, All, -1]]


"Simons, F.H." <F.H.Simons at> wrote in message news:<c1iqsd$68r$1 at>...
> 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