Dmitry,
=20
Efficiency of several kinds is hotly debated and sometimes it depends a =
lot on what is done within loops.
=20
Many suggest a mild speed up of some comprehensions over loops but the =
loops are not gone but somewhat hidden and perhaps some aspects are =
faster for having been written in C carefully and not interpreted.
=20
Comprehensions (and there are other versions that generate dictionaries =
and tuples and sets) may also be sped up a bit for other reasons like =
your fairly expensive APPPEND that has to keep finding the end o f a =
growing list and is not done the same way in a comprehension.
=20
If you do a search, you find many opinions including on using functional = programming techniques such as map/reduce. There are also=20
=20
Your particular case is interesting because it just makes all =
combination of three variables. Some languages, like R, have functions =
that do this for you, like expand.grd. Python has many modules, like = itertools that do things including combinations but perhaps not designed =
for your case.=20
=20
Here is a version of your scenario:
=20
import itertools
a =3D range(3)
b =3D range(4)
c =3D range(5)
=20
list(itertools.product(a,b,c))
=20
The result comes as tuples but as you are moving the result into numpy, =
does it matter:
=20
list(itertools.product(a,b,c))
[(0, 0, 0), (0, 0, 1), (0, 0, 2), (0, 0, 3), (0, 0, 4), (0, 1, 0), (0, =
1, 1), (0, 1, 2), (0, 1, 3), (0, 1, 4), (0, 2, 0), (0, 2, 1), (0, 2, 2), =
(0, 2, 3), (0, 2, 4), (0, 3, 0), (0, 3, 1), (0, 3, 2), (0, 3, 3), (0, 3, =
4), (1, 0, 0), (1, 0, 1), (1, 0, 2), (1, 0, 3), (1, 0, 4), (1, 1, 0), =
(1, 1, 1), (1, 1, 2), (1, 1, 3), (1, 1, 4), (1, 2, 0), (1, 2, 1), (1, 2, =
2), (1, 2, 3), (1, 2, 4), (1, 3, 0), (1, 3, 1), (1, 3, 2), (1, 3, 3), =
(1, 3, 4), (2, 0, 0), (2, 0, 1), (2, 0, 2), (2, 0, 3), (2, 0, 4), (2, 1, =
0), (2, 1, 1), (2, 1, 2), (2, 1, 3), (2, 1, 4), (2, 2, 0), (2, 2, 1), =
(2, 2, 2), (2, 2, 3), (2, 2, 4), (2, 3, 0), (2, 3, 1), (2, 3, 2), (2, 3, =
3), (2, 3, 4)]
=20
Or a atd easier to read pretty printed:
=20
import pprint
pprint.pprint(list(itertools.product(a,b,c)))
[(0, 0, 0),
(0, 0, 1),
(0, 0, 2),
(0, 0, 3),
(0, 0, 4),
(0, 1, 0),
(0, 1, 1),
(0, 1, 2),
(0, 1, 3),
(0, 1, 4),
(0, 2, 0),
(0, 2, 1),
(0, 2, 2),
(0, 2, 3),
(0, 2, 4),
(0, 3, 0),
(0, 3, 1),
(0, 3, 2),
(0, 3, 3),
(0, 3, 4),
(1, 0, 0),
(1, 0, 1),
(1, 0, 2),
(1, 0, 3),
(1, 0, 4),
(1, 1, 0),
(1, 1, 1),
(1, 1, 2),
(1, 1, 3),
(1, 1, 4),
(1, 2, 0),
(1, 2, 1),
(1, 2, 2),
(1, 2, 3),
(1, 2, 4),
(1, 3, 0),
(1, 3, 1),
(1, 3, 2),
(1, 3, 3),
(1, 3, 4),
(2, 0, 0),
(2, 0, 1),
(2, 0, 2),
(2, 0, 3),
(2, 0, 4),
(2, 1, 0),
(2, 1, 1),
(2, 1, 2),
(2, 1, 3),
(2, 1, 4),
(2, 2, 0),
(2, 2, 1),
(2, 2, 2),
(2, 2, 3),
(2, 2, 4),
(2, 3, 0),
(2, 3, 1),
(2, 3, 2),
(2, 3, 3),
(2, 3, 4)]
=20
I think that is close enough to what you want but is it faster? You can =
try a benchmarking method on alternatives.
=20
=20
=20
=20
From: Popov, Dmitry Yu <
dpopov@anl.gov>=20
Sent: Friday, July 12, 2024 11:10 PM
To:
avi.e.gross@gmail.com; 'Popov, Dmitry Yu via Python-list' = <
python-list@python.org>;
oscar.j.benjamin@gmail.com
Subject: Re: Relatively prime integers in NumPy
=20
Thank you very much. List comprehensions make code much more concise =
indeed. Do list comprehensions also improve the speed of calculations?
_____ =20
From:
avi.e.gross@gmail.com <mailto:
avi.e.gross@gmail.com> = <
avi.e.gross@gmail.com <mailto:
avi.e.gross@gmail.com> >
Sent: Friday, July 12, 2024 6:57 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> >;
oscar.j.benjamin@gmail.com = <mailto:
oscar.j.benjamin@gmail.com> <
oscar.j.benjamin@gmail.com = <mailto:
oscar.j.benjamin@gmail.com> >
Subject: RE: Relatively prime integers in NumPy=20
=20
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=20
ZjQcmQRYFpfptBannerStart
This Message Is From an External Sender=20
This message came from outside your organization.=20
=20
ZjQcmQRYFpfptBannerEnd
Dmitry,
=20
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.
Ditr
I am guessing you have programming experience in other languages and are =
not as =E2=80=9Cpythonic=E2=80=9D 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:
=20
hkl_list =3D [ [h, k, l] for SOMETHING in RANGE for SOMETHING2 in =
RANGE2 for SOMETHING3 in RANGE3] =20
=20
Where h, k. l come from the somethings.
=20
Back to the real world.
=20
=20
From: Popov, Dmitry Yu <
dpopov@anl.gov <mailto:
dpopov@anl.gov> >=20
Sent: Friday, July 12, 2024 1:13 PM
To:
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> >;
oscar.j.benjamin@gmail.com = <mailto:
oscar.j.benjamin@gmail.com> ; Popov, Dmitry Yu <
dpopov@anl.gov = <mailto:
dpopov@anl.gov> >
Subject: Re: Relatively prime integers in NumPy
=20
Thank you very much, Oscar.=20
=20
Using the following code looks like a much better solution than my =
current Python code indeed.
np.gcd.reduce(np.transpose(a))=20
or=20
np.gcd.reduce(a,1) =20
=20
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.
=20
import numpy as np
hkl_list=3D[]
for h in range(0, max_h): =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82for k in range(0, = max_k): =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82=E2=80=82=E2=80=82for l in range(0, max_l): =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80= =82=E2=80=82hkl_local=3D[] =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80= =82=E2=80=82hkl_local.append(h) =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80= =82=E2=80=82hkl_local.append(k) =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80= =82=E2=80=82hkl_local.append(l) =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80= =82=E2=80=82hkl_list.append(hkl_local)
hkl=3Dnp.array(hkl_list, dtype=3Dnp.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?=20
=20
Regards,
Dmitry
=20
=20
=20
_____ =20
From: Python-list <python-list-bounces+dpopov=
3Danl.gov@python.org = <mailto:python-list-bounces+dpopov=
3Danl.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=20
=20
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=20
ZjQcmQRYFpfptBannerStart
This Message Is From an External Sender=20
This message came from outside your organization.=20
=20
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.
=20
This is the code I'm currently using. Any prompts how to implement it in = NumPy would be highly appreciated.
=20
for h in range(0, max_h): =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82for k in range(0, = max_k): =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82=E2=80=82=E2=80=82for l in range(0, max_l): =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80= =82=E2=80=82chvec=3D1 =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80= =82=E2=80=82maxmult=3D2 =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80= =82=E2=80=82if h > = 1:=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82= =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82 =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80= =82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82maxmult=
=3Dh =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80= =82=E2=80=82if k > 1: =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80= =82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82maxmult=
=3Dk =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80= =82=E2=80=82if l > 1: =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80= =82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82maxmult=
=3Dl =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80= =82=E2=80=82if h > 1: =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80= =82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82if =
maxmult > h: =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80= =82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82= =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82maxmult=3Dh =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80= =82=E2=80=82if k > 1: =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80= =82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82if =
maxmult > k: =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80= =82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82= =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82maxmult=3Dk =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80= =82=E2=80=82if l > 1: =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80= =82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82if =
maxmult > l: =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80= =82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82= =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82maxmult=3Dl =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80= =82=E2=80=82maxmult=3Dmaxmult+1 =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80= =82=E2=80=82for innen in range(2, maxmult): =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80= =82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82if h =
in range(0, (max_h+1), innen): =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80= =82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82= =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82if k in range(0, (max_k+1), = innen): =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80= =82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82= =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82=E2=80=82if l in range(0, (max_l+1), innen): =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80= =82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82= =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80= =82chvec=3D0 =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80= =82=E2=80=82if chvec=3D=3D1: =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80= =82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82# Only = relatively prime integers h,k,l pass to this block of the code
=20
=20
________________________________
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
=20
=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9, 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.
=20
ZjQcmQRYFpfptBannerEnd
=20
=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9,
=20
You may think you explained what you wanted but I do not see what result =
you
expect from your examples.
=20
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.
=20
Is there a reason you cannot solve this mostly outside numpy?
=20
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.
=20
Maybe a better explanation is needed as I cannot see what your latter =
words
about -1 and 1 are about. Perhaps someone else knows.
=20
=20
=20
=20
-----Original Message-----
From: Python-list =
<python-list-bounces+avi.e.gross=
3Dgmail.com@python.org = <mailto:python-list-bounces+avi.e.gross=
3Dgmail.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 = <mailto:
python-list@python.org> >
Subject: Relatively prime integers in NumPy
=20
Dear Sirs.
=20
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.
=20
Regards,
Dmitry Popov
=20
Argonne, IL
USA
=20
--
https://urldefense.us/v3/__https://mail.python.org/mailman/listinfo/pytho= n-list__;!!G_uCfscf7eWS!ZGK1ZXYgmC6cpNa1xTXVTNklhunjYiinwaDe_xE3sJyVs4ZcV= gUB_v2FKvDzDspx7IzFCZI7JpFsiV5iH58P$ = <
https://urldefense.us/v3/__https:/mail.python.org/mailman/listinfo/pytho= n-list__;!!G_uCfscf7eWS!ZGK1ZXYgmC6cpNa1xTXVTNklhunjYiinwaDe_xE3sJyVs4ZcV= gUB_v2FKvDzDspx7IzFCZI7JpFsiV5iH58P$-->=20
=
<
https://urldefense.us/v3/__https:/mail.python.org/mailman/listinfo/pytho= n-list__;!!G_uCfscf7eWS!ZGK1ZXYgmC6cpNa1xTXVTNklhunjYiinwaDe_xE3sJyVs4ZcV= gUB_v2FKvDzDspx7IzFCZI7JpFsiV5iH58P$--> =20
=
<
https://urldefense.us/v3/__https:/mail.python.org/mailman/listinfo/pytho= n-list__;!!G_uCfscf7eWS!ZGK1ZXYgmC6cpNa1xTXVTNklhunjYiinwaDe_xE3sJyVs4ZcV= gUB_v2FKvDzDspx7IzFCZI7JpFsiV5iH58P$--> =20
-- =
<
https://urldefense.us/v3/__https:/mail.python.org/mailman/listinfo/pytho= n-list__;!!G_uCfscf7eWS!ZGK1ZXYgmC6cpNa1xTXVTNklhunjYiinwaDe_xE3sJyVs4ZcV= gUB_v2FKvDzDspx7IzFCZI7JpFsiV5iH58P$-->=20
https://urldefense.us/v3/__https://mail.python.org/mailman/listinfo/pytho= n-list__;!!G_uCfscf7eWS!avZA_RNHnI2aBy2E2Z3kwPCY3B4aDtoxObit540PzHeIW_4s1= Tkkq5NapXL3KzGXv2BTWbYQJHf6AskeTC-IEA$ = <
https://urldefense.us/v3/__https:/mail.python.org/mailman/listinfo/pytho= n-list__;!!G_uCfscf7eWS!avZA_RNHnI2aBy2E2Z3kwPCY3B4aDtoxObit540PzHeIW_4s1= Tkkq5NapXL3KzGXv2BTWbYQJHf6AskeTC-IEA$>=20
--- MBSE BBS v1.0.8.4 (Linux-x86_64)
* Origin: ---:- FTN<->UseNet Gate -:--- (3:633/280.2@fidonet)