Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #83: Support staff hung over, send aspirin and come back LATER.


comp / comp.lang.python / Re: Relatively prime integers in NumPy

SubjectAuthor
* RE: Relatively prime integers in NumPy<avi.e.gross
`* Re: Relatively prime integers in NumPyPaul Rubin
 `- Re: Relatively prime integers in NumPyLawrence D'Oliveiro

1
Subject: RE: Relatively prime integers in NumPy
From: <avi.e.gross@gmail.com>
Newsgroups: comp.lang.python
Date: Thu, 11 Jul 2024 18:22 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: <avi.e.gross@gmail.com>
Newsgroups: comp.lang.python
Subject: RE: Relatively prime integers in NumPy
Date: Thu, 11 Jul 2024 14:22:24 -0400
Lines: 65
Message-ID: <mailman.29.1720722147.2981.python-list@python.org>
References: <SA0PR09MB6363F3E6B493202E73869DF4DBDA2@SA0PR09MB6363.namprd09.prod.outlook.com>
<00e801dad3bf$473daed0$d5b90c70$@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain;
charset="koi8-r"
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de eiTe64MdZS9bcjtIxA81FQoR+yIPv1V69d+CB2Q/cXfQ==
Cancel-Lock: sha1:RB7yWefrKfZyVPmXkqnc2jw9MHE= sha256:TmNiMMVZ0MK5gOu7GOqTeBvYjoQqmpf8OypyI7MtEYA=
Return-Path: <avi.e.gross@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=iZvuKsSd;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.047
X-Spam-Evidence: '*H*': 0.91; '*S*': 0.00; 'looks': 0.02;
'explanation': 0.07; 'matches': 0.07; 'modules': 0.07;
'mechanism': 0.09; 'numpy': 0.09; 'url:mailman': 0.15; '2024':
0.16; '3:10': 0.16; 'divisors': 0.16; 'examples.': 0.16; 'numpy.':
0.16; 'numpy?': 0.16; 'prime': 0.16; 'relatively': 0.16; 'python':
0.16; 'message-id:@gmail.com': 0.18; 'solve': 0.19; 'to:addr
:python-list': 0.20; 'i.e.': 0.22; 'maybe': 0.22; 'skip:- 10':
0.25; 'url-ip:188.166.95.178/32': 0.25; 'url-ip:188.166.95/24':
0.25; 'url:listinfo': 0.25; 'cannot': 0.25; 'url-ip:188.166/16':
0.25; 'else': 0.27; 'bit': 0.27; 'function': 0.27; 'expect': 0.28;
'mostly': 0.28; 'purpose': 0.28; 'example,': 0.28; 'module': 0.31;
'url-ip:188/8': 0.31; 'think': 0.32; 'needed,': 0.32; 'python-
list': 0.32; 'structure': 0.32; 'but': 0.32; 'there': 0.33;
'someone': 0.34; 'header:In-Reply-To:1': 0.34;
'received:google.com': 0.34; 'words': 0.35; 'from:addr:gmail.com':
0.35; 'request': 0.35; 'built': 0.36; 'those': 0.36; 'lists':
0.37; 'using': 0.37; 'could': 0.38; 'put': 0.38; 'list': 0.39;
'use': 0.39; 'methods': 0.39; 'received:100': 0.39; 'exact': 0.40;
'want': 0.40; 'july': 0.60; 'usa': 0.60; 'provide': 0.60;
'search': 0.61; 'from:': 0.62; 'to:': 0.62; 'dear': 0.62;
'involved': 0.63; 'great': 0.63; 'identify': 0.64; 'about.': 0.64;
'explained': 0.64; 'imagine': 0.64; 'your': 0.64; 'top': 0.65;
'numbers': 0.67; 'back': 0.67; 'outside': 0.67; 'candidate': 0.69;
'compare': 0.69; 'factor': 0.69; 'latter': 0.69; 'factors': 0.76;
'sent:': 0.78; 'axis': 0.84; 'popov': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20230601; t=1720722145; x=1721326945; darn=python.org;
h=content-language:thread-index:content-transfer-encoding
:mime-version:message-id:date:subject:in-reply-to:references:to:from
:from:to:cc:subject:date:message-id:reply-to;
bh=aAEUUpcQyDWOfiZzC4cHrJm4rFSX6XQz+FCoAPEK7tc=;
b=iZvuKsSdjpXqdNg4WlL1dmI3t6JqE0fd0AIIOdM3+PeRyR1k79AA9061ye0rad2p+v
Ql2UXfm/I3lbcfG5Ne2PrF2r3xULr4lpwGjACEvHiOTIh5ZnAzbaTvoBrjR0xKheG4Y0
RZs1bzgoMCUqRZYbjLmRzK5aI+iiAoc+PnbXQJttV8qMR0vfwfh2k7rV8QVdrEf8Dydt
jCtagnv6gmrwDzgfpubo4MGZoQ4lfez/Kmk7izDyO6F4niLUz9InXj3gqZeGOkWgwdr/
SatgIgfWAYGh904uP5rOchDnCMVoCgEHHiXJf4fWtcJYcvjFVl4fs9tgdQEA0WnJ0tqn
oMYQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1720722145; x=1721326945;
h=content-language:thread-index:content-transfer-encoding
:mime-version:message-id:date:subject:in-reply-to:references:to:from
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
bh=aAEUUpcQyDWOfiZzC4cHrJm4rFSX6XQz+FCoAPEK7tc=;
b=SLh8RG4Z5U5NBIsOCadsmLyhsyuIIxOPgddYdaJVeU/MdP1rzDuKWDjUCCHyjwrvr9
tHmbs+AGXBzimHtvwtgAWMxLeVhJH4d+PXuXcyQni6KRkLwdQrwwRDW7E/lYni3GAKeh
mQ07NqALeLtAe0g2Yz8rl68YqIQI5hirQeqMw51vcqMuva/GuhVtebaiOCynZ17Ppudk
DgvdRFnn4HOZkObPaPHEIwqm61IETXUT5b6BaUBNfa+7KFZWqjxH2h7ir4C4wm4WMLIK
eR5A+JawosdbsIxKzUMgIt86Egc/pxioYj7knO1VUTNEAML/29YOfFFWW5rPmX2Uwzde
lOzg==
X-Forwarded-Encrypted: i=1;
AJvYcCUveWMUfYSnIsmtmzFTv5+/ToUHx0G/4DfiB8hOMFV34Os4T2LcFqGylYeWEkFkvRc1/OslWhMFvIj/RoxE2jPwWlSrF33d
X-Gm-Message-State: AOJu0YxOBenXJgGoXLBNY0GthCWVMem1BPsFohjraQF5wTwEBsjUHmlK
76r2xJtcse5+HOOr+OMYm7ZsUz3J7OSxI1Pb7gsTHhEOOpdwz7BW2YJr7RAf
X-Google-Smtp-Source: AGHT+IE4X6cF07YZOqtSmUqECUhCf3vNrv83giMRgSjLzDKlbPhjlzwWUyyyOsFTu4g9vGbMhI7tdA==
X-Received: by 2002:a05:6214:765:b0:6b5:550d:bff2 with SMTP id
6a1803df08f44-6b61bce14d1mr103817346d6.25.1720722144665;
Thu, 11 Jul 2024 11:22:24 -0700 (PDT)
In-Reply-To: <SA0PR09MB6363F3E6B493202E73869DF4DBDA2@SA0PR09MB6363.namprd09.prod.outlook.com>
X-Mailer: Microsoft Outlook 16.0
Thread-Index: AQHaqdYQj6Isi+wDzs9EemRqPkPTEbHyJ16A
Content-Language: en-us
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <00e801dad3bf$473daed0$d5b90c70$@gmail.com>
X-Mailman-Original-References: <SA0PR09MB6363F3E6B493202E73869DF4DBDA2@SA0PR09MB6363.namprd09.prod.outlook.com>
View all headers

Дмитрий,

You may think you explained what you wanted but I do not see what result you
expect from your examples.

Your request is a bit too esoteric to be a great candidate for being built
into a module like numpy for general purpose se but I can imagine it could
be available in modules build on top of numpy.

Is there a reason you cannot solve this mostly outside numpy?

It looks like you could use numpy to select the numbers you want to compare,
then call one of many methods you can easily search for to see how to use
python to make some list or other data structure for divisors of each number
involved and then use standard methods to compare the lists and exact common
divisors. If needed, you could then put the results back into your original
data structure using numpy albeit the number of matches can vary.

Maybe a better explanation is needed as I cannot see what your latter words
about -1 and 1 are about. Perhaps someone else knows.

-----Original Message-----
From: Python-list <python-list-bounces+avi.e.gross=gmail.com@python.org> On
Behalf Of Popov, Dmitry Yu via Python-list
Sent: Monday, July 8, 2024 3:10 PM
To: Popov, Dmitry Yu via Python-list <python-list@python.org>
Subject: Relatively prime integers in NumPy

Dear Sirs.

Does NumPy provide a simple mechanism to identify relatively prime integers,
i.e. integers which don't have a common factor other than +1 or -1? For
example, in case of this array:
[[1,5,8],
[2,4,8],
[3,3,9]]
I can imagine a function which would return array of common factors along
axis 0: [1,2,3]. Those triples of numbers along axis 1 with the factor of1
or -1 would be relatively prime integers.

Regards,
Dmitry Popov

Argonne, IL
USA

--
https://mail.python.org/mailman/listinfo/python-list

Subject: Re: Relatively prime integers in NumPy
From: Paul Rubin
Newsgroups: comp.lang.python
Organization: A noiseless patient Spider
Date: Thu, 11 Jul 2024 18:35 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: no.email@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.python
Subject: Re: Relatively prime integers in NumPy
Date: Thu, 11 Jul 2024 11:35:44 -0700
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <87wmlrn5dr.fsf@nightsong.com>
References: <SA0PR09MB6363F3E6B493202E73869DF4DBDA2@SA0PR09MB6363.namprd09.prod.outlook.com>
<00e801dad3bf$473daed0$d5b90c70$@gmail.com>
<mailman.29.1720722147.2981.python-list@python.org>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Thu, 11 Jul 2024 20:35:45 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="682b26ab0de75d5eae664fc8da881298";
logging-data="2724915"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18l0oVEd28Fd7w8ihSRM2h1"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:5JKBo2H4sutlVfrfpsb7qXu6yko=
sha1:OkKQQFl+72BtGO7B1TFVRzex7r8=
View all headers

<avi.e.gross@gmail.com> writes:
> python to make some list or other data structure for divisors of each number
> involved

Two numbers a and b are coprime if math.gcd(a,b) == 1, I am pretty sure.
That is true by definition(?) when a and b are both > 0. Experiment
indicates it seems to work even when one or both of a and b are
negative, but I don't have a proof and haven't examined the
implementation. I don't know how gcd is mathematically defined in that
situation.

Subject: Re: Relatively prime integers in NumPy
From: Lawrence D'Oliv
Newsgroups: comp.lang.python
Organization: A noiseless patient Spider
Date: Thu, 11 Jul 2024 21:43 UTC
References: 1 2 3 4
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.lang.python
Subject: Re: Relatively prime integers in NumPy
Date: Thu, 11 Jul 2024 21:43:47 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <v6pjmj$2kqvg$3@dont-email.me>
References: <SA0PR09MB6363F3E6B493202E73869DF4DBDA2@SA0PR09MB6363.namprd09.prod.outlook.com>
<00e801dad3bf$473daed0$d5b90c70$@gmail.com>
<mailman.29.1720722147.2981.python-list@python.org>
<87wmlrn5dr.fsf@nightsong.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 11 Jul 2024 23:43:47 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="ead23d2d8cf5f779654345cfcdaaae64";
logging-data="2780144"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX195C4kJAiltkdVwk6EK7hwC"
User-Agent: Pan/0.158 (Avdiivka; )
Cancel-Lock: sha1:fxOn0I3YPqkzXcxZFTGy22V1s2w=
View all headers

On Thu, 11 Jul 2024 11:35:44 -0700, Paul Rubin wrote:

> Two numbers a and b are coprime if math.gcd(a,b) == 1, I am pretty sure.
> That is true by definition(?) when a and b are both > 0. Experiment
> indicates it seems to work even when one or both of a and b are
> negative, but I don't have a proof and haven't examined the
> implementation. I don't know how gcd is mathematically defined in that
> situation.

You can derive the answer quite trivially by observing that negative
numbers are smaller (less than, not greater than) positive numbers.

1

rocksolid light 0.9.8
clearnet tor