Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

A light wife doth make a heavy husband. -- Wm. Shakespeare, "The Merchant of Venice"


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

SubjectAuthor
o Re: Relatively prime integers in NumPyPopov, Dmitry Yu

1
Subject: Re: Relatively prime integers in NumPy
From: Popov, Dmitry Yu
Newsgroups: comp.lang.python
Date: Thu, 11 Jul 2024 19:25 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: dpopov@anl.gov (Popov, Dmitry Yu)
Newsgroups: comp.lang.python
Subject: Re: Relatively prime integers in NumPy
Date: Thu, 11 Jul 2024 19:25:37 +0000
Lines: 100
Message-ID: <mailman.34.1720791996.2981.python-list@python.org>
References: <SA0PR09MB6363F3E6B493202E73869DF4DBDA2@SA0PR09MB6363.namprd09.prod.outlook.com>
<00e801dad3bf$473daed0$d5b90c70$@gmail.com>
<DM8PR09MB63603191F5509E5013D1BEDCDBA52@DM8PR09MB6360.namprd09.prod.outlook.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: base64
X-Trace: news.uni-berlin.de wPT6xkNbiqx+ellYdlwcxAQFNB3Vb8XVrjshpN0/tITA==
Cancel-Lock: sha1:c9wFcVi1Qny4vTVSVGWFW3DT55Y= sha256:yw2v4MbGZLcfS+3Xpp04lrrHDgZBvGTmsZci3yQK9kI=
Return-Path: <dpopov@anl.gov>
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=anl.gov header.i=@anl.gov header.b=lW0S/oOX;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: UNSURE 0.237
X-Spam-Level: **
X-Spam-Evidence: '*H*': 0.53; '*S*': 0.00; 'looks': 0.02;
'explanation': 0.07; 'matches': 0.07; 'modules': 0.07;
'mechanism': 0.09; 'numpy': 0.09; 'routine': 0.09; 'skip:z 20':
0.09; '&gt;': 0.14; 'url:mailman': 0.15; '2024': 0.16; '3:10':
0.16; 'divisors': 0.16; 'examples.': 0.16; 'far,': 0.16; 'loops':
0.16; 'numpy.': 0.16; 'numpy?': 0.16; 'patterns.': 0.16; 'prime':
0.16; 'procedure': 0.16; 'prompts': 0.16;
'received:namprd09.prod.outlook.com': 0.16; 'relatively': 0.16;
'sorry.': 0.16; 'url-ip:3.215/16': 0.16; 'url:urldefense': 0.16;
'url:v3': 0.16; 'using.': 0.16; 'python': 0.16; 'solve': 0.19;
'implement': 0.19; 'i.e.': 0.22; 'maybe': 0.22; 'code': 0.23;
'skip:- 10': 0.25; 'url:listinfo': 0.25; 'cannot': 0.25; '11,':
0.26; 'else': 0.27; 'bit': 0.27; 'function': 0.27; 'expect': 0.28;
'mostly': 0.28; 'purpose': 0.28; 'email addr:python.org&gt;':
0.28; 'example,': 0.28; 'dir="ltr"': 0.31; 'module': 0.31;
'think': 0.32; 'collected': 0.32; 'needed,': 0.32; 'python-list':
0.32; 'structure': 0.32; 'develop': 0.32; 'but': 0.32; "i'm":
0.33; 'there': 0.33; 'someone': 0.34; 'appreciated.': 0.34;
'header:In-Reply-To:1': 0.34; 'trying': 0.35; 'words': 0.35;
'request': 0.35; 'built': 0.36; 'those': 0.36; 'lists': 0.37;
'currently': 0.37; 'using': 0.37; 'skip:_ 30': 0.37; 'could':
0.38; 'put': 0.38; 'list': 0.39; 'use': 0.39; 'block': 0.39;
'methods': 0.39; 'exact': 0.40; 'want': 0.40; 'july': 0.60; 'usa':
0.60; 'provide': 0.60; 'search': 0.61; 'skip:b 30': 0.61; 'skip:o
10': 0.61; 'from:': 0.62; 'to:': 0.62; 'skip:i 20': 0.62; 'dear':
0.62; 'involved': 0.63; 'email addr:gmail.com': 0.63; 'great':
0.63; 'skip:b 20': 0.63; 'skip:m 20': 0.63; 'skip:b 10': 0.63;
'identify': 0.64; 'pass': 0.64; 'our': 0.64; '8bit%:93': 0.64;
'about.': 0.64; 'explained': 0.64; 'imagine': 0.64; 're:': 0.64;
'your': 0.64; 'top': 0.65; 'came': 0.65; 'skip:t 20': 0.66;
'numbers': 0.67; 'back': 0.67; 'outside': 0.67; 'url-ip:18/8':
0.67; 'url-ip:3/8': 0.67; 'skip:# 10': 0.68; '8bit%:91': 0.69;
'8bit%:96': 0.69; '8bit%:99': 0.69; 'candidate': 0.69; 'compare':
0.69; 'enclosed': 0.69; 'factor': 0.69; 'latter': 0.69; 'skip:\xe2
20': 0.69; 'url:us': 0.69; 'skip:f 30': 0.71; '8bit%:89': 0.75;
'8bit%:92': 0.75; 'skip:f 20': 0.75; 'factors': 0.76; 'sent:':
0.78; 'highly': 0.78; '8bit%:95': 0.84; '16px': 0.84; '8bit%:76':
0.84; '8bit%:97': 0.84; 'axis': 0.84; 'email name:&lt;python-
list': 0.84; 'lot.': 0.84; 'popov': 0.84; '8bit%:98': 0.91; '8px':
0.91; 'skip:\xd0 10': 0.91; 'interest.': 0.93
ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;
b=ir9yocrZQMAOfl4qZQV39uL26jeGKPoesZ1TjbWLge6vlDxX8FnDJGd1XoklZyL3bX2LLdoWlXoeHmaiHdxeG+RNgxBLVmHCSCoGSVSf9+WCAk1gFZFmprchNA8KCY5e7ES48w8kC+PN0vTmEtX0dGgvU+E0NB7ck7l2ITW82rN5VMf2o5h/N67wxNzjzrVp99muOwre2vmAhfPimQ9Xdjo9HyES+otETxSbyn+W+xg0joCqKnt348kibzm6gN5qBK4SB4kwUcsLbNWuWIXFH7MfkoKkgb2uQ80o0ifsWfbzTDDClMK0vup1jXWFgxmvwXSlhIq09TKVBIkl/2PVqQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
s=arcselector10001;
h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
bh=vUwixD8RblY7pYZRV4ErG/j667NPQpT35GDccQxDuxE=;
b=tRFZ00Qlo4g/Dza5bT6uD5+M65/xbFf0jiWCzmAYLLSe43PVxGhPwnkbnSENGko/8xKjRXxmMmpb18rfyhBPo/JUW9vomy2MaH71XoABgabBfI2YEKMaHu1E8sRRNqOpeK86h1MKUItsLaCkxDZHt1IYuWxk3JGRSs+bYd3lnnRJxTJeRsmV3ocHb3GBVGff7gFopNxuet+78khKEDG7R5jSXad32o6kf6vlaLdX3a4C7fpA3vylzQeeGDmur1zTL4TzCTTt8sW8coXjccdrMfLwYyYP5w2nxOxlI+QJcW5lVMyAsbMgwMssA15oZZNaJA/nJJBdJHIMIMjR1m/GWQ==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
smtp.mailfrom=anl.gov; dmarc=pass action=none header.from=anl.gov; dkim=pass
header.d=anl.gov; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anl.gov; s=selector1;
h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
bh=vUwixD8RblY7pYZRV4ErG/j667NPQpT35GDccQxDuxE=;
b=lW0S/oOXvfzCCJRDJz3OVyK6wHx/znMSO6vt0/VS3P//u9uRCmsWdcJmItfjQoy8oTSgE75n1o47jdtf1jdtbxJSdyuaQt12LqHsqJW3oFLATUMvjkNwvcsh8RcNoWdCNZd64ifcJwMceiV6ystfkcLL/ucilfysjP6FjMpVLrkgjYpNNOxicIicuaPwV0atBRs463jGX8K0jRhxx6fUCBM/AqwjFOfGVSuafh9clYRLbXZrfCSr/rPxjkbuxXGtdlivEOaB3msSopYihfV5CyDsggmdBdMX+/+WEXW6WggpkGkP2CzHn/SlM5ancaa8FZUG/UH0QpYqWK+0QoVXfA==
Thread-Topic: Relatively prime integers in NumPy
Thread-Index: AQHa0WffJqhGflnACk65nSD3UBURMbHx270AgAADEHY=
In-Reply-To: <00e801dad3bf$473daed0$d5b90c70$@gmail.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
msip_labels:
authentication-results: dkim=none (message not signed)
header.d=none;dmarc=none action=none header.from=anl.gov;
x-ms-publictraffictype: Email
x-ms-traffictypediagnostic: DM8PR09MB6360:EE_|SA1PR09MB10452:EE_
x-ms-office365-filtering-correlation-id: 37faf643-abcc-4073-da62-08dca1df3e99
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam: BCL:0;ARA:13230040|1800799024|366016|38070700018;
x-microsoft-antispam-message-info: 1+5lnhQ0/3LAX+kWmlT+c9fcdex1xgaXQZSRg+e/Zm6X7
AV6OYVREbxYkoAUlMES+Jva6H61XvraVZnc2IB5lerW63
BqEcmjgYCvbAb6Sn9hSGLjpFJYyowBV8QVBc5oDtAA111
X8WyeY/63QZTXfPpktt6rAIXFHmo3BMBK4PxtHWCEu40T
bkpCYWFaJ691FgopuTQed1RTDPP+jL8+JdRfUGqVIPhBy
et0NsxAkDOXmE9aGFhLcrXlnRFSrtQqOZ8GHimHf7GmNx
MiMxWUizoL4potI6dbeiVaXU6rFVCzzscxqY5hwGKwUug
j4d01lngdBZ334iOhHbEc8dkHhsDIDPPEWYpIbVB60Kcy
GPuq8julLKTfNiL5sUyvZ+2NJev8/XjaKEh8zxOTZXxYF
rDL/yUJqbpwMwuY5PEKXOjYZCoAstdGfi3i1F9f89JXRm
kuEDi4z4PkOvwz5i4tD2WzeI2F3KD0mQrrTDZDPKG4X/d
+7hK6j2W7SkII9E77buNI3cmSVo9b2304vn8Fcuzpz2/R
UQT0kmjsagO0tGZfpTc6H0qXc0/0oJPtXrTQgvL1FE7CX
/A6TajAo+kWzCaTeeuNRaRtOdsJE+FWwUamo3yHagYO1G
i5WERmMc3rJVRihWetQ+u3g6C1BwCaxqyxa9nv2kY55ow
ufvfxgEOvP9bL9x2eSUUgaTkMdDVPKDOKTqq+dBsIQsmC
pw6sF2sRZS+F94OOH4i/tkhWQIjUhWnVra0GWRHKxMiy5
sm/f0Mlqr4r2HFbxlfoiJol3ZQQxVrLynkA6SPtqTZflE
2w9/fHdEPCfuLTOtLu1BWTzJD4ATT6jRN1/TpZ41iGdW5
kzNcM7EQ75XbA8qqegJ+8AMgZrpsrxKBfVODp+RFHiye6
057YNYfEdiO5qNVLvi3CeS6K0ca1AytXKQu4sfTGzJpR8
gEI+bDwcdCCE6eRsCF7t2AudMMlf0K3PxkiJtO/Ysjnly
giW4efIOUM24jx4r1HKFr9bNOxh3jQ7rGPY5ijz6kFLqh
XlD/g1q4Fu43+xd0OkNFUe50d0VU3/pNQZIjFSXFVTDKY
DY5b7/0jg5iQjLxrHgYzdNZ+2b5BlM7Tf+Jy7n69GhQ78
i2D95t/Ra43rGgoGHv+wBOSAMjteS928ToPp7ghRVXWYs
qEL5ySvXuRPvgCFHVRHJNLYlY23cEhEwB+OUbZbIWSQoR
M2JwM/C+R/O1q/8tipXvgkR/fEJ9IIZ0QLHMvKsJXKGlp
NyFxX2jaNaExvp1wREB62hj6gWRIONKhtpJ5SAkbeUJvY
AL9j4Jfk9Lwra6jWgvrWu2/muk2fZ0RFSj7xSAhB2jj3b
s5XSnnn8uLow9hlbmOYU4j2C8Kyvf91wnspV8=
x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:;
IPV:NLI; SFV:NSPM; H:DM8PR09MB6360.namprd09.prod.outlook.com; PTR:; CAT:NONE;
SFS:(13230040)(1800799024)(366016)(38070700018); DIR:OUT; SFP:1101;
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0: Z2jCC9fwDukrS8F/fjRj2+jgay1MP67ImRdf7GxLZ4oIU
2xM4A914w0j0faz4yJF8JFEXPuT9GOURB50nxPKpzDL2O
8VXDIqEEJAHRKuqBlhaDCJdHDkjaj6FCvwpcg+OnGZJGd
FkPCXlU8YI/m/L9hPdbnw9d0rrhHe9/B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4Mcomd08E/wdtyf4kneUNSWEhyhUEGhNPWFWSy
6FE1wjre0LCzZhuSYrg643uq0bJflDOy4Y4AvJiQnnXWb
fLc+SlTMQtJYkOjio1Et7eNN3sU+EqnoTpozpPiS6OI0c
iTyPqb6MvipnTtHCLLHOSuQJP0Agg4/QBZrcObiMRjWgo
cVLodqfURDFwSbsoznbd1uu8AW8Dr6x4fQQMoYXrK6f6S
6wqdLn83OdqJ+Fh5iy8ZtyagFuOdwRwLSreksAhk45d+W
AGcxuDYHd4M6DG3DbUaMXWj28kGTY21jDnCFX4m9ps0WQ
ChPoKDXLmg8NY5BWRX/AaxfIzcR/jYWz46XOh9ypHVTYT
5Y6A=
X-OriginatorOrg: anl.gov
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: DM8PR09MB6360.namprd09.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: 37faf643-abcc-4073-da62-08dca1df3e99
X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Jul 2024 19:25:37.9304 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 0cfca185-25f7-49e3-8ae7-704d5326e285
X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR09MB10452
X-Mailman-Approved-At: Fri, 12 Jul 2024 09:46:35 -0400
X-Content-Filtered-By: Mailman/MimeDel 2.1.39
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: <DM8PR09MB63603191F5509E5013D1BEDCDBA52@DM8PR09MB6360.namprd09.prod.outlook.com>
X-Mailman-Original-References: <SA0PR09MB6363F3E6B493202E73869DF4DBDA2@SA0PR09MB6363.namprd09.prod.outlook.com>
<00e801dad3bf$473daed0$d5b90c70$@gmail.com>
View all headers

Thank you for your interest. My explanation is too concise indeed, sorry. So far, I have used Python code with three enclosed 'for' loops for this purpose which is pretty time consuming. I'm trying to develop a NumPy based code to make this procedure faster. This routine is kind of 'heart' of the algorithm to index of X-ray Laue diffraction patterns. In our group we have to process huge amount of such patterns. They are collected at a synchrotron radiation facility. Faster indexation routine would help a lot.
This is the code I'm currently using. Any prompts how to implement it in NumPy would be highly appreciated.
for h in range(0, max_h):
      for k in range(0, max_k):
            for l in range(0, max_l):
                  chvec=1
                  maxmult=2
                  if h > 1:                     
                        maxmult=h
                  if k > 1:
                        maxmult=k
                  if l > 1:
                        maxmult=l
                  if h > 1:
                        if maxmult > h:
                              maxmult=h
                  if k > 1:
                        if maxmult > k:
                              maxmult=k
                  if l > 1:
                        if maxmult > l:
                              maxmult=l
                  maxmult=maxmult+1
                  for innen in range(2, maxmult):
                        if h in range(0, (max_h+1), innen):
                              if k in range(0, (max_k+1), innen):
                                    if l in range(0, (max_l+1), innen):
                                          chvec=0
                  if chvec==1:
                        # Only relatively prime integers h,k,l pass to this block of the code

________________________________
From: avi.e.gross@gmail.com <avi.e.gross@gmail.com>
Sent: Thursday, July 11, 2024 1:22 PM
To: Popov, Dmitry Yu <dpopov@anl.gov>; 'Popov, Dmitry Yu via Python-list' <python-list@python.org>
Subject: RE: Relatively prime integers in NumPy
Дмитрий, 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
ZjQcmQRYFpfptBannerStart
This Message Is From an External Sender
This message came from outside your organization.
ZjQcmQRYFpfptBannerEnd
Дмитрий,
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://urldefense.us/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!G_uCfscf7eWS!ZGK1ZXYgmC6cpNa1xTXVTNklhunjYiinwaDe_xE3sJyVs4ZcVgUB_v2FKvDzDspx7IzFCZI7JpFsiV5iH58P$

1

rocksolid light 0.9.8
clearnet tor