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

Volker Wysk post at volker-wysk.de
Tue Oct 10 20:52:05 AEDT 2023


Am Dienstag, dem 10.10.2023 um 19:41 +1100 schrieb Julien Fischer:
> On Tue, 10 Oct 2023, Volker Wysk wrote:
> 
> > Am Dienstag, dem 10.10.2023 um 17:06 +1100 schrieb Julien Fischer:
> > > Hi Volker,
> > > 
> > > On Mon, 9 Oct 2023, Volker Wysk wrote:
> > > 
> > > > You're welcome. 
> > > > 
> > > > I'm not sure how efficient this is, though.
> > > 
> > > Not as efficient as it could be -- see cartesian_product1b in the
> > > attached.
> > 
> > desktop ~/src/cart_prod $ ./cproduct 
> > N = 250, repeats = 100, time1 = 250 ms, time2 = 2100 ms
> > 
> > That's a high difference in speed... solutions/2 and solutions_set/2 should
> > be avoided when speed is essential.
> 
> It's more that det code is faster than the equivalent nondet code.
> That's not particularly surpsising given that more has to be done
> at runtime in order to execute nondet code.

I see. And nondet/multi code only works when the results are collected by
solutions somewhere. And solutions in turn only works with nondet/multi
code, otherwise there isn't anything to collect.

But the large difference in speed surprised me.

Cheers,
Volker


More information about the users mailing list