[m-users.] Cartesian product of two sets of things.

Sean Charles (emacstheviking) objitsu at gmail.com
Wed Oct 11 22:13:51 AEDT 2023


Interesting, I am using -O4 as well for the ahead of time compiling of floating point operations that are constants.

> On 11 Oct 2023, at 04:50, Julien Fischer <jfischer at opturion.com> wrote:
> 
> 
> 
> On Wed, 11 Oct 2023, Zoltan Somogyi wrote:
> 
>> 
>> On 2023-10-10 21:02 +11:00 AEDT, "Julien Fischer" <jfischer at opturion.com> wrote:
>>> A big part of the difference would be that the nondet version sorts
>>> the elements and (redundantly) attempt to remove duplicates, whereas the
>>> det version just constructs the elements in reverse order directly.
>> 
>> Another source of difference is that its lowest level operations
>> are tail recursive, while the lowest level operations in the nondet version
>> can't be tail recursive, because you can't recover a nondet stack frame
>> while the values of the variables it contains may be needed to find
>> another solution.
>> 
>> You should note that even the det version in cproduct.m is not
>> as fast as it could be, because it adds each new item to the cross product
>> using a higher order call. Converting the sets to sorted lists and iterating
>> over the lists directly could replace those higher order calls with simple
>> unifications, which would make that version even faster.
> 
> Granted, although with --intermod -O3 the compiler will do that for you
> with the det version as it is written.
> 
> Julien.
> _______________________________________________
> users mailing list
> users at lists.mercurylang.org <mailto:users at lists.mercurylang.org>
> https://lists.mercurylang.org/listinfo/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20231011/44ba7ec3/attachment.html>


More information about the users mailing list