John Cremona on Fri, 03 Nov 2023 17:48:57 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: asking for a new GP-Pari command |
Dear John,
you're looking at the short form of the documentation (intended as a
1 or 2-line general description and not as a complete reference)
Please check '?? matreduce' for the actual documentation.
Cheers,
K.B.
* John Cremona [2023-11-03 12:43]:
> On Fri, 3 Nov 2023 at 08:53, Bill Allombert <
> Bill.Allombert@math.u-bordeaux.fr> wrote:
>
> > On Thu, Nov 02, 2023 at 04:28:04PM -0700, American Citizen wrote:
> > > To all:
> > >
> > > Recently I had to remove duplicate entries from a vector.
> > >
> > > Can GP-Pari create a command which will work with both lists and vectors
> > to
> > > output duplicate entries?
> > >
> > > I am aware that vecsort has flag=8 in vecsort(V,,8) and listsort has
> > flag =
> > > 1 in listsort(L,1) to remove duplicates, but I need to find them, not
> > erase
> > > them.
> > >
> > > Suppose v = [1,2,3,4,5,3,6]
> > >
> > > Then I would like a GP-Pari command called "duplicates(v)" to produce the
> > > following output.
> > >
> > > duplicates(v) = [3]
> >
> > You can do that:
> >
> > duplicates(v) = [x[1]|x<-matreduce(v)~,x[2]>1];
> >
>
>
> That's interesting, I did not know that matreduce() could do that. I
> suggest that its documentation "reduce the factorization matrix m to
> canonical form (sorted first row with unique elements) matrix." is
> incomplete, it certainly suggests that the input must be a matrix. As far
> as I can see, given a list (or vector) it returns a matrix with two
> columns, the unique entries in the first column (sorted) and their
> multiplicities in the second. And the entries don't have to be numbers, I
> just tried with a random list of letters (i.e. variables).
>
> Please can the documentation for matreduce be revised?
>
> John
>
> >
> > ? v = [1,2,3,4,5,3,6]
> > ? duplicates(v)
> > %6 = [3]
> >
> > Cheers,
> > Bill
> >
> >
K.B.
--
Pr. Karim Belabas, U. Bordeaux, Vice-président en charge du Numérique
Institut de Mathématiques de Bordeaux UMR 5251 - (+33) 05 40 00 29 77
http://www.math.u-bordeaux.fr/~kbelabas/