Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

Q: What's the difference between an Irish wedding and an Irish wake? A: One less drunk.


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: Sat, 13 Jul 2024 03:10 UTC
References: 1 2 3 4 5 6
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: Sat, 13 Jul 2024 03:10:12 +0000
Lines: 197
Message-ID: <mailman.37.1720840220.2981.python-list@python.org>
References: <SA0PR09MB6363F3E6B493202E73869DF4DBDA2@SA0PR09MB6363.namprd09.prod.outlook.com>
<00e801dad3bf$473daed0$d5b90c70$@gmail.com>
<DM8PR09MB63603191F5509E5013D1BEDCDBA52@DM8PR09MB6360.namprd09.prod.outlook.com>
<DM8PR09MB636055F61171899BF14B01D3DBA62@DM8PR09MB6360.namprd09.prod.outlook.com>
<011801dad4b7$44a07100$cde15300$@gmail.com>
<DM8PR09MB6360AD8A1C512FAC31F32F70DBA72@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 v9KgjYWtX8OKkRzRQ8Etrg9KNoQjg5We61nRjNp2j3nw==
Cancel-Lock: sha1:J0s7HuPTwHnF09wCMbSyyPPLRrI= sha256:U5FXkwbeWjnN7ycb9ekPLYAiMAYg0X8uDnjTGd3A7lI=
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=VmpgvFte;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.119
X-Spam-Level: *
X-Spam-Evidence: '*H*': 0.76; '*S*': 0.00; 'looks': 0.02;
'explanation': 0.07; 'matches': 0.07; 'modules': 0.07; 'enough.':
0.09; 'indeed.': 0.09; 'mechanism': 0.09; 'much,': 0.09; 'numpy':
0.09; 'routine': 0.09; 'skip:z 20': 0.09; '&gt;': 0.14; 'import':
0.15; '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:gcc02-bl0-obe.outbound.protection.outlook.com': 0.16;
'received:namprd09.prod.outlook.com': 0.16; 'relatively': 0.16;
'sorry.': 0.16; 'step.': 0.16; 'url-ip:3.215/16': 0.16;
'url:urldefense': 0.16; 'url:v3': 0.16; 'using.': 0.16; 'python':
0.16; 'code.': 0.17; 'solve': 0.19; 'implement': 0.19; 'issue':
0.21; 'languages': 0.22; 'i.e.': 0.22; 'maybe': 0.22; 'to:no real
name:2**1': 0.22; 'code': 0.23; 'skip:- 10': 0.25; 'url:listinfo':
0.25; 'cannot': 0.25; 'programming': 0.25; '11,': 0.26; 'friday,':
0.26; 'else': 0.27; 'bit': 0.27; 'function': 0.27; 'done': 0.28;
'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; 'question': 0.32; '(as': 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; 'following':
0.35; 'request': 0.35; 'addressed': 0.36; 'built': 0.36; 'those':
0.36; 'lists': 0.37; 'currently': 0.37; 'using': 0.37; 'skip:b
10': 0.63; 'identify': 0.64; 'pass': 0.64; 'range': 0.64; 'our':
0.64; 'experience': 0.64; 'clear': 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; 'hesitate': 0.65; 'well':
0.65; 'skip:t 20': 0.66; 'improve': 0.66; 'earlier': 0.67;
'numbers': 0.67; 'skip:n 30': 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; '8bit%:43': 0.70;
'skip:f 30': 0.71; 'speed': 0.71; 'skip:\xe2 10': 0.71;
'8bit%:89': 0.75; '8bit%:92': 0.75; 'skip:f 20': 0.75; 'factors':
0.76; 'sent:': 0.78; 'highly': 0.78; '0in': 0.81; '8bit%:95':
0.84; '0in;': 0.84; '16px': 0.84; '8bit%:76': 0.84; '8bit%:97':
0.84; 'axis': 0.84; 'email name:&lt;python-list': 0.84; 'indices':
0.84; 'lot.': 0.84; 'popov': 0.84; 'skip:& 50': 0.84; 'url:--':
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=HXMvM6946w7wYjkjbt/2I5Dj8kQKcr6921o+6c+Gy9bBEbbTKNvy9B0oZK3i248/dh3YMy4rGgOv1MGrXeXVLTUDeRnMJ2IxQBdHP8OKI4bu3M8RqhrJ9ZXZnwLvCDtE5AP2dqJhitoJwgmxnb3tZolaSvaqGzxYTabZC3aOrBJvToGEmS25q1xqQddUWNfecRXwFrlkQYGvUPYSTCsElur8QJfAI1oaJYnR3U6WrkjJMDiYNXBtE5VHSp6OU2GNBDMVweLi4tmpeLFqjoDzJD48Yy+/DbKSNVJMDLIqeBR1pl5wBrgFdPyPKFCvGCapBGFPtLoHydEpjF0HDMjNOg==
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=3MV4iQpm43Ao4CpMcE/tGNCRPbX0dMXOzJJhVPsajYM=;
b=EwSTqDGwVKAVScE92aK8dlyCk6sJZhUPGj7KpylE50X2KyYzx2GkN5XKUdHUHID5jecyurF86m9NB1SX5i4kyedeFKnCnOFnSThyrfsD3F0q6odx07eVeuD8Czvgg94MjXUCZ4pixa8MfkSx8OaaoSkNoYjc2Ic6+LnY9PffdLMwtU0LLjUX5ATEqUXz0Y3rzWt4tns8U3IyOdYVmchxkJk0NBkOpOimhsoI4vGU4hIM6+rPZJK8cxhzAyLf6g6ZCsUHt7mP4rNt1LWBn8bwtX2ZaYlE4RmvX7l4SzjgSFv5gyGufABGtT0wxRAT94qpKxrXR2Aej8q6fPT4vo3McQ==
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=3MV4iQpm43Ao4CpMcE/tGNCRPbX0dMXOzJJhVPsajYM=;
b=VmpgvFteBARbrbjG+8XZ4hn02u8BzOcgnoiSMYz9mxTG6Zw7ZYapBU5dazAeajC+EygwBaohaS0z7Sw8NGzJZDvTGfFDC0YwAc+1hUwAhvKywd4ds8C9nt3lwOlHKICnKWId5o4cCCAVjX5giDsMS1WK+UuzgN9LDVG5mVdy5WBPBRHja1DIJdNsVlLt/uN8ZIiZ34MuGglSK/fLXYb5cL8RG4FRHE8WdO6dn2By/CzPHQx1W1f1rDqTRGcvhzHFxHUC0DsgfG0yHknvXGHbK1EHOUPV6je/4e31Exc3Pp1F905k5yCABzLICrpCBQ5b45IcFYYvv9aLMxw2kzIqxA==
Thread-Topic: Relatively prime integers in NumPy
Thread-Index: AQHa0WffJqhGflnACk65nSD3UBURMbHx270AgAADEHaAAW/W/oAAfRWAgAA1Wx4=
In-Reply-To: <011801dad4b7$44a07100$cde15300$@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_|SJ0PR09MB11650:EE_
x-ms-office365-filtering-correlation-id: 523e3725-f31c-4fb3-68b3-08dca2e94f50
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: bdrtdDfUtxR2N9Txfti1kQA5wtHiH1HPTErBXUZw9vZz5
Bsrdiz+gToCVktw23faNcYISJ+06oF619nDlCCxZ1l3sv
zUIXBo8+zn0NH6NQhDSL5bHVt0JaeBkNbALiFOBW2ai6G
cRt266CadFMzBenQI3cU8mH2tNR1q5OsXfQuXvQ2kZr+q
Y7kIpzf6NACok1gpKplmJP6ij0afXj/5Re/YJDOu3W5c3
oU+YN99ILy4tY9YorjOhCMDt6EbVuIi6XttHEmHLM0F8A
zn39rcHov/Cj7PVDZezgh+v622T4uldhDazqoolLdv3yV
tnYrkffT/doSfx2MHplInomWNK4dqlppb259E7NF3o9ym
80dYJoKN5Ch5f3qiqj2fDEn8CTv11/7Pp+5soKBAmJaL7
m+AZHcRL2nvm9U3nNBr0+qB5rQCn+F8muieFS0j1omFze
drzjGA7EnEuzK7BqucD+Afj/eYGRiA9YBxrycqfCq9Vlm
W/vU7IW95xfj7S1wPr1yaOI8YWBou1inCS9ltZAzCVEcp
KR5Q1nMW7nszyM4Ou54HplLMnO+86yZrBpNykzaFIbZ1q
VMhOw2/w9nsholQEZMZ7WWhjcp222xtfnm9C+WZ8MI4PN
+9uF48cAzN83828ZMXsU2Xu6O/cbdyawmkkQKJ0L2nDrw
MYC9pkg+fDYCIbYJYx14V5rovyEPzXZdL5wxpIfaCo3Uw
umPbh8NkUa+yPmQadHbQFOwE/vx3noA3NMRzcrJ/0NsZZ
uPiz8bgEYPYvjmTzVkjZjJ4jdSNIOF9cCmmQNzIZAp5CU
Yg6tG/NbLQwThswEIpJt2bl8v3iBG+Nsna7kxmCn4mnLh
Ksh4/aVcUDV7bdyxWvTw+eO7C8EU+dhMDgFGoxLzVX3Ng
9EhKkmf2yP0X7N3YK5uyAPphstuJjpoKSmlt+UJ1T30ij
zqWuf7pVYT7krYGp807Jtc7M6clYK7+Ap1aW31CD3KG7f
oQYEhlFLv1TGuPC2tmRJ/KqK3Ct2O9uQ5gEYPkLsJLz5G
wMIagjmBiWgCmMT1/P7DTN4lE/w7wTtTmn8NRTqN+JFY4
JftFAmSXxkJPCWogyMwKxC4DkNp9H9eEmQvgSjjNW3b6t
RSTyP5qlAMgSY8DjpxwXr5TyEI+PnnArun9iXdeoQgRs2
UJysl/7IEBBls7GcoiuxRS+T9Bj3Vzkw2fQLm0nJQqLw1
2e+xX+aGgK/3yPTT4PQgjxlJ67fB6UdpB+VAYDVd8B9xG
4J61ptqAlssoR+dUb4UTUSAh6NacJfGhAZw9KIv12hFK7
VvNbqJyP0moF3N6YAFncdIGTLGxKMTmkSViTiQmEEubek
xYZq58HHlP5CNvRTM4ECMHbIsMEUBTk42OIXc=
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: 0scFM2X3Owb7kNfu7HWjl6s2O/VINMsSiFzei3mJ0/HHs
5m0KOShA5tOTEqOJFHnY9fKGiHsIdr+GKTolvszwJWyDn
f17YEgWPnvIEaDUXsMxngADQ1TvHmbFuqGAqvjac5nJ9J
lmwjdi3iwkLdCDLx1tHB53TVzmdvIyjfrbF89RjbtbX+c
mq0S8Jo3BuxYoDiONAvDWFsWjBqiObfvSfDRe3M2rIu+a
jluTqCfG9NiLvSJ+WDje6459a63sMaYP8U8C3a9xgkcsB
9lHBYsGtMu8Hq8shls5+YGv+cG4+J6ZMN8Kan68vfD+qa
NA7I4CbspZkAiMWaodRljxfdWpry/Eu29uLH4J+l7bdRp
DkKtMwktUjVIyYp24GoEJpqpBE+PdLZEB92mm+bjAt5OZ
cnFuIetJNGYcpkmEtiD3wnHBaCVeSwL9bYiyg8upuRSWQ
a6iibtGaqDIrz0VIOpJ/BboueE++P2IAFwXfMbDoh8OdB
o6X+71++0iVbbBBJqkUxLnpDBul+n7EOALHjZNSk+1rVC
Edtx3eHKOlvyAEZQg6HUMq9LzmJhPho+NSf1oo3xWvlOJ
pvEWsnkc6YpceCkAu4AjaZkDq3SXxR8J5Q/KatPZnuqJ0
sfEJmyRGLc1D8bWNvi65mtIZklHxYrfJSSqFeBKFWZlvg
aMltgcsj0Y4XliCDev3WcPdmxdkNMcUe0MuevSAPMZq4f
eGBwGB+MHtU41rObRUlCxCT1EEeJP9y+QmJF245Lpx/ch
w4N19ePP7BUJgHk+AOBQTIvdURc8g1jomE1rbnZBK/TIs
jFs6gHQ5z86dvUsTEJ8bl+i/lRvQ0tiqXZtkInGftx/18
hRA1N1hYLFmX9lGGbXfnEsNFIjamwTFd8yhd/GWU34GuZ
pTjZ3JRzSy9LK42cTW7cCTusbrQsXvdneb+jZao7ToPju
FW7+WyBeA4so0R6DkeZYZCN/u7gXEdMdszlFN075/RxuY
POM2r/ycwXlq051istrJj8od5llg/6K9rruhjC89yrKQ9
jPv463mCvAIe4ZoM8TP4NhTXqr6Hn4/aFqPsEnv9gcaHu
h2v8XZ8tGZAAyNIcb+pvCweMniflJJBuoL5SiNxUi1tn1
HXAmmsCs3jvmJJue1I3+lp/MUQHyk/eF6+g4395ateS3U
p1UpSYlWu08g6XEXkLEIeFuSzSBFjuIld7HuwMgtG0ksK
RGf71KzQ5BLlmS8TvzE/tlySpYESp9tIROP9n0ewXT6Lr
SiDUb2tmFziA5XFhcfApbqiAruLnzfHk6oreQWIqMhvbt
ARvF3G3iv66ZaR+UdD3zjFwHceBgFsv0O5/cQMR8aZeOB
NoqXek82Yc2WFxJlI0dGxxVFS3t54iRY2yd8WBvjfV3X7
5XnMlo2EUgSiJ1w1n99bixmtfxB+6YynzTZFrk3umnxtt
L/JQ0fJevery212ojIKg/POef/T1nDK89VgIDwHf5A+D+
edjKiSrPOirlUd52AspvV+txjgas/Q5pILZOoWBcqnkqx
/k/ng7KfBnH0+GdqK3UkCW5ICtoO0ULazNDTtHoFXGySl
ytJU=
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: 523e3725-f31c-4fb3-68b3-08dca2e94f50
X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Jul 2024 03:10:12.1017 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 0cfca185-25f7-49e3-8ae7-704d5326e285
X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR09MB11650
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: <DM8PR09MB6360AD8A1C512FAC31F32F70DBA72@DM8PR09MB6360.namprd09.prod.outlook.com>
X-Mailman-Original-References: <SA0PR09MB6363F3E6B493202E73869DF4DBDA2@SA0PR09MB6363.namprd09.prod.outlook.com>
<00e801dad3bf$473daed0$d5b90c70$@gmail.com>
<DM8PR09MB63603191F5509E5013D1BEDCDBA52@DM8PR09MB6360.namprd09.prod.outlook.com>
<DM8PR09MB636055F61171899BF14B01D3DBA62@DM8PR09MB6360.namprd09.prod.outlook.com>
<011801dad4b7$44a07100$cde15300$@gmail.com>
View all headers

Thank you very much. List comprehensions make code much more concise indeed. Do list comprehensions also improve the speed of calculations?
________________________________
From: avi.e.gross@gmail.com <avi.e.gross@gmail.com>
Sent: Friday, July 12, 2024 6:57 PM
To: Popov, Dmitry Yu <dpopov@anl.gov>; 'Popov, Dmitry Yu via Python-list' <python-list@python.org>; oscar.j.benjamin@gmail.com <oscar.j.benjamin@gmail.com>
Subject: RE: Relatively prime integers in NumPy
Dmitry, I clearly did not understand what you wanted earlier as you had not made clear that in your example, you already had progressed to some level where you had the data and were now doing a second step. So, I hesitate to say much until
ZjQcmQRYFpfptBannerStart
This Message Is From an External Sender
This message came from outside your organization.
ZjQcmQRYFpfptBannerEnd
Dmitry,

I clearly did not understand what you wanted earlier as you had not made clear that in your example, you already had progressed to some level where you had the data and were now doing a second step. So, I hesitate to say much until either nobody else addressed the issue (as clearly some have) or you explain well enough.

I am guessing you have programming experience in other languages and are not as “pythonic” as some. The code you show may not be quite how others might do it. Some may write mch of your code as a single line of python using a list comprehension such as:

hkl_list = [ [h, k, l] for SOMETHING in RANGE for SOMETHING2 in RANGE2 for SOMETHING3 in RANGE3]

Where h, k. l come from the somethings.

Back to the real world.


From: Popov, Dmitry Yu <dpopov@anl.gov>
Sent: Friday, July 12, 2024 1:13 PM
To: avi.e.gross@gmail.com; 'Popov, Dmitry Yu via Python-list' <python-list@python.org>; oscar.j.benjamin@gmail.com; Popov, Dmitry Yu <dpopov@anl.gov>
Subject: Re: Relatively prime integers in NumPy

Thank you very much, Oscar.

Using the following code looks like a much better solution than my current Python code indeed.
np.gcd.reduce(np.transpose(a))
or
np.gcd.reduce(a,1)

The next question is how I can generate ndarray of h,k,l indices. This can be easily done from a Python list by using the following code.

import numpy as np
hkl_list=[]
for h in range(0, max_h):
      for k in range(0, max_k):
            for l in range(0, max_l):
                  hkl_local=[]
                  hkl_local.append(h)
                  hkl_local.append(k)
                  hkl_local.append(l)
                  hkl_list.append(hkl_local)
hkl=np.array(hkl_list, dtype=np.int64)
This code will generate a two-dimensional ndarray of h,k,l indices but is it possible to make a faster routine with NumPy?

Regards,
Dmitry



________________________________
From: Python-list <python-list-bounces+dpopov=anl.gov@python.org<mailto:python-list-bounces+dpopov=anl.gov@python.org>> on behalf of Popov, Dmitry Yu via Python-list <python-list@python.org<mailto:python-list@python.org>>
Sent: Thursday, July 11, 2024 2:25 PM
To: avi.e.gross@gmail.com<mailto:avi.e.gross@gmail.com> <avi.e.gross@gmail.com<mailto:avi.e.gross@gmail.com>>; 'Popov, Dmitry Yu via Python-list' <python-list@python.org<mailto:python-list@python.org>>
Subject: Re: Relatively prime integers in NumPy

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
ZjQcmQRYFpfptBannerStart
This Message Is From an External Sender
This message came from outside your organization.

ZjQcmQRYFpfptBannerEnd
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<mailto:avi.e.gross@gmail.com> <avi.e.gross@gmail.com<mailto:avi.e.gross@gmail.com>>
Sent: Thursday, July 11, 2024 1:22 PM
To: Popov, Dmitry Yu <dpopov@anl.gov<mailto:dpopov@anl.gov>>; 'Popov, Dmitry Yu via Python-list' <python-list@python.org<mailto: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<mailto:python-list-bounces+avi.e.gross=gmail.com@python.org>> On
Behalf Of Popov, Dmitry Yu via Python-list

Click here to read the complete article

1

rocksolid light 0.9.8
clearnet tor