On Sun, Feb 26, 2023 at 09:52:19AM +0800, Qian Yun wrote:
>
>
> On 2/26/23 04:18, Waldek Hebisch wrote:
> > On Thu, Oct 06, 2022 at 08:24:09AM +0800, Qian Yun wrote:
> > > By using macros, this avoids code duplication.
> > >
> > > One minor question: the exported signature should belong to
> > > IndexedDirectProductCategory or IndexedProductCategory?
> > > They look similar to me...
> > >
> > > - Qian
> >
> > First, let me note that this is "dangerous" patch. Namely
> > mathematical objects should be unmutable. We allow mutation
> > to get better performance, but mutation is used in specific
> > patterns that are safe. So, basic question is what is
> > intended pattern of use of 'add!'. Related question is
> > what we gain. We already have 'pomopo!' which covers
> > typical case where mutation gives gain.
>
> The purpose of "add!" is to optimize sparse polynomial multiplication,
> (as I said in other threads), which 'pomopo!' can't do.
Well, 'pomopo!' limits extra allocations, which probably is
most important for small cases. My impression is that
you want to use 'add!' in tree-like manner adding pieces
of similar size. I suspect that you will get best performance
adding not so small parts build using 'pomopo!'. Of course,
that really needs measurements to know.
> > As extra remark, let me mention that result of 'add' can
> > share nodes with any of its arguments. If the same holds
> > for 'add!', then using 'add!' again on the result may modify
> > both arguments of first 'add!'. Anyway, we need first to
> > formulate restrictions on use of 'add!' and only then we
> > can decide if it is correct.
>
> Yes, the usage of 'add!' should be very careful, normally it
> would be used for freshly allocated temporary objects, which
> there is no data sharing with outside.
Basically patch looks resonable. First, one little remark.
Currently 'add' computes 'first' just once for each node
avoiding repeated calls. I looks that your change computes
first second time in argument of cons. I would prefer to
avoid this extra call.
Given that in-place modification inherently increases chance
of bugs there is need for tests. If 'add!' were used by
polynomial multiplication, then such use would probably
give enough testing. But I hesitant to add such routine
without knowing that you did enough testing.
--
Waldek Hebisch
--
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/fricas-devel/20230303023702.7fle2xurzolhyjlr%40fricas.math.uni.wroc.pl.